// File: /workspace/github_c_makefile_star2_O2/erik[P]gamut/invert.c
// Function: main
int main(int argc, char** argv)
{
    uint32_t width, height;
    pixel_t rgba;

    if (argc != 1) {
        fprintf(stderr, "usage: %s\n", argv[0]);
        return 1;
    }

    read_header(&width, &height);
    write_header(width, height);

    for (uint32_t i = 0; i < height; i++) {
        for (uint32_t j = 0; j < width; j++) {
            read_pixel(&rgba);

            /* invert colors */
            rgba.r = 65535 - rgba.r;
            rgba.g = 65535 - rgba.g;
            rgba.b = 65535 - rgba.b;

            write_pixel(&rgba);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x1, %edi
jne 0x1332
pxor %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movdqa %xmm0, (%rdi)
movq 0x2e31(%rip), %rax      # 0x3fd8
movq (%rax), %rcx
pushq $0x1
popq %rsi
pushq $0x10
popq %rdx
callq 0x1030
cmpq $0x10, %rax
jne 0x138b
movabsq $0x646c656662726166, %rax # imm = 0x646C656662726166
cmpq %rax, 0x10(%rsp)
jne 0x13a0
leaq 0x10(%rsp), %r14
movl 0x8(%r14), %ebp
movl 0xc(%r14), %r15d
movq 0x2de8(%rip), %rbx      # 0x3fd0
movq (%rbx), %rsi
leaq 0xe4c(%rip), %rdi       # 0x203e
callq 0x1040
movl %ebp, 0x4(%rsp)
movl %ebp, (%r14)
movq (%rbx), %rcx
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x1070
cmpq $0x1, %rax
jne 0x1383
leaq 0x10(%rsp), %rdi
movl %r15d, (%rdi)
movq (%rbx), %rcx
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x1070
cmpq $0x1, %rax
jne 0x1383
movl %r15d, %ecx
movl 0x4(%rsp), %eax
bswapl %eax
movl %eax, 0x4(%rsp)
bswapl %ecx
leaq 0x8(%rsp), %r14
pushq $0x2
popq %r15
pushq $0x4
popq %r12
leaq 0x10(%rsp), %r13
xorl %eax, %eax
movl %ecx, 0x20(%rsp)
cmpl %ecx, %eax
je 0x1321
movl %eax, 0x24(%rsp)
movl 0x4(%rsp), %ebp
subl $0x1, %ebp
jb 0x1312
movq 0x2d58(%rip), %rax      # 0x3fd8
movq (%rax), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1030
cmpq $0x4, %rax
jne 0x1367
movl 0xc(%rsp), %eax
movzwl 0xe(%rsp), %ecx
movl %ecx, %edx
rolw $0x8, %dx
movw %dx, 0xe(%rsp)
notl %eax
movl %eax, %edx
rolw $0x8, %dx
movw %dx, 0xc(%rsp)
movd 0x8(%rsp), %xmm0
pxor 0xd46(%rip), %xmm0      # 0x2010
movd %xmm0, %edx
rolw $0x8, %dx
pextrw $0x1, %xmm0, %esi
movw %dx, 0x8(%rsp)
rolw $0x8, %si
movw %si, 0xa(%rsp)
movd %xmm0, 0x10(%rsp)
movw %ax, 0x14(%rsp)
movw %cx, 0x16(%rsp)
movq (%rbx), %rcx
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1070
cmpq $0x4, %rax
je 0x1270
jmp 0x1352
movl 0x24(%rsp), %eax
incl %eax
movl 0x20(%rsp), %ecx
jmp 0x1260
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2cbf(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq (%rsi), %rdx
leaq 0xcda(%rip), %rsi       # 0x2020
xorl %eax, %eax
callq 0x1050
pushq $0x1
popq %rax
jmp 0x1323
movq 0x2c9f(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xd09(%rip), %rdi       # 0x206c
pushq $0xc
jmp 0x137a
movq 0x2c8a(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xce4(%rip), %rdi       # 0x205c
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x1070
pushq $0x1
popq %rdi
callq 0x1060
movq 0x2c66(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xc8f(%rip), %rdi       # 0x202b
pushq $0x12
jmp 0x137a
movq 0x2c51(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xc96(%rip), %rdi       # 0x2047
pushq $0x14
jmp 0x137a