// File: /workspace/github_c_makefile_star2_O3/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, %r12
movl 0x10(%rsi), %eax
movl %eax, 0x10(%rdi)
movq 0x8(%rsi), %r15
movq %r15, 0x8(%rdi)
movq %r15, 0x10(%rsp)
movl %eax, 0xc(%rsp)
imull %eax, %r15d
movq %r15, %rdi
callq 0x10f0
movq %rax, (%r12)
movl (%r14), %ecx
cmpl $0x2, %ecx
je 0x1f73
cmpl $0x3, %ecx
je 0x1e3a
cmpl $0x4, %ecx
jne 0x205a
cmpl $0x4, 0xc(%rsp)
jl 0x204b
movl 0x4(%r14), %ecx
movl 0x8(%r14), %edx
movq 0x10(%rsp), %r8
movslq %r8d, %rsi
leal 0x1(%r8), %edi
movslq %edi, %rdi
leal -0x2(%r8,%r8), %r8d
movq %rsi, %r9
notq %r9
movq %rdi, 0x20(%rsp)
addq %rdi, %r9
addq (%rbx), %r9
movq %r9, 0x30(%rsp)
addl $-0x3, 0xc(%rsp)
movl $0x1, %edi
leaq 0x158d(%rip), %r10      # 0x3260
pxor %xmm0, %xmm0
leaq 0x1542(%rip), %r11      # 0x3220
movl $0xff, %r14d
xorl %r15d, %r15d
movl %edi, %r12d
movq 0x10(%rsp), %rbx
imull %ebx, %edi
movq %r12, 0x28(%rsp)
leal 0x1(%r12), %r9d
movl %r9d, 0x18(%rsp)
imull %ebx, %r9d
addl $-0x2, %r9d
incl %edi
cmpl %r9d, %edi
jge 0x1e13
movq 0x30(%rsp), %r13
movq 0x20(%rsp), %rdi
xorl %ebp, %ebp
movq %r13, %r9
xorl %r12d, %r12d
xorl %ebx, %ebx
movd %r12d, %xmm1
movd %ebx, %xmm2
movdqa (%rbp,%r10), %xmm3
movd (%r9), %xmm4
punpcklbw %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1],xmm4[2],xmm0[2],xmm4[3],xmm0[3],xmm4[4],xmm0[4],xmm4[5],xmm0[5],xmm4[6],xmm0[6],xmm4[7],xmm0[7]
punpcklwd %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1],xmm4[2],xmm0[2],xmm4[3],xmm0[3]
pshufd $0xf5, %xmm3, %xmm5     # xmm5 = xmm3[1,1,3,3]
pmuludq %xmm4, %xmm3
pshufd $0xe8, %xmm3, %xmm3     # xmm3 = xmm3[0,2,2,3]
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pmuludq %xmm6, %xmm5
pshufd $0xe8, %xmm5, %xmm5     # xmm5 = xmm5[0,2,2,3]
punpckldq %xmm5, %xmm3    # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
paddd %xmm1, %xmm3
movdqa (%rbp,%r11), %xmm1
pmuludq %xmm1, %xmm4
pshufd $0xe8, %xmm4, %xmm4     # xmm4 = xmm4[0,2,2,3]
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
pmuludq %xmm6, %xmm1
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
paddd %xmm2, %xmm4
pshufd $0xee, %xmm3, %xmm1     # xmm1 = xmm3[2,3,2,3]
paddd %xmm3, %xmm1
pshufd $0x55, %xmm1, %xmm2     # xmm2 = xmm1[1,1,1,1]
paddd %xmm1, %xmm2
movd %xmm2, %r12d
pshufd $0xee, %xmm4, %xmm1     # xmm1 = xmm4[2,3,2,3]
paddd %xmm4, %xmm1
pshufd $0x55, %xmm1, %xmm2     # xmm2 = xmm1[1,1,1,1]
paddd %xmm1, %xmm2
movd %xmm2, %ebx
addq $0x10, %rbp
addq %rsi, %r9
cmpq $0x40, %rbp
jne 0x1d28
movl %ebx, %r9d
negl %r9d
cmovsl %ebx, %r9d
movl %r12d, %ebx
negl %ebx
cmovsl %r12d, %ebx
addl %r9d, %ebx
imull %ecx, %ebx
movl $0xaaaaaaab, %r9d       # imm = 0xAAAAAAAB
imulq %r9, %rbx
shrq $0x24, %rbx
cmpl %r14d, %ebx
cmovael %r14d, %ebx
cmpl %edx, %ebx
cmovbl %r15d, %ebx
movb %bl, (%rax,%rdi)
incq %rdi
incq %r13
cmpl %edi, %r8d
jne 0x1d1e
addq %rsi, 0x20(%rsp)
addl 0x10(%rsp), %r8d
addq %rsi, 0x30(%rsp)
movq 0x28(%rsp), %rdi
cmpl 0xc(%rsp), %edi
movl 0x18(%rsp), %edi
jne 0x1ce7
jmp 0x204b
cmpl $0x3, 0xc(%rsp)
jl 0x204b
movq (%rbx), %rcx
movl 0x4(%r14), %edx
movl 0x8(%r14), %esi
movq 0x10(%rsp), %r8
leal 0x1(%r8), %edi
movslq %edi, %r11
movslq %r8d, %rdi
addl $-0x2, 0xc(%rsp)
addq %r11, %rax
leaq (%r11,%rcx), %r8
incq %r8
leal -0x2(%rdi), %r9d
movq %r11, %r10
subq %rdi, %r10
addq %rcx, %r10
movq %rdi, 0x20(%rsp)
addq %rdi, %rcx
addq %r11, %rcx
movl $0x1, %edi
movl %edi, %ebx
movl %edi, %ebp
movq 0x10(%rsp), %rdi
imull %edi, %ebp
incl %ebp
movq %rbx, 0x28(%rsp)
leal 0x1(%rbx), %r14d
movl %r14d, 0x18(%rsp)
imull %edi, %r14d
decl %r14d
cmpl %r14d, %ebp
jge 0x1f4a
xorl %r14d, %r14d
movzbl (%rcx,%r14), %r15d
movzbl (%r10,%r14), %ebp
subl %ebp, %r15d
movzbl -0x1(%rcx,%r14), %r12d
movzbl -0x1(%r10,%r14), %r13d
movzbl 0x1(%rcx,%r14), %ebp
movzbl 0x1(%r10,%r14), %r11d
leal (%r12,%r15,2), %r15d
addl %ebp, %r15d
subl %r13d, %r15d
subl %r11d, %r15d
movl %r15d, %edi
negl %edi
cmovsl %r15d, %edi
movzbl (%r8,%r14), %r15d
movzbl -0x2(%r8,%r14), %ebx
subl %ebx, %r15d
addl %r12d, %r13d
subl %r13d, %ebp
addl %r11d, %ebp
leal (%rbp,%r15,2), %r11d
movl %r11d, %ebp
negl %ebp
cmovsl %r11d, %ebp
addl %edi, %ebp
imull %edx, %ebp
shrl $0x3, %ebp
movl $0xff, %edi
cmpl %edi, %ebp
jb 0x1f30
movl $0xff, %ebp
xorl %r15d, %r15d
cmpl %esi, %ebp
jb 0x1f3a
movl %ebp, %r15d
movb %r15b, (%rax,%r14)
incq %r14
cmpl %r14d, %r9d
jne 0x1eba
movq 0x20(%rsp), %rdi
addq %rdi, %rax
addq %rdi, %r8
addq %rdi, %r10
addq %rdi, %rcx
movq 0x28(%rsp), %rdi
cmpl 0xc(%rsp), %edi
movl 0x18(%rsp), %edi
jne 0x1e8b
jmp 0x204b
cmpl $0x2, 0xc(%rsp)
jl 0x204b
movq (%rbx), %rcx
movl 0x4(%r14), %edx
movl 0x8(%r14), %esi
movq 0x10(%rsp), %rdi
movslq %edi, %r8
movq %r8, 0x18(%rsp)
leal -0x1(%rdi), %r8d
addl $-0x2, 0xc(%rsp)
incq %rcx
xorl %r9d, %r9d
movl %r9d, %r10d
movl %r9d, %r11d
movq 0x10(%rsp), %rdi
imull %edi, %r11d
leal 0x1(%r10), %r9d
movl %r9d, %ebx
imull %edi, %ebx
decl %ebx
cmpl %ebx, %r11d
jge 0x2035
movq 0x18(%rsp), %rdi
leaq (%rcx,%rdi), %r11
xorl %ebx, %ebx
movzbl -0x1(%r11,%rbx), %r14d
movzbl -0x1(%rcx,%rbx), %r15d
movzbl (%r11,%rbx), %r12d
movzbl (%rcx,%rbx), %r13d
leal (%r14,%r12), %ebp
subl %r15d, %ebp
subl %r13d, %ebp
movl %ebp, %edi
negl %edi
cmovsl %ebp, %edi
addl %r14d, %r15d
subl %r15d, %r12d
addl %r13d, %r12d
movl %r12d, %ebp
negl %ebp
cmovsl %r12d, %ebp
addl %edi, %ebp
imull %edx, %ebp
shrl $0x2, %ebp
movl $0xff, %edi
cmpl %edi, %ebp
jb 0x201f
movl $0xff, %ebp
xorl %r14d, %r14d
cmpl %esi, %ebp
jb 0x2029
movl %ebp, %r14d
movb %r14b, (%rax,%rbx)
incq %rbx
cmpl %ebx, %r8d
jne 0x1fd0
movq 0x18(%rsp), %rdi
addq %rdi, %rax
addq %rdi, %rcx
cmpl 0xc(%rsp), %r10d
jne 0x1fa5
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rsi
movq %rax, %rdi
movq %r15, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10e0