// File: /workspace/github_cpp_makefile_star2_O2/DimitriFourny[P]uaf_replacer/main.cc
// Function: dump_member(rapidjson::GenericDocument<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>, rapidjson::CrtAllocator> const&, rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> const&, unsigned long, unsigned int)
void dump_member(const rapidjson::Document& document,   
                 const rapidjson::Value& member, uint64_t base_offset, 
                 unsigned int deep_size) {
  if (!member.HasMember("name")) {
    return; 
  }

  // Dumped format: offset type name
  uint64_t offset = member["offset"].GetUint64() + base_offset;
  printf("    +0x%-3lx ", offset);
  for (size_t j = 0; j < deep_size; j++) {
    printf("    ");
  }

  const char* type_id = "";
  std::string type_name = "";
  if (member.HasMember("type_id")) {
    type_id = member["type_id"].GetString();
    type_name = get_type_name(document, type_id);
  }
  printf("%s %s\n", type_name.c_str(), member["name"].GetString());

  // Show the submembers
  if (document.HasMember(type_id)) {
    if (document[type_id].HasMember("members")) {
      dump_members(document, document[type_id], document[type_id]["members"], 
        offset, deep_size+1);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
leaq 0x379f(%rip), %rsi      # 0x6091
movq %r13, %rdi
callq 0x37c6
testb %al, %al
je 0x2a60
leaq 0x37c2(%rip), %rsi      # 0x60cb
movq %r13, %rdi
callq 0x3ef6
movq %rax, %rdi
callq 0x385e
movq %rax, %r15
addq %r12, %r15
leaq 0x37ac(%rip), %rdi      # 0x60d2
movq %r15, %rsi
xorl %eax, %eax
callq 0x2050
movl %ebx, %ebp
leaq 0x37a7(%rip), %r12      # 0x60e0
subq $0x1, %rbp
jb 0x294b
movq %r12, %rdi
xorl %eax, %eax
callq 0x2050
jmp 0x2939
leaq 0x373c(%rip), %r12      # 0x608e
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r12, %rsi
callq 0x378a
leaq 0x3738(%rip), %rsi      # 0x60a3
movq %r13, %rdi
callq 0x37c6
testb %al, %al
je 0x29bb
leaq 0x3725(%rip), %rsi      # 0x60a3
movq %r13, %rdi
callq 0x3ef6
movq %rax, %rdi
callq 0x37ec
movq %rax, %r12
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x246f
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rbp
movq %rbp, %rsi
callq 0x21b0
movq %rbp, %rdi
callq 0x20b0
movq 0x8(%rsp), %rbp
leaq 0x36ca(%rip), %rsi      # 0x6091
movq %r13, %rdi
callq 0x3ef6
movq %rax, %rdi
callq 0x37ec
leaq 0x3711(%rip), %rdi      # 0x60ef
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2050
movq %r14, %rdi
movq %r12, %rsi
callq 0x37c6
testb %al, %al
je 0x2a56
movq %r14, %rdi
movq %r12, %rsi
callq 0x3ef6
leaq 0x36d9(%rip), %rsi      # 0x60e5
movq %rax, %rdi
callq 0x37c6
testb %al, %al
je 0x2a56
movq %r14, %rdi
movq %r12, %rsi
callq 0x3ef6
movq %rax, %r13
movq %r14, %rdi
movq %r12, %rsi
callq 0x3ef6
leaq 0x36ad(%rip), %rsi      # 0x60e5
movq %rax, %rdi
callq 0x3ef6
incl %ebx
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r15, %rcx
movl %ebx, %r8d
callq 0x2a86
leaq 0x8(%rsp), %rdi
callq 0x20b0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a71
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2250