// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/exe.c
// Function: do_pe_resource_dir_table
static void do_pe_resource_dir_table(deark *c, lctx *d, i64 rel_pos, int level)
{
	i64 named_node_count;
	i64 unnamed_node_count;
	i64 node_count;
	i64 i;

	// 16-byte "Resource node header" a.k.a "Resource directory table"

	if(d->rsrc_errflag) goto done;

	if(level>3) {
		de_warn(c, "Resource tree too deep");
		goto done;
	}

	de_dbg(c, "resource directory table at %"I64_FMT"(%"I64_FMT"), level=%d",
		(i64)(d->pe_cur_base_addr+rel_pos), rel_pos, level);

	named_node_count = de_getu16le(d->pe_cur_base_addr+rel_pos+12);
	unnamed_node_count = de_getu16le(d->pe_cur_base_addr+rel_pos+14);
	de_dbg(c, "number of node entries: named=%u, unnamed=%u", (UI)named_node_count,
		(UI)unnamed_node_count);

	node_count = named_node_count + unnamed_node_count;

	// An array of 8-byte "Resource node entries" follows the Resource node header.
	for(i=0; i<node_count; i++) {
		if(d->rsrc_errflag) goto done;
		do_pe_resource_node(c, d, rel_pos+16+8*i, level);
	}

done:
	;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpb $0x0, 0x6(%rsi)
je 0x44ec6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %r13d
movq %rdi, %rbp
cmpl $0x4, %ecx
jl 0x44ef0
leaq 0xcb1fd(%rip), %rsi     # 0x1100d5
movq %rbp, %rdi
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdf05a
movq %rdx, %rbx
movq %rsi, %r12
movq 0xe8(%rsi), %rdx
addq %rbx, %rdx
leaq 0xcb1e5(%rip), %rsi     # 0x1100ec
movq %rbp, %rdi
movq %rbx, %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%rbx,%rax), %rsi
addq $0xc, %rsi
callq 0xe3fa3
movq %rax, %r14
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%rbx,%rax), %rsi
addq $0xe, %rsi
callq 0xe3fa3
movq %rax, %r15
leaq 0xcb1c5(%rip), %rsi     # 0x11011b
movq %rbp, %rdi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xde896
addq %r14, %r15
leal 0x1(%r13), %eax
movl %eax, 0x28(%rsp)
testq %r15, %r15
movl $0x0, %eax
cmovleq %rax, %r15
addq $0x10, %rbx
movq %rbp, 0x30(%rsp)
subq $0x1, %r15
jb 0x44eb7
cmpb $0x0, 0x6(%r12)
jne 0x44eb7
movq %rbp, %rdi
leaq 0x2c(%rsp), %rsi
callq 0xdebae
movq 0x118(%r12), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x118(%r12)
cmpq $0x2710, %rax           # imm = 0x2710
jl 0x44fe1
movq %rbp, %rdi
leaq 0xcb179(%rip), %rsi     # 0x110148
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, 0x6(%r12)
jmp 0x4533e
movq %r15, 0x10(%rsp)
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rsi
addq %rbx, %rsi
callq 0xe409f
movq %rax, %r14
movl %r14d, %r15d
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
testl %r14d, %r14d
cmovnsl %r14d, %r15d
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
movq %rbx, 0x20(%rsp)
leaq (%rbx,%rax), %rsi
addq $0x4, %rsi
callq 0xe409f
movq %rax, %rbp
leaq -0x80000000(%rax), %rcx
testl %ebp, %ebp
movq %rax, 0x8(%rsp)
movq %rcx, 0x18(%rsp)
cmovsq %rcx, %rbp
movq %r13, %rbx
cmpl $0x1, %r13d
jne 0x45067
movl %r15d, 0x108(%r12)
movl %r15d, %edi
callq 0x45353
movq %rax, 0x110(%r12)
movl %r14d, %r10d
shrl $0x1f, %r10d
movq 0x8(%rsp), %r11
shrl $0x1f, %r11d
movq 0xe8(%r12), %rcx
movq 0x20(%rsp), %rax
addq %rax, %rcx
subq $0x8, %rsp
movq 0x38(%rsp), %rdi
leaq 0xcb0c4(%rip), %rsi     # 0x11015b
movq %rbx, %r13
movq %rax, %rbx
movl %r13d, %edx
movq %rax, %r8
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq %rbp
movq %rdi, %rbp
callq 0xde896
addq $0x20, %rsp
movq 0xe8(%r12), %rax
addq %rbx, %rax
movq 0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x450d9
movb $0x1, 0x6(%r12)
jmp 0x45339
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movl 0x108(%r12), %edx
cmpl $0x18, %edx
ja 0x452b3
movl $0x100010e, %eax        # imm = 0x100010E
btl %edx, %eax
jae 0x452b3
cmpl $0x2, %r13d
jne 0x4513b
testl %r14d, %r14d
jns 0x4513d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
addq 0xf8(%r12), %r14
movq %r14, 0x100(%r12)
movq %rbp, %rdi
leaq 0xcb099(%rip), %rsi     # 0x1101c8
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
jmp 0x45146
jge 0x45146
andq $0x0, 0x100(%r12)
cmpl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %r15
jns 0x4516b
movq %rbp, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x28(%rsp), %ecx
callq 0x44ea3
jmp 0x4533e
movq 0x110(%r12), %rax
testq %rax, %rax
je 0x45181
movq 0x8(%rax), %r9
testq %r9, %r9
jne 0x45188
leaq 0xd9d59(%rip), %r9      # 0x11eee1
movl 0x108(%r12), %r8d
movq 0xe8(%r12), %rdx
movq 0x8(%rsp), %r15
addq %r15, %rdx
movq %rbp, %rdi
leaq 0xcb144(%rip), %rsi     # 0x1102ee
movq %r15, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rsi
addq %r15, %rsi
callq 0xe409f
movq %rax, %r14
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%r15,%rax), %rsi
addq $0x4, %rsi
callq 0xe409f
movq %rbp, %rdi
leaq 0xcb127(%rip), %rsi     # 0x110320
movq %r14, %rdx
movl %r14d, %ecx
movq %rax, 0x18(%rsp)
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
subq 0xf0(%r12), %r14
addq 0xf8(%r12), %r14
movq %rbp, %rdi
leaq 0xcb128(%rip), %rsi     # 0x110350
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbp, %rdi
callq 0xdfd1a
movq %rax, 0x8(%rsp)
movq 0x100(%r12), %r15
testq %r15, %r15
je 0x45300
cmpb $0x0, 0xd0(%rbp)
je 0x452e8
movq 0x18(%rbp), %rdi
movq %r15, %rsi
callq 0xe3fa3
movq %rbp, %rbx
testq %rax, %rax
jle 0x452ed
movq %rax, %rbp
movq %rbx, %rdi
callq 0xeac74
movq 0x18(%rbx), %rdi
addq $0x2, %r15
addq %rbp, %rbp
movq %r15, %rsi
movq %rax, %r15
movq %rbp, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
pushq $0x3
popq %r9
callq 0xe4c9a
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xdfd55
jmp 0x452f0
movq 0x110(%r12), %rax
testq %rax, %rax
movq 0x10(%rsp), %r15
je 0x452ce
movq 0x8(%rax), %rcx
testq %rcx, %rcx
jne 0x452d5
leaq 0xd9c0c(%rip), %rcx     # 0x11eee1
movq %rbp, %rdi
leaq 0xcaec5(%rip), %rsi     # 0x1101a4
xorl %eax, %eax
callq 0xde896
jmp 0x4533e
xorl %r15d, %r15d
jmp 0x452f8
xorl %r15d, %r15d
movq %rbx, %rbp
movq 0x20(%rsp), %rbx
movq %r15, %rdi
callq 0xeaf3c
movq 0x110(%r12), %rdx
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rcx
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r14
movq %r14, %r9
callq 0x4594b
movq %rbp, %rdi
movq %r14, %rsi
callq 0xdfd24
movq %rbp, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x10(%rsp), %r15
movl 0x2c(%rsp), %esi
movq %rbp, %rdi
callq 0xdebb7
addq $0x8, %rbx
jmp 0x44f86