// File: /workspace/github_cpp_makefile_star2_O1/cloudinary[P]fuif/transform/subsample.h
// Function: inv_subsample(Image&, std::vector<int, std::allocator<int>>)
bool inv_subsample(Image &input, std::vector<int> parameters) {
    check_subsample_parameters(parameters);

    for (int i=0; i<parameters.size(); i+=4) {
        int c1 = parameters[i+0];
        int c2 = parameters[i+1];
        int srh = parameters[i+2];
        int srv = parameters[i+3];
        for (int c=c1; c<=c2; c++) {
         int ow = input.channel[c].w;
         int oh = input.channel[c].h;
         if (ow >= input.channel[input.nb_meta_channels].w && oh >= input.channel[input.nb_meta_channels].h) {
            // this can happen in case of LQIP and 1:16 scale decodes
            v_printf(5,"Skipping upscaling of channel %i because it is already as large as channel %i.\n",c,input.nb_meta_channels);
            continue;
         }
         Channel channel(ow*srh,oh*srv,input.channel[c].minval,input.channel[c].maxval);
         if (srv <= 2 && srh <= 2) {
          // 'fancy' horizontal upscale
          if (srh == 2) {
           for (int y=0; y<oh; y++) {
            for (int x=0; x<ow; x++) {
             channel.value(y*srv,x*srh) =   (3*input.channel[c].value(y,x) + input.channel[c].value(y,(x?x-1:0)) + 1)>>2;
             channel.value(y*srv,x*srh+1) = (3*input.channel[c].value(y,x) + input.channel[c].value(y,(x+1<ow?x+1:x)) + 2)>>2;
            }
           }
          } else {
           for (int y=0; y<oh; y++) {
            for (int x=0; x<ow; x++) {
             channel.value(y*srv,x) = input.channel[c].value(y,x);
            }
           }
          }
          if (srv == 2) {
           Channel orig = channel;
           for (int y=0; y<oh; y++) {
            for (int x=0; x<ow*srh; x++) {
             channel.value(y*srv,x) =   (3*orig.value(y*srv,x) + orig.value((y?(y-1)*srv:0),x) + 1)>>2;
             channel.value(y*srv+1,x) = (3*orig.value(y*srv,x) + orig.value((y+1<oh?(y+1)*srv:y*srv),x) + 2)>>2;
            }
           }
          }
         } else {
         // simple box filter upscaling. fancier upscaling could be done too...
          for (int y=0; y<oh*srv; y++) {
           for (int x=0; x<ow*srh; x++) {
             channel.value(y,x) = input.channel[c].value(y/srv,x/srh);
           }
          }
         }
         v_printf(5,"Upscaled channel %i from %ix%i to %ix%i\n",c,input.channel[c].w,input.channel[c].h,channel.w,channel.h);
         input.channel[c] = channel;
        }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x6a76
movq (%rbx), %rax
movq %rbx, 0xb0(%rsp)
cmpq %rax, 0x8(%rbx)
je 0x747a
xorl %edx, %edx
movq %r15, 0x48(%rsp)
movslq (%rax,%rdx,4), %rbx
movq %rdx, 0xa8(%rsp)
movl 0x4(%rax,%rdx,4), %ecx
movl %ecx, 0x40(%rsp)
cmpl %ecx, %ebx
jg 0x744f
movq 0xa8(%rsp), %rcx
movl 0x8(%rax,%rcx,4), %r14d
movl 0xc(%rax,%rcx,4), %eax
movl %eax, 0x10(%rsp)
cmpl $0x3, %eax
setl %al
cmpl $0x3, %r14d
setl %cl
andb %al, %cl
movb %cl, 0x7(%rsp)
incl 0x40(%rsp)
movl %r14d, 0x44(%rsp)
movq (%r15), %rax
movq %rbx, %r12
shlq $0x6, %r12
movl 0x18(%rax,%r12), %esi
movl 0x1c(%rax,%r12), %r13d
movslq 0x6c(%r15), %rcx
movq %rcx, %rdx
shlq $0x6, %rdx
movq %rsi, 0x8(%rsp)
cmpl 0x18(%rax,%rdx), %esi
jl 0x6d4b
addq %rax, %rdx
cmpl 0x1c(%rdx), %r13d
jge 0x702d
addq %r12, %rax
movq 0x8(%rsp), %rcx
movl %ecx, %esi
imull %r14d, %esi
movl %r13d, %ebp
imull 0x10(%rsp), %ebp
movswl 0x20(%rax), %ecx
movswl 0x22(%rax), %r8d
leaq 0x68(%rsp), %rdi
movl %esi, 0x14(%rsp)
movl %ebp, %edx
movl $0x1, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
pushq %rax
pushq %rax
callq 0xdc18
addq $0x20, %rsp
cmpb $0x0, 0x7(%rsp)
movq %r12, 0x50(%rsp)
movq %rbx, 0xb8(%rsp)
je 0x6f56
cmpl $0x2, %r14d
movq %r13, 0x60(%rsp)
jne 0x7047
testl %r13d, %r13d
movq 0x8(%rsp), %r10
jle 0x7125
movslq %r10d, %r15
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq 0x50(%rsp), %rax
leaq (%rcx,%rax), %rdx
addq $0x24, %rdx
addq %rax, %rcx
movq %rcx, 0x28(%rsp)
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rdi
movq %rax, 0x58(%rsp)
subq %rax, %rdi
sarq %rdi
movl 0x80(%rsp), %eax
imull 0x10(%rsp), %eax
movl %eax, 0x30(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x38(%rsp)
testl %r10d, %r10d
jle 0x6f28
movslq 0x20(%rsp), %r11
movq 0x58(%rsp), %rax
leaq (%rax,%r11,2), %r13
movq 0x28(%rsp), %rax
movl 0x18(%rax), %ecx
movl %ecx, %esi
movq 0x38(%rsp), %r9
imull %r9d, %esi
movl %esi, 0x18(%rsp)
movq (%rax), %r8
movq 0x8(%rax), %r12
subq %r8, %r12
sarq %r12
imull %r9d, %ecx
movslq %ecx, %rcx
leaq (%r8,%rcx,2), %r14
xorl %ebp, %ebp
xorl %r9d, %r9d
cmpl $0x1, %ebp
movl $0x1, %ebx
cmovbl %ebp, %ebx
movl %ecx, %r10d
subl %ebx, %r10d
leaq (%rcx,%rbp), %rbx
cmpq %rbx, %r12
movq %rdx, %rbx
cmovaq %r14, %rbx
movq %r15, %rax
movswl (%rbx), %r15d
leal (%r15,%r15,2), %r15d
addl %ebp, %r10d
movslq %r10d, %r10
cmpq %r10, %r12
leaq (%r8,%r10,2), %r10
cmovbeq %rdx, %r10
movswl (%r10), %r10d
addl %r15d, %r10d
incl %r10d
shrl $0x2, %r10d
cmpq %r11, %rdi
leaq 0x8c(%rsp), %rsi
movq %rsi, %r15
cmovaq %r13, %r15
movw %r10w, (%r15)
movq %rax, %r15
incq %r9
cmpq %rax, %r9
movl %r9d, %r10d
cmovgel %ebp, %r10d
movswl (%rbx), %ebx
leal (%rbx,%rbx,2), %ebx
addl 0x18(%rsp), %r10d
movslq %r10d, %r10
cmpq %r10, %r12
leaq (%r8,%r10,2), %r10
cmovbeq %rdx, %r10
movswl (%r10), %r10d
addl %ebx, %r10d
addl $0x2, %r10d
shrl $0x2, %r10d
leaq 0x1(%r11), %rbx
cmpq %rbx, %rdi
leaq 0x2(%r13), %rbx
cmovbeq %rsi, %rbx
movw %r10w, (%rbx)
movq 0x8(%rsp), %r10
addq $0x2, %r11
addq $0x4, %r13
addq $0x2, %r14
movq %r9, %rbp
cmpq %r9, %r10
jne 0x6e61
movq 0x38(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rax
addl 0x30(%rsp), %eax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %r13
movq %rcx, 0x38(%rsp)
cmpq %r13, %rcx
jne 0x6e16
jmp 0x7125
testl %ebp, %ebp
jle 0x73a7
movq 0x48(%rsp), %rax
movq (%rax), %r8
movq 0x50(%rsp), %rax
leaq (%r8,%rax), %r9
addq $0x24, %r9
addq %rax, %r8
movslq 0x80(%rsp), %rax
movq 0x68(%rsp), %r13
movq 0x70(%rsp), %rbx
subq %r13, %rbx
sarq %rbx
movl %ebp, %ecx
movq %rcx, 0x8(%rsp)
movl 0x14(%rsp), %r12d
movq %rax, %r15
addq %rax, %rax
movq %rax, 0x18(%rsp)
xorl %r10d, %r10d
xorl %ecx, %ecx
cmpl $0x0, 0x14(%rsp)
jle 0x7016
movl %ecx, %eax
cltd
idivl 0x10(%rsp)
movl %eax, %esi
imull 0x18(%r8), %esi
movq (%r8), %rbp
movq 0x8(%r8), %r14
subq %rbp, %r14
sarq %r14
movq %r13, %r11
xorl %edi, %edi
movl %edi, %eax
cltd
idivl 0x44(%rsp)
addl %esi, %eax
cltq
cmpq %rax, %r14
ja 0x6fe6
movq %r9, %rax
jmp 0x6ff1
leaq (,%rax,2), %rax
addq %rbp, %rax
movzwl (%rax), %eax
leaq (%r10,%rdi), %rdx
cmpq %rdx, %rbx
leaq 0x8c(%rsp), %rdx
cmovaq %r11, %rdx
movw %ax, (%rdx)
incq %rdi
addq $0x2, %r11
cmpq %rdi, %r12
jne 0x6fd1
incq %rcx
addq %r15, %r10
addq 0x18(%rsp), %r13
cmpq 0x8(%rsp), %rcx
jne 0x6faa
jmp 0x73a7
movl $0x5, %edi
leaq 0x1e801(%rip), %rsi     # 0x2583a
movl %ebx, %edx
xorl %eax, %eax
callq 0x1d0d6
jmp 0x7442
testl %r13d, %r13d
movq 0x8(%rsp), %rdi
jle 0x7125
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rdx
leaq (%rax,%rdx), %rcx
addq $0x24, %rcx
addq %rdx, %rax
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rsi
movq %rdx, 0x20(%rsp)
subq %rdx, %rsi
sarq %rsi
movl 0x80(%rsp), %edx
imull 0x10(%rsp), %edx
movl %edx, 0x18(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r10d, %r10d
testl %edi, %edi
leaq 0x8c(%rsp), %rdi
jle 0x7106
movslq %r8d, %r11
movq 0x20(%rsp), %rdx
leaq (%rdx,%r11,2), %r14
movslq 0x18(%rax), %r12
movq (%rax), %rbx
movq 0x8(%rax), %r13
subq %rbx, %r13
sarq %r13
movq %r10, %rbp
imulq %r12, %rbp
imulq %r9, %r12
addq %rbx, %r12
movq 0x8(%rsp), %rbx
cmpq %rbp, %r13
movq %rcx, %r15
cmovaq %r12, %r15
cmpq %r11, %rsi
movq %rdi, %rdx
cmovaq %r14, %rdx
movzwl (%r15), %r15d
movw %r15w, (%rdx)
incq %rbp
addq $0x2, %r12
incq %r11
addq $0x2, %r14
decq %rbx
jne 0x70d7
incq %r10
addq $0x2, %r9
addl 0x18(%rsp), %r8d
movq 0x60(%rsp), %r13
cmpq %r13, %r10
movq 0x8(%rsp), %rdi
jne 0x709b
cmpl $0x2, 0x10(%rsp)
jne 0x73a7
leaq 0xe8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xe09e
leaq 0x80(%rsp), %rdx
movq 0x20(%rdx), %rax
leaq 0x100(%rsp), %rcx
movq %rax, 0x20(%rcx)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
testl %r13d, %r13d
jle 0x738a
movslq 0x100(%rsp), %rax
movq 0xe8(%rsp), %rcx
movq 0xf0(%rsp), %rdx
subq %rcx, %rdx
sarq %rdx
movslq 0x80(%rsp), %r15
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %r8
movq %rsi, 0x58(%rsp)
subq %rsi, %r8
sarq %r8
movl 0x14(%rsp), %ebx
leaq (%rax,%rax), %rsi
movq %rsi, 0xe0(%rsp)
movq %rax, 0xc8(%rsp)
shlq $0x2, %rax
movq %rax, 0xd8(%rsp)
leaq (%r15,%r15), %rax
leaq (,%r15,4), %rsi
movq %rsi, 0xd0(%rsp)
xorl %esi, %esi
movq %rcx, 0xc0(%rsp)
movq %rcx, 0x30(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x28(%rsp)
movq %rax, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
cmpl $0x0, 0x14(%rsp)
leaq 0x10c(%rsp), %r10
jle 0x733b
movq 0x28(%rsp), %rsi
testq %rsi, %rsi
leal -0x2(%rsi,%rsi), %eax
movl $0x0, %ecx
cmovel %ecx, %eax
movq 0xc8(%rsp), %r9
imull %r9d, %eax
leaq 0x1(%rsi), %rcx
leal (%rsi,%rsi), %edi
cmpq 0x60(%rsp), %rcx
leal 0x2(%rsi,%rsi), %ecx
cmovael %edi, %ecx
imull %r9d, %ecx
movslq %ecx, %rcx
movslq %eax, %rsi
movq 0xc0(%rsp), %rax
movq %rsi, 0x38(%rsp)
leaq (%rax,%rsi,2), %r13
movq %rcx, 0x20(%rsp)
leaq (%rax,%rcx,2), %rdi
movq 0x58(%rsp), %rcx
movq 0x30(%rsp), %rbp
xorl %eax, %eax
movq %r15, %rsi
leaq (%r14,%rax), %r15
cmpq %r15, %rdx
movq %r10, %r15
cmovaq %rbp, %r15
movswl (%r15), %r9d
leal (%r9,%r9,2), %r9d
movq %rbx, %r11
movq 0x38(%rsp), %rbx
addq %rax, %rbx
cmpq %rbx, %rdx
movq %r10, %rbx
cmovaq %r13, %rbx
movswl (%rbx), %ebx
addl %ebx, %r9d
incl %r9d
shrl $0x2, %r9d
movq 0x8(%rsp), %rbx
addq %rax, %rbx
cmpq %rbx, %r8
leaq 0x8c(%rsp), %r12
movq %r12, %rbx
cmovaq %rcx, %rbx
movw %r9w, (%rbx)
movswl (%r15), %r9d
movq %rsi, %r15
leal (%r9,%r9,2), %r9d
movq 0x20(%rsp), %rsi
leaq (%rsi,%rax), %rbx
cmpq %rbx, %rdx
movq %r10, %rbx
cmovaq %rdi, %rbx
movswl (%rbx), %ebx
addl %ebx, %r9d
addl $0x2, %r9d
shrl $0x2, %r9d
leaq (%r15,%rax), %rbx
cmpq %rbx, %r8
movq 0x18(%rsp), %rsi
leaq (%rcx,%rsi), %rbx
cmovbeq %r12, %rbx
movw %r9w, (%rbx)
movq %r11, %rbx
incq %rax
addq $0x2, %rbp
addq $0x2, %r13
addq $0x2, %rcx
addq $0x2, %rdi
cmpq %rax, %r11
jne 0x727f
movq 0x28(%rsp), %rcx
incq %rcx
addq 0xe0(%rsp), %r14
movq 0x30(%rsp), %rax
addq 0xd8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdi
addq %rdi, %rsi
movq 0xd0(%rsp), %rax
addq %rax, 0x58(%rsp)
addq %rdi, %r15
movq %rcx, 0x28(%rsp)
cmpq 0x60(%rsp), %rcx
jne 0x7204
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x73a7
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x48(%rsp), %r15
movq (%r15), %rax
movq 0x50(%rsp), %r14
movl 0x18(%rax,%r14), %ecx
movl 0x1c(%rax,%r14), %r8d
movl 0x80(%rsp), %r9d
movl 0x84(%rsp), %r10d
subq $0x8, %rsp
movl $0x5, %edi
leaq 0x1e4ac(%rip), %rsi     # 0x2588a
movq 0xc0(%rsp), %rbx
movl %ebx, %edx
xorl %eax, %eax
pushq %r10
callq 0x1d0d6
addq $0x10, %rsp
addq (%r15), %r14
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0xe65e
leaq 0x80(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %rax, 0x38(%r14)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x28(%r14)
movups %xmm0, 0x18(%r14)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x743d
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl 0x44(%rsp), %r14d
incq %rbx
cmpl %ebx, 0x40(%rsp)
jne 0x6d14
movq 0xa8(%rsp), %rdx
addq $0x4, %rdx
movq 0xb0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rdx, %rcx
ja 0x6cc7
movb $0x1, %al
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7490
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x74aa
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x35a0