// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/olepropset.c
// Function: do_PropertySet
static void do_PropertySet(deark *c, lctx *d, struct propset_struct *si,
	i64 tblindex)
{
	i64 nproperties;
	i64 n;
	i64 i;
	struct prop_info_struct pinfo;
	u8 *whichpass = NULL;
	u8 pass;

	// I think this is the length of the data section
	n = dbuf_getu32le(d->f, si->tbloffset);
	de_dbg(c, "property data length: %d", (int)n);

	nproperties = dbuf_getu32le(d->f, si->tbloffset+4);
	de_dbg(c, "number of properties: %d", (int)nproperties);
	if(nproperties>200) goto done;

	// AFAICT it's legal for the interpretation of a property to depend on
	// properties that appear *after* it in the property table. For example,
	// a Dictionary really needs to be interpreted after Code Page, and before
	// any properties whose names are given in it. But it can appear anywhere.
	whichpass = de_malloc(c, nproperties);
	for(i=0; i<nproperties; i++) {
		u32 prop_id;
		prop_id = (u32)dbuf_getu32le(d->f, si->tbloffset+8 + 8*i);
		if(prop_id==0x00000001U || prop_id==0x80000000U || prop_id==0x80000001U ||
			prop_id==0x80000003U)
		{
			whichpass[i] = 1;
		}
		else if(prop_id==0x00000000U) {
			whichpass[i] = 2;
		}
		else {
			whichpass[i] = 3;
		}
	}

	for(pass=1; pass<=3; pass++) {
		de_dbg2(c, "pass %u", (unsigned int)pass);

		for(i=0; i<nproperties; i++) {
			char displayname[100];

			if(whichpass[i] != pass) continue;

			de_zeromem(&pinfo, sizeof(struct prop_info_struct));

			pinfo.prop_id = (u32)dbuf_getu32le(d->f, si->tbloffset+8 + 8*i);
			pinfo.data_offs_rel = dbuf_getu32le(d->f, si->tbloffset+8 + 8*i + 4);
			pinfo.dpos = si->tbloffset+pinfo.data_offs_rel+4;
			set_prop_name(c, si, &pinfo);

			if(pinfo.name_disposition==1) {
				de_strlcpy(displayname, pinfo.name, sizeof(displayname));
			}
			else if(pinfo.name_disposition==2) {
				de_snprintf(displayname, sizeof(displayname), "\"%s\"", pinfo.name);
			}
			else {
				de_strlcpy(displayname, "?", sizeof(displayname));
			}

			de_dbg(c, "prop[%d]: id=0x%08x (%s), data_offs=%d", (int)i,
				(unsigned int)pinfo.prop_id, displayname, (int)pinfo.data_offs_rel);
			de_dbg_indent(c, 1);
			if(pinfo.prop_id==0x00000000U) {
				do_dictionary(c, d, si, &pinfo);
			}
			else {
				do_prop_toplevel(c, d, si, &pinfo);
			}
			de_dbg_indent(c, -1);
		}
	}

done:
	de_free(c, whichpass);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x165540
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl %eax, %edx
leaq 0xee847(%rip), %rsi     # 0x1b8dd5
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq $0x4, %rsi
callq 0x165540
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0xee82d(%rip), %rsi     # 0x1b8dee
movb $0x0, %al
callq 0x15b0d0
cmpq $0xc8, -0x28(%rbp)
jle 0xca5d7
jmp 0xca8be
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x15b780
movq %rax, -0xb0(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xca6a5
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x165540
movl %eax, -0xb8(%rbp)
cmpl $0x1, -0xb8(%rbp)
je 0xca656
cmpl $0x80000000, -0xb8(%rbp) # imm = 0x80000000
je 0xca656
cmpl $0x80000001, -0xb8(%rbp) # imm = 0x80000001
je 0xca656
cmpl $0x80000003, -0xb8(%rbp) # imm = 0x80000003
jne 0xca667
movq -0xb0(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xca692
cmpl $0x0, -0xb8(%rbp)
jne 0xca681
movq -0xb0(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x2, (%rax,%rcx)
jmp 0xca690
movq -0xb0(%rbp), %rax
movq -0x38(%rbp), %rcx
movb $0x3, (%rax,%rcx)
jmp 0xca692
jmp 0xca694
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xca5f3
movb $0x1, -0xb1(%rbp)
movzbl -0xb1(%rbp), %eax
cmpl $0x3, %eax
jg 0xca8bc
movq -0x8(%rbp), %rdi
movzbl -0xb1(%rbp), %edx
leaq 0xee739(%rip), %rsi     # 0x1b8e07
movb $0x0, %al
callq 0x15b350
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jge 0xca8a7
movq -0xb0(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movzbl -0xb1(%rbp), %ecx
cmpl %ecx, %eax
je 0xca70a
jmp 0xca896
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x19140
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x165540
movl %eax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
addq $0x8, %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
addq $0x4, %rsi
callq 0x165540
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
addq -0xa0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0xca970
cmpl $0x1, -0x90(%rbp)
jne 0xca7c6
leaq -0x120(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
addq $0x1c, %rsi
movl $0x64, %edx
callq 0x15aa30
jmp 0xca810
cmpl $0x2, -0x90(%rbp)
jne 0xca7f6
leaq -0x120(%rbp), %rdi
leaq -0xa8(%rbp), %rcx
addq $0x1c, %rcx
movl $0x64, %esi
leaq 0xd8c70(%rip), %rdx     # 0x1a345d
movb $0x0, %al
callq 0x15a980
jmp 0xca80e
leaq -0x120(%rbp), %rdi
leaq 0xed429(%rip), %rsi     # 0x1b7c2d
movl $0x64, %edx
callq 0x15aa30
jmp 0xca810
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
movl -0xa8(%rbp), %ecx
leaq -0x120(%rbp), %r8
movq -0xa0(%rbp), %rax
movl %eax, %r9d
leaq 0xee5d7(%rip), %rsi     # 0x1b8e0f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpl $0x0, -0xa8(%rbp)
jne 0xca870
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0xcab10
jmp 0xca888
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0xcad40
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xca6dd
jmp 0xca8a9
movb -0xb1(%rbp), %al
addb $0x1, %al
movb %al, -0xb1(%rbp)
jmp 0xca6ac
jmp 0xca8be
movq -0x8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x15b820
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)