// File: lvandeve[P]lodepng/lodepng_unittest.cpp
// Function: testSbitChunk2(unsigned int, unsigned int, unsigned int, unsigned int, LodePNGColorType, unsigned int, LodePNGColorType, unsigned int, LodePNGColorType, unsigned int, int, bool)
void testSbitChunk2(unsigned r, unsigned g, unsigned b, unsigned a,
                   LodePNGColorType type_pixels, unsigned bitdepth_pixels,
                   LodePNGColorType type_raw, unsigned bitdepth_raw,
                   LodePNGColorType type_png, unsigned bitdepth_png,
                   int auto_convert,
                   bool expect_encoder_error = false) {

  unsigned error;
  Image image;
  generateTestImageRequiringColorType16(image, type_pixels, bitdepth_pixels, false);

  LodePNGColorMode mode_raw; lodepng_color_mode_init(&mode_raw); mode_raw.bitdepth = bitdepth_raw; mode_raw.colortype = type_raw;
  LodePNGColorMode mode_test; lodepng_color_mode_init(&mode_test); mode_test.bitdepth = 16; mode_test.colortype = LCT_RGBA;
  LodePNGColorMode mode_png; lodepng_color_mode_init(&mode_png); mode_png.bitdepth = bitdepth_png; mode_png.colortype = type_png;
  std::vector<unsigned char> temp((image.width * image.height * lodepng_get_bpp(&mode_raw) + 7) / 8);
  error = lodepng_convert(temp.data(), image.data.data(), &mode_raw, &mode_test, image.width, image.height);
  ASSERT_NO_PNG_ERROR(error);
  image.data = temp;

  if(auto_convert == 0 || auto_convert == 2) testSbitChunk(r, g, b, a, image.data, image.width, image.height, mode_raw, mode_png, false, expect_encoder_error);
  if(auto_convert == 1 || auto_convert == 2) testSbitChunk(r, g, b, a, image.data, image.width, image.height, mode_raw, mode_png, true, expect_encoder_error);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movb 0x38(%rbp), %al
movl 0x30(%rbp), %r10d
movl 0x28(%rbp), %r10d
movl 0x20(%rbp), %r10d
movl 0x18(%rbp), %r10d
movl 0x10(%rbp), %r10d
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl %r8d, -0x14(%rbp)
movl %r9d, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0xaaae0
movq -0x1d0(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
xorl %ecx, %ecx
callq 0x29b10
jmp 0x7fdc1
leaq -0x80(%rbp), %rdi
callq 0x56a0
jmp 0x7fdcc
movl 0x18(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x80(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x56a0
jmp 0x7fde6
movl $0x10, -0xa4(%rbp)
movl $0x6, -0xa8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x56a0
jmp 0x7fe08
movl 0x28(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl 0x20(%rbp), %eax
movl %eax, -0xd0(%rbp)
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x1d8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5a60
movl %eax, -0x1d4(%rbp)
jmp 0x7fe3a
movl -0x1d4(%rbp), %ecx
movl -0x1d8(%rbp), %eax
imull %ecx, %eax
addl $0x7, %eax
shrl $0x3, %eax
movq %rax, -0x1e8(%rbp)
movb $0x0, -0xe9(%rbp)
leaq -0xea(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x1bfa0
movq -0x1e8(%rbp), %rsi
movq -0x1e0(%rbp), %rcx
leaq -0xe8(%rbp), %rdi
leaq -0xe9(%rbp), %rdx
callq 0xaab60
jmp 0x7fe93
leaq -0xea(%rbp), %rdi
callq 0x1bff0
leaq -0xe8(%rbp), %rdi
callq 0xab120
movq %rax, -0x1f0(%rbp)
jmp 0x7feb4
leaq -0x48(%rbp), %rdi
callq 0xab120
movq %rax, -0x1f8(%rbp)
jmp 0x7fec6
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdi
movl -0x30(%rbp), %r8d
movl -0x2c(%rbp), %r9d
leaq -0x80(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x6d60
movl %eax, -0x1fc(%rbp)
jmp 0x7fef4
movl -0x1fc(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x20c(%rbp)
leaq -0x151(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x3440
movq -0x208(%rbp), %rdx
leaq 0x331ee(%rip), %rsi     # 0xb3115
leaq -0x150(%rbp), %rdi
callq 0x3340
jmp 0x7ff35
leaq 0x364ee(%rip), %rdx     # 0xb642a
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xaa1b0
jmp 0x7ff51
leaq -0x199(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x3440
movq -0x218(%rbp), %rdx
movb $0x0, -0x19b(%rbp)
movb $0x0, -0x1c2(%rbp)
movb $0x0, -0x1c3(%rbp)
leaq 0x3457d(%rip), %rsi     # 0xb4504
leaq -0x198(%rbp), %rdi
callq 0x3340
jmp 0x7ff95
leaq -0x198(%rbp), %rdi
callq 0x33f0
movb %al, -0x219(%rbp)
jmp 0x7ffa9
movb -0x219(%rbp), %al
testb $0x1, %al
jne 0x7ffb5
jmp 0x7ffed
leaq -0x19a(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x3440
movq -0x228(%rbp), %rdx
movb $0x1, -0x19b(%rbp)
leaq 0x34527(%rip), %rsi     # 0xb4504
leaq -0x178(%rbp), %rdi
callq 0x3340
jmp 0x7ffeb
jmp 0x80048
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x3440
movq -0x230(%rbp), %rdx
movb $0x1, -0x1c2(%rbp)
leaq 0x344ef(%rip), %rsi     # 0xb4504
leaq -0x1c0(%rbp), %rdi
callq 0x3340
jmp 0x80023
movb $0x1, -0x1c3(%rbp)
leaq 0x366b2(%rip), %rsi     # 0xb66e3
leaq -0x178(%rbp), %rdi
leaq -0x1c0(%rbp), %rdx
callq 0xaa6d0
jmp 0x80046
jmp 0x80048
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x178(%rbp), %rdx
callq 0xaa240
jmp 0x80064
movl -0x20c(%rbp), %edi
leaq -0x110(%rbp), %rsi
callq 0x28d30
jmp 0x80078
leaq -0x110(%rbp), %rdi
callq 0x34a8
jmp 0x80086
leaq -0x178(%rbp), %rdi
callq 0x34a8
jmp 0x80094
testb $0x1, -0x1c3(%rbp)
jne 0x8009f
jmp 0x800af
leaq -0x1c0(%rbp), %rdi
callq 0x34a8
jmp 0x800ad
jmp 0x800af
testb $0x1, -0x1c2(%rbp)
jne 0x800ba
jmp 0x800c6
leaq -0x1c1(%rbp), %rdi
callq 0x3290
testb $0x1, -0x19b(%rbp)
jne 0x800d1
jmp 0x800dd
leaq -0x19a(%rbp), %rdi
callq 0x3290
leaq -0x198(%rbp), %rdi
callq 0x34a8
jmp 0x800eb
leaq -0x199(%rbp), %rdi
callq 0x3290
leaq -0x130(%rbp), %rdi
callq 0x34a8
jmp 0x80105
leaq -0x150(%rbp), %rdi
callq 0x34a8
jmp 0x80113
leaq -0x151(%rbp), %rdi
callq 0x3290
leaq -0x48(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x23520
jmp 0x80131
cmpl $0x0, 0x30(%rbp)
je 0x80141
cmpl $0x2, 0x30(%rbp)
jne 0x80315
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movl -0x30(%rbp), %r9d
movl -0x2c(%rbp), %r8d
movzbl -0x19(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, 0x20(%rax)
leaq -0xd0(%rbp), %r10
movq %r10, 0x10(%rax)
leaq -0x80(%rbp), %r10
movq %r10, 0x8(%rax)
movl %r8d, (%rax)
movl $0x0, 0x18(%rax)
leaq -0x48(%rbp), %r8
callq 0x7c930
jmp 0x8018d
jmp 0x80315
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8039f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xea(%rbp), %rdi
callq 0x1bff0
jmp 0x8039f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8038f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x80307
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x802f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x802db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x802cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x802b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x80299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8027c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8026c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x34a8
jmp 0x8026a
jmp 0x8026c
leaq -0x178(%rbp), %rdi
callq 0x34a8
jmp 0x8027a
jmp 0x8027c
testb $0x1, -0x1c3(%rbp)
jne 0x80287
jmp 0x80297
leaq -0x1c0(%rbp), %rdi
callq 0x34a8
jmp 0x80295
jmp 0x80297
jmp 0x80299
testb $0x1, -0x1c2(%rbp)
jne 0x802a4
jmp 0x802b0
leaq -0x1c1(%rbp), %rdi
callq 0x3290
jmp 0x802b2
testb $0x1, -0x19b(%rbp)
jne 0x802bd
jmp 0x802c9
leaq -0x19a(%rbp), %rdi
callq 0x3290
jmp 0x802cb
leaq -0x198(%rbp), %rdi
callq 0x34a8
jmp 0x802d9
jmp 0x802db
leaq -0x199(%rbp), %rdi
callq 0x3290
leaq -0x130(%rbp), %rdi
callq 0x34a8
jmp 0x802f5
jmp 0x802f7
leaq -0x150(%rbp), %rdi
callq 0x34a8
jmp 0x80305
jmp 0x80307
leaq -0x151(%rbp), %rdi
callq 0x3290
jmp 0x8038f
cmpl $0x1, 0x30(%rbp)
je 0x80321
cmpl $0x2, 0x30(%rbp)
jne 0x8036f
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movl -0x30(%rbp), %r9d
movl -0x2c(%rbp), %r8d
movzbl -0x19(%rbp), %r10d
andl $0x1, %r10d
movq %rsp, %rax
movl %r10d, 0x20(%rax)
leaq -0xd0(%rbp), %r10
movq %r10, 0x10(%rax)
leaq -0x80(%rbp), %r10
movq %r10, 0x8(%rax)
movl %r8d, (%rax)
movl $0x1, 0x18(%rax)
leaq -0x48(%rbp), %r8
callq 0x7c930
jmp 0x8036d
jmp 0x8036f
leaq -0xe8(%rbp), %rdi
callq 0x1a4c0
jmp 0x8037d
leaq -0x48(%rbp), %rdi
callq 0xaab00
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0xe8(%rbp), %rdi
callq 0x1a4c0
jmp 0x8039d
jmp 0x8039f
leaq -0x48(%rbp), %rdi
callq 0xaab00
jmp 0x803aa
jmp 0x803ac
movq -0x50(%rbp), %rdi
callq 0x3430
movq %rax, %rdi
callq 0x1a490
nopl (%rax)