// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/wmf.c
// Function: wmf_handler_ESCAPE
static int wmf_handler_ESCAPE(deark *c, lctx *d, struct decoder_params *dp)
{
	u16 escfn;
	i64 bytecount = 0;
	const struct escape_info *einfo = NULL;
	const char *name;
	size_t k;

	escfn = (u16)de_getu16le(dp->dpos);

	// Find the name, etc. of this record type
	for(k=0; k<DE_ARRAYCOUNT(escape_info_arr); k++) {
		if(escape_info_arr[k].escfn == escfn) {
			einfo = &escape_info_arr[k];
			break;
		}
	}

	if(einfo && einfo->name)
		name = einfo->name;
	else
		name = "?";

	de_dbg(c, "escape function: 0x%04x (%s)", (unsigned int)escfn, name);

	if(dp->dlen>=4) {
		bytecount = de_getu16le(dp->dpos+2);
		de_dbg(c, "bytecount: %d (offset %d + %d = %d)", (int)bytecount,
			(int)(dp->dpos+4), (int)bytecount, (int)(dp->dpos+4+bytecount));
	}

	if(4+bytecount > dp->dlen) {
		goto done;
	}

	if(escfn==0x000f) {
		do_ESCAPE_MFCOMMENT(c, d, dp, bytecount);
	}

done:
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movq 0x20(%rdx), %rsi
callq 0xeebc8
movl $0x8, %ecx
leaq 0xba996(%rip), %rdx     # 0x18d790
cmpw %ax, -0x8(%rcx,%rdx)
je 0xd2e10
addq $0x10, %rcx
cmpq $0x3c8, %rcx            # imm = 0x3C8
jne 0xd2dfa
jmp 0xd2e19
movq (%rcx,%rdx), %rcx
testq %rcx, %rcx
jne 0xd2e20
leaq 0x59331(%rip), %rcx     # 0x12c151
movzwl %ax, %ebp
leaq 0x6dd6f(%rip), %rsi     # 0x140b99
xorl %r12d, %r12d
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x28(%r15), %rax
cmpq $0x4, %rax
jl 0xd2e83
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
addq $0x2, %rsi
callq 0xeebc8
movq %rax, %r12
movl 0x20(%r15), %eax
leal (%rax,%r12), %r9d
addl $0x4, %r9d
movl %eax, %ecx
addl $0x4, %ecx
leaq 0x6dd47(%rip), %rsi     # 0x140bb6
movq %rbx, %rdi
movl %r12d, %edx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xe8617
movq 0x28(%r15), %rax
cmpl $0xf, %ebp
jne 0xd2f52
leaq 0x4(%r12), %rcx
cmpq %rax, %rcx
jg 0xd2f52
movq 0x20(%r15), %rbp
leaq 0x4(%rbp), %r13
cmpq $0x4, %r12
jl 0xd2f18
movq %r14, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed61
movl %eax, %r14d
cmpq $0x43464d57, %r14       # imm = 0x43464D57
leaq 0x6e050(%rip), %rax     # 0x140f1a
leaq 0x59280(%rip), %rdx     # 0x12c151
cmoveq %rax, %rdx
leaq 0x57f7e(%rip), %rsi     # 0x12ae5a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
cmpq $0x43464d57, %r14       # imm = 0x43464D57
jne 0xd2f30
movq 0x28(%r15), %r12
addq 0x20(%r15), %r12
movq %r13, 0x10(%rsp)
addq $0x26, %rbp
cmpq %r12, %rbp
jle 0xd2f66
leaq 0x6e02c(%rip), %rsi     # 0x140f38
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
jmp 0xd2f52
leaq 0x57f3b(%rip), %rsi     # 0x12ae5a
leaq 0x5922b(%rip), %rdx     # 0x12c151
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0xe8bea
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xeed83
movq %rax, %r15
leaq 0x6dfea(%rip), %rsi     # 0x140f68
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x43464d57, %r15d      # imm = 0x43464D57
movq 0x20(%rsp), %r14
jne 0xd2f52
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xeed83
movq %rax, %r15
leaq 0x6dfd1(%rip), %rsi     # 0x140f82
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
cmpq $0x1, %r15
jne 0xd314d
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xeed83
leaq 0x5eaea(%rip), %rsi     # 0x131aca
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeebeb
leaq 0x6dfd5(%rip), %rsi     # 0x140fd4
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
leaq 0x6dfd2(%rip), %rsi     # 0x140ff0
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
leaq 0x6dfc1(%rip), %rsi     # 0x140ffe
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, %r13
leaq 0x6dfb6(%rip), %rsi     # 0x141015
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
leaq 0x6dfac(%rip), %rsi     # 0x14102b
movq %rbx, %rdi
movq %rax, 0x18(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, %rbp
leaq 0x6df98(%rip), %rsi     # 0x14103e
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq (%r15), %rdx
leaq (%rdx,%r13), %rax
cmpq %r12, %rax
jg 0xd2f52
leaq 0x6df92(%rip), %rsi     # 0x14105b
movq %rbx, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x20(%r14), %rcx
testq %rcx, %rcx
jne 0xd3106
movq 0x18(%rsp), %rax
addq %r13, %rax
cmpq %rbp, %rax
jne 0xd3106
leaq 0x48082(%rip), %rsi     # 0x11b175
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %rcx
movq %rax, 0x20(%r14)
testq %rcx, %rcx
je 0xd2f52
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq %r13, %rdx
callq 0xef481
movq 0x20(%r14), %rdi
testq %rdi, %rdi
sete %al
cmpq $0x0, 0x18(%rsp)
setne %cl
orb %al, %cl
jne 0xd2f52
callq 0xf052b
movq $0x0, 0x20(%r14)
jmp 0xd2f52
leaq 0x6de42(%rip), %rsi     # 0x140f96
jmp 0xd2f0c