// File: /workspace/github_c_makefile_star2_O3/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
movl $0x30, %esi
callq 0xe8b2b
movq %rax, %r14
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, 0x4(%r14)
movq 0x18(%rbx), %rdi
leaq 0x6e245(%rip), %rdx     # 0x1407f0
movl $0x4, %ecx
xorl %esi, %esi
callq 0xefc85
testl %eax, %eax
je 0xd25c4
leaq 0x6e243(%rip), %rsi     # 0x140805
jmp 0xd25d2
movl $0x1, (%r14)
leaq 0x6e223(%rip), %rsi     # 0x1407f5
movq %rbx, %rdi
callq 0xeb125
cmpl $0x0, (%r14)
je 0xd269b
leaq 0x6e22e(%rip), %rsi     # 0x140819
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movl $0x6, %esi
callq 0xeec55
movq %rax, %r15
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0xeec55
movq %rax, %r12
movq 0x18(%rbx), %rdi
movl $0xa, %esi
callq 0xeec55
movq %rax, %r13
movq 0x18(%rbx), %rdi
movl $0xc, %esi
callq 0xeec55
leaq 0x6e1f4(%rip), %rsi     # 0x14083e
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0xe, %esi
callq 0xeebc8
leaq 0x6e1e5(%rip), %rsi     # 0x14085a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movl $0x28, %r12d
movl $0x16, %edx
jmp 0xd26a3
movl $0x12, %r12d
xorl %edx, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd29b8
testl %eax, %eax
je 0xd28a5
movq %r14, (%rsp)
leaq 0x62f22(%rip), %rsi     # 0x1355e3
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
cmpq %r12, 0x18(%rdi)
jle 0xd2894
leaq 0xbaa10(%rip), %rbp     # 0x18d100
xorl %r13d, %r13d
movq %rbx, 0x8(%rsp)
movq %r12, %rsi
callq 0xeed61
cmpq $0x3, %rax
jl 0xd2894
leaq (%r12,%rax,2), %rcx
movq 0x18(%rbx), %rdi
movq %rcx, 0x10(%rsp)
cmpq 0x18(%rdi), %rcx
jg 0xd2894
leaq (%rax,%rax), %rbx
movq $0x0, 0x18(%rsp)
movq %r12, 0x20(%rsp)
shlq $0x2, %rax
movq %rax, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
leaq 0x6(%r12), %r15
movq %r15, 0x38(%rsp)
addq $-0x6, %rbx
movq %rbx, 0x40(%rsp)
leaq 0x4(%r12), %rsi
callq 0xeebc8
movw %ax, 0x18(%rsp)
movb %al, 0x1a(%rsp)
xorl %r14d, %r14d
cmpb %al, (%r14,%rbp)
je 0xd27bd
addq $0x18, %r14
cmpq $0x690, %r14            # imm = 0x690
jne 0xd276a
movzwl %ax, %r8d
movq 0x8(%rsp), %rdi
leaq 0x6e1cc(%rip), %rsi     # 0x140959
movl %r13d, %edx
movl %r12d, %ecx
leaq 0x599b7(%rip), %r9      # 0x12c151
xorl %eax, %eax
pushq %rbx
movq %rdi, %rbx
pushq %r15
callq 0xe8617
addq $0x10, %rsp
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
jmp 0xd2867
movzwl %ax, %r8d
movq 0x8(%r14,%rbp), %r9
movq 0x8(%rsp), %rdi
leaq 0x6e187(%rip), %rsi     # 0x140959
movl %r13d, %edx
movl %r12d, %ecx
xorl %eax, %eax
pushq %rbx
movq %rdi, %rbx
pushq %r15
callq 0xe8617
addq $0x10, %rsp
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
testb $0x1, 0x1(%r14,%rbp)
je 0xd284f
movq (%rsp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
je 0xd284f
movq (%rsp), %rcx
movl 0x18(%rcx), %ecx
testq %rcx, %rcx
je 0xd2827
xorl %edx, %edx
cmpb $0x0, (%rax,%rdx)
je 0xd283a
incq %rdx
cmpq %rdx, %rcx
jne 0xd2819
movq %rbx, %rdi
leaq 0x6e99d(%rip), %rsi     # 0x1411ce
xorl %eax, %eax
callq 0xe8faa
jmp 0xd284f
movb $0x1, (%rax,%rdx)
movq %rbx, %rdi
leaq 0x6e96c(%rip), %rsi     # 0x1411b4
xorl %eax, %eax
callq 0xe8617
movq 0x10(%r14,%rbp), %rax
testq %rax, %rax
je 0xd2867
movq %rbx, %rdi
movq (%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq *%rax
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpb $0x0, 0x1a(%rsp)
je 0xd2894
incq %r13
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rax
movq %rax, %r12
cmpq 0x18(%rdi), %rax
jl 0xd26f8
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq (%rsp), %r14
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0xd28b3
callq 0xf052b
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq