// File: /workspace/github_c_makefile_star2_O1/ravenexp[P]aatrace/diff.c
// Function: aatrace_diff
void aatrace_diff(struct aatrace_pic* dst,
		  const struct aatrace_pic* src,
		  const struct aatrace_diff_ctx* ctx)
{
	dst->w = src->w;
	dst->h = src->h;
	dst->ll = src->ll;

	dst->buf = (unsigned char*)malloc(dst->ll*dst->h);

	switch (ctx->kernel) {
	default:
	case AATRACE_DIFF_KERNEL_NONE:
		memcpy(dst->buf, src->buf, src->ll*src->h);
		break;
	case AATRACE_DIFF_KERNEL_2x2:
		aatrace_diff2(dst->buf, src->buf, src->ll, src->h,
			      ctx->scale, ctx->threshold);
		break;
	case AATRACE_DIFF_KERNEL_3x3:
		aatrace_diff3(dst->buf, src->buf, src->ll, src->h,
			      ctx->scale, ctx->threshold);
		break;
	case AATRACE_DIFF_KERNEL_4x4:
		aatrace_diff4(dst->buf, src->buf, src->ll, src->h,
			      ctx->scale, ctx->threshold);
		break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movl 0xc(%rsi), %eax
movl %eax, 0xc(%rdi)
movl 0x10(%rsi), %eax
movl %eax, 0x10(%rdi)
movl 0x8(%rsi), %edi
movl %edi, 0x8(%r15)
imull %eax, %edi
callq 0x1100
movq %rax, (%r15)
movl (%r14), %ecx
cmpl $0x2, %ecx
je 0x1f16
cmpl $0x3, %ecx
je 0x1de7
cmpl $0x4, %ecx
jne 0x1ff3
movl 0x10(%rbx), %ecx
movl %ecx, 0x1c(%rsp)
cmpl $0x4, %ecx
jl 0x1fe4
movslq 0x8(%rbx), %rdx
movl 0x4(%r14), %ecx
movl %ecx, 0x10(%rsp)
movl 0x8(%r14), %ecx
movl %ecx, 0x8(%rsp)
leal 0x1(%rdx), %ecx
movslq %ecx, %rcx
leal -0x2(,%rdx,2), %r9d
addl $-0x3, 0x1c(%rsp)
movq %rdx, %rsi
notq %rsi
movq %rcx, 0x30(%rsp)
addq %rcx, %rsi
addq (%rbx), %rsi
movq %rsi, 0x28(%rsp)
movl $0x1, %ecx
movl $0xff, %ebp
movl %ecx, %edi
imull %edx, %ecx
movq %rdi, 0x20(%rsp)
leal 0x1(%rdi), %r8d
movl %r8d, 0x4(%rsp)
imull %edx, %r8d
addl $-0x2, %r8d
incl %ecx
cmpl %r8d, %ecx
jge 0x1dc2
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
xorl %r12d, %r12d
movq %rcx, %r10
leaq 0x14ec(%rip), %rbx      # 0x3220
leaq 0x1525(%rip), %r14      # 0x3260
xorl %r13d, %r13d
xorl %r11d, %r11d
xorl %r15d, %r15d
movzbl (%r10,%r15), %esi
movl (%rbx,%r15,4), %edi
imull %esi, %edi
imull (%r14,%r15,4), %esi
addl %edi, %r11d
addl %esi, %r13d
incq %r15
cmpq $0x4, %r15
jne 0x1d44
incq %r12
addq $0x10, %r14
addq $0x10, %rbx
addq %rdx, %r10
cmpq $0x4, %r12
jne 0x1d41
movl %r11d, %esi
negl %esi
cmovsl %r11d, %esi
movl %r13d, %edi
negl %edi
cmovsl %r13d, %edi
addl %esi, %edi
imull 0x10(%rsp), %edi
movl $0xaaaaaaab, %esi       # imm = 0xAAAAAAAB
imulq %rsi, %rdi
shrq $0x24, %rdi
cmpl %ebp, %edi
cmovael %ebp, %edi
cmpl 0x8(%rsp), %edi
movl $0x0, %esi
cmovbl %esi, %edi
movb %dil, (%rax,%r8)
incq %r8
incq %rcx
cmpl %r8d, %r9d
jne 0x1d27
addq %rdx, 0x30(%rsp)
addl %edx, %r9d
addq %rdx, 0x28(%rsp)
movq 0x20(%rsp), %rcx
cmpl 0x1c(%rsp), %ecx
movl 0x4(%rsp), %ecx
jne 0x1cf7
jmp 0x1fe4
movl 0x10(%rbx), %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x3, %ecx
jl 0x1fe4
movq (%rbx), %r15
movslq 0x8(%rbx), %rcx
movl 0x4(%r14), %esi
movl 0x8(%r14), %edi
leal 0x1(%rcx), %r8d
movslq %r8d, %r8
addl $-0x2, 0x4(%rsp)
leaq (%r15,%rcx), %r9
addq %r8, %r9
addq %r8, %rax
leaq (%r15,%r8), %r10
leal -0x2(%rcx), %r11d
subq %rcx, %r8
addq %r15, %r8
movl $0x1, %edx
movq %rcx, 0x20(%rsp)
movl %edx, %ebx
movl %edx, %ebp
imull %ecx, %ebp
incl %ebp
movq %rbx, 0x8(%rsp)
leal 0x1(%rbx), %r15d
movl %r15d, 0x10(%rsp)
imull %ecx, %r15d
decl %r15d
cmpl %r15d, %ebp
jge 0x1eed
xorl %r15d, %r15d
movzbl (%r9,%r15), %r12d
movzbl (%r8,%r15), %ebp
subl %ebp, %r12d
movzbl -0x1(%r9,%r15), %r13d
movzbl -0x1(%r8,%r15), %ebp
movzbl 0x1(%r9,%r15), %ecx
movzbl 0x1(%r8,%r15), %ebx
leal (%r13,%r12,2), %r12d
addl %ecx, %r12d
subl %ebp, %r12d
subl %ebx, %r12d
movl %r12d, %r14d
negl %r14d
cmovsl %r12d, %r14d
movzbl 0x1(%r10,%r15), %r12d
movzbl -0x1(%r10,%r15), %edx
subl %edx, %r12d
addl %r13d, %ebp
subl %ebp, %ecx
addl %ebx, %ecx
leal (%rcx,%r12,2), %ecx
movl %ecx, %ebp
negl %ebp
cmovsl %ecx, %ebp
addl %r14d, %ebp
imull %esi, %ebp
shrl $0x3, %ebp
movl $0xff, %ecx
cmpl %ecx, %ebp
jb 0x1ed3
movl $0xff, %ebp
xorl %r12d, %r12d
cmpl %edi, %ebp
jb 0x1edd
movl %ebp, %r12d
movb %r12b, (%rax,%r15)
incq %r15
cmpl %r15d, %r11d
jne 0x1e5e
movq 0x20(%rsp), %rcx
addq %rcx, %r9
addq %rcx, %rax
addq %rcx, %r10
addq %rcx, %r8
movq 0x8(%rsp), %rdx
cmpl 0x4(%rsp), %edx
movl 0x10(%rsp), %edx
jne 0x1e34
jmp 0x1fe4
movl 0x10(%rbx), %ecx
movl %ecx, 0x8(%rsp)
cmpl $0x2, %ecx
jl 0x1fe4
movq (%rbx), %rdx
movslq 0x8(%rbx), %rsi
movl 0x4(%r14), %edi
movl 0x8(%r14), %r8d
leal -0x1(%rsi), %r9d
addl $-0x2, 0x8(%rsp)
incq %rdx
xorl %r11d, %r11d
movl %r11d, %ebx
imull %esi, %ebx
leal 0x1(%r11), %ecx
movq %rcx, 0x10(%rsp)
movl %ecx, %ebp
imull %esi, %ebp
decl %ebp
cmpl %ebp, %ebx
jge 0x1fce
leaq (%rdx,%rsi), %rbx
xorl %r14d, %r14d
movzbl -0x1(%rbx,%r14), %r15d
movzbl -0x1(%rdx,%r14), %r12d
movzbl (%rbx,%r14), %r13d
movzbl (%rdx,%r14), %ebp
leal (%r15,%r13), %ecx
subl %r12d, %ecx
subl %ebp, %ecx
movl %ecx, %r10d
negl %r10d
cmovsl %ecx, %r10d
addl %r15d, %r12d
subl %r12d, %r13d
addl %ebp, %r13d
movl %r13d, %ebp
negl %ebp
cmovsl %r13d, %ebp
addl %r10d, %ebp
imull %edi, %ebp
shrl $0x2, %ebp
movl $0xff, %ecx
cmpl %ecx, %ebp
jb 0x1fb7
movl $0xff, %ebp
xorl %r15d, %r15d
cmpl %r8d, %ebp
jb 0x1fc2
movl %ebp, %r15d
movb %r15b, (%rax,%r14)
incq %r14
cmpl %r14d, %r9d
jne 0x1f65
addq %rsi, %rax
addq %rsi, %rdx
cmpl 0x8(%rsp), %r11d
movq 0x10(%rsp), %r11
jne 0x1f44
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%rbx), %edx
imull 0x8(%rbx), %edx
movq (%rbx), %rsi
movq %rax, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0