/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
undefined4 FUN_00010ad4(int *param_1,int param_2,undefined4 param_3,int param_4)
{
bool bVar1;
short sVar2;
undefined4 uVar3;
int *piVar4;
uint uVar5;
uint uVar6;
undefined4 *puVar7;
undefined4 *__ptr;
int *piVar8;
code *pcVar9;
int iVar10;
int *piVar11;
uint uVar12;
if (param_1 == __dl_symbol_tables) {
LAB_00010dec:
uVar3 = 0;
}
else {
piVar11 = __dl_handles;
piVar4 = (int *)0x0;
while (piVar8 = piVar11, piVar8 != (int *)0x0) {
if (piVar8 == param_1) {
piVar11 = (int *)param_1[1];
if (piVar4 != (int *)0x0) {
piVar4[1] = param_1[1];
piVar11 = __dl_handles;
}
__dl_handles = piVar11;
sVar2 = *(short *)(*param_1 + 0x20) //possible issue identified - semgrep
uVar12 = 0;
if (sVar2 == 1) {
for (; uVar12 < (uint)param_1[3]; uVar12 = uVar12 + 1) {
piVar11 = *(int **)(param_1[2] + uVar12 * 4);
sVar2 = (short)piVar11[8] + -1 //possible issue identified - semgrep
*(short *)(piVar11 + 8) = sVar2;
if (sVar2 == 0) {
if ((piVar11[0x1d] == 0) && (piVar11[0x2a] == 0)) {
piVar4 = (int *)piVar11[0x37];
}
else if (param_2 == 0) {
piVar4 = (int *)piVar11[0x37];
}
else if ((*(ushort *)((int)piVar11 + 0x22) & 8) == 0) {
*(ushort *)((int)piVar11 + 0x22) = *(ushort *)((int)piVar11 + 0x22) | 8;
_dl_run_fini_array(piVar11);
if (piVar11[0x1d] != 0) {
(*(code *)(piVar11[0x1d] + *piVar11))();
}
piVar4 = (int *)piVar11[0x37];
}
else {
piVar4 = (int *)piVar11[0x37];
}
uVar6 = 0;
uVar5 = 0;
while (bVar1 = uVar6 < (uint)piVar11[0x36], uVar6 = uVar6 + 1, bVar1) {
if (*piVar4 == 1) {
if (uVar5 < (uint)(piVar4[5] + piVar4[2])) {
uVar5 = piVar4[5] + piVar4[2];
}
piVar4 = piVar4 + 8;
}
else {
piVar4 = piVar4 + 8;
}
}
syscall(0) //possible issue identified - semgrep
if (param_4 != 0) {
__dl_errno = 0xffb;
}
__ptr = (undefined4 *)piVar11[0xd];
while (__ptr != (undefined4 *)0x0) {
puVar7 = (undefined4 *)*__ptr;
free(__ptr);
__ptr = puVar7;
}
piVar4 = __dl_loaded_modules;
if (__dl_loaded_modules == piVar11) {
__dl_loaded_modules = (int *)piVar11[3];
if (__dl_loaded_modules != (int *)0x0) {
__dl_loaded_modules[4] = 0;
}
}
else {
do {
piVar8 = piVar4;
if (piVar8 == (int *)0x0) goto LAB_00010d00;
piVar4 = (int *)piVar8[3];
} while ((int *)piVar8[3] != piVar11);
iVar10 = piVar11[3];
piVar8[3] = iVar10;
if (iVar10 != 0) {
*(int **)(iVar10 + 0x10) = piVar8;
}
}
LAB_00010d00:
if (__dl_symbol_tables != (int *)0x0) {
if ((int *)*__dl_symbol_tables == piVar11) {
__dl_symbol_tables = (int *)__dl_symbol_tables[4];
if (__dl_symbol_tables != (int *)0x0) {
__dl_symbol_tables[5] = 0;
}
}
else {
piVar8 = __dl_symbol_tables;
for (piVar4 = (int *)__dl_symbol_tables[4]; piVar4 != (int *)0x0;
piVar4 = (int *)piVar4[4]) {
if ((int *)*piVar4 == piVar11) {
iVar10 = piVar4[4];
free(piVar4);
piVar8[4] = iVar10;
if (iVar10 != 0) {
*(int **)(iVar10 + 0x14) = piVar8;
}
break;
}
piVar8 = piVar4;
}
}
}
free((void *)piVar11[1]);
free(piVar11);
}
}
free((void *)param_1[2]);
free(param_1);
if ((__dl_debug_addr != 0) &&
(pcVar9 = *(code **)(__dl_debug_addr + 8), pcVar9 != (code *)0x0)) {
*(undefined4 *)(__dl_debug_addr + 0xc) = 2;
(*pcVar9)();
*(undefined4 *)(__dl_debug_addr + 0xc) = 0;
(*pcVar9)();
}
}
else {
*(short *)(*param_1 + 0x20) = sVar2 + -1;
free(param_1);
}
goto LAB_00010dec;
}
piVar4 = piVar8;
piVar11 = (int *)piVar8[1];
}
__dl_error_number = 9;
uVar3 = 1;
}
return uVar3;
}