// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/debug_directory.c
// Function: debug_directory_print
int debug_directory_print(
  FILE *in,
  int addr,
  int size,
  struct section_header_t *section_header)
{
  struct debug_directory_t debug_directory;
  int n;

  uint32_t virtual_address = section_header->VirtualAddress;
  uint32_t raw_ptr = section_header->PointerToRawData;

  addr = (addr - virtual_address) + raw_ptr;
  long marker = ftell(in);
  fseek(in, addr, SEEK_SET);

  printf("  -- Debug Directory --\n\n");

  for (n = 0; n < size; n += 28)
  {
    printf("  -- Debug Directory Entry %d --\n", n / 28);

    debug_directory_entry_read(&debug_directory, in);
    debug_directory_entry_print(&debug_directory);

    if (debug_directory.type == 2)
    {
      debug_directory_print_codeview(&debug_directory, in);
    }
  }

  fseek(in, marker, SEEK_SET);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
subl 0x10(%rcx), %r14d
addl 0x18(%rcx), %r14d
callq 0x30f0
movq %rax, 0x28(%rsp)
movslq %r14d, %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3100
leaq 0x4e46(%rip), %rdi      # 0x8e22
callq 0x3060
movl %ebp, 0x20(%rsp)
testl %ebp, %ebp
jle 0x425f
leaq 0x8(%rsp), %r13
leaq 0x4c85(%rip), %r14      # 0x8c7e
leaq 0x4d22(%rip), %rbp      # 0x8d22
leaq 0x4df8(%rip), %r15      # 0x8dff
xorl %r12d, %r12d
movl %r12d, %eax
shrl $0x2, %eax
imulq $0x24924925, %rax, %rsi # imm = 0x24924925
shrq $0x20, %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3090
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x51f0
movw %ax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x51f0
movw %ax, 0xe(%rsp)
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x51ae
movl %eax, 0x1c(%rsp)
movl 0x4(%rsp), %esi
movq %rbp, %rdi
xorl %eax, %eax
callq 0x3090
movq %r13, %rdi
callq 0x3080
leaq 0x4c96(%rip), %rdi      # 0x8d3a
movq %rax, %rsi
xorl %eax, %eax
callq 0x3090
movzwl 0xc(%rsp), %esi
leaq 0x4c97(%rip), %rdi      # 0x8d51
xorl %eax, %eax
callq 0x3090
movzwl 0xe(%rsp), %esi
leaq 0x4c9c(%rip), %rdi      # 0x8d69
xorl %eax, %eax
callq 0x3090
movl 0x10(%rsp), %esi
leaq 0x4ca2(%rip), %rdi      # 0x8d81
xorl %eax, %eax
callq 0x3090
movl 0x10(%rsp), %eax
cmpq $0x10, %rax
ja 0x410e
leaq 0x4d45(%rip), %rcx      # 0x8e3c
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x4c49(%rip), %rdi      # 0x8d4e
xorl %eax, %eax
callq 0x3090
jmp 0x411c
leaq 0x4c85(%rip), %rdi      # 0x8d9a
xorl %eax, %eax
callq 0x3090
leaq 0x6cd3(%rip), %rdi      # 0xadf6
callq 0x3060
movl 0x14(%rsp), %esi
leaq 0x4c6b(%rip), %rdi      # 0x8d9e
xorl %eax, %eax
callq 0x3090
movl 0x18(%rsp), %esi
leaq 0x4c71(%rip), %rdi      # 0x8db6
xorl %eax, %eax
callq 0x3090
movl 0x1c(%rsp), %esi
leaq 0x4c7b(%rip), %rdi      # 0x8dd2
xorl %eax, %eax
callq 0x3090
movl $0xa, %edi
callq 0x3030
cmpl $0x2, 0x10(%rsp)
jne 0x4250
movq %r14, %rbp
movq %rbx, %rdi
callq 0x30f0
movq %rax, %r14
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3100
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
movl $0x4, %edx
callq 0x525a
cmpl $0x53445352, 0x24(%rsp) # imm = 0x53445352
jne 0x4246
movq %r14, 0x30(%rsp)
leaq 0x4c38(%rip), %rdi      # 0x8df3
xorl %eax, %eax
callq 0x3090
movl $0x10, %r13d
movq %rbx, %rdi
callq 0x3150
movq %r15, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x3090
decl %r13d
jne 0x41c8
movl $0xa, %edi
callq 0x3030
movq %rbx, %rdi
callq 0x51ae
leaq 0x4c0b(%rip), %rdi      # 0x8e05
movl %eax, %esi
xorl %eax, %eax
callq 0x3090
leaq 0x4c0b(%rip), %rdi      # 0x8e15
xorl %eax, %eax
callq 0x3090
movq %rbx, %rdi
callq 0x3150
testl %eax, %eax
je 0x4226
movl %eax, %edi
callq 0x3030
jmp 0x4211
leaq 0x3eed(%rip), %rdi      # 0x811a
callq 0x3060
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0x3100
leaq 0x8(%rsp), %r13
movq %rbp, %r14
leaq 0x4ad2(%rip), %rbp      # 0x8d22
addl $0x1c, %r12d
cmpl 0x20(%rsp), %r12d
jl 0x400a
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x3100
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop