// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: testCustomZlibCompress()
void testCustomZlibCompress() {
  std::cout << "testCustomZlibCompress" << std::endl;
  Image image;
  generateTestImage(image, 5, 5, LCT_RGBA, 8);

  std::vector<unsigned char> encoded;
  int customcontext = 5;

  struct TestFun {
    static unsigned custom_zlib(unsigned char**, size_t*,
                          const unsigned char*, size_t,
                          const LodePNGCompressSettings* settings) {
      ASSERT_EQUALS(5, *(int*)(settings->custom_context));
      custom_proof = 1;
      return 5555; // return a custom error code, which will be converted to an error known to lodepng.
    }
  };

  lodepng::State state;
  state.encoder.zlibsettings.custom_zlib = TestFun::custom_zlib;
  state.encoder.zlibsettings.custom_context = &customcontext;

  custom_proof = 0;
  unsigned error = lodepng::encode(encoded, image.data, image.width, image.height, state);
  ASSERT_EQUALS(1, custom_proof); // check that the custom zlib was called

  ASSERT_EQUALS(111, error); // expect a known lodepng error, not the custom 5555
}

// Assembly:
pushq %rbx
subq $0x380, %rsp            # imm = 0x380
movq 0x7b89e(%rip), %rdi     # 0xa2fd8
leaq 0x39e86(%rip), %rsi     # 0x615c7
callq 0x21f0
movq %rax, %rdi
callq 0x2100
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
pushq $0x5
popq %rdx
pushq $0x6
popq %rcx
pushq $0x8
popq %r8
movl %edx, %esi
callq 0x138c7
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
andq $0x0, 0xc0(%rsp)
movl $0x5, 0x4c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xb84c
leaq 0x456(%rip), %rax       # 0x27bf8
leaq 0x100(%rsp), %r8
movq %rax, 0x68(%r8)
leaq 0x4c(%rsp), %rax
andl $0x0, 0x7ba86(%rip)     # 0xa3240
movq %rax, 0x78(%r8)
leaq 0xd0(%rsp), %rsi
movl 0x18(%rsi), %edx
movl 0x1c(%rsi), %ecx
leaq 0xb0(%rsp), %rdi
callq 0xbbcf
movl %eax, 0x48(%rsp)
cmpl $0x1, 0x7ba5c(%rip)     # 0xa3240
jne 0x2781f
cmpl $0x6f, %eax
jne 0x27971
leaq 0x100(%rsp), %rdi
callq 0xb874
leaq 0xb0(%rsp), %rdi
callq 0xea7c
leaq 0xd0(%rsp), %rdi
callq 0xea7c
addq $0x380, %rsp            # imm = 0x380
popq %rbx
retq
leaq 0x389b7(%rip), %rsi     # 0x601dd
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x20c0
leaq 0x39da2(%rip), %rdx     # 0x615de
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a5df
leaq 0x3bf50(%rip), %rdx     # 0x637a5
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5a5df
leaq 0x39d75(%rip), %rdx     # 0x615e3
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5a5df
leaq 0x389a1(%rip), %rdx     # 0x60225
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5a5df
movq 0x7b73e(%rip), %rdi     # 0xa2fd8
leaq 0x28(%rsp), %rsi
callq 0x21d0
leaq 0x28(%rsp), %rdi
callq 0x2270
leaq 0x8(%rsp), %rdi
callq 0x2270
leaq 0x50(%rsp), %rdi
callq 0x2270
leaq 0x90(%rsp), %rdi
callq 0x2270
leaq 0x70(%rsp), %rdi
callq 0x2270
movq 0x7b6f8(%rip), %rdi     # 0xa2fd8
leaq 0x61626(%rip), %rsi     # 0x88f0d
callq 0x21f0
movq %rax, %rbx
leaq 0x50(%rsp), %rsi
movl $0x1, (%rsi)
leaq 0x28(%rsp), %rdi
callq 0x5aaac
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x21d0
leaq 0x38925(%rip), %rsi     # 0x6023d
movq %rax, %rdi
callq 0x21f0
movq %rax, %rbx
leaq 0x7b916(%rip), %rsi     # 0xa3240
leaq 0x8(%rsp), %rdi
callq 0x5aaac
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x21d0
leaq 0x387dc(%rip), %rsi     # 0x60124
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2100
leaq 0x8(%rsp), %rdi
callq 0x2270
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x27abc
leaq 0x38865(%rip), %rsi     # 0x601dd
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x20c0
leaq 0x39c62(%rip), %rdx     # 0x615f0
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a5df
leaq 0x3bdfe(%rip), %rdx     # 0x637a5
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5a5df
leaq 0x3877d(%rip), %rdx     # 0x6013d
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5a5df
leaq 0x3884f(%rip), %rdx     # 0x60225
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5a5df
movq 0x7b5ec(%rip), %rdi     # 0xa2fd8
leaq 0x28(%rsp), %rsi
callq 0x21d0
leaq 0x28(%rsp), %rdi
callq 0x2270
leaq 0x8(%rsp), %rdi
callq 0x2270
leaq 0x50(%rsp), %rdi
callq 0x2270
leaq 0x90(%rsp), %rdi
callq 0x2270
leaq 0x70(%rsp), %rdi
callq 0x2270
movq 0x7b5a6(%rip), %rdi     # 0xa2fd8
leaq 0x614d4(%rip), %rsi     # 0x88f0d
callq 0x21f0
movq %rax, %rbx
leaq 0x50(%rsp), %rsi
movl $0x6f, (%rsi)
leaq 0x28(%rsp), %rdi
callq 0x5aaac
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x21d0
leaq 0x387d3(%rip), %rsi     # 0x6023d
movq %rax, %rdi
callq 0x21f0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5a957
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x21d0
leaq 0x3868c(%rip), %rsi     # 0x60124
movq %rax, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2100
leaq 0x8(%rsp), %rdi
callq 0x2270
leaq 0x28(%rsp), %rdi
callq 0x2270
callq 0x13280
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x27ae6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x27af8
jmp 0x27ae3
jmp 0x27af5
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x27bbb
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x27bbb
jmp 0x27bb8
jmp 0x27bb8
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x27b32
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x27b41
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x27b50
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x27b5f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2270
jmp 0x27b6e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2270
jmp 0x27b80
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2270
jmp 0x27b92
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2270
jmp 0x27ba1
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2270
jmp 0x27bbb
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2270
jmp 0x27bbb
jmp 0x27bb8
jmp 0x27bb8
jmp 0x27bb3
movq %rax, %rbx
jmp 0x27bda
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0xb874
jmp 0x27bcd
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xea7c
leaq 0xd0(%rsp), %rdi
callq 0xea7c
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xe6cc
nop