// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/emf.c
// Function: emf_handler_4c
static int emf_handler_4c(deark *c, lctx *d, struct decoder_params *dp)
{
	i64 rop;
	i64 bmi_offs;
	i64 bmi_len;
	i64 bits_offs;
	i64 bits_len;

	if(dp->recsize_bytes<100) return 1;

	rop = de_getu32le(dp->recpos+40);
	de_dbg(c, "raster operation: 0x%08x", (UI)rop);

	bmi_offs = de_getu32le(dp->recpos+84);
	bmi_len = de_getu32le(dp->recpos+88);
	de_dbg(c, "bmi offset=%"I64_FMT", len=%"I64_FMT, bmi_offs, bmi_len);
	bits_offs = de_getu32le(dp->recpos+92);
	bits_len = de_getu32le(dp->recpos+96);
	de_dbg(c, "bits offset=%"I64_FMT", len=%"I64_FMT, bits_offs, bits_len);

	if(bmi_len<12) return 1;
	if(bmi_offs<100) return 1;
	if(bmi_offs+bmi_len>dp->recsize_bytes) return 1;
	if(bits_len<1) return 1;
	if(bits_offs<100) return 1;
	if(bits_offs+bits_len>dp->recsize_bytes) return 1;
	extract_dib(c, d, dp->recpos+bmi_offs, bmi_len, dp->recpos+bits_offs, bits_len);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x64, 0x10(%rax)
jge 0x5af2b
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x28, %rsi
callq 0x165540
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
leaq 0x14cb59(%rip), %rsi    # 0x1a7ab2
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x54, %rsi
callq 0x165540
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x58, %rsi
callq 0x165540
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq 0x14cb1e(%rip), %rsi    # 0x1a7acb
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x5c, %rsi
callq 0x165540
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x60, %rsi
callq 0x165540
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0x14cae2(%rip), %rsi    # 0x1a7ae3
movb $0x0, %al
callq 0x15b0d0
cmpq $0xc, -0x38(%rbp)
jge 0x5b01b
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
cmpq $0x64, -0x30(%rbp)
jge 0x5b02e
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0x5b049
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
cmpq $0x1, -0x48(%rbp)
jge 0x5b059
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
cmpq $0x64, -0x40(%rbp)
jge 0x5b069
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
movq -0x40(%rbp), %rax
addq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0x5b084
movl $0x1, -0x4(%rbp)
jmp 0x5b0b8
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
addq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
addq -0x40(%rbp), %r8
movq -0x48(%rbp), %r9
callq 0x5c370
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)