// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rcx, 0x28(%rsp)
cmpb $0x0, 0x6(%rsi)
je 0x46fec
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbp
movq 0x28(%rsp), %r8
cmpl $0x4, %r8d
jl 0x47019
leaq 0xd60b4(%rip), %rsi     # 0x11d0b5
movq %rbp, %rdi
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9b27
movq %rdx, %rbx
movq %rsi, %r12
movq 0xe8(%rsi), %rdx
addq %rbx, %rdx
leaq 0xd609c(%rip), %rsi     # 0x11d0cc
movq %rbp, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%rbx,%rax), %rsi
addq $0xc, %rsi
callq 0xef1ca
movq %rax, %r14
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%rbx,%rax), %rsi
addq $0xe, %rsi
callq 0xef1ca
movq %rax, %r15
leaq 0xd607f(%rip), %rsi     # 0x11d0fb
movq %rbp, %rdi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe9226
addq %r14, %r15
jle 0x46fdd
addq $0x10, %rbx
movq 0x28(%rsp), %rax
incl %eax
movl %eax, 0x34(%rsp)
leaq 0x4(%rsp), %r14
xorl %r13d, %r13d
movq %rbp, 0x38(%rsp)
movq %rbx, 0x18(%rsp)
movq %r15, 0x10(%rsp)
cmpb $0x0, 0x6(%r12)
jne 0x46fdd
movq %rbp, %rdi
movq %r14, %rsi
callq 0xe958c
movq 0x118(%r12), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x118(%r12)
cmpq $0x2710, %rax           # imm = 0x2710
jl 0x4710a
movq %rbp, %rdi
leaq 0xd6030(%rip), %rsi     # 0x11d128
xorl %eax, %eax
callq 0xe9df7
movb $0x1, 0x6(%r12)
jmp 0x474bc
movq %r13, 0x20(%rsp)
leaq (%rbx,%r13,8), %rbx
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rsi
addq %rbx, %rsi
callq 0xef37e
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
leaq (%rbx,%rax), %rsi
addq $0x4, %rsi
callq 0xef37e
movq %rax, %r13
addq $-0x80000000, %rax      # imm = 0x80000000
testl %r13d, %r13d
cmovnsq %r13, %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rdx
cmpl $0x1, %edx
jne 0x471a5
movl %r15d, 0x108(%r12)
xorl %eax, %eax
leaq 0x13a42c(%rip), %rcx    # 0x1815b0
cmpl %r15d, (%rax,%rcx)
je 0x4719a
addq $0x18, %rax
cmpq $0x198, %rax            # imm = 0x198
jne 0x47184
xorl %eax, %eax
jmp 0x4719d
addq %rcx, %rax
movq %rax, 0x110(%r12)
movl %r14d, %r10d
shrl $0x1f, %r10d
movl %r13d, %r11d
shrl $0x1f, %r11d
movq 0xe8(%r12), %rcx
addq %rbx, %rcx
subq $0x8, %rsp
movq 0x40(%rsp), %rbp
movq %rbp, %rdi
leaq 0xd5f6a(%rip), %rsi     # 0x11d13b
movq %rbx, %r8
movl %r15d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x20(%rsp)
callq 0xe9226
addq $0x20, %rsp
addq 0xe8(%r12), %rbx
movq 0x18(%rbp), %rax
cmpq 0x18(%rax), %rbx
jle 0x47207
movb $0x1, 0x6(%r12)
jmp 0x474a8
movq %rbp, %rdi
movl $0x1, %esi
callq 0xe9585
movl 0x108(%r12), %edx
cmpl $0x18, %edx
ja 0x473ef
movl $0x100010e, %eax        # imm = 0x100010E
btl %edx, %eax
jae 0x473ef
cmpl $0x2, 0x28(%rsp)
jne 0x47265
testl %r14d, %r14d
jns 0x47267
movl %r15d, %edx
addq 0xf8(%r12), %rdx
movq %rdx, 0x100(%r12)
movq %rbp, %rdi
leaq 0xd5f4c(%rip), %rsi     # 0x11d1a8
xorl %eax, %eax
callq 0xe9226
jmp 0x47273
jge 0x47273
movq $0x0, 0x100(%r12)
testl %r13d, %r13d
jns 0x47291
movq %rbp, %rdi
movq %r12, %rsi
movq 0x8(%rsp), %rdx
movl 0x34(%rsp), %ecx
callq 0x46fc4
jmp 0x474a8
movq 0x110(%r12), %rax
testq %rax, %rax
je 0x472a7
movq 0x8(%rax), %r9
testq %r9, %r9
jne 0x472ae
leaq 0xe4bbb(%rip), %r9      # 0x12be69
movl 0x108(%r12), %r8d
movq 0xe8(%r12), %rdx
movq 0x8(%rsp), %rbx
addq %rbx, %rdx
movq %rbp, %rdi
leaq 0xd5ffe(%rip), %rsi     # 0x11d2ce
movq %rbx, %rcx
xorl %eax, %eax
callq 0xe9226
movq %rbp, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rsi
addq %rbx, %rsi
callq 0xef37e
movq %rax, %r13
movq 0x18(%rbp), %rdi
movq 0xe8(%r12), %rax
leaq (%rbx,%rax), %rsi
addq $0x4, %rsi
callq 0xef37e
movq %rax, %rbx
movq %rbp, %rdi
leaq 0xd5fdc(%rip), %rsi     # 0x11d300
movq %r13, %rdx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xe9226
subq 0xf0(%r12), %r13
addq 0xf8(%r12), %r13
movq %rbp, %rdi
leaq 0xd5fe2(%rip), %rsi     # 0x11d330
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbp, %rdi
callq 0xea9a9
movq %rax, %r14
movq 0x100(%r12), %r15
testq %r15, %r15
je 0x4744e
cmpb $0x0, 0xd0(%rbp)
je 0x47436
movq %r14, 0x8(%rsp)
movq 0x18(%rbp), %rdi
movq %r15, %rsi
callq 0xef1ca
testq %rax, %rax
jle 0x4743a
movq %rax, %r14
movq %rbp, %rdi
callq 0xf6870
movq %rbx, 0x40(%rsp)
movq %rbp, %rbx
movq %rax, %rbp
movq 0x18(%rbx), %rdi
addq $0x2, %r15
addq %r14, %r14
movq %r15, %rsi
movq %r14, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
movl $0x3, %r9d
callq 0xf01b0
movq %rbx, %rdi
movq 0x40(%rsp), %rbx
movq 0x8(%rsp), %r14
movq %r14, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0xea9e4
jmp 0x47441
movq 0x110(%r12), %rax
testq %rax, %rax
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r15
leaq 0x4(%rsp), %r14
movq 0x20(%rsp), %r13
je 0x47419
movq 0x8(%rax), %rcx
testq %rcx, %rcx
jne 0x47420
leaq 0xe4a49(%rip), %rcx     # 0x12be69
movq %rbp, %rdi
leaq 0xd5d5a(%rip), %rsi     # 0x11d184
xorl %eax, %eax
callq 0xe9226
jmp 0x474bc
xorl %ebp, %ebp
jmp 0x47441
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
movq %rbp, %rdi
callq 0xf6bb0
movq 0x38(%rsp), %rbp
cmpb $0x0, 0x4(%r12)
je 0x47490
movq 0x110(%r12), %rax
leaq -0x1(%rbx), %rcx
cmpq $0x5f5e100, %rcx        # imm = 0x5F5E100
setae %cl
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x47490
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x47490
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq *%rax
movq %rbp, %rdi
movq %r14, %rsi
callq 0xea9b3
movq %rbp, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r15
leaq 0x4(%rsp), %r14
movq 0x20(%rsp), %r13
movl 0x4(%rsp), %esi
movq %rbp, %rdi
callq 0xe9595
incq %r13
cmpq %r15, %r13
jne 0x470bb
jmp 0x46fdd