// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/exe.c
// Function: do_opt_coff_data_dirs
static void do_opt_coff_data_dirs(deark *c, lctx *d, i64 pos)
{
	i64 rsrc_tbl_rva;
	i64 rsrc_tbl_size;
	i64 pe_security_pos;
	i64 pe_security_size;

	de_dbg(c, "COFF/PE optional header (data directories) at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	rsrc_tbl_rva = de_getu32le(pos+16);
	// I don't know if rsrc_tbl_rva will be needed for anything. It seems redundant.
	rsrc_tbl_size = de_getu32le(pos+20);
	de_dbg(c, "resource table RVA=0x%08x, size=%"I64_FMT, (UI)rsrc_tbl_rva,
		rsrc_tbl_size);

	pe_security_pos = de_getu32le(pos+32);
	pe_security_size = de_getu32le(pos+36);
	de_dbg(c, "security pos=0x%08x, size=%"I64_FMT, (UI)pe_security_pos,
		pe_security_size);
	if(pe_security_pos>0) {
		de_dbg_indent(c, 1);
		do_certificate(c, d, pe_security_pos, pe_security_size);
		de_dbg_indent(c, -1);
	}

	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xd5eed(%rip), %rsi     # 0x11cd49
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
leaq 0x10(%r12), %rsi
callq 0xeed61
movq %rax, %r15
movq 0x18(%rbx), %rdi
leaq 0x14(%r12), %rsi
callq 0xeed61
leaq 0xd5ee5(%rip), %rsi     # 0x11cd7b
movq %rbx, %rdi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
leaq 0x20(%r12), %rsi
callq 0xeed61
movq %rax, %r15
movq 0x18(%rbx), %rdi
addq $0x24, %r12
movq %r12, %rsi
callq 0xeed61
movq %rax, %r12
leaq 0xd5ece(%rip), %rsi     # 0x11cd9f
movq %rbx, %rdi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8617
testq %r15, %r15
jle 0x47008
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
cmpq $0x9, %r12
jl 0x46ffb
leaq (%r12,%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x46ffb
leaq 0xd5ea3(%rip), %rsi     # 0x11cdbd
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed61
movq %rax, %r13
leaq 0xcfd31(%rip), %rsi     # 0x116c7b
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
leaq 0x4(%r15), %rsi
callq 0xeebc8
leaq 0xd5e6a(%rip), %rsi     # 0x11cdd5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
leaq 0x6(%r15), %rsi
callq 0xeebc8
movq %rax, %rbp
leaq 0xd5e58(%rip), %rsi     # 0x11cde6
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
cmpq $0x9, %r13
setl %al
cmpq %r12, %r13
setg %cl
orb %al, %cl
jne 0x46fee
cmpb $0x0, 0x4(%r14)
je 0x46fee
cmpl $0x2, 0x90(%rbx)
jl 0x46fee
cmpq $0x2, %rbp
leaq 0xd5e2e(%rip), %rax     # 0x11cdf4
leaq 0xd5e2b(%rip), %rcx     # 0x11cdf8
cmoveq %rax, %rcx
movq 0x18(%rbx), %rdi
addq $0x8, %r15
addq $-0x8, %r13
movq %r15, %rsi
movq %r13, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xefd48
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8a15