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

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

  struct TestFun {
    static unsigned custom_deflate(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_deflate = TestFun::custom_deflate;
  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 deflate was called

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

// Assembly:
pushq %rbx
subq $0x380, %rsp            # imm = 0x380
movq 0x7a9b6(%rip), %rdi     # 0xa2fd8
leaq 0x38ff8(%rip), %rsi     # 0x61621
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       # 0x28ae0
leaq 0x100(%rsp), %r8
movq %rax, 0x70(%r8)
leaq 0x4c(%rsp), %rax
andl $0x0, 0x7ab9e(%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, 0x7ab74(%rip)     # 0xa3240
jne 0x28707
cmpl $0x6f, %eax
jne 0x28859
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 0x37acf(%rip), %rsi     # 0x601dd
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x20c0
leaq 0x38f0f(%rip), %rdx     # 0x61633
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a5df
leaq 0x3b068(%rip), %rdx     # 0x637a5
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5a5df
leaq 0x38e8d(%rip), %rdx     # 0x615e3
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5a5df
leaq 0x37ab9(%rip), %rdx     # 0x60225
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5a5df
movq 0x7a856(%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 0x7a810(%rip), %rdi     # 0xa2fd8
leaq 0x6073e(%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 0x37a3d(%rip), %rsi     # 0x6023d
movq %rax, %rdi
callq 0x21f0
movq %rax, %rbx
leaq 0x7aa2e(%rip), %rsi     # 0xa3240
leaq 0x8(%rsp), %rdi
callq 0x5aaac
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x21d0
leaq 0x378f4(%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 0x289a4
leaq 0x3797d(%rip), %rsi     # 0x601dd
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x20c0
leaq 0x38dc2(%rip), %rdx     # 0x61638
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a5df
leaq 0x3af16(%rip), %rdx     # 0x637a5
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x5a5df
leaq 0x37895(%rip), %rdx     # 0x6013d
leaq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5a5df
leaq 0x37967(%rip), %rdx     # 0x60225
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5a5df
movq 0x7a704(%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 0x7a6be(%rip), %rdi     # 0xa2fd8
leaq 0x605ec(%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 0x378eb(%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 0x377a4(%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 0x289ce
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x289e0
jmp 0x289cb
jmp 0x289dd
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x28aa3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x28aa3
jmp 0x28aa0
jmp 0x28aa0
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x28a1a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2270
jmp 0x28a29
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x28a38
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
jmp 0x28a47
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2270
jmp 0x28a56
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2270
jmp 0x28a68
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2270
jmp 0x28a7a
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2270
jmp 0x28a89
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2270
jmp 0x28aa3
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2270
jmp 0x28aa3
jmp 0x28aa0
jmp 0x28aa0
jmp 0x28a9b
movq %rax, %rbx
jmp 0x28ac2
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0xb874
jmp 0x28ab5
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