// File: /workspace/github_c_makefile_star2_O3/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 0xcc69
movl 0x8(%rbx), %edx
leaq 0x868d(%rip), %rsi      # 0x152a5
leaq -0x460(%rbp), %rdi
xorl %eax, %eax
callq 0x2040
cltq
leaq (%rax,%rbp), %r14
addq $-0x460, %r14           # imm = 0xFBA0
movl 0xc(%rbx), %edx
leaq 0x8676(%rip), %rsi      # 0x152b3
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r15
addq %r14, %r15
movl 0x10(%rbx), %edx
leaq 0x866a(%rip), %rsi      # 0x152c1
movq %r15, %rdi
xorl %eax, %eax
callq 0x2040
movslq %eax, %r12
addq %r15, %r12
jmp 0xcc70
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 0x870e(%rip), %r14      # 0x153ba
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 0xccaf
movw $0xa, (%r12)
leaq 0x1(%r12), %rdi
subq $0x8, %rsp
leaq 0x8638(%rip), %r10      # 0x15323
leaq 0x85ec(%rip), %rsi      # 0x152de
leaq 0x8608(%rip), %rdx      # 0x15301
leaq 0x860a(%rip), %rcx      # 0x1530a
leaq 0x860c(%rip), %r8       # 0x15313
leaq 0x860d(%rip), %r9       # 0x1531b
xorl %eax, %eax
pushq %r10
callq 0x2040
addq $0x10, %rsp
cltq
leaq (%r12,%rax), %r15
incq %r15
movq $-0x18, %r12
leaq 0xbffe(%rip), %rax      # 0x18d30
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 0x85c4(%rip), %rsi      # 0x1532c
movl %r13d, %edx
xorl %eax, %eax
pushq %r15
pushq %r11
pushq %r10
callq 0x2040
addq $0x20, %rsp
movslq %eax, %r15
leaq 0xbfaa(%rip), %rax      # 0x18d30
addq %r14, %r15
incq %r13
addq $0x8, %r12
jne 0xcd39
cmpb $0x0, -0x34(%rbp)
je 0xcdc8
leaq 0x85ad(%rip), %r14      # 0x1534c
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 0xcda6
jmp 0xcdcc
movq -0x30(%rbp), %r13
movups 0x858b(%rip), %xmm0     # 0x1535e
movups %xmm0, (%r15)
movl $0xa3a65, 0xf(%r15)     # imm = 0xA3A65
leaq 0x12(%r15), %rdi
movl 0x94(%r13), %edx
movl 0x98(%r13), %ecx
leaq 0x8579(%rip), %rsi      # 0x15371
xorl %eax, %eax
callq 0x2040
cltq
leaq (%r15,%rax), %r14
addq $0x12, %r14
movl 0x9c(%r13), %edx
movl 0xa0(%r13), %ecx
leaq 0x8567(%rip), %rsi      # 0x15385
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
cltq
movups 0x8568(%rip), %xmm0     # 0x15399
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 0x8551(%rip), %rbx      # 0x153ab
leaq 0x8559(%rip), %r15      # 0x153ba
xorl %r12d, %r12d
leaq 0xbec5(%rip), %rax      # 0x18d30
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 0xcea3
movw $0xa, (%rax)
incq %rax
incq %r12
movq %rax, %r13
cmpq $0x3, %r12
jne 0xce64
leaq 0x84d5(%rip), %rdi      # 0x153b7
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