int * iptc_init(char *param_1)
{
ushort uVar1;
size_t sVar2;
int *piVar3;
int __fd;
int iVar4;
char *__dest;
int iVar5;
int iVar6;
int *piVar7;
undefined4 *puVar8;
short *psVar9;
uint uVar10;
void *pvVar11;
int *piVar12;
int *piVar13;
uint uVar14;
int *piVar15;
socklen_t local_98 [3];
undefined1 auStack_8c [4];
char acStack_88 [80];
int local_38;
undefined1 *local_30;
socklen_t *local_2c;
iptc_fn = iptc_init;
sVar2 = strlen(param_1);
if (sVar2 < 0x20) {
__fd = socket(2,3,0xff);
if (-1 < __fd) {
do {
local_98[1] = 0x54;
strcpy(acStack_88,param_1) //possible issue identified - semgrep
iVar4 = getsockopt(__fd,0,0x40,acStack_88,local_98 + 1);
iVar5 = local_38;
if (iVar4 < 0) {
LAB_00014a74:
close(__fd);
return (int *)0x0;
}
piVar3 = (int *)malloc(0x80) //possible issue identified - semgrep
if (piVar3 == (int *)0x0) {
piVar3 = __errno_location();
*piVar3 = 0xc;
goto LAB_00014a74;
}
memset(piVar3,0,0x80) //possible issue identified - semgrep
piVar15 = piVar3 + 2;
piVar3[2] = (int)piVar15;
piVar3[3] = (int)piVar15;
strcpy((char *)(piVar3 + 10),acStack_88) //possible issue identified - semgrep
__dest = (char *)malloc(iVar5 + 0x28) //possible issue identified - semgrep
piVar3[0x1f] = (int)__dest;
if (__dest == (char *)0x0) {
free(piVar3);
goto LAB_00014a74;
}
strcpy(__dest,acStack_88) //possible issue identified - semgrep
*(int *)(piVar3[0x1f] + 0x20) = iVar5;
*piVar3 = __fd;
memcpy(piVar3 + 10,acStack_88,0x54) //possible issue identified - semgrep
pvVar11 = (void *)piVar3[0x1f];
*(int *)((int)pvVar11 + 0x20) = piVar3[0x1e];
local_98[0] = piVar3[0x1e] + 0x28;
iVar5 = getsockopt(*piVar3,0,0x41,pvVar11,local_98);
if (-1 < iVar5) {
piVar3[9] = 1;
local_2c = local_98 + 2;
local_98[2] = 0;
uVar14 = 0;
while( true ) {
uVar10 = *(uint *)(piVar3[0x1f] + 0x20);
iVar5 = piVar3[0x1f] + 0x28;
if (uVar10 <= uVar14) break;
pvVar11 = (void *)(iVar5 + uVar14);
iVar4 = (int)pvVar11 - iVar5;
if (iVar4 + (uint)*(ushort *)((int)pvVar11 + 0x5a) == uVar10) {
(*(code *)0x1c44)(piVar3,local_98[2]);
piVar3[4] = 0;
}
else {
uVar1 = *(ushort *)((int)pvVar11 + 0x58);
iVar6 = strcmp((char *)((int)pvVar11 + uVar1 + 2),(char *)0x5130);
if (iVar6 == 0) {
iVar5 = (*(code *)0x3f20)((int)pvVar11 + uVar1 + 0x20,0);
if (iVar5 == 0) {
LAB_00014bf0:
piVar13 = __errno_location();
iVar5 = -0xc;
LAB_00014ce0:
*piVar13 = iVar5;
break;
}
piVar3[6] = piVar3[6] + 1;
(*(code *)0x2d9c)(piVar3,iVar5,iVar4,local_2c);
}
else {
uVar10 = 0;
piVar13 = piVar3;
do {
if (((1 << (uVar10 & 0x1f) & piVar3[0x12]) != 0) &&
(pvVar11 == (void *)(iVar5 + piVar13[0x13]))) {
iVar5 = uVar10 + 1;
if (iVar5 != 0) {
iVar6 = (*(code *)0x3f20)((&hooknames)[uVar10],iVar5);
if (iVar6 == 0) goto LAB_00014bf0;
*(int *)(iVar6 + 0x28) = iVar5;
(*(code *)0x2d9c)(piVar3,iVar6,iVar4,local_2c);
}
break;
}
uVar10 = uVar10 + 1;
piVar13 = piVar13 + 1;
} while (uVar10 != 5);
piVar13 = (int *)(*(code *)0x1204)(piVar3[4],*(undefined2 *)((int)pvVar11 + 0x5a));
if (piVar13 == (int *)0x0) {
piVar13 = __errno_location();
iVar5 = 0xc;
goto LAB_00014ce0;
}
uVar1 = *(ushort *)((int)pvVar11 + 0x5a);
piVar13[5] = local_98[2];
piVar13[6] = iVar4;
memcpy(piVar13 + 10,pvVar11,(uint)uVar1) //possible issue identified - semgrep
uVar1 = *(ushort *)((int)pvVar11 + 0x58);
piVar13[4] = piVar13[5];
piVar13[3] = 1;
psVar9 = (short *)((int)pvVar11 + (uint)uVar1);
if ((char)psVar9[1] == '\0') {
if (*psVar9 != 0x28) {
piVar13 = __errno_location();
iVar5 = 0x16;
goto LAB_00014ce0;
}
if (*(int *)(psVar9 + 0x10) < 0) {
piVar13[7] = 0;
}
else {
iVar5 = 2;
if (*(int *)(psVar9 + 0x10) !=
(uint)*(ushort *)((int)pvVar11 + 0x5a) + piVar13[6]) {
iVar5 = 3;
}
piVar13[7] = iVar5;
}
}
else {
piVar13[7] = 1;
}
iVar4 = piVar3[4];
iVar5 = *(int *)(iVar4 + 0x50);
piVar12 = *(int **)(iVar4 + 0x58);
*piVar13 = iVar4 + 0x54;
*(int **)(iVar4 + 0x58) = piVar13;
*(int *)(iVar4 + 0x50) = iVar5 + 1;
*piVar12 = (int)piVar13;
piVar13[1] = (int)piVar12;
}
}
local_98[2] = local_98[2] + 1;
uVar14 = uVar14 + *(ushort *)((int)pvVar11 + 0x5a);
}
iVar5 = (*(code *)0x1150)(piVar3);
if (-1 < iVar5) {
(*(code *)0xf00)(piVar3);
local_30 = auStack_8c;
piVar13 = (int *)piVar3[2];
do {
if (piVar13 == piVar15) {
return piVar3;
}
for (piVar12 = (int *)piVar13[0x15]; piVar12 != piVar13 + 0x15;
piVar12 = (int *)*piVar12) {
if (piVar12[7] == 3) {
piVar7 = (int *)piVar3[2];
uVar14 = *(uint *)((int)piVar12 + *(ushort *)(piVar12 + 0x20) + 0x48);
if (piVar7 == piVar15) goto LAB_00014ec4;
if (piVar3[9] != 0) {
piVar7 = (int *)(*(code *)0x1d0c)(0,uVar14,local_30,piVar3,1);
}
puVar8 = *(undefined4 **)piVar7[1];
while( true ) {
if (puVar8 == (undefined4 *)piVar7[1]) goto LAB_00014ec4;
if (((uint)puVar8[0x18] <= uVar14) && (uVar14 <= (uint)puVar8[0x1a])) break;
puVar8 = (undefined4 *)*puVar8;
}
iVar5 = puVar8[0xb];
piVar12[8] = (int)puVar8;
puVar8[0xb] = iVar5 + 1;
}
}
piVar13 = (int *)*piVar13;
} while( true );
}
}
LAB_00014ec4:
iptc_free(piVar3);
piVar3 = __errno_location();
} while (*piVar3 == 0xb);
}
}
else {
piVar3 = __errno_location();
*piVar3 = 0x16;
}
return (int *)0x0;
}