// File: /workspace/github_c_makefile_star2_O3/mrkite[P]regs/src/2mg.cc
// Function: doFile(unsigned short, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::shared_ptr<TheHandle>, int)
static void doFile(uint16_t key, uint32_t len, std::string name,
                   Handle h, int type) {
  h->seek(key * 512);
  std::ofstream f(name, std::ios::out | std::ios::binary | std::ios::trunc);
  if (!f.is_open()) {
    std::cerr << "Failed to create " << name << std::endl;
    return;
  }
  switch (type) {
    case 1:
      dumpSeedling(h, len, f);
      break;
    case 2:
      dumpSapling(h, len, f);
      break;
    case 3:
      dumpTree(h, len, f);
      break;
  }
  f.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movl %r8d, %r15d
movq %rcx, %rbx
movq %rdx, %r14
movl %esi, %ebp
movl %edi, %esi
movq (%rcx), %rdi
shll $0x9, %esi
callq 0x741e
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movl $0x34, %edx
callq 0x5380
leaq 0x98(%rsp), %rdi
callq 0x5060
testb %al, %al
je 0x6914
cmpl $0x3, %r15d
je 0x6995
cmpl $0x2, %r15d
je 0x696e
cmpl $0x1, %r15d
jne 0x6ad3
movq (%rbx), %rdi
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x6aba
movq 0x66bd(%rip), %rax      # 0xcfc0
cmpb $0x0, (%rax)
je 0x6ab6
incl 0x8(%rbx)
jmp 0x6aba
movq 0x66cd(%rip), %rdi      # 0xcfe8
leaq 0x17ff(%rip), %rsi      # 0x8121
movl $0x11, %edx
callq 0x5200
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x66ae(%rip), %rdi      # 0xcfe8
callq 0x5200
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5120
jmp 0x6add
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x69b6
movq 0x6635(%rip), %rcx      # 0xcfc0
cmpb $0x0, (%rcx)
je 0x69b2
incl 0x8(%rax)
jmp 0x69b6
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x69d5
movq 0x6618(%rip), %rax      # 0xcfc0
cmpb $0x0, (%rax)
je 0x69d1
incl 0x8(%rbx)
jmp 0x69d5
lock
incl 0x8(%rax)
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movl %ebp, %esi
callq 0x6ca7
movq 0x10(%rsp), %rbx
jmp 0x6ac6
lock
incl 0x8(%rbx)
movq %r14, %rdi
callq 0x724e
testl %ebp, %ebp
je 0x6ac6
movq %rax, %r15
leaq 0x28(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x741e
movq %r14, %rdi
callq 0x72f0
movl %eax, %r13d
movl $0xff, %esi
movq %r14, %rdi
callq 0x7428
movq %r14, %rdi
callq 0x72f0
movzbl %al, %ecx
shll $0x8, %ecx
movzbl %r13b, %eax
movl $0x20000, %edx          # imm = 0x20000
cmpl %edx, %ebp
movl $0x20000, %r13d         # imm = 0x20000
cmovbl %ebp, %r13d
orw %cx, %ax
je 0x6a49
movzwl %ax, %eax
shll $0x9, %eax
leal 0x200(%rax), %ecx
cmpq %rcx, (%r14)
jge 0x6a5b
movl %r13d, %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x5190
jmp 0x6aa8
movl %eax, %esi
movq %r14, %rdi
callq 0x741e
movq %r14, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
testq %rbx, %rbx
je 0x6a89
movq 0x6545(%rip), %rax      # 0xcfc0
cmpb $0x0, (%rax)
je 0x6a85
incl 0x8(%rbx)
jmp 0x6a89
lock
incl 0x8(%rbx)
leaq 0x18(%rsp), %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x6ca7
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6aa8
callq 0x6f48
incq %r15
subl %r13d, %ebp
jne 0x69ed
jmp 0x6ac6
lock
incl 0x8(%rbx)
movl %ebp, %esi
leaq 0x28(%rsp), %rdx
callq 0x742e
testq %rbx, %rbx
je 0x6ad3
movq %rbx, %rdi
callq 0x6f48
leaq 0x28(%rsp), %rdi
callq 0x5270
movq 0x64cc(%rip), %rax      # 0xcfb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x5150
leaq 0x120(%rsp), %rdi
callq 0x50c0
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6b4d
jmp 0x6b4d
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x6b58
jmp 0x6b5d
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6b50
callq 0x6f48
jmp 0x6b50
movq %rax, %r14
jmp 0x6b5d
movq %rax, %r14
testq %rbx, %rbx
je 0x6b5d
movq %rbx, %rdi
callq 0x6f48
leaq 0x28(%rsp), %rdi
callq 0x52a0
movq %r14, %rdi
callq 0x5340