// File: /workspace/github_c_makefile_star2_O3/ravenexp[P]aatrace/match.c
// Function: aatrace_match_tile
struct match_result
aatrace_match_tile(const unsigned char* tilebuf,
		   const unsigned char* fontbuf,
		   int nchars,
		   const struct aatrace_match_ctx* ctx)
{
	switch (ctx->method) {
	default:
	case AATRACE_MATCH_METHOD_MINSAD:
		return aatrace_match_tile_sad(tilebuf, fontbuf, nchars);
	case AATRACE_MATCH_METHOD_MINSADASD:
		return aatrace_match_tile_sadasd(tilebuf, fontbuf, nchars,
						 ctx->sad_weight, ctx->asd_weight);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpl $0x2, (%rcx)
jne 0x1e3d
movl 0x4(%rcx), %r8d
movl 0x8(%rcx), %r9d
leal (%r9,%r8), %eax
imull $0x7f80, %eax, %eax     # imm = 0x7F80
xorl %ecx, %ecx
testl %edx, %edx
jle 0x1e34
movl %edx, %edx
pxor %xmm0, %xmm0
xorl %r10d, %r10d
xorl %r11d, %r11d
movslq %ecx, %rbx
addq %rsi, %rbx
xorl %r14d, %r14d
movq %rdi, %r15
xorl %ebp, %ebp
xorl %r12d, %r12d
movd %ebp, %xmm2
movd %r12d, %xmm1
xorl %r12d, %r12d
movd (%r15,%r12), %xmm3
movdqa %xmm3, %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]
movd (%rbx,%r12), %xmm5
psadbw %xmm5, %xmm3
punpcklbw %xmm0, %xmm5    # xmm5 = xmm5[0],xmm0[0],xmm5[1],xmm0[1],xmm5[2],xmm0[2],xmm5[3],xmm0[3],xmm5[4],xmm0[4],xmm5[5],xmm0[5],xmm5[6],xmm0[6],xmm5[7],xmm0[7]
punpcklwd %xmm0, %xmm5    # xmm5 = xmm5[0],xmm0[0],xmm5[1],xmm0[1],xmm5[2],xmm0[2],xmm5[3],xmm0[3]
psubd %xmm5, %xmm4
paddd %xmm4, %xmm2
paddd %xmm3, %xmm1
addq $0x4, %r12
cmpq $0x8, %r12
jne 0x1d87
pshufd $0xee, %xmm2, %xmm3     # xmm3 = xmm2[2,3,2,3]
paddd %xmm2, %xmm3
pshufd $0x55, %xmm3, %xmm2     # xmm2 = xmm3[1,1,1,1]
paddd %xmm3, %xmm2
movd %xmm2, %ebp
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
paddd %xmm1, %xmm2
pshufd $0x55, %xmm2, %xmm1     # xmm1 = xmm2[1,1,1,1]
paddd %xmm2, %xmm1
movd %xmm1, %r12d
incq %r14
addq $0x8, %r15
addq $0x8, %rbx
cmpq $0x10, %r14
jne 0x1d7b
movl %ebp, %ebx
negl %ebx
cmovsl %ebp, %ebx
imull %r8d, %r12d
imull %r9d, %ebx
addl %r12d, %ebx
cmpl %eax, %ebx
cmovbl %r10d, %r11d
cmovbl %ebx, %eax
testl %eax, %eax
je 0x1e31
incq %r10
subl $-0x80, %ecx
cmpq %rdx, %r10
jne 0x1d6a
movl %r11d, %ecx
shlq $0x20, %rax
jmp 0x1ede
testl %edx, %edx
jle 0x1eca
movl %edx, %edx
movl $0x7f80, %ecx           # imm = 0x7F80
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %eax, %eax
movslq %r8d, %r10
addq %rsi, %r10
movq %rdi, %r11
xorl %ebx, %ebx
xorl %ebp, %ebp
movd %ebp, %xmm0
xorl %r14d, %r14d
movd (%r11,%r14), %xmm1
movd (%r10,%r14), %xmm2
psadbw %xmm1, %xmm2
paddd %xmm2, %xmm0
addq $0x4, %r14
cmpq $0x8, %r14
jne 0x1e68
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddd %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
paddd %xmm1, %xmm0
movd %xmm0, %ebp
incq %rbx
addq $0x8, %r11
addq $0x8, %r10
cmpq $0x10, %rbx
jne 0x1e61
cmpl %ecx, %ebp
cmovbl %r9d, %eax
testl %ebp, %ebp
je 0x1ed6
cmpl %ecx, %ebp
cmovbl %ebp, %ecx
incq %r9
subl $-0x80, %r8d
cmpq %rdx, %r9
jne 0x1e54
jmp 0x1ed8
movabsq $0x7f8000000000, %rax   # imm = 0x7F8000000000
jmp 0x1ee1
xorl %ecx, %ecx
shlq $0x20, %rcx
movl %eax, %eax
orq %rcx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop