// File: /workspace/github_c_makefile_star2_O2/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 $0x468, %rsp            # imm = 0x468
movq %rdi, %rbx
movl %esi, -0x2c(%rbp)
testl %esi, %esi
je 0x342d
movl 0x8(%rbx), %edx
leaq 0xeed9(%rip), %rsi      # 0x122b5
leaq -0x470(%rbp), %rdi
xorl %eax, %eax
callq 0x2040
cltq
leaq (%rax,%rbp), %r15
addq $-0x470, %r15           # imm = 0xFB90
movl 0xc(%rbx), %edx
leaq 0xeec2(%rip), %rsi      # 0x122c3
movq %r15, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r12
addq %r15, %r12
movl 0x10(%rbx), %edx
leaq 0xeeb6(%rip), %rsi      # 0x122d1
movq %r12, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %rsi
addq %r12, %rsi
jmp 0x3434
leaq -0x470(%rbp), %rsi
movabsq $0x203a64695f646c, %rax # imm = 0x203A64695F646C
movq %rax, 0x7(%rsi)
movabsq $0x6c6975625f756e67, %rax # imm = 0x6C6975625F756E67
movq %rax, (%rsi)
addq $0xe, %rsi
movups 0x44(%rbx), %xmm0
movups 0x54(%rbx), %xmm1
movaps %xmm1, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps -0x70(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x5fc2
movq %rax, %r15
movw $0xa, (%rax)
leaq 0x1(%rax), %rdi
leaq 0xeea4(%rip), %rax      # 0x12333
movq %rax, (%rsp)
leaq 0xee54(%rip), %rsi      # 0x122ee
leaq 0xee70(%rip), %rdx      # 0x12311
leaq 0xee72(%rip), %rcx      # 0x1231a
leaq 0xee74(%rip), %r8       # 0x12323
leaq 0xee75(%rip), %r9       # 0x1232b
xorl %eax, %eax
callq 0x2040
cltq
addq %rax, %r15
incq %r15
pushq $0x19
popq %r13
leaq 0xee6c(%rip), %r12      # 0x1233c
xorl %r14d, %r14d
cmpq $0x1c, %r13
je 0x3526
leaq 0x13850(%rip), %rax     # 0x16d30
movq (%r14,%rax), %rcx
movl (%rbx,%r13,4), %r9d
movl 0x14(%rbx,%r14,2), %r8d
movl 0x18(%rbx,%r14,2), %eax
movl 0x1c(%rbx,%r14,2), %esi
movl 0x20(%rbx,%r14,2), %edi
leal -0x19(%r13), %edx
movl %edi, 0x10(%rsp)
movl %esi, 0x8(%rsp)
movl %eax, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2040
cltq
addq %rax, %r15
incq %r13
addq $0x8, %r14
jmp 0x34d3
cmpb $0x0, -0x2c(%rbp)
je 0x3558
leaq 0xee29(%rip), %r14      # 0x1235c
xorl %r12d, %r12d
cmpq $0x9, %r12
je 0x3558
movl 0x70(%rbx,%r12,4), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
cltq
addq %rax, %r15
incq %r12
jmp 0x3536
movups 0xee0f(%rip), %xmm0     # 0x1236e
movups %xmm0, (%r15)
movl $0xa3a65, 0xf(%r15)     # imm = 0xA3A65
leaq 0x12(%r15), %rdi
movl 0x94(%rbx), %edx
movl 0x98(%rbx), %ecx
leaq 0xedff(%rip), %rsi      # 0x12381
xorl %eax, %eax
callq 0x2040
cltq
leaq (%r15,%rax), %r14
addq $0x12, %r14
movl 0x9c(%rbx), %edx
movl 0xa0(%rbx), %ecx
leaq 0xedef(%rip), %rsi      # 0x12395
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
cltq
movups 0xedf0(%rip), %xmm0     # 0x123a9
leaq (%rax,%r14), %r12
addq $0x11, %r12
movups %xmm0, -0x11(%r12)
movw $0xa, -0x1(%r12)
leaq 0xede5(%rip), %r14      # 0x123bb
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x364b
leaq 0x13747(%rip), %rax     # 0x16d30
movq (%r13,%rax), %rcx
movq %r12, %rdi
movq %r14, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2040
movslq %eax, %rsi
addq %r12, %rsi
movups 0xa4(%rbx,%r13,4), %xmm0
movups 0xb4(%rbx,%r13,4), %xmm1
movaps %xmm0, -0x50(%rbp)
movaps %xmm1, -0x40(%rbp)
movaps -0x50(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x5fc2
movq %rax, %r12
movw $0xa, (%rax)
incq %r12
incq %r15
addq $0x8, %r13
jmp 0x35dc
leaq 0xed75(%rip), %rdi      # 0x123c7
leaq -0x470(%rbp), %rsi
xorl %eax, %eax
callq 0x2030
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq