// File: lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: testColor(int, int, int, int)
void testColor(int r, int g, int b, int a) {
  std::cout << "codec test color " << r << " " << g << " " << b << " " << a << std::endl;
  Image image;
  image.width = 20;
  image.height = 20;
  image.colorType = LCT_RGBA;
  image.bitDepth = 8;
  image.data.resize(20 * 20 * 4);
  for(size_t y = 0; y < 20; y++)
  for(size_t x = 0; x < 20; x++) {
    image.data[20 * 4 * y + 4 * x + 0] = r;
    image.data[20 * 4 * y + 4 * x + 0] = g;
    image.data[20 * 4 * y + 4 * x + 0] = b;
    image.data[20 * 4 * y + 4 * x + 0] = a;
  }

  doCodecTest(image);

  Image image2 = image;
  image2.data[3] = 0; //one fully transparent pixel
  doCodecTest(image2);
  image2.data[3] = 128; //one semi transparent pixel
  doCodecTest(image2);

  Image image3 = image;
  // add 255 different colors
  for(size_t i = 0; i < 255; i++) {
    image.data[i * 4 + 0] = i;
    image.data[i * 4 + 1] = i;
    image.data[i * 4 + 2] = i;
    image.data[i * 4 + 3] = 255;
  }
  doCodecTest(image3);
  // a 256th color
  image.data[255 * 4 + 0] = 255;
  image.data[255 * 4 + 1] = 255;
  image.data[255 * 4 + 2] = 255;
  image.data[255 * 4 + 3] = 255;
  doCodecTest(image3);

  testSinglePixel(r, g, b, a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq 0xc5e9a(%rip), %rdi     # 0xf7fd8
leaq 0x812b1(%rip), %rsi     # 0xb33f6
callq 0x3230
movq %rax, %rdi
movl -0x4(%rbp), %esi
callq 0x3420
movq %rax, %rdi
leaq 0x823a4(%rip), %rsi     # 0xb4503
movq %rsi, -0xc0(%rbp)
callq 0x3230
movq %rax, %rdi
movl -0x8(%rbp), %esi
callq 0x3420
movq -0xc0(%rbp), %rsi
movq %rax, %rdi
callq 0x3230
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x3420
movq -0xc0(%rbp), %rsi
movq %rax, %rdi
callq 0x3230
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x3420
movq %rax, %rdi
movq 0xc5e0c(%rip), %rsi     # 0xf7fc0
callq 0x3280
leaq -0x38(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xaaae0
movq -0xb8(%rbp), %rdi
movl $0x14, -0x20(%rbp)
movl $0x14, -0x1c(%rbp)
movl $0x6, -0x18(%rbp)
movl $0x8, -0x14(%rbp)
movl $0x640, %esi            # imm = 0x640
xorl %edx, %edx
callq 0x1a540
jmp 0x321fa
movq $0x0, -0x50(%rbp)
cmpq $0x14, -0x50(%rbp)
jae 0x3234d
movq $0x0, -0x58(%rbp)
cmpq $0x14, -0x58(%rbp)
jae 0x3233a
movb -0x4(%rbp), %al
movb %al, -0xc9(%rbp)
movq -0x50(%rbp), %rax
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0xc8(%rbp)
jmp 0x3224f
movq -0xc8(%rbp), %rax
movb -0xc9(%rbp), %cl
movb %cl, (%rax)
movb -0x8(%rbp), %al
movb %al, -0xd9(%rbp)
movq -0x50(%rbp), %rax
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0xd8(%rbp)
jmp 0x3228d
movq -0xd8(%rbp), %rax
movb -0xd9(%rbp), %cl
movb %cl, (%rax)
movb -0xc(%rbp), %al
movb %al, -0xe9(%rbp)
movq -0x50(%rbp), %rax
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0xe8(%rbp)
jmp 0x322cb
movq -0xe8(%rbp), %rax
movb -0xe9(%rbp), %cl
movb %cl, (%rax)
movb -0x10(%rbp), %al
movb %al, -0xf9(%rbp)
movq -0x50(%rbp), %rax
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
movq -0x58(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0xf8(%rbp)
jmp 0x32309
movq -0xf8(%rbp), %rax
movb -0xf9(%rbp), %cl
movb %cl, (%rax)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x32215
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x325ef
jmp 0x3233c
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x32202
leaq -0x38(%rbp), %rdi
callq 0x30ea0
jmp 0x32358
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xaab20
jmp 0x32367
leaq -0x80(%rbp), %rdi
movl $0x3, %esi
callq 0x1a5f0
movq %rax, -0x108(%rbp)
jmp 0x3237e
movq -0x108(%rbp), %rax
movb $0x0, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x30ea0
jmp 0x32393
leaq -0x80(%rbp), %rdi
movl $0x3, %esi
callq 0x1a5f0
movq %rax, -0x110(%rbp)
jmp 0x323aa
movq -0x110(%rbp), %rax
movb $-0x80, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x30ea0
jmp 0x323bf
leaq -0xa8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xaab20
jmp 0x323d1
movq $0x0, -0xb0(%rbp)
cmpq $0xff, -0xb0(%rbp)
jae 0x32502
movq -0xb0(%rbp), %rsi
movb %sil, %al
movb %al, -0x119(%rbp)
shlq $0x2, %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x118(%rbp)
jmp 0x32413
movq -0x118(%rbp), %rax
movb -0x119(%rbp), %cl
movb %cl, (%rax)
movq -0xb0(%rbp), %rax
movb %al, %cl
movb %cl, -0x129(%rbp)
leaq 0x1(,%rax,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x128(%rbp)
jmp 0x3244b
movq -0x128(%rbp), %rax
movb -0x129(%rbp), %cl
movb %cl, (%rax)
movq -0xb0(%rbp), %rax
movb %al, %cl
movb %cl, -0x139(%rbp)
leaq 0x2(,%rax,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x138(%rbp)
jmp 0x32483
movq -0x138(%rbp), %rax
movb -0x139(%rbp), %cl
movb %cl, (%rax)
movq -0xb0(%rbp), %rax
leaq 0x3(,%rax,4), %rsi
leaq -0x38(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x148(%rbp)
jmp 0x324b3
movq -0x148(%rbp), %rax
movb $-0x1, (%rax)
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x323dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x325e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xaab00
jmp 0x325e0
leaq -0xa8(%rbp), %rdi
callq 0x30ea0
jmp 0x32510
leaq -0x38(%rbp), %rdi
movl $0x3fc, %esi            # imm = 0x3FC
callq 0x1a5f0
movq %rax, -0x150(%rbp)
jmp 0x32527
movq -0x150(%rbp), %rax
movb $-0x1, (%rax)
leaq -0x38(%rbp), %rdi
movl $0x3fd, %esi            # imm = 0x3FD
callq 0x1a5f0
movq %rax, -0x158(%rbp)
jmp 0x32548
movq -0x158(%rbp), %rax
movb $-0x1, (%rax)
leaq -0x38(%rbp), %rdi
movl $0x3fe, %esi            # imm = 0x3FE
callq 0x1a5f0
movq %rax, -0x160(%rbp)
jmp 0x32569
movq -0x160(%rbp), %rax
movb $-0x1, (%rax)
leaq -0x38(%rbp), %rdi
movl $0x3ff, %esi            # imm = 0x3FF
callq 0x1a5f0
movq %rax, -0x168(%rbp)
jmp 0x3258a
movq -0x168(%rbp), %rax
movb $-0x1, (%rax)
leaq -0xa8(%rbp), %rdi
callq 0x30ea0
jmp 0x325a2
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
callq 0x31f70
jmp 0x325b5
leaq -0xa8(%rbp), %rdi
callq 0xaab00
jmp 0x325c3
leaq -0x80(%rbp), %rdi
callq 0xaab00
jmp 0x325ce
leaq -0x38(%rbp), %rdi
callq 0xaab00
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
jmp 0x325e2
leaq -0x80(%rbp), %rdi
callq 0xaab00
jmp 0x325ed
jmp 0x325ef
leaq -0x38(%rbp), %rdi
callq 0xaab00
jmp 0x325fa
jmp 0x325fc
movq -0x40(%rbp), %rdi
callq 0x3430
movq %rax, %rdi
callq 0x1a490
nopl (%rax)