// File: /workspace/github_c_makefile_star2_O2/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 0xe3fa3
xorl %edx, %edx
leaq 0xc669e(%rip), %rcx     # 0x190790
leaq 0x10(%rdx), %rsi
cmpq $0x3d0, %rsi            # imm = 0x3D0
je 0xca112
cmpw %ax, (%rdx,%rcx)
movq %rsi, %rdx
jne 0xca0f2
movq -0x8(%rsi,%rcx), %rcx
testq %rcx, %rcx
jne 0xca119
leaq 0x54dc8(%rip), %rcx     # 0x11eee1
movzwl %ax, %ebp
leaq 0x69706(%rip), %rsi     # 0x133829
xorl %r12d, %r12d
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq 0x28(%r15), %rax
cmpq $0x4, %rax
jl 0xca17c
movq 0x18(%rbx), %rdi
movq 0x20(%r15), %rsi
addq $0x2, %rsi
callq 0xe3fa3
movq %rax, %r12
movl 0x20(%r15), %eax
leal (%rax,%r12), %r9d
addl $0x4, %r9d
movl %eax, %ecx
addl $0x4, %ecx
leaq 0x696de(%rip), %rsi     # 0x133846
movq %rbx, %rdi
movl %r12d, %edx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xde896
movq 0x28(%r15), %rax
cmpl $0xf, %ebp
jne 0xca24b
leaq 0x4(%r12), %rcx
cmpq %rax, %rcx
jg 0xca24b
movq 0x20(%r15), %rbp
leaq 0x4(%rbp), %r13
cmpq $0x4, %r12
jl 0xca211
movq %r14, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe409f
movl %eax, %r14d
cmpq $0x43464d57, %r14       # imm = 0x43464D57
leaq 0x699e7(%rip), %rax     # 0x133baa
leaq 0x54d17(%rip), %rdx     # 0x11eee1
cmoveq %rax, %rdx
leaq 0x53a15(%rip), %rsi     # 0x11dbea
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpq $0x43464d57, %r14       # imm = 0x43464D57
jne 0xca229
movq %r13, 0x10(%rsp)
movq 0x28(%r15), %r13
addq 0x20(%r15), %r13
addq $0x26, %rbp
cmpq %r13, %rbp
jle 0xca25d
leaq 0x699c3(%rip), %rsi     # 0x133bc8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
jmp 0xca24b
leaq 0x539d2(%rip), %rsi     # 0x11dbea
leaq 0x54cc2(%rip), %rdx     # 0x11eee1
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
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 0xded3a
pushq $0x1
popq %rax
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 0xe40bf
movq %rax, %r15
leaq 0x69983(%rip), %rsi     # 0x133bf8
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x43464d57, %r15d      # imm = 0x43464D57
movq 0x20(%rsp), %r14
jne 0xca24b
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe40bf
movq %rax, %r15
leaq 0x6996a(%rip), %rsi     # 0x133c12
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
cmpq $0x1, %r15
jne 0xca441
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xe40bf
leaq 0x5a507(%rip), %rsi     # 0x1247de
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
leaq 0x6996e(%rip), %rsi     # 0x133c64
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
leaq 0x6996b(%rip), %rsi     # 0x133c80
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
leaq 0x6995a(%rip), %rsi     # 0x133c8e
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, %r12
leaq 0x6994f(%rip), %rsi     # 0x133ca5
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
leaq 0x69945(%rip), %rsi     # 0x133cbb
movq %rbx, %rdi
movq %rax, 0x18(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, %rbp
leaq 0x69931(%rip), %rsi     # 0x133cce
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq (%r15), %rdx
leaq (%rdx,%r12), %rax
cmpq %r13, %rax
jg 0xca24b
leaq 0x6992b(%rip), %rsi     # 0x133ceb
movq %rbx, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x20(%r14), %rcx
testq %rcx, %rcx
jne 0xca3fd
movq 0x18(%rsp), %rax
addq %r12, %rax
cmpq %rbp, %rax
jne 0xca3fd
leaq 0x43c9b(%rip), %rsi     # 0x10e085
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %rcx
movq %rax, 0x20(%r14)
testq %rcx, %rcx
je 0xca24b
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0xe45f4
movq 0x20(%r14), %rdi
testq %rdi, %rdi
sete %al
cmpq $0x0, 0x18(%rsp)
setne %cl
orb %al, %cl
jne 0xca24b
callq 0xe5591
andq $0x0, 0x20(%r14)
jmp 0xca24b
leaq 0x697de(%rip), %rsi     # 0x133c26
jmp 0xca205