// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/xmlparser.c
// Function: xml_parse
BOOLEAN xml_parse(Xmldocumentptr document)
{
 FILE* infile;
 XML_TEXT_TYPE texttype = XML_TEXT_ATTRIBUTE;
 XML_TOKEN_TYPE tokentype;
 BOOLEAN sibling_closed = BOOLEAN_FALSE;
 char* token;
 Xmlattributeptr att = NULL;
 Xmlelementptr parent = NULL, sibling = NULL, current = NULL;
 infile = fopen(document->filename, "r");
 if (!infile)
   return BOOLEAN_FALSE;
 token = xml_get_next_token(infile, &tokentype);
 while (tokentype != XML_END)
  {
   switch (tokentype){
     case    XML_OPENING_TAG_WITH_ATTRIBUTES:
     case XML_OPENING_TAG_WITHOUT_ATTRIBUTES:current = xmlelement(token, parent, tokentype == XML_OPENING_TAG_WITH_ATTRIBUTES);
                                             if (parent)
                                              {
                                               if (sibling && sibling_closed)
                                                {
                                                 sibling->sibling = current;
                                                 sibling = current;
                                                }
                                               else
                                                 parent->child = current;
                                              }
                                             else
                                               if (!(document->root))
                                                 document->root = current;
                                               else
                                                 return BOOLEAN_FALSE;
                                             parent = current;
                                             sibling_closed = BOOLEAN_FALSE;
                                             if (tokentype == XML_OPENING_TAG_WITH_ATTRIBUTES)
                                               texttype = XML_TEXT_ATTRIBUTE;
                                             else
                                               texttype = XML_TEXT_VALUE;
                                             break;
     case             XML_OPENING_TAG_FINISH:texttype = XML_TEXT_VALUE;
                                             sibling_closed = BOOLEAN_FALSE;
                                             break;
     case    XML_CLOSING_TAG_WITH_ATTRIBUTES:sibling = current;
                                             parent = current->parent;
                                             texttype = XML_TEXT_VALUE;
                                             sibling_closed = BOOLEAN_TRUE;
                                             break;
     case XML_CLOSING_TAG_WITHOUT_ATTRIBUTES:if (strcmp(token, current->name) == 0)
                                              {
                                               sibling = current;
                                               parent = current->parent;
                                              }
                                             else
                                               if (strcmp(token, current->parent->name) == 0)
                                                {
                                                 sibling = parent;
                                                 parent = current->parent->parent;
                                                 current = current->parent;
                                                }
                                               else
                                                 return BOOLEAN_FALSE;
                                             sibling_closed = BOOLEAN_TRUE;
                                             texttype = XML_TEXT_VALUE;
                                             break;
     case                XML_ATTRIBUTE_VALUE:if (att)
                                               if (token)
                                                 att->value = strcopy(att->value, token);
                                               else
                                                 att->value = strcopy(att->value, "");
                                             else
                                               return BOOLEAN_FALSE;
                                             texttype = XML_TEXT_ATTRIBUTE;
                                             break;
     case                          XML_EQUAL:texttype = XML_TEXT_NOT_AVAILABLE;
                                             break;
     case                           XML_TEXT:if (texttype == XML_TEXT_ATTRIBUTE)
                                              {
                                               att = xmlattribute(token);
                                               link_list_insert(current->attributes, att);
                                              }
                                             else
                                               if (texttype == XML_TEXT_VALUE)
                                                 current->pcdata = strcopy(current->pcdata, token);
                                               else 
                                                 return BOOLEAN_FALSE;
                                             break;
     default                                :printf("This token type not supported\n");
                                             break;
   }
   if (token)
     safe_free(token);
   token = xml_get_next_token(infile, &tokentype);
  }
 fclose(infile);
 return BOOLEAN_TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
leaq 0x7b5f(%rip), %rsi      # 0xab95b
callq 0x40f0
testq %rax, %rax
je 0xa4049
leaq 0xc(%rsp), %rsi
movq %rax, (%rsp)
movq %rax, %rdi
callq 0xa38ca
movq %rax, %rbp
addq $0x8, %rbx
movq %rbx, 0x20(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movl 0xc(%rsp), %r13d
cmpq $0x8, %r13
ja 0xa3f96
movl $0x1, %r12d
leaq 0xe83b(%rip), %rcx      # 0xb26a0
movslq (%rcx,%r13,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %edx, %edx
testl %r13d, %r13d
sete %dl
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xa39c6
testq %rbx, %rbx
je 0xa3fa7
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
setne %cl
cmpl $0x0, 0x8(%rsp)
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xa3fb7
addq $0x28, %rsi
movq %rsi, %rbx
movq %rax, 0x10(%rsp)
jmp 0xa3fbb
movq (%r15), %rsi
movq %rbp, %rdi
callq 0x4260
testl %eax, %eax
je 0xa4014
movq 0x18(%r15), %r15
movq (%r15), %rsi
movq %rbp, %rdi
callq 0x4260
testl %eax, %eax
je 0xa4017
jmp 0xa4049
movl $0x0, 0x8(%rsp)
jmp 0xa3fe5
movq 0x18(%r15), %rax
movl $0x1, 0x8(%rsp)
movq %r15, 0x10(%rsp)
jmp 0xa3fe8
cmpl $0x1, %r14d
je 0xa3fd5
testl %r14d, %r14d
jne 0xa4049
movl $0x10, %edi
leaq 0xe7b2(%rip), %rsi      # 0xb26dc
movl $0x2, %edx
callq 0x3a0e1
movq %rax, %r14
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x3b494
movq %rax, (%r14)
movq 0x10(%r15), %rdi
movq %r14, 0x18(%rsp)
movq %r14, %rsi
callq 0x1bcea
xorl %r12d, %r12d
jmp 0xa3fe5
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0xa4049
movq 0x8(%r14), %rdi
testq %rbp, %rbp
je 0xa4030
movq %rbp, %rsi
callq 0x3b494
movq %rax, 0x8(%r14)
xorl %r12d, %r12d
movq (%rsp), %r14
jmp 0xa3ff4
movl $0x2, %r12d
jmp 0xa3fe5
leaq 0xe7ce(%rip), %rdi      # 0xb276b
callq 0x4090
movl %r14d, %r12d
jmp 0xa3fe5
movq 0x20(%rsp), %rbx
cmpq $0x0, (%rbx)
je 0xa3fbb
jmp 0xa4049
addq $0x20, %rbx
movq %rax, (%rbx)
xorl %r12d, %r12d
testl %r13d, %r13d
setne %r12b
movl $0x0, 0x8(%rsp)
movq %rax, %r15
jmp 0xa3fe8
movq 0x8(%r15), %rdi
movq %rbp, %rsi
callq 0x3b494
movq %rax, 0x8(%r15)
movq %rbx, %rax
movq (%rsp), %r14
movq %rax, %rbx
testq %rbp, %rbp
je 0xa3ffc
movq %rbp, %rdi
callq 0x3a180
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xa38ca
movq %rax, %rbp
movl %r12d, %r14d
jmp 0xa3e49
movq %r15, %rbx
movq 0x18(%r15), %rax
movl $0x1, %r12d
movl $0x1, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
jmp 0xa3fe8
leaq 0xd987(%rip), %rsi      # 0xb19be
callq 0x3b494
movq %rax, 0x8(%r14)
xorl %r12d, %r12d
movq (%rsp), %r14
jmp 0xa3ffc
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rdi
callq 0x42a0
movl $0x1, %eax
jmp 0xa404b