// File: /workspace/github_c_makefile_star2_O1/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 0xef1ca
xorl %ecx, %ecx
leaq 0xb9d36(%rip), %rdx     # 0x18d790
xorl %esi, %esi
cmpw %ax, (%rsi,%rdx)
je 0xd3a71
addq $0x10, %rsi
cmpq $0x3c0, %rsi            # imm = 0x3C0
jne 0xd3a5c
jmp 0xd3a77
addq %rsi, %rdx
movq %rdx, %rcx
testq %rcx, %rcx
je 0xd3a85
movq 0x8(%rcx), %rcx
testq %rcx, %rcx
jne 0xd3a8c
leaq 0x583dd(%rip), %rcx     # 0x12be69
movzwl %ax, %ebp
leaq 0x6cd03(%rip), %rsi     # 0x140799
xorl %r12d, %r12d
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x4, 0x28(%r15)
jl 0xd3ae8
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
addq $0x2, %rsi
callq 0xef1ca
movq %rax, %r12
movl 0x20(%r15), %eax
leal (%rax,%r12), %r9d
addl $0x4, %r9d
movl %eax, %ecx
addl $0x4, %ecx
leaq 0x6ccde(%rip), %rsi     # 0x1407b6
movq %rbx, %rdi
movl %r12d, %edx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xe9226
cmpl $0xf, %ebp
jne 0xd3bcf
leaq 0x4(%r12), %rcx
movq 0x28(%r15), %rax
cmpq %rax, %rcx
jg 0xd3bcf
movq 0x20(%r15), %rbp
addq %rbp, %rax
leaq (%r12,%rbp), %rcx
addq $0x4, %rcx
cmpq %rax, %rcx
jg 0xd3bcf
leaq 0x4(%rbp), %r13
cmpq $0x4, %r12
jl 0xd3b95
movq %r14, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef37e
movl %eax, %r14d
cmpq $0x43464d57, %r14       # imm = 0x43464D57
leaq 0x6cfd3(%rip), %rax     # 0x140b1a
leaq 0x5831b(%rip), %rdx     # 0x12be69
cmoveq %rax, %rdx
leaq 0x57031(%rip), %rsi     # 0x12ab8a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpq $0x43464d57, %r14       # imm = 0x43464D57
jne 0xd3bad
movq %r13, 0x10(%rsp)
movq 0x28(%r15), %r13
addq 0x20(%r15), %r13
addq $0x26, %rbp
cmpq %r13, %rbp
jle 0xd3be3
leaq 0x6cfaf(%rip), %rsi     # 0x140b38
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
jmp 0xd3bcf
leaq 0x56fee(%rip), %rsi     # 0x12ab8a
leaq 0x582c6(%rip), %rdx     # 0x12be69
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
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 0xe975a
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 0xef3a0
movq %rax, %r15
leaq 0x6cf6d(%rip), %rsi     # 0x140b68
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x43464d57, %r15d      # imm = 0x43464D57
movq 0x20(%rsp), %r14
jne 0xd3bcf
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xef3a0
movq %rax, %r15
leaq 0x6cf54(%rip), %rsi     # 0x140b82
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x1, %r15
jne 0xd3dc3
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xef3a0
leaq 0x5dae9(%rip), %rsi     # 0x131746
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef1ed
leaq 0x6cf58(%rip), %rsi     # 0x140bd4
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
leaq 0x6cf55(%rip), %rsi     # 0x140bf0
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
leaq 0x6cf44(%rip), %rsi     # 0x140bfe
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
movq %rax, %r12
leaq 0x6cf39(%rip), %rsi     # 0x140c15
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
leaq 0x6cf2f(%rip), %rsi     # 0x140c2b
movq %rbx, %rdi
movq %rax, 0x18(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
movq %rax, %rbp
leaq 0x6cf1b(%rip), %rsi     # 0x140c3e
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq (%r15), %rdx
leaq (%rdx,%r12), %rax
cmpq %r13, %rax
jg 0xd3bcf
leaq 0x6cf15(%rip), %rsi     # 0x140c5b
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe9226
cmpq $0x0, 0x20(%r14)
movq 0x18(%rsp), %r15
jne 0xd3d7f
leaq (%r15,%r12), %rax
cmpq %rbp, %rax
jne 0xd3d7f
leaq 0x472de(%rip), %rsi     # 0x11b04d
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, 0x20(%r14)
movq 0x20(%r14), %rcx
testq %rcx, %rcx
je 0xd3d99
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0xefabc
movq 0x20(%r14), %rdi
testq %rdi, %rdi
sete %al
testq %r15, %r15
setne %cl
orb %al, %cl
jne 0xd3bcf
callq 0xf0b13
movq $0x0, 0x20(%r14)
jmp 0xd3bcf
leaq 0x6cdcc(%rip), %rsi     # 0x140b96
jmp 0xd3b89