int Parser_LoadDocument(int *param_1,char *param_2,int param_3)
{
undefined4 *puVar1;
undefined *__s2;
int *__s;
FILE *__stream;
size_t sVar2;
char *pcVar3;
void *pvVar4;
undefined4 *puVar5;
int iVar6;
undefined4 uVar7;
size_t sVar8;
char cVar9;
int iVar10;
void *pvVar11;
undefined4 *puVar12;
char *pcVar13;
int iVar14;
char *pcVar15;
int *piVar16;
int local_a8;
undefined4 local_a4;
undefined4 local_a0;
undefined4 local_9c;
char *local_98;
undefined4 local_94;
undefined4 *local_90;
char *local_8c;
char *local_88;
uint local_84;
char *local_7c;
char *local_78;
char *local_58;
char *local_54;
char *local_50;
char *local_4c;
char *local_48;
char *local_44;
char *local_40;
char *local_3c;
char *local_38;
undefined4 *local_34;
undefined4 *local_30;
__s = (int *)malloc(0x40) //possible issue identified - semgrep
if (__s == (int *)0x0) {
return 0x66;
}
memset(__s,0,0x40) //possible issue identified - semgrep
piVar16 = __s + 7;
ixml_membuf_init(piVar16);
ixml_membuf_init(__s + 3);
if (param_3 == 0) {
pcVar3 = strdup(param_2);
*__s = (int)pcVar3;
if (pcVar3 == (char *)0x0) {
iVar14 = 0x66;
goto LAB_004194bc;
}
}
else {
__stream = fopen(param_2,"rb") //possible issue identified - semgrep
if (__stream == (FILE *)0x0) {
iVar14 = 0x65;
goto LAB_004194bc;
}
fseek(__stream,0,2);
sVar2 = ftell(__stream);
if (sVar2 == 0) {
fclose(__stream);
iVar14 = 0xc;
goto LAB_004194bc;
}
pvVar4 = malloc(sVar2 + 1) //possible issue identified - semgrep
*__s = (int)pvVar4;
if (pvVar4 == (void *)0x0) {
fclose(__stream);
iVar14 = 0x66;
goto LAB_004194bc;
}
fseek(__stream,0,0);
sVar2 = fread((void *)*__s,1,sVar2,__stream) //possible issue identified - semgrep
*(undefined1 *)(*__s + sVar2) = 0;
fclose(__stream);
}
__s[1] = *__s;
local_a8 = 0;
local_a4 = 0;
local_a0 = 0;
ixmlNode_init(&local_8c);
iVar14 = ixmlDocument_createDocumentEx(&local_a8);
if (iVar14 == 0) {
__s[0xd] = local_a8;
FUN_004181e0(__s);
local_58 = PTR_s_<_xml_004303c0;
sVar2 = strlen(PTR_s_<_xml_004303c0);
iVar14 = strncmp((char *)__s[1],local_58,sVar2) //possible issue identified - semgrep
if (iVar14 == 0) {
iVar14 = FUN_0041879c(__s + 1,PTR_s__>_004303cc);
FUN_004181e0(__s);
if (iVar14 != 0) goto LAB_0041949c;
}
iVar14 = FUN_00418998(__s);
__s2 = PTR_s_<_DOCTYPE_004303c4;
if (iVar14 == 0) {
pcVar13 = (char *)__s[1];
sVar2 = strlen(PTR_s_<_DOCTYPE_004303c4);
iVar14 = strncmp(pcVar13,__s2,sVar2) //possible issue identified - semgrep
pcVar3 = pcVar13 + 1;
if (iVar14 == 0) {
__s[1] = (int)pcVar3;
if (pcVar3 != (char *)0x0) {
iVar10 = 1;
cVar9 = pcVar13[1] //possible issue identified - semgrep
while (cVar9 != '\0') {
if (cVar9 == '<') {
iVar10 = iVar10 + 1;
}
else if (cVar9 == '>') {
iVar10 = iVar10 + -1;
}
else if ((cVar9 == '\"') && (pcVar3 = strchr(pcVar3 + 1,0x22), pcVar3 == (char *)0x0)) {
iVar14 = 0xc;
goto LAB_0041949c;
}
pcVar3 = pcVar3 + 1;
if (pcVar3 == (char *)0x0) {
iVar14 = 0xc;
if (iVar10 != 0) goto LAB_0041949c;
LAB_004196dc:
__s[1] = (int)pcVar3;
goto LAB_004196e0;
}
if (iVar10 == 0) goto LAB_004196dc;
cVar9 = *pcVar3;
}
goto LAB_00419618;
}
LAB_0041986c:
iVar14 = 0x6a;
}
else {
LAB_004196e0:
iVar14 = FUN_00418998(__s);
if (iVar14 == 0) {
local_48 = PTR_s_<_[CDATA[_004303e8;
local_4c = PTR_DAT_004303ec;
local_44 = PTR_DAT_004303d0;
local_40 = PTR_DAT_004303d8;
local_54 = PTR_s_<_xml__004303d4;
local_50 = PTR_s__>_004303cc;
local_3c = PTR_DAT_004303e0;
local_38 = PTR_s__>_004303e4;
local_34 = &local_9c;
local_30 = &local_a4;
iVar14 = 0;
LAB_00419764:
ixmlNode_init(&local_8c);
if (*(char *)__s[1] == '\0') goto code_r0x0041978c;
if (__s[0xe] == 2) {
__s[2] = __s[1];
FUN_004181e0(__s);
pcVar3 = (char *)__s[1];
if (*pcVar3 != '\0') {
if (*pcVar3 == '<') {
local_98 = pcVar3;
sVar2 = strlen(local_48);
iVar10 = strncmp(pcVar3,local_48,sVar2);
pcVar15 = pcVar3 + sVar2;
pcVar13 = pcVar15;
if (iVar10 == 0) {
while( true ) {
iVar10 = (int)*pcVar13;
if (((((1 < iVar10 - 9U) && (iVar10 != 0xd)) && (0xd7df < iVar10 - 0x20U)) &&
((0x1ffd < iVar10 - 0xe000U && (0xfffff < iVar10 - 0x10000U)))) ||
(iVar10 == 0x30)) break;
sVar2 = strlen(local_4c);
iVar6 = strncmp(pcVar13,local_4c,sVar2);
if (iVar6 == 0) break;
pcVar13 = pcVar13 + 1;
}
sVar2 = (int)pcVar13 - (int)pcVar15;
if ((((int)sVar2 < 1) || (iVar10 == 0x30)) ||
(local_88 = (char *)malloc(sVar2 + 1), local_88 == (char *)0x0))
goto LAB_0041986c;
strncpy(local_88,pcVar15,sVar2);
local_88[sVar2] = '\0';
local_8c = strdup("#cdata-section");
if (local_8c == (char *)0x0) goto LAB_0041986c;
local_84 = 4;
sVar2 = strlen(local_4c);
local_98 = pcVar13 + sVar2;
__s[1] = (int)local_98;
}
else {
sVar2 = strlen(local_44);
iVar10 = strncmp(pcVar3,local_44,sVar2);
if (iVar10 == 0) {
iVar10 = FUN_004188ac(&local_98);
pcVar13 = local_98;
if (iVar10 != 0) goto LAB_0041986c;
}
else {
sVar2 = strlen(local_40);
iVar10 = strncmp(pcVar3,local_40,sVar2);
if (iVar10 != 0) {
__s[0xe] = 0;
goto LAB_00419a34;
}
sVar8 = strlen(local_58);
iVar10 = strncasecmp(pcVar3,local_58,sVar8);
if (iVar10 == 0) goto LAB_0041986c;
sVar8 = strlen(local_54);
iVar10 = strncasecmp(pcVar3,local_54,sVar8);
if ((iVar10 == 0) ||
((iVar10 = strncasecmp(pcVar3,local_40,sVar2), pcVar13 = local_98,
iVar10 == 0 &&
((pcVar15 = strstr(pcVar3,local_50), pcVar15 == (char *)0x0 ||
(pcVar13 = pcVar15 + sVar2, pcVar3 == pcVar15)))))) goto LAB_0041986c;
}
local_98 = pcVar13;
__s[1] = (int)local_98;
}
}
else {
pcVar3 = (char *)__s[2];
__s[1] = (int)pcVar3;
cVar9 = *pcVar3;
while (local_98 = pcVar3, cVar9 != '<') {
iVar10 = strncmp(pcVar3,"]]>",3);
if (iVar10 == 0) goto LAB_0041986c;
if (cVar9 == '\0') goto LAB_00419f74;
pcVar3 = pcVar3 + 1;
cVar9 = *pcVar3;
}
iVar10 = strncmp(pcVar3,"]]>",3);
if (iVar10 == 0) goto LAB_0041986c;
LAB_00419f74:
iVar10 = __s[1];
ixml_membuf_destroy(piVar16);
iVar6 = FUN_00418b58(__s,__s[1],(int)pcVar3 - iVar10);
if (((iVar6 != 0) || ((char *)__s[7] == (char *)0x0)) ||
((local_88 = strdup((char *)__s[7]), local_88 == (char *)0x0 ||
(local_8c = strdup("#text"), local_8c == (char *)0x0)))) goto LAB_0041986c;
local_84 = 3;
__s[1] = __s[1] + ((int)pcVar3 - iVar10);
}
}
}
else {
FUN_004181e0(__s);
iVar10 = FUN_00419158(__s);
if (((iVar10 == 0) && (__s[0xc] == 0)) && (*(char *)__s[1] == '\0')) goto LAB_00419a34;
if (__s[8] == 0) goto LAB_0041986c;
pcVar3 = (char *)__s[7];
cVar9 = *pcVar3;
if (cVar9 == '>') goto LAB_00419a34;
iVar10 = strcmp(pcVar3,local_3c);
if (iVar10 == 0) {
iVar10 = FUN_00419158(__s);
iVar14 = 0x6a;
if (((iVar10 == 0) || ((char *)__s[7] == (char *)0x0)) ||
(local_8c = strdup((char *)__s[7]), local_8c == (char *)0x0)) goto LAB_0041949c;
local_88 = (char *)0x0;
local_84 = 1;
FUN_004181e0(__s);
iVar14 = FUN_00419158(__s);
if (((iVar14 == 0) || ((char *)__s[7] == (char *)0x0)) ||
(iVar14 = strcmp((char *)__s[7],">"), iVar14 != 0)) goto LAB_0041986c;
if (local_84 == 1) {
LAB_00419b78:
puVar12 = (undefined4 *)__s[0xc];
iVar14 = strcmp((char *)*puVar12,local_8c);
if (iVar14 != 0) goto LAB_00419618;
__s[0xc] = puVar12[4];
FUN_004184ac(puVar12);
pvVar4 = (void *)puVar12[3];
while (pvVar4 != (void *)0x0) {
pvVar11 = *(void **)((int)pvVar4 + 8);
FUN_00418550(pvVar4);
free(pvVar4);
pvVar4 = pvVar11;
}
free(puVar12);
}
puVar12 = (undefined4 *)__s[0xd];
iVar14 = strcmp(local_8c,(char *)*puVar12);
if (iVar14 != 0) goto LAB_00419618;
__s[0xd] = puVar12[7];
__s[0xe] = 2;
iVar14 = 0;
goto LAB_00419a58;
}
if (cVar9 == '<') {
iVar10 = FUN_00419158(__s);
if ((((iVar10 != 0) && ((char *)__s[7] != (char *)0x0)) &&
(local_8c = strdup((char *)__s[7]), local_8c != (char *)0x0)) &&
((iVar10 = ixml_membuf_assign_str(__s + 3,local_8c), iVar10 == 0 &&
(iVar10 = Parser_setNodePrefixAndLocalName(&local_8c), iVar10 == 0)))) {
local_84 = 1;
__s[2] = __s[1];
local_88 = (char *)0x0;
iVar10 = FUN_00419158(__s);
if (iVar10 != 0) {
pcVar3 = (char *)__s[7];
iVar10 = strcmp(pcVar3,"/>");
if (iVar10 == 0) {
__s[0xe] = 0;
__s[1] = __s[2];
}
else {
iVar10 = strcmp(pcVar3,">");
if (iVar10 == 0) goto LAB_0041a694;
__s[0xe] = 1;
__s[1] = __s[2];
}
goto LAB_00419a34;
}
}
goto LAB_0041986c;
}
iVar10 = strcmp(pcVar3,local_38);
if (iVar10 == 0) {
if (((char *)__s[3] != (char *)0x0) &&
(local_8c = strdup((char *)__s[3]), local_8c != (char *)0x0)) {
local_84 = 1;
goto LAB_00419b78;
}
goto LAB_0041986c;
}
if ((__s[0xe] != 1) || (local_94 = 0, pcVar3 == (char *)0x0)) goto LAB_0041986c;
uVar7 = FUN_00417ef8(pcVar3,&local_94);
iVar10 = FUN_00417e20(uVar7,0);
if ((iVar10 == 0) ||
((((local_8c = strdup(pcVar3), local_8c == (char *)0x0 ||
(iVar10 = FUN_00419158(__s), iVar10 == 0)) || (*(char *)__s[7] != '=')) ||
(iVar10 = FUN_00419158(__s), iVar10 == 0)))) goto LAB_0041986c;
cVar9 = *(char *)__s[7];
if ((cVar9 != '\"') && (cVar9 != '\'')) goto LAB_0041986c;
pcVar13 = (char *)__s[1];
pcVar3 = strstr(pcVar13,(char *)__s[7]);
if (pcVar3 == (char *)0x0) goto LAB_0041986c;
if (pcVar13 < pcVar3) {
cVar9 = *pcVar13;
if (cVar9 == '<') goto LAB_0041986c;
while( true ) {
if (cVar9 == '&') {
pcVar13 = pcVar13 + 1;
}
pcVar13 = pcVar13 + 1;
if (pcVar3 <= pcVar13) break;
cVar9 = *pcVar13;
if (cVar9 == '<') {
iVar14 = 0x6a;
goto LAB_0041949c;
}
}
}
ixml_membuf_destroy(piVar16);
pcVar13 = (char *)__s[1];
if ((pcVar3 != pcVar13) &&
(iVar10 = FUN_00418b58(__s,pcVar13,(int)pcVar3 - (int)pcVar13), iVar10 != 0))
goto LAB_0041986c;
__s[1] = (int)(pcVar3 + 1);
if (((char *)__s[7] != (char *)0x0) &&
(local_88 = strdup((char *)__s[7]), local_88 == (char *)0x0)) goto LAB_0041986c //possible issue identified - semgrep
pcVar3 = local_8c;
local_84 = 2;
iVar10 = strcmp(local_8c,"xmlns");
iVar6 = __s[0xc];
if (iVar10 == 0) {
if (*(void **)(iVar6 + 8) != (void *)0x0) {
free(*(void **)(iVar6 + 8));
}
LAB_0041992c:
pcVar3 = strdup(local_88) //possible issue identified - semgrep
*(char **)(iVar6 + 8) = pcVar3;
if (pcVar3 == (char *)0x0) goto LAB_0041986c;
}
else {
iVar10 = strncmp(pcVar3,"xmlns:",6);
if (iVar10 == 0) {
iVar10 = Parser_setNodePrefixAndLocalName(&local_8c);
if ((iVar10 != 0) || (iVar6 == 0)) goto LAB_0041986c;
if ((*(char **)(iVar6 + 4) != (char *)0x0) &&
(iVar10 = strcmp(*(char **)(iVar6 + 4),local_78), iVar10 == 0))
goto LAB_0041992c;
pcVar3 = local_78;
puVar5 = *(undefined4 **)(iVar6 + 0xc);
puVar12 = *(undefined4 **)(iVar6 + 0xc);
while (puVar1 = puVar5, puVar1 != (undefined4 *)0x0) {
if (((char *)puVar1[1] != (char *)0x0) &&
(iVar10 = strcmp((char *)puVar1[1],pcVar3), iVar10 == 0)) {
if ((void *)*puVar1 != (void *)0x0) {
free((void *)*puVar1);
}
pcVar3 = strdup(local_88);
*puVar1 = pcVar3;
if (pcVar3 != (char *)0x0) goto LAB_00419948;
iVar14 = 0x6a;
goto LAB_0041949c;
}
puVar12 = puVar1;
puVar5 = (undefined4 *)puVar1[2];
}
puVar5 = (undefined4 *)malloc(0xc) //possible issue identified - semgrep
if (puVar5 == (undefined4 *)0x0) goto LAB_0041986c;
*puVar5 = 0;
puVar5[1] = 0;
puVar5[2] = 0;
pcVar3 = strdup(local_78);
puVar5[1] = pcVar3;
if (pcVar3 != (char *)0x0) {
pcVar3 = strdup(local_88);
*puVar5 = pcVar3;
if (pcVar3 != (char *)0x0) {
if (*(int *)(iVar6 + 0xc) == 0) {
*(undefined4 **)(iVar6 + 0xc) = puVar5;
}
else {
puVar12[2] = puVar5;
}
goto LAB_00419948;
}
FUN_00418550(puVar5);
}
free(puVar5);
iVar14 = 0x6a;
goto LAB_0041949c;
}
}
LAB_00419948:
puVar12 = (undefined4 *)__s[0xb];
if (puVar12 != (undefined4 *)0x0) {
pcVar3 = (char *)puVar12[4];
puVar5 = (undefined4 *)__s[0xc];
if (pcVar3 == (char *)0x0) {
iVar10 = strcmp((char *)*puVar12,(char *)*puVar5);
if (iVar10 != 0) goto LAB_0041986c;
pcVar3 = (char *)puVar5[2];
if (pcVar3 != (char *)0x0) goto LAB_004199b4;
__s[0xb] = 0;
}
else {
iVar10 = strcmp((char *)*puVar12,(char *)*puVar5);
if ((iVar10 != 0) && (iVar10 = strcmp(pcVar3,(char *)puVar5[1]), iVar10 != 0))
goto LAB_0041986c;
pcVar3 = (char *)puVar5[2];
if (pcVar3 != (char *)0x0) {
LAB_004199b4:
pcVar3 = strdup(pcVar3) //possible issue identified - semgrep
puVar12[3] = pcVar3;
if (pcVar3 == (char *)0x0) goto LAB_0041986c;
__s[0xb] = 0;
}
}
}
__s[2] = __s[1];
iVar10 = FUN_00419158(__s);
if (iVar10 == 0) goto LAB_0041986c;
pcVar3 = (char *)__s[7];
iVar10 = strcmp(pcVar3,"<");
if (iVar10 == 0) goto LAB_0041986c;
iVar10 = strcmp(pcVar3,">");
if (iVar10 == 0) {
LAB_0041a694:
__s[0xe] = 2;
}
else {
__s[1] = __s[2];
}
}
LAB_00419a34:
pcVar3 = local_8c;
iVar10 = local_a8;
if (local_84 == 2) {
local_9c = 0;
for (puVar12 = *(undefined4 **)(__s[0xd] + 0x2c); puVar12 != (undefined4 *)0x0;
puVar12 = (undefined4 *)puVar12[10]) {
iVar6 = strcmp((char *)*puVar12,pcVar3);
iVar14 = 0xc;
if (iVar6 == 0) goto LAB_0041949c;
}
iVar14 = ixmlDocument_createAttributeEx(iVar10,pcVar3,local_34);
if ((iVar14 != 0) ||
(iVar14 = ixmlNode_setNodeProperties(local_9c,&local_8c), iVar14 != 0))
goto LAB_0041949c;
iVar14 = ixmlElement_setAttributeNode(__s[0xd],local_9c,0);
}
else {
if (local_84 < 3) {
if (local_84 != 1) goto LAB_00419a58;
local_90 = (undefined4 *)0x0;
if (__s[0xf] == 1) {
if (__s[0xc] == 0) goto LAB_00419618;
}
else {
__s[0xf] = 1;
}
__s[2] = __s[1];
iVar14 = ixmlDocument_createElementEx(local_a8,local_8c,&local_90);
if (iVar14 != 0) goto LAB_0041949c;
iVar14 = ixmlNode_setNodeProperties(local_90,&local_8c);
pcVar3 = local_7c;
if (iVar14 == 0) {
if (local_7c == (char *)0x0) {
for (iVar14 = __s[0xc]; iVar14 != 0; iVar14 = *(int *)(iVar14 + 0x10)) {
if ((*(int *)(iVar14 + 4) == 0) &&
(pcVar3 = *(char **)(iVar14 + 8), pcVar3 != (char *)0x0)) goto LAB_00419d84;
}
if (__s[0xe] == 1) goto LAB_0041a02c;
}
else {
iVar14 = __s[0xc];
if (iVar14 != 0) {
LAB_00419d10:
if ((*(char **)(iVar14 + 4) == (char *)0x0) ||
(iVar10 = strcmp(*(char **)(iVar14 + 4),pcVar3), iVar10 != 0))
goto LAB_00419d3c;
pcVar3 = *(char **)(iVar14 + 8);
LAB_00419d84:
puVar12 = local_90;
if ((local_90 != (undefined4 *)0x0) && (local_90[3] == 0)) {
pcVar3 = strdup(pcVar3) //possible issue identified - semgrep
puVar12[3] = pcVar3;
}
goto LAB_00419da4;
}
LAB_0041a02c:
__s[0xb] = (int)local_90;
}
LAB_00419da4:
iVar14 = ixmlNode_appendChild(__s[0xd],local_90);
puVar12 = local_90;
if (iVar14 == 0) {
__s[0xd] = (int)local_90;
iVar14 = 0;
if (local_90 == (undefined4 *)0x0) goto LAB_00419a58;
puVar5 = (undefined4 *)malloc(0x14) //possible issue identified - semgrep
if (puVar5 != (undefined4 *)0x0) {
*puVar5 = 0;
puVar5[1] = 0;
puVar5[2] = 0;
puVar5[3] = 0;
puVar5[4] = 0;
pcVar3 = strdup((char *)*puVar12);
*puVar5 = pcVar3;
if (pcVar3 != (char *)0x0) {
if ((char *)puVar12[4] == (char *)0x0) {
LAB_00419e48:
if ((char *)puVar12[3] != (char *)0x0) {
pcVar3 = strdup((char *)puVar12[3]);
puVar5[2] = pcVar3;
if (pcVar3 == (char *)0x0) goto LAB_0041a450;
}
iVar10 = __s[0xc];
__s[0xc] = (int)puVar5;
puVar5[4] = iVar10;
goto LAB_00419a58;
}
pcVar3 = strdup((char *)puVar12[4]);
puVar5[1] = pcVar3;
if (pcVar3 != (char *)0x0) goto LAB_00419e48;
LAB_0041a450:
FUN_004184ac(puVar5);
}
free(puVar5);
}
iVar14 = 0x66;
goto LAB_0041949c;
}
}
ixmlElement_free(local_90);
goto LAB_0041949c;
}
if (local_84 == 3) {
iVar14 = ixmlDocument_createTextNodeEx(local_a8,local_88,local_30);
if (iVar14 != 0) goto LAB_0041949c;
iVar14 = __s[0xd];
uVar7 = local_a4;
}
else {
if (local_84 != 4) goto LAB_00419a58;
iVar14 = ixmlDocument_createCDATASectionEx(local_a8,local_88,&local_a0);
if (iVar14 != 0) goto LAB_0041949c;
iVar14 = __s[0xd];
uVar7 = local_a0;
}
iVar14 = ixmlNode_appendChild(iVar14,uVar7);
}
if (iVar14 != 0) goto LAB_0041949c;
LAB_00419a58:
Parser_freeNodeContent(&local_8c);
goto LAB_00419764;
}
}
}
}
goto LAB_0041949c;
LAB_00419d3c:
for (puVar12 = *(undefined4 **)(iVar14 + 0xc); puVar12 != (undefined4 *)0x0;
puVar12 = (undefined4 *)puVar12[2]) {
iVar10 = strcmp((char *)puVar12[1],pcVar3);
if (iVar10 == 0) {
pcVar3 = (char *)*puVar12;
goto LAB_00419d84;
}
}
iVar14 = *(int *)(iVar14 + 0x10);
if (iVar14 == 0) goto LAB_0041a02c;
goto LAB_00419d10;
code_r0x0041978c:
if (__s[0xc] == 0) {
*param_1 = local_a8;
FUN_004185c4(__s);
return iVar14;
}
LAB_00419618:
iVar14 = 0xc;
LAB_0041949c:
Parser_freeNodeContent(&local_8c);
ixmlDocument_free(local_a8);
LAB_004194bc:
FUN_004185c4(__s);
return iVar14;
}