// File: /workspace/github_cpp_makefile_star2_O3/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 $0x138, %rsp            # imm = 0x138
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x69f2
movq (%rbx), %rax
movq %rbx, 0xb8(%rsp)
movq 0x8(%rbx), %rcx
cmpq %rax, %rcx
je 0x7438
leaq 0x9c(%rsp), %r15
xorl %edx, %edx
movq %r14, 0x48(%rsp)
movslq (%rax,%rdx,4), %rbx
movl 0x4(%rax,%rdx,4), %ebp
cmpl %ebp, %ebx
jg 0x741b
movl 0x8(%rax,%rdx,4), %r12d
movq %rdx, 0xc0(%rsp)
movl 0xc(%rax,%rdx,4), %eax
movl %eax, 0xc(%rsp)
cmpl $0x3, %eax
setl %al
cmpl $0x3, %r12d
setl %cl
andb %al, %cl
movb %cl, 0xb(%rsp)
incl %ebp
movl %ebp, 0x74(%rsp)
movl %r12d, 0x44(%rsp)
movq (%r14), %rax
movq %rbx, %rsi
shlq $0x6, %rsi
movl 0x18(%rax,%rsi), %r8d
movl 0x1c(%rax,%rsi), %edi
movslq 0x6c(%r14), %rcx
movq %rcx, %rdx
shlq $0x6, %rdx
movq %r8, 0x20(%rsp)
cmpl 0x18(%rax,%rdx), %r8d
jl 0x6ce8
addq %rax, %rdx
cmpl 0x1c(%rdx), %edi
jge 0x6fcd
movq %rsi, 0x50(%rsp)
addq %rsi, %rax
movq 0x20(%rsp), %rbp
movl %ebp, %esi
imull %r12d, %esi
movq %rdi, 0x30(%rsp)
movl %edi, %r13d
imull 0xc(%rsp), %r13d
movswl 0x20(%rax), %ecx
movswl 0x22(%rax), %r8d
leaq 0x78(%rsp), %rdi
movl %esi, 0x1c(%rsp)
movl %r13d, %edx
movl $0x1, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
pushq %rax
pushq %rax
callq 0xdb78
addq $0x20, %rsp
cmpb $0x0, 0xb(%rsp)
movq %rbx, 0xc8(%rsp)
je 0x6ef9
cmpl $0x2, %r12d
jne 0x6fe7
movq 0x30(%rsp), %rbx
testl %ebx, %ebx
jle 0x70c7
movslq %ebp, %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq 0x50(%rsp), %rax
leaq (%rcx,%rax), %rdx
addq $0x24, %rdx
addq %rax, %rcx
movq %rcx, 0x60(%rsp)
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rdi
movq %rax, 0x58(%rsp)
subq %rax, %rdi
sarq %rdi
movl 0x90(%rsp), %eax
imull 0xc(%rsp), %eax
movl %eax, 0x68(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x38(%rsp)
testl %ebp, %ebp
leaq 0x9c(%rsp), %rax
jle 0x6ecb
movslq 0x10(%rsp), %r11
movq 0x58(%rsp), %rcx
leaq (%rcx,%r11,2), %r13
movq 0x60(%rsp), %r9
movl 0x18(%r9), %ecx
movl %ecx, %esi
movq 0x38(%rsp), %r10
imull %r10d, %esi
movq (%r9), %r8
movq 0x8(%r9), %rbx
subq %r8, %rbx
sarq %rbx
imull %r10d, %ecx
movslq %ecx, %rcx
leaq (%r8,%rcx,2), %r14
xorl %r12d, %r12d
xorl %r9d, %r9d
cmpl $0x1, %r12d
movl $0x1, %ebp
cmovbl %r12d, %ebp
movl %ecx, %r10d
subl %ebp, %r10d
leaq (%rcx,%r12), %rbp
cmpq %rbp, %rbx
movq %rdx, %rbp
cmovaq %r14, %rbp
movswl (%rbp), %r15d
leal (%r15,%r15,2), %r15d
addl %r12d, %r10d
movslq %r10d, %r10
cmpq %r10, %rbx
leaq (%r8,%r10,2), %r10
cmovbeq %rdx, %r10
movswl (%r10), %r10d
addl %r15d, %r10d
incl %r10d
shrl $0x2, %r10d
cmpq %r11, %rdi
movq %rax, %r15
cmovaq %r13, %r15
movw %r10w, (%r15)
incq %r9
cmpq 0x28(%rsp), %r9
movl %r9d, %r10d
cmovgel %r12d, %r10d
movswl (%rbp), %r15d
movq 0x20(%rsp), %rbp
leal (%r15,%r15,2), %r15d
addl %esi, %r10d
movslq %r10d, %r10
cmpq %r10, %rbx
leaq (%r8,%r10,2), %r10
cmovbeq %rdx, %r10
movswl (%r10), %r10d
addl %r15d, %r10d
addl $0x2, %r10d
shrl $0x2, %r10d
leaq 0x1(%r11), %r15
cmpq %r15, %rdi
leaq 0x2(%r13), %r15
cmovbeq %rax, %r15
movw %r10w, (%r15)
addq $0x2, %r11
addq $0x4, %r13
addq $0x2, %r14
movq %r9, %r12
cmpq %r9, %rbp
jne 0x6e0c
movq 0x38(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %rax
addl 0x68(%rsp), %eax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rbx
movq %rcx, 0x38(%rsp)
cmpq %rbx, %rcx
jne 0x6dbc
jmp 0x70c7
testl %r13d, %r13d
jle 0x7354
movq 0x48(%rsp), %rax
movq (%rax), %r8
movq 0x50(%rsp), %rax
leaq (%r8,%rax), %r9
addq $0x24, %r9
addq %rax, %r8
movslq 0x90(%rsp), %rax
movq 0x78(%rsp), %rbp
movq 0x80(%rsp), %rbx
subq %rbp, %rbx
sarq %rbx
movl %r13d, %ecx
movq %rcx, 0x28(%rsp)
movl 0x1c(%rsp), %r13d
movq %rax, 0x20(%rsp)
addq %rax, %rax
movq %rax, 0x10(%rsp)
xorl %r10d, %r10d
xorl %ecx, %ecx
cmpl $0x0, 0x1c(%rsp)
jle 0x6fb4
movl %ecx, %eax
cltd
idivl 0xc(%rsp)
movl %eax, %esi
imull 0x18(%r8), %esi
movq (%r8), %r12
movq 0x8(%r8), %r14
subq %r12, %r14
sarq %r14
movq %rbp, %r11
xorl %edi, %edi
movl %edi, %eax
cltd
idivl 0x44(%rsp)
addl %esi, %eax
cltq
cmpq %rax, %r14
ja 0x6f90
movq %r9, %rax
jmp 0x6f94
leaq (%r12,%rax,2), %rax
movzwl (%rax), %eax
leaq (%r10,%rdi), %rdx
cmpq %rdx, %rbx
movq %r15, %rdx
cmovaq %r11, %rdx
movw %ax, (%rdx)
incq %rdi
addq $0x2, %r11
cmpq %rdi, %r13
jne 0x6f7b
incq %rcx
addq 0x20(%rsp), %r10
addq 0x10(%rsp), %rbp
cmpq 0x28(%rsp), %rcx
jne 0x6f54
jmp 0x7354
movl $0x5, %edi
leaq 0x1e861(%rip), %rsi     # 0x2583a
movl %ebx, %edx
xorl %eax, %eax
callq 0x1cede
jmp 0x73f9
movq 0x30(%rsp), %rbx
testl %ebx, %ebx
jle 0x70c7
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x50(%rsp), %rdx
leaq (%rax,%rdx), %rcx
addq $0x24, %rcx
addq %rdx, %rax
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rsi
movq %rdx, 0x10(%rsp)
subq %rdx, %rsi
sarq %rsi
movl 0x90(%rsp), %edx
imull 0xc(%rsp), %edx
movl %edx, 0x28(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r10d, %r10d
testl %ebp, %ebp
leaq 0x9c(%rsp), %rdi
jle 0x70a8
movslq %r8d, %r11
movq 0x10(%rsp), %rdx
leaq (%rdx,%r11,2), %rbx
movslq 0x18(%rax), %r14
movq (%rax), %r15
movq 0x8(%rax), %r12
subq %r15, %r12
sarq %r12
movq %r10, %r13
imulq %r14, %r13
imulq %r9, %r14
addq %r15, %r14
movq 0x20(%rsp), %rbp
cmpq %r13, %r12
movq %rcx, %r15
cmovaq %r14, %r15
cmpq %r11, %rsi
movq %rdi, %rdx
cmovaq %rbx, %rdx
movzwl (%r15), %r15d
movw %r15w, (%rdx)
incq %r13
addq $0x2, %r14
incq %r11
addq $0x2, %rbx
decq %rbp
jne 0x7079
incq %r10
addq $0x2, %r9
addl 0x28(%rsp), %r8d
movq 0x30(%rsp), %rbx
cmpq %rbx, %r10
movq 0x20(%rsp), %rbp
jne 0x703d
cmpl $0x2, 0xc(%rsp)
leaq 0x9c(%rsp), %r15
jne 0x7354
leaq 0xf8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xe010
leaq 0x90(%rsp), %rcx
movq 0x20(%rcx), %rax
leaq 0x110(%rsp), %rdx
movq %rax, 0x20(%rdx)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movq 0xf8(%rsp), %rdi
testl %ebx, %ebx
jle 0x733f
movslq 0x110(%rsp), %rax
movq 0x100(%rsp), %rcx
subq %rdi, %rcx
sarq %rcx
movslq 0x90(%rsp), %rdx
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %r8
movq %rsi, 0xe8(%rsp)
subq %rsi, %r8
sarq %r8
movl 0x1c(%rsp), %ebp
movq %rax, 0x58(%rsp)
leaq (,%rax,4), %rax
movq %rax, 0xe0(%rsp)
leaq (,%rdx,4), %rax
movq %rax, 0xd8(%rsp)
movq %rdx, 0xf0(%rsp)
leaq (%rdx,%rdx), %rax
movq %rax, 0xd0(%rsp)
xorl %r9d, %r9d
movq %rdi, 0x60(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x7330
leaq (%r9,%r9), %rax
movq %rax, %rdx
movq 0x58(%rsp), %r10
imulq %r10, %rdx
movq %rdx, 0x20(%rsp)
leal -0x2(%rax), %edx
testq %r9, %r9
movl $0x0, %esi
cmovel %esi, %edx
movslq %edx, %r14
imulq %r10, %r14
movq %rax, %rdx
movq 0xf0(%rsp), %r11
imulq %r11, %rdx
movq %rdx, 0x10(%rsp)
leaq 0x1(%r9), %rdx
movq %rdx, 0x68(%rsp)
cmpq %rbx, %rdx
leal 0x2(%r9,%r9), %edx
cmovgel %eax, %edx
imull %r10d, %edx
movslq %edx, %rax
movq 0xe0(%rsp), %rsi
imulq %r9, %rsi
addq %rdi, %rsi
movq %r14, 0x28(%rsp)
leaq (%rdi,%r14,2), %r14
movq 0xd8(%rsp), %rdx
imulq %r9, %rdx
movq 0xe8(%rsp), %r12
addq %r12, %rdx
movq %rax, 0x38(%rsp)
leaq (%rdi,%rax,2), %rax
leaq 0x1(,%r9,2), %r10
movq %r11, %rdi
imulq %r10, %rdi
imulq 0xd0(%rsp), %r10
addq %r12, %r10
xorl %r12d, %r12d
movq %r15, %r13
leaq 0x11c(%rsp), %r11
movq 0x20(%rsp), %r9
leaq (%r9,%r12), %r15
cmpq %r15, %rcx
movq %r11, %r15
cmovaq %rsi, %r15
movswl (%r15), %r9d
leal (%r9,%r9,2), %r9d
movq %rbp, %rbx
movq 0x28(%rsp), %rbp
addq %r12, %rbp
cmpq %rbp, %rcx
movq %r11, %rbp
cmovaq %r14, %rbp
movswl (%rbp), %ebp
addl %ebp, %r9d
incl %r9d
shrl $0x2, %r9d
movq 0x10(%rsp), %rbp
addq %r12, %rbp
cmpq %rbp, %r8
movq %r13, %rbp
cmovaq %rdx, %rbp
movw %r9w, (%rbp)
movq %rbx, %rbp
movswl (%r15), %r9d
leal (%r9,%r9,2), %r9d
movq 0x38(%rsp), %rbx
leaq (%rbx,%r12), %r15
cmpq %r15, %rcx
movq %r11, %r15
cmovaq %rax, %r15
movswl (%r15), %r15d
addl %r15d, %r9d
addl $0x2, %r9d
shrl $0x2, %r9d
leaq (%rdi,%r12), %r15
cmpq %r15, %r8
movq %r13, %r15
cmovaq %r10, %r15
movw %r9w, (%r15)
incq %r12
addq $0x2, %rsi
addq $0x2, %r14
addq $0x2, %rdx
addq $0x2, %rax
addq $0x2, %r10
cmpq %r12, %rbp
jne 0x7265
movq 0x68(%rsp), %rax
movq %rax, %r9
movq %r13, %r15
movq 0x30(%rsp), %rbx
movq 0x60(%rsp), %rdi
jmp 0x7336
incq %r9
movq %r9, %rax
cmpq %rbx, %rax
jne 0x71a0
testq %rdi, %rdi
je 0x7354
movq 0x108(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x48(%rsp), %r14
movq (%r14), %rax
movq 0x50(%rsp), %r12
movl 0x18(%rax,%r12), %ecx
movl 0x1c(%rax,%r12), %r8d
movl 0x90(%rsp), %r9d
movl 0x94(%rsp), %r10d
subq $0x8, %rsp
movl $0x5, %edi
leaq 0x1e4ff(%rip), %rsi     # 0x2588a
movq 0xd0(%rsp), %rbx
movl %ebx, %edx
xorl %eax, %eax
pushq %r10
callq 0x1cede
addq $0x10, %rsp
addq (%r14), %r12
movq %r12, %rdi
leaq 0x78(%rsp), %rsi
callq 0xe5dc
leaq 0x90(%rsp), %rcx
movq 0x20(%rcx), %rax
movq %rax, 0x38(%r12)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x28(%r12)
movups %xmm0, 0x18(%r12)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x73f0
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl 0x74(%rsp), %ebp
movl 0x44(%rsp), %r12d
incq %rbx
cmpl %ebx, %ebp
jne 0x6cb2
movq 0xb8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq 0xc0(%rsp), %rdx
addq $0x4, %rdx
movq %rdx, %rsi
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
movq %rsi, %rdx
ja 0x6c6f
movb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x744e
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x746b
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3590