// File: /workspace/github_c_makefile_star2_O2/akumrao[P]videoAnalyzer/core/pixel.c
// Function: pixel_satd_wxh(unsigned char*, int, unsigned char*, int, int, int)
static int pixel_satd_wxh( uint8_t *pix1, int i_pix1, uint8_t *pix2, int i_pix2, int i_width, int i_height )
{
    int16_t tmp[4][4];
    int16_t diff[4][4];
    int x, y;
    int i_satd = 0;

    for( y = 0; y < i_height; y += 4 )
    {
        for( x = 0; x < i_width; x += 4 )
        {
            int d;

            pixel_sub_4x4( diff, &pix1[x], i_pix1, &pix2[x], i_pix2 );

            for( d = 0; d < 4; d++ )
            {
                int s01, s23;
                int d01, d23;

                s01 = diff[d][0] + diff[d][1]; s23 = diff[d][2] + diff[d][3];
                d01 = diff[d][0] - diff[d][1]; d23 = diff[d][2] - diff[d][3];

                tmp[d][0] = s01 + s23;
                tmp[d][1] = s01 - s23;
                tmp[d][2] = d01 - d23;
                tmp[d][3] = d01 + d23;
            }
            for( d = 0; d < 4; d++ )
            {
                int s01, s23;
                int d01, d23;

                s01 = tmp[0][d] + tmp[1][d]; s23 = tmp[2][d] + tmp[3][d];
                d01 = tmp[0][d] - tmp[1][d]; d23 = tmp[2][d] - tmp[3][d];

                i_satd += abs( s01 + s23 ) + abs( s01 - s23 ) + abs( d01 - d23 ) + abs( d01 + d23 );
            }

        }
        pix1 += 4 * i_pix1;
        pix2 += 4 * i_pix2;
    }

    return i_satd / 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, -0x2c(%rbp)
movq %rdx, %r15
movq %rdi, %r13
movq %rsi, -0x68(%rbp)
leal (,%rsi,4), %eax
cltq
movq %rax, -0x60(%rbp)
movq %rcx, -0x70(%rbp)
leal (,%rcx,4), %eax
cltq
movq %rax, -0x58(%rbp)
movslq %r8d, %r14
xorl %ebx, %ebx
xorl %eax, %eax
cmpl -0x2c(%rbp), %eax
jge 0x8688
movl %eax, -0x30(%rbp)
xorl %r12d, %r12d
cmpq %r14, %r12
jge 0x8675
leaq (%r12,%r13), %rsi
leaq (%r15,%r12), %rcx
leaq -0x90(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq -0x70(%rbp), %r8
callq 0x8263
xorl %eax, %eax
cmpq $0x4, %rax
je 0x8600
movzwl -0x90(%rbp,%rax,8), %ecx
movzwl -0x8e(%rbp,%rax,8), %edx
leal (%rdx,%rcx), %esi
movzwl -0x8c(%rbp,%rax,8), %edi
movzwl -0x8a(%rbp,%rax,8), %r8d
leal (%r8,%rdi), %r9d
subl %edx, %ecx
subl %r8d, %edi
leal (%r9,%rsi), %edx
movw %dx, -0x50(%rbp,%rax,8)
subl %r9d, %esi
movw %si, -0x4e(%rbp,%rax,8)
movl %ecx, %edx
subl %edi, %edx
movw %dx, -0x4c(%rbp,%rax,8)
addl %ecx, %edi
movw %di, -0x4a(%rbp,%rax,8)
incq %rax
jmp 0x85a7
pushq $-0x8
popq %rax
testq %rax, %rax
je 0x866c
movswl -0x48(%rbp,%rax), %ecx
movswl -0x40(%rbp,%rax), %esi
leal (%rsi,%rcx), %edi
movswl -0x38(%rbp,%rax), %edx
movswl -0x30(%rbp,%rax), %r8d
leal (%r8,%rdx), %r9d
subl %esi, %ecx
subl %r8d, %edx
leal (%r9,%rdi), %esi
movl %esi, %r8d
negl %r8d
cmovsl %esi, %r8d
subl %r9d, %edi
movl %edi, %esi
negl %esi
cmovsl %edi, %esi
movl %ecx, %edi
subl %edx, %edi
movl %edi, %r9d
negl %r9d
cmovsl %edi, %r9d
addl %ecx, %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
addl %ebx, %esi
addl %r8d, %r9d
addl %esi, %r9d
addl %ecx, %r9d
addq $0x2, %rax
movl %r9d, %ebx
jmp 0x8603
addq $0x4, %r12
jmp 0x8580
addq -0x60(%rbp), %r13
addq -0x58(%rbp), %r15
movl -0x30(%rbp), %eax
addl $0x4, %eax
jmp 0x8571
pushq $0x2
popq %rcx
movl %ebx, %eax
cltd
idivl %ecx
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq