// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: testColorConvert2()
void testColorConvert2() {
  std::cout << "testColorConvert2" << std::endl;
  struct Combo {
    LodePNGColorType colortype;
    unsigned bitdepth;
  };

  Combo combos[15] = { { LCT_GREY, 1}, { LCT_GREY, 2}, { LCT_GREY, 4}, { LCT_GREY, 8}, { LCT_GREY, 16}, { LCT_RGB, 8}, { LCT_RGB, 16}, { LCT_PALETTE, 1}, { LCT_PALETTE, 2}, { LCT_PALETTE, 4}, { LCT_PALETTE, 8}, { LCT_GREY_ALPHA, 8}, { LCT_GREY_ALPHA, 16}, { LCT_RGBA, 8}, { LCT_RGBA, 16},
  };

  lodepng::State state;
  LodePNGColorMode& mode_in = state.info_png.color;
  LodePNGColorMode& mode_out = state.info_raw;
  LodePNGColorMode mode_8;
  lodepng_color_mode_init(&mode_8);

  for(size_t i = 0; i < 256; i++) {
    size_t j = i == 1 ? 255 : i;
    lodepng_palette_add(&mode_in, j, j, j, 255);
    lodepng_palette_add(&mode_out, j, j, j, 255);
  }

  for(size_t i = 0; i < 15; i++) {
    mode_in.colortype = combos[i].colortype;
    mode_in.bitdepth = combos[i].bitdepth;

    for(size_t j = 0; j < 15; j++) {
      mode_out.colortype = combos[j].colortype;
      mode_out.bitdepth = combos[j].bitdepth;

      unsigned char eight[36] = {
          0,0,0,255, 255,255,255,255,
          0,0,0,255, 255,255,255,255,
          255,255,255,255, 0,0,0,255,
          255,255,255,255, 255,255,255,255,
          0,0,0,255 }; //input in RGBA8
      unsigned char in[72]; //custom input color type
      unsigned char out[72]; //custom output color type
      unsigned char eight2[36]; //back in RGBA8 after all conversions to check correctness
      unsigned error = 0;

      error |= lodepng_convert(in, eight, &mode_in, &mode_8, 3, 3);
      if(!error) error |= lodepng_convert(out, in, &mode_out, &mode_in, 3, 3); //Test input to output type
      if(!error) error |= lodepng_convert(eight2, out, &mode_8, &mode_out, 3, 3);

      if(!error) {
        for(size_t k = 0; k < 36; k++) {
          if(eight[k] != eight2[k]) {
            error = 99999;
            break;
          }
        }
      }

      if(error) {
        std::cout << "Error " << error << " i: " << i << " j: " << j
          << " colortype i: " << combos[i].colortype
          << " bitdepth i: " << combos[i].bitdepth
          << " colortype j: " << combos[j].colortype
          << " bitdepth j: " << combos[j].bitdepth
          << std::endl;
        if(error != 99999) ASSERT_NO_PNG_ERROR(error);
        else fail();
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq 0x890ee(%rip), %rdi     # 0xa2fd8
leaq 0x469d7(%rip), %rsi     # 0x608c8
callq 0x21f0
movq %rax, %rdi
callq 0x2100
leaq 0x1f8(%rsp), %rdi
callq 0xb84c
leaq 0xc8(%rsp), %rdi
callq 0x4970
xorl %r14d, %r14d
movl $0xff, %ebp
cmpq $0x100, %r14            # imm = 0x100
je 0x19f6d
cmpq $0x1, %r14
movl %r14d, %eax
cmovel %ebp, %eax
movzbl %al, %ebx
leaq 0x2d8(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movl $0xff, %r8d
callq 0x4a2f
leaq 0x2a0(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movl $0xff, %r8d
callq 0x4a2f
incq %r14
jmp 0x19f20
xorl %eax, %eax
cmpq $0xf, %rax
je 0x1a2a0
leaq 0x6f1b0(%rip), %rcx     # 0x89130
movl (%rcx,%rax,8), %edx
movq %rax, 0x10(%rsp)
movl 0x4(%rcx,%rax,8), %eax
movl %edx, 0xc(%rsp)
movl %edx, 0x2d8(%rsp)
movq %rax, 0x18(%rsp)
movl %eax, 0x2dc(%rsp)
xorl %r15d, %r15d
cmpq $0xf, %r15
je 0x1a293
leaq 0x6f179(%rip), %rax     # 0x89130
movl (%rax,%r15,8), %r14d
movl 0x4(%rax,%r15,8), %ebp
movl %r14d, 0x2a0(%rsp)
movl %ebp, 0x2a4(%rsp)
movaps 0x6f1ea(%rip), %xmm0    # 0x891c0
movaps %xmm0, 0x30(%rsp)
movaps 0x6f1ce(%rip), %xmm0    # 0x891b0
movaps %xmm0, 0x20(%rsp)
movl $0xff000000, 0x40(%rsp) # imm = 0xFF000000
leaq 0x1b0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x2d8(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
pushq $0x3
popq %r8
movl %r8d, %r9d
callq 0x5390
movl %eax, %r13d
testl %eax, %eax
jne 0x1a0af
leaq 0x160(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
leaq 0x2a0(%rsp), %rdx
leaq 0x2d8(%rsp), %rcx
pushq $0x3
popq %r8
movl %r8d, %r9d
callq 0x5390
movl %eax, %r13d
testl %eax, %eax
jne 0x1a0af
leaq 0x130(%rsp), %rdi
leaq 0x160(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0x2a0(%rsp), %rcx
pushq $0x3
popq %r8
movl %r8d, %r9d
callq 0x5390
movl %eax, %r13d
testl %eax, %eax
jne 0x1a0af
xorl %eax, %eax
cmpq $0x24, %rax
je 0x1a28b
movb 0x20(%rsp,%rax), %cl
leaq 0x1(%rax), %rdx
movl $0x1869f, %r13d         # imm = 0x1869F
cmpb 0x130(%rsp,%rax), %cl
movq %rdx, %rax
je 0x1a08b
movq 0x88f22(%rip), %rdi     # 0xa2fd8
leaq 0x4681d(%rip), %rsi     # 0x608da
callq 0x21f0
movl %r13d, %esi
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
leaq 0x46814(%rip), %rsi     # 0x608eb
callq 0x21f0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x46815(%rip), %rsi     # 0x60908
callq 0x21f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x467d4(%rip), %rsi     # 0x608e1
callq 0x21f0
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x2360
movq %rax, %rdi
leaq 0x467c8(%rip), %rsi     # 0x608f0
callq 0x21f0
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x467ba(%rip), %rsi     # 0x608fe
callq 0x21f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2360
movq %rax, %rdi
leaq 0x467af(%rip), %rsi     # 0x6090d
callq 0x21f0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x2100
cmpl $0x1869f, %r13d         # imm = 0x1869F
leaq 0xf0(%rsp), %rbp
je 0x1a2bf
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
leaq 0x46040(%rip), %rsi     # 0x601dd
leaq 0xb(%rsp), %rdx
callq 0x20c0
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x46767(%rip), %rdx     # 0x6091b
callq 0x5a5df
leaq 0x48(%rsp), %rdi
leaq 0x47401(%rip), %rsi     # 0x615c6
leaq 0xa(%rsp), %rdx
callq 0x20c0
movq 0x50(%rsp), %r14
testq %r14, %r14
je 0x1a20e
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
leaq 0x473db(%rip), %rsi     # 0x615c6
leaq 0x8(%rsp), %rdx
callq 0x20c0
leaq 0x68(%rsp), %r12
movq %r12, %rdi
leaq 0x495a1(%rip), %rsi     # 0x637a5
movq %rbx, %rdx
callq 0x5a8d9
jmp 0x1a227
leaq 0x68(%rsp), %r12
movq %r12, %rdi
leaq 0x473a9(%rip), %rsi     # 0x615c6
leaq 0x9(%rsp), %rdx
callq 0x20c0
leaq 0x110(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x5a61f
movl %r13d, %edi
movq %rbx, %rsi
callq 0x13352
movq %rbx, %rdi
callq 0x2270
leaq 0x68(%rsp), %rdi
callq 0x2270
testq %r14, %r14
je 0x1a26c
leaq 0x88(%rsp), %rdi
callq 0x2270
leaq 0x48(%rsp), %rdi
callq 0x2270
movq %rbp, %rdi
callq 0x2270
leaq 0xa8(%rsp), %rdi
callq 0x2270
incq %r15
jmp 0x19fa6
movq 0x10(%rsp), %rax
incq %rax
jmp 0x19f6f
leaq 0x1f8(%rsp), %rdi
callq 0xb874
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x13280
jmp 0x1a33e
jmp 0x1a33e
jmp 0x1a2e8
movq %rax, %rbx
jmp 0x1a30b
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x2270
jmp 0x1a2fc
jmp 0x1a33e
movq %rax, %rbx
jmp 0x1a306
movq %rax, %rbx
jmp 0x1a318
jmp 0x1a33e
movq %rax, %rbx
jmp 0x1a32f
movq %rax, %rbx
jmp 0x1a322
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2270
testq %r14, %r14
je 0x1a318
leaq 0x88(%rsp), %rdi
callq 0x2270
leaq 0x48(%rsp), %rdi
callq 0x2270
leaq 0xf0(%rsp), %rdi
callq 0x2270
leaq 0xa8(%rsp), %rdi
callq 0x2270
jmp 0x1a341
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0xb874
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xe6cc