// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rsi, %r15
movq %rdi, %r12
movslq 0x10(%rsi), %rcx
movl %ecx, 0x10(%rdi)
movq 0x8(%rsi), %r14
movq %r14, 0x8(%rdi)
movq %r14, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
imull %ecx, %r14d
movq %r14, %rdi
callq 0x10f0
movq %rax, %rdi
movq %rax, (%r12)
movl (%rbx), %eax
movq (%r15), %rsi
cmpl $0x2, %eax
je 0x1d8c
cmpl $0x3, %eax
je 0x1c8e
cmpl $0x4, %eax
jne 0x1e63
movl 0x4(%rbx), %eax
movl %eax, 0x20(%rsp)
movl 0x8(%rbx), %eax
movl %eax, 0x18(%rsp)
movq 0x8(%rsp), %rcx
addl $-0x2, %ecx
movq 0x10(%rsp), %rax
movslq %eax, %r9
movslq %ecx, %rcx
movq %rcx, 0x30(%rsp)
subq %r9, %rsi
pushq $0x1
popq %r11
cmpq 0x30(%rsp), %r11
jge 0x1e54
movl %eax, 0x28(%rsp)
movslq %eax, %r13
leaq (%rsi,%r13), %r15
incq %r11
movq %r11, 0x8(%rsp)
imulq %r9, %r11
addq $-0x2, %r11
incq %r13
cmpq %r11, %r13
jge 0x1c7c
xorl %eax, %eax
movq %r15, %r10
leaq 0x629(%rip), %r14       # 0x2220
leaq 0x662(%rip), %rbp       # 0x2260
xorl %ebx, %ebx
xorl %edx, %edx
cmpq $0x4, %rax
je 0x1c3e
xorl %ecx, %ecx
cmpq $0x4, %rcx
je 0x1c2e
movzbl (%r10,%rcx), %r8d
movl (%r14,%rcx,4), %r12d
imull %r8d, %r12d
addl %r12d, %ebx
imull (%rbp,%rcx,4), %r8d
addl %r8d, %edx
incq %rcx
jmp 0x1c0a
incq %rax
addq $0x10, %rbp
addq $0x10, %r14
addq %r9, %r10
jmp 0x1c02
movl %ebx, %ecx
negl %ecx
cmovsl %ebx, %ecx
movl %edx, %eax
negl %eax
cmovsl %edx, %eax
addl %ecx, %eax
imull 0x20(%rsp), %eax
xorl %edx, %edx
pushq $0x18
popq %rcx
divl %ecx
movl $0xff, %ecx
cmpl %ecx, %eax
cmovael %ecx, %eax
cmpl 0x18(%rsp), %eax
movl $0x0, %ecx
cmovbl %ecx, %eax
movb %al, (%rdi,%r13)
incq %r15
jmp 0x1bdf
movl 0x28(%rsp), %eax
addl 0x10(%rsp), %eax
movq 0x8(%rsp), %r11
jmp 0x1bb9
movl 0x4(%rbx), %eax
movl 0x8(%rbx), %ecx
decq 0x8(%rsp)
movq 0x10(%rsp), %rdx
leal 0x1(%rdx), %r8d
movslq %edx, %rdx
leaq (%rsi,%rdx), %r9
movq %rsi, %r10
movq %rdx, 0x28(%rsp)
subq %rdx, %r10
pushq $0x1
popq %r14
cmpq 0x8(%rsp), %r14
jge 0x1e54
movl %r8d, 0x20(%rsp)
movslq %r8d, %rbx
incq %r14
movq %r14, 0x18(%rsp)
imulq 0x28(%rsp), %r14
decq %r14
cmpq %r14, %rbx
jge 0x1d78
movzbl (%r9,%rbx), %r15d
movzbl (%r10,%rbx), %r12d
subl %r12d, %r15d
movzbl -0x1(%r9,%rbx), %r12d
movzbl -0x1(%r10,%rbx), %r13d
movzbl 0x1(%r9,%rbx), %r8d
movzbl 0x1(%r10,%rbx), %ebp
leal (%r12,%r15,2), %r15d
addl %r8d, %r15d
subl %r13d, %r15d
subl %ebp, %r15d
movl %r15d, %edx
negl %edx
cmovsl %r15d, %edx
movzbl 0x1(%rsi,%rbx), %r15d
movzbl -0x1(%rsi,%rbx), %r11d
subl %r11d, %r15d
addl %r12d, %r13d
subl %r13d, %r8d
addl %ebp, %r8d
leal (%r8,%r15,2), %r8d
movl %r8d, %r15d
negl %r15d
cmovsl %r8d, %r15d
addl %edx, %r15d
imull %eax, %r15d
shrl $0x3, %r15d
movl $0xff, %edx
cmpl %edx, %r15d
jb 0x1d61
movl $0xff, %r15d
xorl %r12d, %r12d
cmpl %ecx, %r15d
jb 0x1d6c
movl %r15d, %r12d
movb %r12b, (%rdi,%rbx)
incq %rbx
jmp 0x1cdc
movl 0x20(%rsp), %r8d
addl 0x10(%rsp), %r8d
movq 0x18(%rsp), %r14
jmp 0x1cb8
movl 0x4(%rbx), %eax
movl 0x8(%rbx), %ecx
movslq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdx
cmpl $0x2, %edx
pushq $0x1
popq %r9
cmovgel %edx, %r9d
decl %r9d
movq %r9, 0x20(%rsp)
movq %r8, 0x18(%rsp)
leaq (%rsi,%r8), %r9
incq %r9
incq %rsi
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq 0x20(%rsp), %r10
je 0x1e54
movslq %r11d, %rbx
incq %r10
movq %r10, %r14
imulq 0x18(%rsp), %r14
decq %r14
cmpq %r14, %rbx
jge 0x1e4a
movzbl -0x1(%r9,%rbx), %r15d
movzbl -0x1(%rsi,%rbx), %r12d
movzbl (%r9,%rbx), %r13d
movzbl (%rsi,%rbx), %ebp
leal (%r15,%r13), %edx
subl %r12d, %edx
subl %ebp, %edx
movl %edx, %r8d
negl %r8d
cmovsl %edx, %r8d
addl %r15d, %r12d
subl %r12d, %r13d
addl %ebp, %r13d
movl %r13d, %ebp
negl %ebp
cmovsl %r13d, %ebp
addl %r8d, %ebp
imull %eax, %ebp
shrl $0x2, %ebp
movl $0xff, %edx
cmpl %edx, %ebp
jb 0x1e37
movl $0xff, %ebp
xorl %r15d, %r15d
cmpl %ecx, %ebp
jb 0x1e41
movl %ebp, %r15d
movb %r15b, (%rdi,%rbx)
incq %rbx
jmp 0x1de1
addl 0x10(%rsp), %r11d
jmp 0x1dc4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10e0