// File: /workspace/github_cpp_makefile_star2_O3/cloudinary[P]fuif/transform/squeeze.h
// Function: inv_vsqueeze(Image&, int, int)
void inv_vsqueeze(Image &input, int c, int rc) {
    const Channel &chin = input.channel[c];
    const Channel &chin_residual = input.channel[rc];
    Channel chout(chin.w, chin.h + chin_residual.h,chin.minval,chin.maxval, chin.q, chin.hshift,chin.vshift-1,chin.hcshift,chin.vcshift-1);
    chout.component = chin.component;
    v_printf(4,"Undoing vertical squeeze of channel %i using residuals in channel %i (going from height %i to %i)\n",c,rc,chin.h,chout.h);

      for (int x=0; x<chin.w; x++) {
        pixel_type diff_minus_tendency = chin_residual.value(0,x);
        pixel_type avg = chin.value_nocheck(0,x);

        pixel_type next_avg = avg;
        if (1<chin.h) next_avg = chin.value_nocheck(1,x);

        pixel_type tendency=smooth_tendency(avg,avg,next_avg);

        pixel_type diff = diff_minus_tendency + tendency;

        pixel_type A = ((avg<<1)+diff+(diff>0?-(diff&1):(diff&1)))>>1;
        chout.value(0,x) = A;
        pixel_type B = A-diff;
        chout.value(1,x) = B;
      }

    for (int y=1; y<chin_residual.h; y++) {
      for (int x=0; x<chin.w; x++) {
        pixel_type diff_minus_tendency = chin_residual.value(y,x);
        pixel_type avg = chin.value_nocheck(y,x);

        pixel_type next_avg = avg;
        if (y+1<chin.h) next_avg = chin.value_nocheck(y+1,x);

//        pixel_type top = (y>0 ? chout.value_nocheck((y<<1)-1,x) : avg);
        pixel_type top = chout.value_nocheck((y<<1)-1,x);
        pixel_type tendency=smooth_tendency(top,avg,next_avg);

        pixel_type diff = diff_minus_tendency + tendency;

        pixel_type A = ((avg<<1)+diff+(diff>0?-(diff&1):(diff&1)))>>1;
        chout.value(y<<1,x) = A;
        pixel_type B = A-diff;
        chout.value((y<<1)+1,x) = B;
      }
    }
    if (chout.h & 1) { int y = chin.h-1;
      for (int x=0; x<chin.w; x++) {
        pixel_type avg = chin.value(y,x);
        chout.value(y<<1,x) = avg;
      }
    }
    input.channel[c] = chout;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movslq %esi, %rbp
movq %rbp, (%rsp)
movq %rdi, 0x48(%rsp)
movq (%rdi), %rbx
shlq $0x6, %rbp
movslq %edx, %r15
movq %r15, %r12
shlq $0x6, %r12
movl 0x1c(%rbx,%r12), %edx
addl 0x1c(%rbx,%rbp), %edx
movswl 0x20(%rbx,%rbp), %ecx
movswl 0x22(%rbx,%rbp), %r8d
movl 0x18(%rbx,%rbp), %esi
movl 0x28(%rbx,%rbp), %r9d
movl 0x2c(%rbx,%rbp), %eax
movl 0x30(%rbx,%rbp), %r10d
decl %r10d
movl 0x34(%rbx,%rbp), %r11d
movl 0x38(%rbx,%rbp), %r14d
decl %r14d
leaq 0x88(%rsp), %r13
movq %r13, %rdi
pushq %r14
pushq %r11
pushq %r10
pushq %rax
callq 0xdb78
addq $0x20, %rsp
movl 0x3c(%rbx,%rbp), %eax
movl %eax, 0x3c(%r13)
movl 0x1c(%rbx,%rbp), %r8d
movl 0x1c(%r13), %r9d
leaq 0x211fb(%rip), %rsi     # 0x25c7e
movl $0x4, %edi
movq (%rsp), %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1cede
movq %rbp, 0x40(%rsp)
leaq (%rbx,%rbp), %rax
addq %rbx, %r12
movq %r12, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movslq 0x18(%rax), %rax
movl %eax, %r12d
movq %rax, 0x30(%rsp)
testq %rax, %rax
movq %r12, 0x38(%rsp)
jle 0x4c39
movq 0x8(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
subq %rax, %rcx
sarq %rcx
addq $0x24, %rdx
movq %rdx, (%rsp)
movq 0x10(%rsp), %rdx
movq (%rdx), %rsi
movl 0x1c(%rdx), %edx
movl %edx, 0x20(%rsp)
leaq 0xac(%rsp), %r8
movq -0x24(%r8), %r9
movq -0x1c(%r8), %r10
subq %r9, %r10
sarq %r10
movslq -0xc(%r8), %r11
leaq (%rsi,%r12,2), %rdx
movq %rdx, 0x18(%rsp)
leaq (%r11,%r11), %r14
xorl %r15d, %r15d
cmpq %r15, %rcx
movq (%rsp), %r13
cmovaq %rax, %r13
movswl (%rsi,%r15,2), %ebp
cmpl $0x1, 0x20(%rsp)
jle 0x4b8e
movq 0x18(%rsp), %rdx
movswl (%rdx,%r15,2), %r12d
cmpw %r12w, %bp
jge 0x4b91
leal (%r12,%r12,2), %edx
leal (%rbp,%rbp,2), %edi
subl %edx, %edi
addl $-0x6, %edi
movslq %edi, %rdx
imulq $0x2aaaaaab, %rdx, %rbx # imm = 0x2AAAAAAB
movq %rbx, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rbx
addl %edx, %ebx
movl %ebx, %edx
andl $0x1, %edx
addl %ebx, %edx
movl $0xffff, %edi           # imm = 0xFFFF
js 0x4b74
movl %ebx, %edi
movl %edi, %edx
andl $0xfffe, %edx           # imm = 0xFFFE
movswl %dx, %edx
movl %ebp, %ebx
subl %r12d, %ebx
addl %ebx, %ebx
cmpl %edx, %ebx
jg 0x4bd7
movl %edi, %ebx
jmp 0x4bd7
movl %ebp, %r12d
leal (%r12,%r12,2), %edi
leal (%rbp,%rbp,2), %ebx
subl %edi, %ebx
addl $0x6, %ebx
movslq %ebx, %rbx
imulq $0x2aaaaaab, %rbx, %rdi # imm = 0x2AAAAAAB
movq %rdi, %rdx
shrq $0x3f, %rdx
shrq $0x21, %rdi
addl %edx, %edi
cmpl $0x18, %ebx
movl $0x1, %edx
cmovgel %edx, %edi
movswl %di, %ebx
movl %ebx, %edx
andl $0x1, %edx
addl %ebx, %edx
movl %ebp, %ebx
subl %r12d, %ebx
addl %ebx, %ebx
cmpl %ebx, %edx
jg 0x4bd7
movl %edi, %ebx
movzwl (%r13), %edx
addl %edx, %ebx
movswl %bx, %edx
leal (%rdx,%rbp,2), %edi
movl %edx, %ebp
andl $0x1, %ebp
movl %ebp, %r12d
negl %r12d
testw %dx, %dx
cmovlel %ebp, %r12d
addl %edi, %r12d
sarl %r12d
cmpq %r15, %r10
movq %r8, %rdx
cmovaq %r9, %rdx
movw %r12w, (%rdx)
subl %ebx, %r12d
leaq (%r11,%r15), %rdx
leaq (%r9,%r14), %rdi
cmpq %rdx, %r10
cmovbeq %r8, %rdi
movw %r12w, (%rdi)
incq %r15
addq $0x2, %r9
addq $0x2, %rax
movq 0x38(%rsp), %r12
cmpq %r15, %r12
jne 0x4b19
movq 0x8(%rsp), %rdi
movslq 0x1c(%rdi), %rax
movq %rax, 0x58(%rsp)
cmpq $0x2, %rax
movq 0x30(%rsp), %r10
jl 0x4ef3
leaq 0x24(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq 0xac(%rsp), %rax
movl -0xc(%rax), %ecx
movl %ecx, 0x2c(%rsp)
movq -0x24(%rax), %rcx
movq -0x1c(%rax), %r11
movq %rcx, 0x50(%rsp)
subq %rcx, %r11
sarq %r11
leaq (%r12,%r12), %rax
movq %rax, 0x68(%rsp)
movl $0x1, %eax
testl %r10d, %r10d
movq 0x10(%rsp), %rsi
jle 0x4ee2
movslq 0x18(%rdi), %rcx
movq %rax, %r12
imulq %rcx, %r12
movq (%rdi), %rdx
movq 0x8(%rdi), %rdi
subq %rdx, %rdi
sarq %rdi
movq %rdi, (%rsp)
movq %rax, %rdi
imulq %r10, %rdi
movq (%rsi), %r8
leaq 0x1(%rax), %r14
movslq 0x1c(%rsi), %rsi
movq %rsi, 0x20(%rsp)
movq %r14, %r9
imulq %r10, %r9
addq %rax, %rax
leal -0x1(%rax), %r10d
movl 0x2c(%rsp), %ebx
imull %ebx, %r10d
movl %ebx, %esi
imull %eax, %esi
movslq %esi, %rsi
movslq %r10d, %r10
leaq (%r8,%rdi,2), %rdi
movq %rdi, 0x18(%rsp)
leaq (%r8,%r9,2), %rdi
movq %rdi, 0x60(%rsp)
movq 0x50(%rsp), %rdi
leaq (%rdi,%r10,2), %r8
movq %r8, 0x80(%rsp)
movq %rax, %r9
imulq %rcx, %r9
addq %rdx, %r9
leaq (%rdi,%rsi,2), %rcx
movq %rcx, 0x78(%rsp)
incl %eax
imull %ebx, %eax
movslq %eax, %rcx
leaq (%rdi,%rcx,2), %rax
xorl %edi, %edi
leaq (%r9,%rdi), %r15
cmpq %r12, (%rsp)
cmovbeq 0x70(%rsp), %r15
movq 0x18(%rsp), %rdx
movzwl (%rdx,%rdi), %r10d
movl %r10d, %edx
cmpq 0x20(%rsp), %r14
jge 0x4d60
movq 0x60(%rsp), %rdx
movzwl (%rdx,%rdi), %edx
movswl %r10w, %r8d
movq 0x80(%rsp), %rbx
movzwl (%rbx,%rdi), %r13d
movswl %r13w, %ebx
cmpw %dx, %r8w
jl 0x4def
cmpw %r10w, %r13w
jl 0x4def
movswl %dx, %edx
leal (,%rbx,4), %r10d
leal (%rdx,%rdx,2), %ebp
addl %r8d, %ebp
subl %ebp, %r10d
addl $0x6, %r10d
movslq %r10d, %r10
imulq $0x2aaaaaab, %r10, %r10 # imm = 0x2AAAAAAB
movq %r10, %r13
shrq $0x3f, %r13
sarq $0x21, %r10
addl %r13d, %r10d
movswl %r10w, %ebp
movl %r10d, %r13d
andl $0x1, %r13d
subl %r13d, %ebp
subl %r8d, %ebx
leal (%rbx,%rbx), %r13d
cmpl %r13d, %ebp
jle 0x4dd3
leal 0x1(,%rbx,2), %r10d
movswl %r10w, %ebx
movl %ebx, %r13d
andl $0x1, %r13d
addl %ebx, %r13d
movl %r8d, %ebp
subl %edx, %ebp
addl %ebp, %ebp
cmpl %ebp, %r13d
jle 0x4e65
jmp 0x4e68
xorl %ebp, %ebp
cmpw %dx, %r10w
jg 0x4e68
cmpw %r10w, %r13w
jg 0x4e68
movswl %dx, %edx
leal (,%rbx,4), %r10d
leal (%rdx,%rdx,2), %ebp
addl %r8d, %ebp
subl %ebp, %r10d
addl $-0x6, %r10d
movslq %r10d, %r10
imulq $0x2aaaaaab, %r10, %r10 # imm = 0x2AAAAAAB
movq %r10, %r13
shrq $0x3f, %r13
sarq $0x21, %r10
addl %r13d, %r10d
movswl %r10w, %ebp
movl %r10d, %r13d
andl $0x1, %r13d
addl %ebp, %r13d
subl %r8d, %ebx
leal (%rbx,%rbx), %ebp
cmpl %ebp, %r13d
jge 0x4e4e
leal -0x1(,%rbx,2), %r10d
movl %r10d, %ebx
andl $0xfffe, %ebx           # imm = 0xFFFE
movswl %bx, %ebx
movl %r8d, %ebp
subl %edx, %ebp
addl %ebp, %ebp
cmpl %ebx, %ebp
jg 0x4e68
movl %r10d, %ebp
movzwl (%r15), %edx
addl %edx, %ebp
movswl %bp, %edx
movl %edx, %r10d
andl $0x1, %r10d
movl %r10d, %ebx
negl %ebx
testw %dx, %dx
cmovlel %r10d, %ebx
leal (%rdx,%r8,2), %edx
addl %edx, %ebx
sarl %ebx
movq 0x78(%rsp), %rdx
addq %rdi, %rdx
cmpq %rsi, %r11
leaq 0xac(%rsp), %r8
cmovbeq %r8, %rdx
movw %bx, (%rdx)
subl %ebp, %ebx
leaq (%rax,%rdi), %rdx
cmpq %rcx, %r11
cmovbeq %r8, %rdx
movw %bx, (%rdx)
addq $0x2, %rdi
incq %r12
incq %rsi
incq %rcx
cmpq %rdi, 0x68(%rsp)
jne 0x4d35
movq %r14, %rax
movq 0x38(%rsp), %r12
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %r10
jmp 0x4ee8
incq %rax
movq %rax, %r14
cmpq 0x58(%rsp), %r14
jne 0x4c8f
testb $0x1, 0xa4(%rsp)
movq 0x40(%rsp), %rbx
movq 0x10(%rsp), %r14
je 0x4f86
testl %r12d, %r12d
jle 0x4f86
movslq 0x1c(%r14), %rdx
decq %rdx
movslq %r12d, %rax
imulq %rdx, %rax
movq (%r14), %r8
movq 0x8(%r14), %rcx
subq %r8, %rcx
sarq %rcx
addq $0x24, %r14
leal (%rdx,%rdx), %esi
leaq 0xac(%rsp), %rdx
movslq -0xc(%rdx), %rdi
movslq %esi, %rsi
imulq %rdi, %rsi
movq -0x24(%rdx), %r9
movq -0x1c(%rdx), %rdi
subq %r9, %rdi
sarq %rdi
leaq (%r8,%rax,2), %r8
leaq (%r9,%rsi,2), %r9
cmpq %rax, %rcx
movq %r14, %r10
cmovaq %r8, %r10
cmpq %rsi, %rdi
movq %rdx, %r11
cmovaq %r9, %r11
movzwl (%r10), %r10d
movw %r10w, (%r11)
incq %rax
addq $0x2, %r8
incq %rsi
addq $0x2, %r9
decq %r12
jne 0x4f57
movq 0x48(%rsp), %rax
addq (%rax), %rbx
leaq 0x88(%rsp), %rsi
movq %rbx, %rdi
callq 0xe5dc
movq 0xc0(%rsp), %rax
movq %rax, 0x38(%rbx)
movups 0xa0(%rsp), %xmm0
movups 0xb0(%rsp), %xmm1
movups %xmm1, 0x28(%rbx)
movups %xmm0, 0x18(%rbx)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x4fdf
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5011
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3590