// File: lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: createComplexPNG(std::vector<unsigned char, std::allocator<unsigned char>>&)
void createComplexPNG(std::vector<unsigned char>& png) {
  unsigned w = 16, h = 17;
  std::vector<unsigned char> image(w * h);
  for(size_t i = 0; i < w * h; i++) {
    image[i] = i % 256;
  }

  lodepng::State state;
  LodePNGInfo& info = state.info_png;
  info.color.colortype = LCT_PALETTE;
  info.color.bitdepth = 8;
  state.info_raw.colortype = LCT_PALETTE;
  state.info_raw.bitdepth = 8;
  state.encoder.auto_convert = false;
  state.encoder.text_compression = 1;
  state.encoder.add_id = 1;
  for(size_t i = 0; i < 256; i++) {
    lodepng_palette_add(&info.color, i, i, i, i);
    lodepng_palette_add(&state.info_raw, i, i, i, i);
  }

  info.background_defined = 1;
  info.background_r = 127;

  lodepng_add_text(&info, "key0", "string0");
  lodepng_add_text(&info, "key1", "string1");

  lodepng_add_itext(&info, "ikey0", "ilangtag0", "itranskey0", "istring0");
  lodepng_add_itext(&info, "ikey1", "ilangtag1", "itranskey1", "istring1");

  info.time_defined = 1;
  info.time.year = 2012;
  info.time.month = 1;
  info.time.day = 2;
  info.time.hour = 3;
  info.time.minute = 4;
  info.time.second = 5;

  info.phys_defined = 1;
  info.phys_x = 1;
  info.phys_y = 2;
  info.phys_unit = 1;

  lodepng_chunk_create(&info.unknown_chunks_data[0], &info.unknown_chunks_size[0], 3, "uNKa", (unsigned char*)"a00");
  lodepng_chunk_create(&info.unknown_chunks_data[0], &info.unknown_chunks_size[0], 3, "uNKa", (unsigned char*)"a01");
  lodepng_chunk_create(&info.unknown_chunks_data[1], &info.unknown_chunks_size[1], 3, "uNKb", (unsigned char*)"b00");
  lodepng_chunk_create(&info.unknown_chunks_data[2], &info.unknown_chunks_size[2], 3, "uNKc", (unsigned char*)"c00");

  unsigned error = lodepng::encode(png, &image[0], w, h, state);
  ASSERT_NO_PNG_ERROR(error);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x8(%rbp)
movl $0x10, -0xc(%rbp)
movl $0x11, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
imull %ecx, %eax
movq %rax, -0x3c8(%rbp)
movb $0x0, -0x29(%rbp)
leaq -0x2a(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x1bfa0
movq -0x3c8(%rbp), %rsi
movq -0x3c0(%rbp), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0xaab60
jmp 0x3a45e
leaq -0x2a(%rbp), %rdi
callq 0x1bff0
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl -0xc(%rbp), %ecx
imull -0x10(%rbp), %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jae 0x3a4e8
movq -0x48(%rbp), %rsi
movb %sil, %al
movb %al, -0x3d1(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x3d0(%rbp)
jmp 0x3a4a0
movq -0x3d0(%rbp), %rax
movb -0x3d1(%rbp), %cl
movb %cl, (%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x3a46f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2a(%rbp), %rdi
callq 0x1bff0
jmp 0x3abfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3abf0
leaq -0x2c8(%rbp), %rdi
callq 0x11ad0
jmp 0x3a4f6
leaq -0x2c8(%rbp), %rax
addq $0xd0, %rax
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rax
movl $0x3, 0x10(%rax)
movq -0x2d0(%rbp), %rax
movl $0x8, 0x14(%rax)
movl $0x3, -0x220(%rbp)
movl $0x8, -0x21c(%rbp)
movl $0x0, -0x248(%rbp)
movl $0x1, -0x228(%rbp)
movl $0x1, -0x22c(%rbp)
movq $0x0, -0x2d8(%rbp)
cmpq $0x100, -0x2d8(%rbp) # imm = 0x100
jae 0x3a5d9
movq -0x2d0(%rbp), %rdi
addq $0x10, %rdi
movzbl -0x2d8(%rbp), %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x58b0
jmp 0x3a593
leaq -0x220(%rbp), %rdi
movzbl -0x2d8(%rbp), %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x58b0
jmp 0x3a5b2
jmp 0x3a5b4
movq -0x2d8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2d8(%rbp)
jmp 0x3a563
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3abe0
movq -0x2d0(%rbp), %rax
movl $0x1, 0x38(%rax)
movq -0x2d0(%rbp), %rax
movl $0x7f, 0x3c(%rax)
movq -0x2d0(%rbp), %rdi
leaq 0x79734(%rip), %rsi     # 0xb3d37
leaq 0x79748(%rip), %rdx     # 0xb3d52
callq 0x5d10
jmp 0x3a611
movq -0x2d0(%rbp), %rdi
leaq 0x7973c(%rip), %rsi     # 0xb3d5b
leaq 0x79750(%rip), %rdx     # 0xb3d76
callq 0x5d10
jmp 0x3a62d
movq -0x2d0(%rbp), %rdi
leaq 0x796fb(%rip), %rsi     # 0xb3d36
leaq 0x796fa(%rip), %rdx     # 0xb3d3c
leaq 0x796fd(%rip), %rcx     # 0xb3d46
leaq 0x79701(%rip), %r8      # 0xb3d51
callq 0x6040
jmp 0x3a657
movq -0x2d0(%rbp), %rdi
leaq 0x796f5(%rip), %rsi     # 0xb3d5a
leaq 0x796f4(%rip), %rdx     # 0xb3d60
leaq 0x796f7(%rip), %rcx     # 0xb3d6a
leaq 0x796fb(%rip), %r8      # 0xb3d75
callq 0x6040
jmp 0x3a681
movq -0x2d0(%rbp), %rax
movl $0x1, 0x9c(%rax)
movq -0x2d0(%rbp), %rax
movl $0x7dc, 0xa0(%rax)      # imm = 0x7DC
movq -0x2d0(%rbp), %rax
movl $0x1, 0xa4(%rax)
movq -0x2d0(%rbp), %rax
movl $0x2, 0xa8(%rax)
movq -0x2d0(%rbp), %rax
movl $0x3, 0xac(%rax)
movq -0x2d0(%rbp), %rax
movl $0x4, 0xb0(%rax)
movq -0x2d0(%rbp), %rax
movl $0x5, 0xb4(%rax)
movq -0x2d0(%rbp), %rax
movl $0x1, 0xb8(%rax)
movq -0x2d0(%rbp), %rax
movl $0x1, 0xbc(%rax)
movq -0x2d0(%rbp), %rax
movl $0x2, 0xc0(%rax)
movq -0x2d0(%rbp), %rax
movl $0x1, 0xc4(%rax)
movq -0x2d0(%rbp), %rsi
movq %rsi, %rdi
addq $0x178, %rdi            # imm = 0x178
addq $0x190, %rsi            # imm = 0x190
leaq 0x79623(%rip), %rcx     # 0xb3d7e
leaq 0x79621(%rip), %r8      # 0xb3d83
movl $0x3, %edx
callq 0x55c0
jmp 0x3a76e
movq -0x2d0(%rbp), %rsi
movq %rsi, %rdi
addq $0x178, %rdi            # imm = 0x178
addq $0x190, %rsi            # imm = 0x190
leaq 0x795f1(%rip), %rcx     # 0xb3d7e
leaq 0x795f3(%rip), %r8      # 0xb3d87
movl $0x3, %edx
callq 0x55c0
jmp 0x3a7a0
movq -0x2d0(%rbp), %rsi
movq %rsi, %rdi
addq $0x180, %rdi            # imm = 0x180
addq $0x198, %rsi            # imm = 0x198
leaq 0x795cc(%rip), %rcx     # 0xb3d8b
leaq 0x795ca(%rip), %r8      # 0xb3d90
movl $0x3, %edx
callq 0x55c0
jmp 0x3a7d2
movq -0x2d0(%rbp), %rsi
movq %rsi, %rdi
addq $0x188, %rdi            # imm = 0x188
addq $0x1a0, %rsi            # imm = 0x1A0
leaq 0x795a3(%rip), %rcx     # 0xb3d94
leaq 0x795a1(%rip), %r8      # 0xb3d99
movl $0x3, %edx
callq 0x55c0
jmp 0x3a804
movq -0x8(%rbp), %rax
movq %rax, -0x3e8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
callq 0x1a5f0
movq %rax, -0x3e0(%rbp)
jmp 0x3a825
movq -0x3e0(%rbp), %rsi
movq -0x3e8(%rbp), %rdi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0x2c8(%rbp), %r8
callq 0x120f0
movl %eax, -0x3ec(%rbp)
jmp 0x3a84d
movl -0x3ec(%rbp), %eax
movl %eax, -0x2dc(%rbp)
movl -0x2dc(%rbp), %eax
movl %eax, -0x3fc(%rbp)
leaq -0x341(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0x3440
movq -0x3f8(%rbp), %rdx
leaq 0x7888f(%rip), %rsi     # 0xb3115
leaq -0x340(%rbp), %rdi
callq 0x3340
jmp 0x3a894
leaq 0x79502(%rip), %rdx     # 0xb3d9d
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0xaa1b0
jmp 0x3a8b0
leaq -0x389(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x3440
movq -0x408(%rbp), %rdx
movb $0x0, -0x38b(%rbp)
movb $0x0, -0x3b2(%rbp)
movb $0x0, -0x3b3(%rbp)
leaq 0x79c1e(%rip), %rsi     # 0xb4504
leaq -0x388(%rbp), %rdi
callq 0x3340
jmp 0x3a8f4
leaq -0x388(%rbp), %rdi
callq 0x33f0
movb %al, -0x409(%rbp)
jmp 0x3a908
movb -0x409(%rbp), %al
testb $0x1, %al
jne 0x3a914
jmp 0x3a94c
leaq -0x38a(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x3440
movq -0x418(%rbp), %rdx
movb $0x1, -0x38b(%rbp)
leaq 0x79bc8(%rip), %rsi     # 0xb4504
leaq -0x368(%rbp), %rdi
callq 0x3340
jmp 0x3a94a
jmp 0x3a9a7
leaq -0x3b1(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x3440
movq -0x420(%rbp), %rdx
movb $0x1, -0x3b2(%rbp)
leaq 0x79b90(%rip), %rsi     # 0xb4504
leaq -0x3b0(%rbp), %rdi
callq 0x3340
jmp 0x3a982
movb $0x1, -0x3b3(%rbp)
leaq 0x7bd53(%rip), %rsi     # 0xb66e3
leaq -0x368(%rbp), %rdi
leaq -0x3b0(%rbp), %rdx
callq 0xaa6d0
jmp 0x3a9a5
jmp 0x3a9a7
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
leaq -0x368(%rbp), %rdx
callq 0xaa240
jmp 0x3a9c3
movl -0x3fc(%rbp), %edi
leaq -0x300(%rbp), %rsi
callq 0x28d30
jmp 0x3a9d7
leaq -0x300(%rbp), %rdi
callq 0x34a8
jmp 0x3a9e5
leaq -0x368(%rbp), %rdi
callq 0x34a8
jmp 0x3a9f3
testb $0x1, -0x3b3(%rbp)
jne 0x3a9fe
jmp 0x3aa0e
leaq -0x3b0(%rbp), %rdi
callq 0x34a8
jmp 0x3aa0c
jmp 0x3aa0e
testb $0x1, -0x3b2(%rbp)
jne 0x3aa19
jmp 0x3aa25
leaq -0x3b1(%rbp), %rdi
callq 0x3290
testb $0x1, -0x38b(%rbp)
jne 0x3aa30
jmp 0x3aa3c
leaq -0x38a(%rbp), %rdi
callq 0x3290
leaq -0x388(%rbp), %rdi
callq 0x34a8
jmp 0x3aa4a
leaq -0x389(%rbp), %rdi
callq 0x3290
leaq -0x320(%rbp), %rdi
callq 0x34a8
jmp 0x3aa64
leaq -0x340(%rbp), %rdi
callq 0x34a8
jmp 0x3aa72
leaq -0x341(%rbp), %rdi
callq 0x3290
leaq -0x2c8(%rbp), %rdi
callq 0x11b20
jmp 0x3aa8c
leaq -0x28(%rbp), %rdi
callq 0x1a4c0
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3abd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3abc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3aba8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3ab98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3ab7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3ab66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3ab49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3ab39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x34a8
jmp 0x3ab37
jmp 0x3ab39
leaq -0x368(%rbp), %rdi
callq 0x34a8
jmp 0x3ab47
jmp 0x3ab49
testb $0x1, -0x3b3(%rbp)
jne 0x3ab54
jmp 0x3ab64
leaq -0x3b0(%rbp), %rdi
callq 0x34a8
jmp 0x3ab62
jmp 0x3ab64
jmp 0x3ab66
testb $0x1, -0x3b2(%rbp)
jne 0x3ab71
jmp 0x3ab7d
leaq -0x3b1(%rbp), %rdi
callq 0x3290
jmp 0x3ab7f
testb $0x1, -0x38b(%rbp)
jne 0x3ab8a
jmp 0x3ab96
leaq -0x38a(%rbp), %rdi
callq 0x3290
jmp 0x3ab98
leaq -0x388(%rbp), %rdi
callq 0x34a8
jmp 0x3aba6
jmp 0x3aba8
leaq -0x389(%rbp), %rdi
callq 0x3290
leaq -0x320(%rbp), %rdi
callq 0x34a8
jmp 0x3abc2
jmp 0x3abc4
leaq -0x340(%rbp), %rdi
callq 0x34a8
jmp 0x3abd2
jmp 0x3abd4
leaq -0x341(%rbp), %rdi
callq 0x3290
leaq -0x2c8(%rbp), %rdi
callq 0x11b20
jmp 0x3abee
jmp 0x3abf0
leaq -0x28(%rbp), %rdi
callq 0x1a4c0
jmp 0x3abfb
jmp 0x3abfd
movq -0x38(%rbp), %rdi
callq 0x3430
movq %rax, %rdi
callq 0x1a490
nop