// File: /workspace/github_c_makefile_star2_O1/shuffle2[P]nx2elf/nx2elf.cpp
// Function: NsoFile::Dump(bool)
void Dump(bool verbose = false) {
    char msg[1024];
    char* p = msg;
    const char* idx2prot[kNumSegment] = {"r-x", "r--", "rw-"};

#define FMT_FIELD(f) p += sprintf(p, #f ": %8x\n", header.f);

    if (verbose) {
      FMT_FIELD(field_4);
      FMT_FIELD(field_8);
      FMT_FIELD(field_c);
    }

    p += sprintf(p, "gnu_build_id: ");
    p = FormatBytes(p, header.gnu_build_id);
    p += sprintf(p, "\n");

    p += sprintf(p, "         %-8s %-8s %-8s %-8s %-8s\n", "file off",
                 "file len", "mem off", "mem len", "bss/algn");
    for (int i = 0; i < kNumSegment; i++) {
      auto& seg = header.segments[i];
      auto& file_size = header.segment_file_sizes[i];
      p += sprintf(p, "%d [%-3s]: %8x %8x %8x %8x %8x\n", i, idx2prot[i],
                   seg.file_offset, file_size, seg.mem_offset, seg.mem_size,
                   seg.bss_align);
    }

    if (verbose) {
      for (int i = 0; i < ARRAY_SIZE(header.field_6c); i++)
        FMT_FIELD(field_6c[i]);
    }

    p += sprintf(p, ".rodata-relative:\n");
    p += sprintf(p, "  .dynstr: %8x %8x\n", header.dynstr.offset,
                 header.dynstr.size);
    p += sprintf(p, "  .dynsym: %8x %8x\n", header.dynsym.offset,
                 header.dynsym.size);

    p += sprintf(p, "segment digests:\n");
    for (int i = 0; i < kNumSegment; i++) {
      p += sprintf(p, "%d [%-3s]: ", i, idx2prot[i]);
      p = FormatBytes(p, header.segment_digests[i]);
      p += sprintf(p, "\n");
    }

#undef FMT_FIELD

    printf("%s", msg);
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdi, %rbx
movl %esi, -0x34(%rbp)
testl %esi, %esi
je 0x5a6b
movl 0x8(%rbx), %edx
leaq 0x1188b(%rip), %rsi     # 0x172a5
leaq -0x460(%rbp), %rdi
xorl %eax, %eax
callq 0x2040
cltq
leaq (%rax,%rbp), %r14
addq $-0x460, %r14           # imm = 0xFBA0
movl 0xc(%rbx), %edx
leaq 0x11874(%rip), %rsi     # 0x172b3
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r15
addq %r14, %r15
movl 0x10(%rbx), %edx
leaq 0x11868(%rip), %rsi     # 0x172c1
movq %r15, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r12
addq %r15, %r12
jmp 0x5a72
leaq -0x460(%rbp), %r12
movabsq $0x203a64695f646c, %rax # imm = 0x203A64695F646C
movq %rax, 0x7(%r12)
movabsq $0x6c6975625f756e67, %rax # imm = 0x6C6975625F756E67
movq %rax, (%r12)
addq $0xe, %r12
movups 0x44(%rbx), %xmm0
movq %rbx, -0x30(%rbp)
movups 0x54(%rbx), %xmm1
movaps %xmm1, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
leaq 0x1190c(%rip), %r14     # 0x173ba
xorl %r13d, %r13d
movq %r12, %r15
movzbl -0x60(%rbp,%r13), %edx
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r12
addq %r15, %r12
incq %r13
cmpq $0x20, %r13
jne 0x5ab1
movw $0xa, (%r12)
leaq 0x1(%r12), %rdi
subq $0x8, %rsp
leaq 0x11836(%rip), %r10     # 0x17323
leaq 0x117ea(%rip), %rsi     # 0x172de
leaq 0x11806(%rip), %rdx     # 0x17301
leaq 0x11808(%rip), %rcx     # 0x1730a
leaq 0x1180a(%rip), %r8      # 0x17313
leaq 0x1180b(%rip), %r9      # 0x1731b
xorl %eax, %eax
pushq %r10
callq 0x2040
addq $0x10, %rsp
cltq
leaq (%r12,%rax), %r15
incq %r15
movq $-0x18, %r12
leaq 0x151fc(%rip), %rax     # 0x1ad30
xorl %r13d, %r13d
movq -0x30(%rbp), %rbx
movq %r15, %r14
movq 0x18(%r12,%rax), %rcx
movl 0x64(%rbx,%r13,4), %r9d
movl 0x44(%rbx,%r12,2), %r8d
movl 0x48(%rbx,%r12,2), %r10d
movl 0x4c(%rbx,%r12,2), %r11d
movl 0x50(%rbx,%r12,2), %r15d
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x117c2(%rip), %rsi     # 0x1732c
movl %r13d, %edx
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
callq 0x2040
addq $0x20, %rsp
movslq %eax, %r15
leaq 0x151a8(%rip), %rax     # 0x1ad30
addq %r14, %r15
incq %r13
addq $0x8, %r12
jne 0x5b3b
cmpb $0x0, -0x34(%rbp)
je 0x5bca
leaq 0x117ab(%rip), %r14     # 0x1734c
xorl %r12d, %r12d
movq -0x30(%rbp), %r13
movl 0x70(%r13,%r12,4), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
cltq
addq %rax, %r15
incq %r12
cmpq $0x9, %r12
jne 0x5ba8
jmp 0x5bce
movq -0x30(%rbp), %r13
movups 0x11789(%rip), %xmm0    # 0x1735e
movups %xmm0, (%r15)
movl $0xa3a65, 0xf(%r15)     # imm = 0xA3A65
leaq 0x12(%r15), %rdi
movl 0x94(%r13), %edx
movl 0x98(%r13), %ecx
leaq 0x11777(%rip), %rsi     # 0x17371
xorl %eax, %eax
callq 0x2040
cltq
leaq (%r15,%rax), %r14
addq $0x12, %r14
movl 0x9c(%r13), %edx
movl 0xa0(%r13), %ecx
leaq 0x11765(%rip), %rsi     # 0x17385
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
cltq
movups 0x11766(%rip), %xmm0    # 0x17399
movq %r13, %rcx
leaq (%rax,%r14), %r13
addq $0x11, %r13
movups %xmm0, -0x11(%r13)
movw $0xa, -0x1(%r13)
addq $0xa4, %rcx
movq %rcx, -0x30(%rbp)
leaq 0x1174f(%rip), %rbx     # 0x173ab
leaq 0x11757(%rip), %r15     # 0x173ba
xorl %r12d, %r12d
leaq 0x150c3(%rip), %rax     # 0x1ad30
movq (%rax,%r12,8), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2040
cltq
addq %r13, %rax
movq %r12, %rcx
shlq $0x5, %rcx
movq -0x30(%rbp), %rdx
movups (%rdx,%rcx), %xmm0
movups 0x10(%rdx,%rcx), %xmm1
movaps %xmm1, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
xorl %r14d, %r14d
movq %rax, %r13
movzbl -0x60(%rbp,%r14), %edx
movq %rax, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2040
cltq
addq %r13, %rax
incq %r14
cmpq $0x20, %r14
jne 0x5ca5
movw $0xa, (%rax)
incq %rax
incq %r12
movq %rax, %r13
cmpq $0x3, %r12
jne 0x5c66
leaq 0x116d3(%rip), %rdi     # 0x173b7
leaq -0x460(%rbp), %rsi
xorl %eax, %eax
callq 0x2030
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq