// File: lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: testChrmToSrgb()
void testChrmToSrgb() {
  std::cout << "testChrmToSrgb" << std::endl;
  // srgb gamma approximation and chromaticities defined as standard by png (multiplied by 100000)
  unsigned sg = 45455; // srgb gamma approximation
  unsigned swx = 31270;
  unsigned swy = 32900;
  unsigned srx = 64000;
  unsigned sry = 33000;
  unsigned sgx = 30000;
  unsigned sgy = 60000;
  unsigned sbx = 15000;
  unsigned sby = 6000;

  testChrmToSrgb(sg, swx, swy, srx, sry, sgx, sgy, sbx, sby, 0, 0, 0, 0, 0, 0);
  testChrmToSrgb(sg, swx, swy, srx, sry, sgx, sgy, sbx, sby, 255, 255, 255, 255, 255, 255);

  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 50, 50, 50, 50, 50, 50);
  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 128, 128, 128, 128, 128, 128);
  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 200, 200, 200, 200, 200, 200);

  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 255, 0, 0, 255, 0, 0);
  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 0, 255, 0, 0, 255, 0);
  testChrmToSrgb(0, swx, swy, srx, sry, sgx, sgy, sbx, sby, 0, 0, 255, 0, 0, 255);

  // swap red and green chromaticities
  testChrmToSrgb(0, swx, swy, sgx, sgy, srx, sry, sbx, sby, 255, 0, 0, 0, 255, 0);
  testChrmToSrgb(0, swx, swy, sgx, sgy, srx, sry, sbx, sby, 0, 255, 0, 255, 0, 0);
  testChrmToSrgb(0, swx, swy, sgx, sgy, srx, sry, sbx, sby, 0, 0, 255, 0, 0, 255);

  // swap red/green/blue chromaticities
  testChrmToSrgb(0, swx, swy, sgx, sgy, sbx, sby, srx, sry, 255, 0, 0, 0, 255, 0);
  testChrmToSrgb(0, swx, swy, sgx, sgy, sbx, sby, srx, sry, 0, 255, 0, 0, 0, 255);
  testChrmToSrgb(0, swx, swy, sgx, sgy, sbx, sby, srx, sry, 0, 0, 255, 255, 0, 0);

  // different whitepoint does not affect white or gray, due to the relative rendering intent (adaptation)
  testChrmToSrgb(0, 35000, 25000, srx, sry, sgx, sgy, sbx, sby, 0, 0, 0, 0, 0, 0);
  testChrmToSrgb(0, 35000, 25000, srx, sry, sgx, sgy, sbx, sby, 50, 50, 50, 50, 50, 50);
  testChrmToSrgb(0, 35000, 25000, srx, sry, sgx, sgy, sbx, sby, 128, 128, 128, 128, 128, 128);
  testChrmToSrgb(0, 35000, 25000, srx, sry, sgx, sgy, sbx, sby, 200, 200, 200, 200, 200, 200);
  testChrmToSrgb(0, 35000, 25000, srx, sry, sgx, sgy, sbx, sby, 255, 255, 255, 255, 255, 255);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movq 0x72bc8(%rip), %rdi     # 0xf7fd8
leaq 0x31354(%rip), %rsi     # 0xb676b
callq 0x3230
movq %rax, %rdi
movq 0x72b9a(%rip), %rsi     # 0xf7fc0
callq 0x3280
movl $0xb18f, -0xc(%rbp)     # imm = 0xB18F
movl $0x7a26, -0x10(%rbp)    # imm = 0x7A26
movl $0x8084, -0x14(%rbp)    # imm = 0x8084
movl $0xfa00, -0x18(%rbp)    # imm = 0xFA00
movl $0x80e8, -0x1c(%rbp)    # imm = 0x80E8
movl $0x7530, -0x20(%rbp)    # imm = 0x7530
movl $0xea60, -0x24(%rbp)    # imm = 0xEA60
movl $0x3a98, -0x28(%rbp)    # imm = 0x3A98
movl $0x1770, -0x2c(%rbp)    # imm = 0x1770
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %ebx, %ebx
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %ebx, %ebx
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xff, 0x18(%rsp)
movl $0xff, 0x20(%rsp)
movl $0xff, 0x28(%rsp)
movl $0xff, 0x30(%rsp)
movl $0xff, 0x38(%rsp)
movl $0xff, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x32, 0x18(%rsp)
movl $0x32, 0x20(%rsp)
movl $0x32, 0x28(%rsp)
movl $0x32, 0x30(%rsp)
movl $0x32, 0x38(%rsp)
movl $0x32, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x80, 0x18(%rsp)
movl $0x80, 0x20(%rsp)
movl $0x80, 0x28(%rsp)
movl $0x80, 0x30(%rsp)
movl $0x80, 0x38(%rsp)
movl $0x80, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xc8, 0x18(%rsp)
movl $0xc8, 0x20(%rsp)
movl $0xc8, 0x28(%rsp)
movl $0xc8, 0x30(%rsp)
movl $0xc8, 0x38(%rsp)
movl $0xc8, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xff, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0xff, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0xff, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0xff, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0xff, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0xff, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x18(%rbp), %r9d
movl -0x1c(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xff, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0xff, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x18(%rbp), %r9d
movl -0x1c(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0xff, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0xff, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x18(%rbp), %r9d
movl -0x1c(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0xff, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0xff, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movl -0x2c(%rbp), %r11d
movl -0x18(%rbp), %r10d
movl -0x1c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xff, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0xff, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movl -0x2c(%rbp), %r11d
movl -0x18(%rbp), %r10d
movl -0x1c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0xff, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0xff, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
movl -0x2c(%rbp), %r11d
movl -0x18(%rbp), %r10d
movl -0x1c(%rbp), %eax
xorl %edi, %edi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0xff, 0x28(%rsp)
movl $0xff, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl $0x88b8, %esi           # imm = 0x88B8
movl $0x61a8, %edx           # imm = 0x61A8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl $0x88b8, %esi           # imm = 0x88B8
movl $0x61a8, %edx           # imm = 0x61A8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x32, 0x18(%rsp)
movl $0x32, 0x20(%rsp)
movl $0x32, 0x28(%rsp)
movl $0x32, 0x30(%rsp)
movl $0x32, 0x38(%rsp)
movl $0x32, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl $0x88b8, %esi           # imm = 0x88B8
movl $0x61a8, %edx           # imm = 0x61A8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x80, 0x18(%rsp)
movl $0x80, 0x20(%rsp)
movl $0x80, 0x28(%rsp)
movl $0x80, 0x30(%rsp)
movl $0x80, 0x38(%rsp)
movl $0x80, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl $0x88b8, %esi           # imm = 0x88B8
movl $0x61a8, %edx           # imm = 0x61A8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xc8, 0x18(%rsp)
movl $0xc8, 0x20(%rsp)
movl $0xc8, 0x28(%rsp)
movl $0xc8, 0x30(%rsp)
movl $0xc8, 0x38(%rsp)
movl $0xc8, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
movl -0x24(%rbp), %r11d
movl -0x28(%rbp), %r10d
movl -0x2c(%rbp), %eax
xorl %edi, %edi
movl $0x88b8, %esi           # imm = 0x88B8
movl $0x61a8, %edx           # imm = 0x61A8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0xff, 0x18(%rsp)
movl $0xff, 0x20(%rsp)
movl $0xff, 0x28(%rsp)
movl $0xff, 0x30(%rsp)
movl $0xff, 0x38(%rsp)
movl $0xff, 0x40(%rsp)
movl $0x0, 0x48(%rsp)
callq 0x82100
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)