// File: /workspace/github_cpp_makefile_star2_O1/DimitriFourny[P]unxip/unxip.cpp
// Function: ParseNodeFile(_xmlNode*, XarFile*)
bool ParseNodeFile(xmlNode* file_node, struct XarFile* xar_file) {
  /*
    <file id="2">
      <data>
        <offset>8111880836</offset>
        <size>355</size>
      </data>
      <name>Metadata</name>
    </file>
  */
  bool is_name_init = false;
  bool is_offset_init = false;
  bool is_size_init = false;

  xmlNode* data_node = nullptr;
  xmlNode* node = file_node->children;
  while (node) {
    if (!node->children) {
      node = node->next;
      continue;
    }
    const char* node_name = reinterpret_cast<const char*>(node->name);
    auto* node_content = reinterpret_cast<const char*>(node->children->content);

    if (!strcmp(node_name, "name")) {
      xar_file->name = std::string(node_content);
      is_name_init = true;
    } else if (!strcmp(node_name, "data")) {
      data_node = node;
    }
    node = node->next;
  }

  if (!is_name_init || !data_node) {
    return false;
  }
  node = data_node->children;
  while (node) {
    if (!node->children) {
      node = node->next;
      continue;
    }
    const char* node_name = reinterpret_cast<const char*>(node->name);
    auto* node_content = reinterpret_cast<const char*>(node->children->content);

    if (!strcmp(node_name, "offset")) {
      xar_file->offset = atol(node_content);
      is_offset_init = true;
    } else if (!strcmp(node_name, "length")) {
      xar_file->size = atol(node_content);
      is_size_init = true;
    }
    node = node->next;
  }

  return is_offset_init && is_size_init;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq 0x18(%rdi), %r13
testq %r13, %r13
je 0x290a
xorl %r15d, %r15d
leaq 0x17e3(%rip), %rsi      # 0x4056
xorl %r12d, %r12d
movq 0x18(%r13), %r14
testq %r14, %r14
jne 0x288d
movq 0x30(%r13), %r13
testq %r13, %r13
jne 0x2876
jmp 0x2910
movq 0x10(%r13), %rbp
movq %rbp, %rdi
callq 0x21d0
testl %eax, %eax
je 0x28b4
movq %rbp, %rdi
leaq 0x17b4(%rip), %rsi      # 0x405b
callq 0x21d0
testl %eax, %eax
cmoveq %r13, %r12
jmp 0x28f4
movq 0x50(%r14), %rsi
leaq 0x18(%rsp), %r14
movq %r14, %rdi
leaq 0xf(%rsp), %rdx
callq 0x2e9c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x28f1
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2140
movb $0x1, %r15b
movq 0x30(%r13), %r13
testq %r13, %r13
leaq 0x1754(%rip), %rsi      # 0x4056
jne 0x2876
jmp 0x2910
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %ebp, %ebp
testb $0x1, %r15b
je 0x29bd
testq %r12, %r12
je 0x29bd
movq 0x18(%r12), %r14
testq %r14, %r14
je 0x29b5
leaq 0x28(%rbx), %rax
movq %rax, 0x10(%rsp)
addq $0x20, %rbx
xorl %r15d, %r15d
leaq 0x1716(%rip), %rsi      # 0x4060
xorl %ebp, %ebp
movq 0x18(%r14), %rax
testq %rax, %rax
jne 0x2960
movq 0x30(%r14), %r14
testq %r14, %r14
jne 0x294c
jmp 0x29ba
movq 0x10(%r14), %r13
movq 0x50(%rax), %r12
movq %r13, %rdi
callq 0x21d0
testl %eax, %eax
je 0x2991
movq %r13, %rdi
leaq 0x16e9(%rip), %rsi      # 0x4067
callq 0x21d0
testl %eax, %eax
jne 0x29a3
movb $0x1, %bpl
movq 0x10(%rsp), %r13
jmp 0x2997
movb $0x1, %r15b
movq %rbx, %r13
movq %r12, %rdi
callq 0x21a0
movq %rax, (%r13)
movq 0x30(%r14), %r14
testq %r14, %r14
leaq 0x16af(%rip), %rsi      # 0x4060
jne 0x294c
jmp 0x29ba
xorl %ebp, %ebp
xorl %r15d, %r15d
andb %r15b, %bpl
andb $0x1, %bpl
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq