// File: /workspace/github_cpp_makefile_star2_O1/cloudinary[P]fuif/transform/dct.h
// Function: default_DCT_scanscript(int, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&)
void default_DCT_scanscript(int nb_components, std::vector<std::vector<int>> & ordering, std::vector<int> & comp, std::vector<int> & coeff) {
   ordering.clear();
   for(int i=0; i<nb_components; i++)
       ordering.push_back(std::vector<int>(64));
   comp.clear();
   coeff.clear();
   std::vector<int> pc(nb_components,0);
   std::vector<int> cshifts(nb_components,3);
   int cc=0;
   int m=0;
   for (int p=0; p<nb_components*64; p++) {
     ordering[cc][pc[cc]] = p;
     comp.push_back(cc);
     coeff.push_back(pc[cc]);
//     v_printf(10,"Position %i: component %i, coefficient %i (cshift=%i)\n",p,cc,pc[cc],cshifts[cc]);
     pc[cc]++;

/*
     if (pc[cc] > 63) {cc++; m=0;}
     else if (dct_cshifts[pc[cc]] < cshifts[cc]) { cshifts[cc]--; cc++; m=0;}
     else if (cshifts[cc] == 2 && ++m == 1) {cc++; m=0;}
     else if (cshifts[cc] == 1 && ++m == 1) {cc++; m=0;}
     else if (cshifts[cc] == 0 && ++m == 2) {cc++; m=0;}
*/

// tried this one, but doesn't seem to be better than doing the simpler thing
//     if (pc[cc] > 63) cc++;
//     else if (dct_cshifts[pc[cc]] < cshifts[cc]) { cshifts[cc]--; cc++; }

// simple scan script: go one coefficient at a time, from low freq to high freq, alternating between the components
     cc++;
     if (cc == nb_components) { cc=0; }

   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
movq (%rsi), %rsi
movq %r15, %rdi
callq 0xf7fa
movl %ebp, 0x8(%rsp)
testl %ebp, %ebp
jle 0x7961
leaq 0x10(%rsp), %r12
movl 0x8(%rsp), %r13d
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x100, %edi            # imm = 0x100
callq 0x32b0
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq %rax, %rbp
addq $0x100, %rbp            # imm = 0x100
movq %rbp, 0x20(%rsp)
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
xorl %esi, %esi
callq 0x3180
movq %rbp, 0x18(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xf844
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x795c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
decl %r13d
jne 0x78f2
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x796e
movq %rax, 0x8(%r14)
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x797b
movq %rax, 0x8(%rbx)
movslq 0x8(%rsp), %r12
leaq 0x30(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rcx
movq %r12, %rsi
callq 0xdcbc
leaq 0x4(%rsp), %rdx
movl $0x3, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r12, %rsi
callq 0xdcbc
movl $0x0, 0x4(%rsp)
cmpl $0x0, 0x8(%rsp)
jle 0x7a82
movl 0x8(%rsp), %eax
shll $0x6, %eax
cmpl $0x2, %eax
movl $0x1, %r13d
cmovgel %eax, %r13d
xorl %ebp, %ebp
xorl %r12d, %r12d
movslq 0x4(%rsp), %rax
movq (%r15), %rcx
leaq (%rax,%rax,2), %rdx
movq 0x10(%rsp), %rsi
movslq (%rsi,%rax,4), %rax
movq (%rcx,%rdx,8), %rcx
movl %r12d, (%rcx,%rax,4)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x7a1d
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%r14)
jmp 0x7a2a
movq %r14, %rdi
leaq 0x4(%rsp), %rdx
callq 0xfa3c
movslq 0x4(%rsp), %rdx
shlq $0x2, %rdx
addq 0x10(%rsp), %rdx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x7a50
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x7a58
movq %rbx, %rdi
callq 0xfa3c
movslq 0x4(%rsp), %rax
movq 0x10(%rsp), %rcx
incl (%rcx,%rax,4)
movl 0x4(%rsp), %eax
incl %eax
cmpl 0x8(%rsp), %eax
cmovel %ebp, %eax
movl %eax, 0x4(%rsp)
incl %r12d
cmpl %r12d, %r13d
jne 0x79e6
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7a99
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7ab0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7ae4
jmp 0x7adf
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x7ae7
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x7ae7
movq %rax, %rbx
jmp 0x7afe
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7afe
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x35a0