// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/macrsrc.c
// Function: do_resource_record
static void do_resource_record(deark *c, lctx *d, struct rsrctypeinfo *rti,
	i64 pos1, UI idx)
{
	i64 dataOffset_rel;
	i64 nameOffset_rel;
	i64 pos = pos1;
	struct rsrcinstanceinfo rii;

	de_zeromem(&rii, sizeof(struct rsrcinstanceinfo));
	rii.idx = idx;
	rii.id = (int)de_geti16be_p(&pos);
	de_dbg(c, "id: %d", rii.id);
	if(rii.id>=(-16384) && rii.id<=(-1)) {
		UI u;
		UI ownertype, ownerid, subid;

		u = (UI)(rii.id + 65536);
		ownertype = (u & 0xf800) >> 11;
		ownerid = (u & 0x07e0) >> 5;
		subid = (u & 0x001f);
		de_dbg_indent(c, 1);
		de_dbg(c, "owner type: %u (%s)", ownertype, get_ownertype_name(ownertype));
		de_dbg(c, "owner id: %u", ownerid);
		de_dbg(c, "sub id: %u", subid);
		de_dbg_indent(c, -1);
	}

	nameOffset_rel = de_getu16be_p(&pos);
	if(nameOffset_rel!=0xffff) {
		rii.has_name = 1;
		de_dbg(c, "nameOffset: (%d+)%d", (int)d->nameListOffset_abs, (int)nameOffset_rel);
		rii.name_offset = d->nameListOffset_abs+nameOffset_rel;
		do_resource_name(c, d, &rii);
	}
	rii.attribs = de_getbyte_p(&pos);
	if(rii.attribs==0) {
		de_dbg(c, "attributes: 0x%02x", (unsigned int)rii.attribs);
	}
	else {
		de_ucstring *flags_str;
		flags_str = ucstring_create(c);
		if(rii.attribs & 0x40) ucstring_append_flags_item(flags_str, "system heap");
		if(rii.attribs & 0x20) ucstring_append_flags_item(flags_str, "purgeable");
		if(rii.attribs & 0x10) ucstring_append_flags_item(flags_str, "locked");
		if(rii.attribs & 0x08) ucstring_append_flags_item(flags_str, "read-only");
		if(rii.attribs & 0x04) ucstring_append_flags_item(flags_str, "preload");
		if(rii.attribs & 0x01) ucstring_append_flags_item(flags_str, "compressed");
		de_dbg(c, "attributes: 0x%02x (%s)", (unsigned int)rii.attribs, ucstring_getpsz_d(flags_str));
		ucstring_destroy(flags_str);
	}

	dataOffset_rel = dbuf_getint_ext(c->infile, pos, 3, 0, 0);
	rii.data_offset = d->data_offs + dataOffset_rel;
	pos += 3;
	de_dbg(c, "dataOffset: (%d+)%d", (int)d->data_offs, (int)dataOffset_rel);
	do_resource_data(c, d, rti, &rii);

	if(rii.name) ucstring_destroy(rii.name);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x19140
movl -0x24(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1653b0
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movl -0x70(%rbp), %edx
leaq 0xe3b6e(%rip), %rsi     # 0x1b676d
movb $0x0, %al
callq 0x15b0d0
cmpl $0xffffc000, -0x70(%rbp) # imm = 0xFFFFC000
jl 0xd2ccd
cmpl $-0x1, -0x70(%rbp)
jg 0xd2ccd
movl -0x70(%rbp), %eax
addl $0x10000, %eax          # imm = 0x10000
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
andl $0xf800, %eax           # imm = 0xF800
shrl $0xb, %eax
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
andl $0x7e0, %eax            # imm = 0x7E0
shrl $0x5, %eax
movl %eax, -0x7c(%rbp)
movl -0x74(%rbp), %eax
andl $0x1f, %eax
movl %eax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x78(%rbp), %edi
callq 0xd2f10
movq -0x98(%rbp), %rdi
movl -0x8c(%rbp), %edx
movq %rax, %rcx
leaq 0xe7b7c(%rip), %rsi     # 0x1ba80a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl -0x7c(%rbp), %edx
leaq 0xe7b7b(%rip), %rsi     # 0x1ba81e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl -0x80(%rbp), %edx
leaq 0xe7b73(%rip), %rsi     # 0x1ba82b
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165210
movq %rax, -0x38(%rbp)
cmpq $0xffff, -0x38(%rbp)    # imm = 0xFFFF
je 0xd2d33
movb $0x1, -0x67(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movl %eax, %ecx
leaq 0xe7b2b(%rip), %rsi     # 0x1ba836
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0xd2f30
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165170
movb %al, -0x68(%rbp)
movzbl -0x68(%rbp), %eax
cmpl $0x0, %eax
jne 0xd2d6b
movq -0x8(%rbp), %rdi
movzbl -0x68(%rbp), %edx
leaq 0xe7aeb(%rip), %rsi     # 0x1ba84a
movb $0x0, %al
callq 0x15b0d0
jmp 0xd2e80
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x88(%rbp)
movzbl -0x68(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xd2d9a
movq -0x88(%rbp), %rdi
leaq 0xe7ac8(%rip), %rsi     # 0x1ba85d
callq 0x172680
movzbl -0x68(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xd2db9
movq -0x88(%rbp), %rdi
leaq 0xe7ab5(%rip), %rsi     # 0x1ba869
callq 0x172680
movzbl -0x68(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xd2dd8
movq -0x88(%rbp), %rdi
leaq 0xe7aa0(%rip), %rsi     # 0x1ba873
callq 0x172680
movzbl -0x68(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xd2df7
movq -0x88(%rbp), %rdi
leaq 0xe7a88(%rip), %rsi     # 0x1ba87a
callq 0x172680
movzbl -0x68(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0xd2e16
movq -0x88(%rbp), %rdi
leaq 0xe7a73(%rip), %rsi     # 0x1ba884
callq 0x172680
movzbl -0x68(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xd2e35
movq -0x88(%rbp), %rdi
leaq 0xdb6fe(%rip), %rsi     # 0x1ae52e
callq 0x172680
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movzbl -0x68(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x88(%rbp), %rdi
callq 0x172650
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %edx
movq %rax, %rcx
leaq 0xe7a1f(%rip), %rsi     # 0x1ba88c
movb $0x0, %al
callq 0x15b0d0
movq -0x88(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x40(%rbp), %rsi
movl $0x3, %edx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x165a80
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x30(%rbp), %rax
movl %eax, %ecx
leaq 0xe79cd(%rip), %rsi     # 0x1ba8a4
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0xd2ff0
cmpq $0x0, -0x48(%rbp)
je 0xd2f03
movq -0x48(%rbp), %rdi
callq 0x171750
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)