// File: /workspace/github_cpp_makefile_star2_O3/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 0x18(%rdi), %r13
testq %r13, %r13
je 0x29b2
movq %rsi, 0x8(%rsp)
xorl %r15d, %r15d
leaq 0x17e7(%rip), %rsi      # 0x4056
xorl %r12d, %r12d
movq 0x18(%r13), %r14
testq %r14, %r14
jne 0x2886
movq 0x30(%r13), %r13
testq %r13, %r13
jne 0x2872
jmp 0x2902
movq 0x10(%r13), %rbp
movq %rbp, %rdi
movq %rsi, %rbx
callq 0x21d0
testl %eax, %eax
je 0x28b0
movq %rbp, %rdi
leaq 0x17b8(%rip), %rsi      # 0x405b
callq 0x21d0
testl %eax, %eax
cmoveq %r13, %r12
jmp 0x28f2
movq 0x50(%r14), %rsi
leaq 0x18(%rsp), %r14
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x2e92
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x28ef
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2140
movb $0x1, %r15b
movq 0x30(%r13), %r13
testq %r13, %r13
movq %rbx, %rsi
jne 0x2872
xorl %ebp, %ebp
testb $0x1, %r15b
je 0x29be
testq %r12, %r12
je 0x29be
movq 0x18(%r12), %r14
testq %r14, %r14
je 0x29b6
movq 0x8(%rsp), %rcx
leaq 0x28(%rcx), %rax
movq %rax, 0x10(%rsp)
addq $0x20, %rcx
movq %rcx, 0x8(%rsp)
xorl %r15d, %r15d
leaq 0x171a(%rip), %rsi      # 0x4060
xorl %ebp, %ebp
movq 0x18(%r14), %rax
testq %rax, %rax
jne 0x295c
movq 0x30(%r14), %r14
testq %r14, %r14
jne 0x2948
jmp 0x29bb
movq 0x10(%r14), %r13
movq 0x50(%rax), %r12
movq %r13, %rdi
movq %rsi, %rbx
callq 0x21d0
testl %eax, %eax
je 0x2990
movq %r13, %rdi
leaq 0x16ea(%rip), %rsi      # 0x4067
callq 0x21d0
testl %eax, %eax
jne 0x29a4
movb $0x1, %bpl
movq 0x10(%rsp), %r13
jmp 0x2998
movb $0x1, %r15b
movq 0x8(%rsp), %r13
movq %r12, %rdi
callq 0x21a0
movq %rax, (%r13)
movq 0x30(%r14), %r14
testq %r14, %r14
movq %rbx, %rsi
jne 0x2948
jmp 0x29bb
xorl %ebp, %ebp
jmp 0x29be
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