// File: /workspace/github_cpp_makefile_star2_O3/cloudinary[P]fuif/transform/ycocg.h
// Function: fwd_YCoCg(Image&)
bool fwd_YCoCg(Image &input) {
    int nb_channels = input.nb_channels;
    if (nb_channels < 3) {
        //e_printf("Invalid number of channels to apply YCoCg.\n");
        return false;
    }
    int m = input.nb_meta_channels;
    int w = input.channel[m+0].w;
    int h = input.channel[m+0].h;
    if (input.channel[m+1].w < w
     || input.channel[m+1].h < h
     || input.channel[m+2].w < w
     || input.channel[m+2].h < h) {
        e_printf("Invalid channel dimensions to apply YCoCg.\n");
        return false;
    }
    for (int y=0; y<h; y++) {
      for (int x=0; x<w; x++) {
        int R = input.channel[m+0].value(y,x);
        int G = input.channel[m+1].value(y,x);
        int B = input.channel[m+2].value(y,x);
        int Y = (((R + B)>>1) + G)>>1;
        int Co = R - B;
        int Cg = G - ((R + B)>>1);
        input.channel[m+0].value(y,x) = Y;
        input.channel[m+1].value(y,x) = Co;
        input.channel[m+2].value(y,x) = Cg;
      }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
cmpl $0x3, 0x64(%rdi)
jge 0x8d69
xorl %ebx, %ebx
jmp 0x8dcc
movslq 0x6c(%rdi), %rax
movq (%rdi), %rcx
shlq $0x6, %rax
movl 0x18(%rcx,%rax), %edx
movslq 0x58(%rcx,%rax), %rdi
movq %rdx, 0x8(%rsp)
movq %rdi, 0x50(%rsp)
cmpl %edx, %edi
jl 0x8dbc
leaq (%rcx,%rax), %rdx
movl 0x1c(%rcx,%rax), %eax
movq %rax, 0x10(%rsp)
cmpl %eax, 0x5c(%rdx)
jl 0x8dbc
movslq 0x98(%rdx), %rcx
movq %rcx, 0x48(%rsp)
cmpl 0x8(%rsp), %ecx
jl 0x8dbc
movq 0x10(%rsp), %rax
cmpl %eax, 0x9c(%rdx)
jge 0x8de0
leaq 0x1ccfd(%rip), %rdi     # 0x25ac0
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x379e
movl %ebx, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %bl
cmpl $0x0, 0x10(%rsp)
jle 0x8dcc
movslq 0x8(%rsp), %rax
leaq 0x24(%rdx), %r9
leaq 0x64(%rdx), %r10
movq %rdx, 0x58(%rsp)
addq $0xa4, %rdx
movq %rax, 0x78(%rsp)
leaq (%rax,%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x50(%rsp), %rax
leaq (%rax,%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x48(%rsp), %rax
addq %rax, %rax
movq %rax, 0x60(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ecx, %ecx
movq %r9, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rcx, 0x80(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x8f88
movq 0x58(%rsp), %rcx
movq (%rcx), %rsi
movq 0x8(%rcx), %rax
subq %rsi, %rax
sarq %rax
movq %rax, 0xa8(%rsp)
movq 0x48(%rcx), %rdi
movq 0x40(%rcx), %rax
subq %rax, %rdi
sarq %rdi
movq %rdi, 0xa0(%rsp)
movq 0x88(%rcx), %rdi
movq 0x80(%rcx), %r13
subq %r13, %rdi
sarq %rdi
movq %rdi, 0x98(%rsp)
addq 0x18(%rsp), %rsi
addq 0x30(%rsp), %rax
addq 0x40(%rsp), %r13
movq 0x8(%rsp), %r14
movq 0x38(%rsp), %rbp
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r8
movq %rsi, 0xb0(%rsp)
cmpq %r8, 0xa8(%rsp)
movq 0x90(%rsp), %r9
cmovaq %rsi, %r9
movswl (%r9), %edi
cmpq %r15, 0xa0(%rsp)
movq %r10, %rsi
cmovaq %rax, %r10
cmpq %rbp, 0x98(%rsp)
movq 0x88(%rsp), %r11
cmovaq %r13, %r11
movswl (%r10), %r12d
movswl (%r11), %ecx
leal (%rcx,%rdi), %ebx
movl %ebx, %edx
sarl %ebx
addl %r12d, %ebx
shrl %ebx
movw %bx, (%r9)
subl %ecx, %edi
movw %di, (%r10)
movq %rsi, %r10
movq 0xb0(%rsp), %rsi
shrl %edx
subl %edx, %r12d
movw %r12w, (%r11)
addq $0x2, %rsi
incq %r8
incq %r15
addq $0x2, %rax
incq %rbp
addq $0x2, %r13
decq %r14
jne 0x8ef5
movq 0x80(%rsp), %rcx
incq %rcx
movq 0x18(%rsp), %rax
addq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
addq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
addq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%rsp), %rax
addq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x38(%rsp), %rax
addq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq 0x10(%rsp), %rcx
jne 0x8e73
movb $0x1, %bl
jmp 0x8dcc