// File: /workspace/github_cpp_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movslq %esi, %rbp
movq %rbp, 0x8(%rsp)
movq %rdi, 0x80(%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 0xc8(%rsp), %r13
movq %r13, %rdi
pushq %r14
pushq %r11
pushq %r10
pushq %rax
callq 0xdc18
addq $0x20, %rsp
movl 0x3c(%rbx,%rbp), %eax
movl %eax, 0x3c(%r13)
movl 0x1c(%rbx,%rbp), %r8d
movl 0x1c(%r13), %r9d
leaq 0x2118d(%rip), %rsi     # 0x25c7e
movl $0x4, %edi
movq 0x8(%rsp), %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x1d0d6
movq %rbp, 0x78(%rsp)
leaq (%rbx,%rbp), %rax
addq %rbx, %r12
movq %rax, 0x18(%rsp)
movslq 0x18(%rax), %rax
movl %eax, %edi
movq %rax, 0x58(%rsp)
testq %rax, %rax
movq %rdi, 0x20(%rsp)
movq %r12, 0x28(%rsp)
jle 0x4cac
movq (%r12), %rax
movq 0x8(%r12), %rcx
subq %rax, %rcx
sarq %rcx
leaq 0x24(%r12), %rdx
movq %rdx, 0x8(%rsp)
movq 0x18(%rsp), %rdx
movq (%rdx), %rsi
movl 0x1c(%rdx), %edx
movl %edx, 0x48(%rsp)
leaq 0xec(%rsp), %r8
movq -0x24(%r8), %r9
movq -0x1c(%r8), %r10
subq %r9, %r10
sarq %r10
movslq -0xc(%r8), %r11
leaq (%rsi,%rdi,2), %rdx
movq %rdx, 0x40(%rsp)
leaq (%r11,%r11), %r14
xorl %r15d, %r15d
cmpq %r15, %rcx
movq 0x8(%rsp), %r12
cmovaq %rax, %r12
movzwl (%rsi,%r15,2), %edi
movl %edi, %ebx
cmpl $0x2, 0x48(%rsp)
jl 0x4baa
movq 0x40(%rsp), %rdx
movzwl (%rdx,%r15,2), %ebx
movswl %di, %r13d
movswl %bx, %ebp
leal (%rbp,%rbp,2), %edi
negl %edi
leal (%r13,%r13,2), %ebx
cmpw %bp, %r13w
jge 0x4c09
leal (%rbx,%rdi), %edx
addl $-0x6, %edx
movslq %edx, %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 0x4bef
movl %ebx, %edi
movl %edi, %edx
andl $0xfffe, %edx           # imm = 0xFFFE
movswl %dx, %edx
movl %r13d, %ebx
subl %ebp, %ebx
addl %ebx, %ebx
cmpl %edx, %ebx
jg 0x4c47
movl %edi, %ebx
jmp 0x4c47
addl %ebx, %edi
addl $0x6, %edi
movslq %edi, %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 %r13d, %ebx
subl %ebp, %ebx
addl %ebx, %ebx
cmpl %ebx, %edx
jg 0x4c47
movl %edi, %ebx
movzwl (%r12), %edx
addl %edx, %ebx
movswl %bx, %edx
leal (%rdx,%r13,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
cmpq %r15, 0x20(%rsp)
movq 0x28(%rsp), %r12
jne 0x4b86
movslq 0x1c(%r12), %rax
movq %rax, 0x98(%rsp)
cmpq $0x2, %rax
jl 0x4ff4
movq 0x28(%rsp), %rax
addq $0x24, %rax
movq %rax, 0xb0(%rsp)
leaq 0xec(%rsp), %rax
movl -0xc(%rax), %ecx
movq -0x24(%rax), %rdx
movq -0x1c(%rax), %r11
movq %rdx, 0x88(%rsp)
subq %rdx, %r11
sarq %r11
leal (%rcx,%rcx), %edx
movq 0x58(%rsp), %rax
leaq (,%rax,4), %rsi
movq %rsi, 0x70(%rsp)
leaq (%rax,%rax), %rsi
movq %rcx, 0x38(%rsp)
leal (%rcx,%rcx,2), %eax
movl %eax, 0x14(%rsp)
movq 0x20(%rsp), %rax
addq %rax, %rax
movq %rax, 0xa8(%rsp)
movl $0x1, %eax
movq %rax, 0x30(%rsp)
movl $0x2, %eax
movq %rax, 0x68(%rsp)
movl %edx, 0x54(%rsp)
movl %edx, 0x10(%rsp)
movq %rsi, 0x90(%rsp)
movq %rsi, 0x60(%rsp)
cmpl $0x0, 0x58(%rsp)
jle 0x4fa9
movslq 0x38(%rsp), %rax
movq 0x88(%rsp), %rdx
leaq (%rdx,%rax,2), %rax
movq %rax, 0x8(%rsp)
movslq 0x10(%rsp), %rax
leaq (%rdx,%rax,2), %rcx
movq %rcx, 0x48(%rsp)
movslq 0x14(%rsp), %rcx
leaq (%rdx,%rcx,2), %rdx
movq %rdx, 0x40(%rsp)
movq 0x28(%rsp), %rdx
movslq 0x18(%rdx), %r12
movq (%rdx), %rdi
movq 0x8(%rdx), %r14
subq %rdi, %r14
sarq %r14
movq 0x18(%rsp), %rdx
movq (%rdx), %rsi
movq 0x30(%rsp), %r8
leaq 0x1(%r8), %r9
movq %r9, 0xc0(%rsp)
movslq 0x1c(%rdx), %rdx
movq %rdx, 0xb8(%rsp)
movq 0x70(%rsp), %rdx
addq %rsi, %rdx
movq %rdx, 0xa0(%rsp)
addq 0x60(%rsp), %rsi
movq %r8, %rdx
imulq %r12, %rdx
imulq 0x68(%rsp), %r12
addq %rdi, %r12
xorl %edi, %edi
leaq (%r12,%rdi), %rbx
cmpq %rdx, %r14
cmovbeq 0xb0(%rsp), %rbx
movzwl (%rsi,%rdi), %r15d
movl %r15d, %r9d
movq 0xb8(%rsp), %r8
cmpq %r8, 0xc0(%rsp)
jge 0x4e29
movq 0xa0(%rsp), %r8
movzwl (%r8,%rdi), %r9d
movswl %r15w, %r8d
movq 0x8(%rsp), %r10
movzwl (%r10,%rdi), %r13d
movswl %r13w, %r10d
cmpw %r9w, %r8w
jl 0x4eb7
cmpw %r15w, %r13w
jl 0x4eb7
movswl %r9w, %r9d
leal (,%r10,4), %ebp
leal (%r9,%r9,2), %r15d
addl %r8d, %r15d
subl %r15d, %ebp
addl $0x6, %ebp
movslq %ebp, %r15
imulq $0x2aaaaaab, %r15, %r15 # imm = 0x2AAAAAAB
movq %r15, %r13
shrq $0x3f, %r13
sarq $0x21, %r15
addl %r13d, %r15d
movswl %r15w, %ebp
movl %r15d, %r13d
andl $0x1, %r13d
subl %r13d, %ebp
subl %r8d, %r10d
leal (%r10,%r10), %r13d
cmpl %r13d, %ebp
jle 0x4e9a
leal 0x1(,%r10,2), %r15d
movswl %r15w, %r10d
movl %r10d, %r13d
andl $0x1, %r13d
addl %r10d, %r13d
movl %r8d, %ebp
subl %r9d, %ebp
addl %ebp, %ebp
cmpl %ebp, %r13d
jle 0x4f33
jmp 0x4f36
xorl %ebp, %ebp
cmpw %r9w, %r15w
jg 0x4f36
cmpw %r15w, %r13w
jg 0x4f36
movswl %r9w, %r9d
leal (,%r10,4), %ebp
leal (%r9,%r9,2), %r15d
addl %r8d, %r15d
subl %r15d, %ebp
addl $-0x6, %ebp
movslq %ebp, %r15
imulq $0x2aaaaaab, %r15, %r15 # imm = 0x2AAAAAAB
movq %r15, %r13
shrq $0x3f, %r13
sarq $0x21, %r15
addl %r13d, %r15d
movswl %r15w, %ebp
movl %r15d, %r13d
andl $0x1, %r13d
addl %ebp, %r13d
subl %r8d, %r10d
leal (%r10,%r10), %ebp
cmpl %ebp, %r13d
jge 0x4f18
leal -0x1(,%r10,2), %r15d
movl %r15d, %r10d
andl $0xfffe, %r10d          # imm = 0xFFFE
movswl %r10w, %r10d
movl %r8d, %ebp
subl %r9d, %ebp
addl %ebp, %ebp
cmpl %r10d, %ebp
jg 0x4f36
movl %r15d, %ebp
movzwl (%rbx), %r9d
addl %r9d, %ebp
movswl %bp, %r9d
movl %r9d, %r10d
andl $0x1, %r10d
movl %r10d, %ebx
negl %ebx
testw %r9w, %r9w
cmovlel %r10d, %ebx
leal (%r9,%r8,2), %r8d
addl %r8d, %ebx
sarl %ebx
movq 0x48(%rsp), %r8
addq %rdi, %r8
cmpq %rax, %r11
leaq 0xec(%rsp), %r9
cmovbeq %r9, %r8
movw %bx, (%r8)
subl %ebp, %ebx
movq 0x40(%rsp), %r8
addq %rdi, %r8
cmpq %rcx, %r11
cmovbeq %r9, %r8
movw %bx, (%r8)
addq $0x2, %rdi
incq %rdx
incq %rax
incq %rcx
cmpq %rdi, 0xa8(%rsp)
jne 0x4df2
movq 0x30(%rsp), %rdx
incq %rdx
movq 0x38(%rsp), %rax
movl 0x54(%rsp), %ecx
addl %ecx, %eax
movq %rax, 0x38(%rsp)
movq 0x90(%rsp), %rax
addq %rax, 0x70(%rsp)
addq %rax, 0x60(%rsp)
addq $0x2, 0x68(%rsp)
addl %ecx, 0x10(%rsp)
addl %ecx, 0x14(%rsp)
movq %rdx, 0x30(%rsp)
cmpq 0x98(%rsp), %rdx
jne 0x4d53
testb $0x1, 0xe4(%rsp)
movq 0x78(%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x20(%rsp), %r15
je 0x508c
testl %r15d, %r15d
jle 0x508c
movslq 0x1c(%r14), %rdx
decq %rdx
movslq %r15d, %rax
imulq %rdx, %rax
movq (%r14), %r8
movq 0x8(%r14), %rcx
subq %r8, %rcx
sarq %rcx
addq $0x24, %r14
leal (%rdx,%rdx), %esi
leaq 0xec(%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 %r15
jne 0x505d
movq 0x80(%rsp), %rax
addq (%rax), %rbx
leaq 0xc8(%rsp), %rsi
movq %rbx, %rdi
callq 0xe65e
movq 0x100(%rsp), %rax
movq %rax, 0x38(%rbx)
movups 0xe0(%rsp), %xmm0
movups 0xf0(%rsp), %xmm1
movups %xmm1, 0x28(%rbx)
movups %xmm0, 0x18(%rbx)
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x50e8
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x511a
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x35a0