// File: /workspace/github_c_makefile_star2_O1/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 0x4e2e(%rip), %rdi      # 0x8e22
callq 0x3060
movl %ebp, 0x20(%rsp)
testl %ebp, %ebp
jle 0x4277
leaq 0x8(%rsp), %r13
leaq 0x4c6d(%rip), %r14      # 0x8c7e
leaq 0x4d0a(%rip), %rbp      # 0x8d22
leaq 0x4de0(%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 0x51ca
movl %eax, 0x4(%rsp)
movq %rbx, %rdi
callq 0x51ca
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x520c
movw %ax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x520c
movw %ax, 0xe(%rsp)
movq %rbx, %rdi
callq 0x51ca
movl %eax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x51ca
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
callq 0x51ca
movl %eax, 0x18(%rsp)
movq %rbx, %rdi
callq 0x51ca
movl %eax, 0x1c(%rsp)
movl 0x4(%rsp), %esi
movq %rbp, %rdi
xorl %eax, %eax
callq 0x3090
movq %r13, %rdi
callq 0x3080
leaq 0x4c7e(%rip), %rdi      # 0x8d3a
movq %rax, %rsi
xorl %eax, %eax
callq 0x3090
movzwl 0xc(%rsp), %esi
leaq 0x4c7f(%rip), %rdi      # 0x8d51
xorl %eax, %eax
callq 0x3090
movzwl 0xe(%rsp), %esi
leaq 0x4c84(%rip), %rdi      # 0x8d69
xorl %eax, %eax
callq 0x3090
movl 0x10(%rsp), %esi
leaq 0x4c8a(%rip), %rdi      # 0x8d81
xorl %eax, %eax
callq 0x3090
movl 0x10(%rsp), %eax
cmpq $0x10, %rax
ja 0x4126
leaq 0x4d2d(%rip), %rcx      # 0x8e3c
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0x4c31(%rip), %rdi      # 0x8d4e
xorl %eax, %eax
callq 0x3090
jmp 0x4134
leaq 0x4c6d(%rip), %rdi      # 0x8d9a
xorl %eax, %eax
callq 0x3090
leaq 0x6cbb(%rip), %rdi      # 0xadf6
callq 0x3060
movl 0x14(%rsp), %esi
leaq 0x4c53(%rip), %rdi      # 0x8d9e
xorl %eax, %eax
callq 0x3090
movl 0x18(%rsp), %esi
leaq 0x4c59(%rip), %rdi      # 0x8db6
xorl %eax, %eax
callq 0x3090
movl 0x1c(%rsp), %esi
leaq 0x4c63(%rip), %rdi      # 0x8dd2
xorl %eax, %eax
callq 0x3090
movl $0xa, %edi
callq 0x3030
cmpl $0x2, 0x10(%rsp)
jne 0x4268
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 0x5276
cmpl $0x53445352, 0x24(%rsp) # imm = 0x53445352
jne 0x425e
movq %r14, 0x30(%rsp)
leaq 0x4c20(%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 0x41e0
movl $0xa, %edi
callq 0x3030
movq %rbx, %rdi
callq 0x51ca
leaq 0x4bf3(%rip), %rdi      # 0x8e05
movl %eax, %esi
xorl %eax, %eax
callq 0x3090
leaq 0x4bf3(%rip), %rdi      # 0x8e15
xorl %eax, %eax
callq 0x3090
movq %rbx, %rdi
callq 0x3150
testl %eax, %eax
je 0x423e
movl %eax, %edi
callq 0x3030
jmp 0x4229
leaq 0x3ed5(%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 0x4aba(%rip), %rbp      # 0x8d22
addl $0x1c, %r12d
cmpl 0x20(%rsp), %r12d
jl 0x4022
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