// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/wmf.c
// Function: de_run_wmf
static void de_run_wmf(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos = 0;

	d = de_malloc(c, sizeof(lctx));

	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	if(!dbuf_memcmp(c->infile, 0, "\xd7\xcd\xc6\x9a", 4)) {
		d->has_aldus_header = 1;
		de_declare_fmt(c, "WMF (placeable)");
	}
	else {
		de_declare_fmt(c, "WMF (non-placeable)");
	}

	if(d->has_aldus_header) {
		do_read_aldus_header(c, d);
		pos = 22;
	}

	if(!do_read_wmf_header(c, d, pos)) {
		goto done;
	}
	pos += 18;

	do_wmf_record_list(c, d, pos);

done:
	if(d) {
		if(d->embedded_emf) dbuf_close(d->embedded_emf);
		de_free(c, d->object_table);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
pushq $0x30
popq %rsi
callq 0xdecaf
movq %rax, %r14
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x4(%r14)
movq 0x18(%rbx), %rdi
leaq 0x69b55(%rip), %rdx     # 0x133480
pushq $0x4
popq %rcx
xorl %esi, %esi
callq 0xe4d48
testl %eax, %eax
je 0xc9942
leaq 0x69b55(%rip), %rsi     # 0x133495
jmp 0xc9950
movl $0x1, (%r14)
leaq 0x69b35(%rip), %rsi     # 0x133485
movq %rbx, %rdi
callq 0xe07f7
cmpl $0x0, (%r14)
je 0xc9a04
leaq 0x69b40(%rip), %rsi     # 0x1334a9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
pushq $0x6
popq %rsi
callq 0xe400a
movq %rax, %r15
movq 0x18(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0xe400a
movq %rax, %r12
movq 0x18(%rbx), %rdi
pushq $0xa
popq %rsi
callq 0xe400a
movq %rax, %r13
movq 0x18(%rbx), %rdi
pushq $0xc
popq %rsi
callq 0xe400a
leaq 0x69b10(%rip), %rsi     # 0x1334ce
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0xe
popq %rsi
callq 0xe3fa3
leaq 0x69b03(%rip), %rsi     # 0x1334ea
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
pushq $0x16
popq %r13
jmp 0xc9a07
xorl %r13d, %r13d
leaq 0x69af8(%rip), %rsi     # 0x133506
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fa3
movq %rax, 0x8(%r14)
leaq 0x3e38e(%rip), %rsi     # 0x107dcb
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x8(%r14), %rdx
leaq -0x1(%rdx), %rax
cmpq $0x2, %rax
jae 0xc9d25
movq 0x18(%rbx), %rdi
leaq 0x2(%r13), %rsi
callq 0xe3fa3
movq %rax, %r15
leal (%rax,%rax), %edx
leaq 0x69acc(%rip), %rsi     # 0x133541
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpq $0x9, %r15
jne 0xc9d31
movq 0x18(%rbx), %rdi
leaq 0x4(%r13), %rsi
callq 0xe3fa3
movq %rax, 0x10(%r14)
movl %eax, %edx
shrl $0x8, %edx
movl $0xff, %ecx
andl %ecx, %edx
andl %eax, %ecx
leaq 0x69ad6(%rip), %rsi     # 0x133585
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x6(%r13), %rsi
callq 0xe409f
leal (%rax,%rax), %edx
leaq 0x69acc(%rip), %rsi     # 0x13359c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0xa(%r13), %rsi
callq 0xe3fa3
movl %eax, 0x18(%r14)
leaq 0x69ac7(%rip), %rsi     # 0x1335b9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x28(%r14), %rsi
testq %rsi, %rsi
je 0xc9b0f
movq %rbx, %rdi
callq 0xded32
movl 0x18(%r14), %esi
movq %rbx, %rdi
callq 0xdecaf
movq %r14, (%rsp)
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
leaq 0xc(%r13), %rsi
callq 0xe409f
leal (%rax,%rax), %edx
leaq 0x69a95(%rip), %rsi     # 0x1335cf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
addq $0x12, %r13
leaq 0x5e7a9(%rip), %rsi     # 0x128303
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0xc6587(%rip), %r12     # 0x190100
xorl %ebp, %ebp
movq %rbx, 0x8(%rsp)
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %r13
jge 0xc9d14
movq %r13, %r15
movq %r13, %rsi
callq 0xe409f
cmpq $0x3, %rax
jl 0xc9d14
leaq (%r15,%rax,2), %rcx
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rcx
jg 0xc9d14
movq %rcx, 0x10(%rsp)
leaq (%rax,%rax), %r13
andq $0x0, 0x18(%rsp)
movq %r15, 0x20(%rsp)
shlq $0x2, %rax
movq %rax, 0x28(%rsp)
movq %r13, 0x30(%rsp)
leaq 0x6(%r15), %rbx
movq %rbx, 0x38(%rsp)
addq $-0x6, %r13
movq %r13, 0x40(%rsp)
leaq 0x4(%r15), %rsi
callq 0xe3fa3
movw %ax, 0x18(%rsp)
movb %al, 0x1a(%rsp)
xorl %ecx, %ecx
leaq 0x18(%rcx), %r14
cmpq $0x6a8, %r14            # imm = 0x6A8
je 0xc9c7e
cmpb %al, (%rcx,%r12)
movq %r14, %rcx
jne 0xc9bfd
movzwl %ax, %r8d
movq -0x10(%r14,%r12), %r9
movq 0x8(%rsp), %rdi
leaq 0x699c1(%rip), %rsi     # 0x1335e9
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
pushq %r13
pushq %rbx
movq %rdi, %rbx
callq 0xde896
popq %rax
popq %rcx
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
testb $0x1, -0x17(%r14,%r12)
movq 0x10(%rsp), %r13
je 0xc9ce3
movq (%rsp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
je 0xc9ce3
movq (%rsp), %rcx
movl 0x18(%rcx), %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0xc9cbb
cmpb $0x0, (%rax,%rdx)
je 0xc9cce
incq %rdx
jmp 0xc9c6e
movzwl %ax, %r8d
movq 0x8(%rsp), %rdi
leaq 0x6995b(%rip), %rsi     # 0x1335e9
movl %ebp, %edx
movl %r15d, %ecx
leaq 0x55247(%rip), %r9      # 0x11eee1
xorl %eax, %eax
pushq %r13
pushq %rbx
movq %rdi, %rbx
callq 0xde896
popq %rax
popq %rcx
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x10(%rsp), %r13
jmp 0xc9cfb
movq %rbx, %rdi
leaq 0x6a199(%rip), %rsi     # 0x133e5e
xorl %eax, %eax
callq 0xdf05a
jmp 0xc9ce3
movb $0x1, (%rax,%rdx)
movq %rbx, %rdi
leaq 0x6a168(%rip), %rsi     # 0x133e44
xorl %eax, %eax
callq 0xde896
movq -0x8(%r14,%r12), %rax
testq %rax, %rax
je 0xc9cfb
movq %rbx, %rdi
movq (%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq *%rax
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
incq %rbp
cmpb $0x0, 0x1a(%rsp)
jne 0xc9b80
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq (%rsp), %r14
jmp 0xc9d50
leaq 0x697eb(%rip), %rsi     # 0x133517
movq %rbx, %rdi
jmp 0xc9d3e
leaq 0x6981f(%rip), %rsi     # 0x133557
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xdf2a5
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0xc9d5e
callq 0xe5591
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq