// File: /workspace/github_c_makefile_star2_O1/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 0xd5e3c(%rip), %rsi     # 0x11cc39
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
leaq 0x10(%r12), %rsi
callq 0xef37e
movq %rax, %r15
movq 0x18(%rbx), %rdi
leaq 0x14(%r12), %rsi
callq 0xef37e
leaq 0xd5e34(%rip), %rsi     # 0x11cc6b
movq %rbx, %rdi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x20(%r12), %rsi
callq 0xef37e
movq %rax, %r15
movq 0x18(%rbx), %rdi
addq $0x24, %r12
movq %r12, %rsi
callq 0xef37e
movq %rax, %r12
leaq 0xd5e1d(%rip), %rsi     # 0x11cc8f
movq %rbx, %rdi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
testq %r15, %r15
jle 0x46fa9
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpq $0x9, %r12
jl 0x46f9c
leaq (%r12,%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x46f9c
leaq 0xd5df2(%rip), %rsi     # 0x11ccad
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef37e
movq %rax, %r13
leaq 0xcfce0(%rip), %rsi     # 0x116bcb
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x4(%r15), %rsi
callq 0xef1ca
leaq 0xd5db9(%rip), %rsi     # 0x11ccc5
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x6(%r15), %rsi
callq 0xef1ca
movq %rax, %rbp
leaq 0xd5da7(%rip), %rsi     # 0x11ccd6
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x9, %r13
setl %al
cmpq %r12, %r13
setg %cl
orb %al, %cl
jne 0x46f8f
cmpb $0x0, 0x4(%r14)
je 0x46f8f
cmpl $0x2, 0x90(%rbx)
jl 0x46f8f
cmpq $0x2, %rbp
leaq 0xd5d7d(%rip), %rax     # 0x11cce4
leaq 0xd5d7a(%rip), %rcx     # 0x11cce8
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 0xf0321
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9585