// File: /workspace/github_c_makefile_star2_O0/avik-das[P]seam-carver/seam-carver.c
// Function: energy_at
unsigned int energy_at(
        const unsigned char *data,
        int w,
        int h,
        int x,
        int y) {
    int x0 = x == 0 ? x : x - 1;
    int x1 = x == w - 1 ? x : x + 1;
    int ix0 = (y * w + x0) * 3;
    int ix1 = (y * w + x1) * 3;
    unsigned int dxr = data[ix0    ] - data[ix1    ];
    unsigned int dxg = data[ix0 + 1] - data[ix1 + 1];
    unsigned int dxb = data[ix0 + 2] - data[ix1 + 2];
    unsigned int dx = dxr * dxr + dxg * dxg + dxb * dxb;

    int y0 = y == 0 ? y : y - 1;
    int y1 = y == h - 1 ? y : y + 1;
    int iy0 = (y0 * w + x) * 3;
    int iy1 = (y1 * w + x) * 3;
    unsigned int dyr = data[iy0    ] - data[iy1    ];
    unsigned int dyg = data[iy0 + 1] - data[iy1 + 1];
    unsigned int dyb = data[iy0 + 2] - data[iy1 + 2];
    unsigned int dy = dyr * dyr + dyg * dyg + dyb * dyb;

    return dx + dy;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x5e03
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x5e0c
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5e27
movl -0x14(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x5e30
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
imull -0xc(%rbp), %eax
addl -0x1c(%rbp), %eax
imull $0x3, %eax, %eax
movl %eax, -0x24(%rbp)
movl -0x18(%rbp), %eax
imull -0xc(%rbp), %eax
addl -0x20(%rbp), %eax
imull $0x3, %eax, %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movslq -0x28(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x28(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x28(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
imull -0x2c(%rbp), %eax
movl -0x30(%rbp), %ecx
imull -0x30(%rbp), %ecx
addl %ecx, %eax
movl -0x34(%rbp), %ecx
imull -0x34(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x5eeb
movl -0x18(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x5ef4
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x18(%rbp), %eax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5f0f
movl -0x18(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0x5f18
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
imull -0xc(%rbp), %eax
addl -0x14(%rbp), %eax
imull $0x3, %eax, %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
imull -0xc(%rbp), %eax
addl -0x14(%rbp), %eax
imull $0x3, %eax, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movslq -0x44(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movslq -0x48(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x48(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movl -0x44(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x48(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
imull -0x4c(%rbp), %eax
movl -0x50(%rbp), %ecx
imull -0x50(%rbp), %ecx
addl %ecx, %eax
movl -0x54(%rbp), %ecx
imull -0x54(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x38(%rbp), %eax
addl -0x58(%rbp), %eax
popq %rbp
retq
nopl (%rax)