// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/lodepng.cpp
// Function: readChunk_iTXt(LodePNGInfo*, LodePNGDecoderSettings const*, unsigned char const*, unsigned long)
static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecoderSettings* decoder,
                               const unsigned char* data, size_t chunkLength) {
  unsigned error = 0;
  unsigned i;

  /*copy the object to change parameters in it*/
  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;

  unsigned length, begin, compressed;
  char *key = 0, *langtag = 0, *transkey = 0;

  while(!error) /*not really a while loop, only used to break on error*/ {
    /*Quick check if the chunk length isn't too small. Even without check
    it'd still fail with other error checks below if it's too short. This just gives a different error code.*/
    if(chunkLength < 5) CERROR_BREAK(error, 30); /*iTXt chunk too short*/

    /*read the key*/
    for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
    if(length + 3 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination char, corrupt?*/
    if(length < 1 || length > 79) CERROR_BREAK(error, 89); /*keyword too short or long*/

    key = (char*)lodepng_malloc(length + 1);
    if(!key) CERROR_BREAK(error, 83); /*alloc fail*/

    lodepng_memcpy(key, data, length);
    key[length] = 0;

    /*read the compression method*/
    compressed = data[length + 1];
    if(data[length + 2] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/

    /*even though it's not allowed by the standard, no error is thrown if
    there's no null termination char, if the text is empty for the next 3 texts*/

    /*read the langtag*/
    begin = length + 3;
    length = 0;
    for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;

    langtag = (char*)lodepng_malloc(length + 1);
    if(!langtag) CERROR_BREAK(error, 83); /*alloc fail*/

    lodepng_memcpy(langtag, data + begin, length);
    langtag[length] = 0;

    /*read the transkey*/
    begin += length + 1;
    length = 0;
    for(i = begin; i < chunkLength && data[i] != 0; ++i) ++length;

    transkey = (char*)lodepng_malloc(length + 1);
    if(!transkey) CERROR_BREAK(error, 83); /*alloc fail*/

    lodepng_memcpy(transkey, data + begin, length);
    transkey[length] = 0;

    /*read the actual text*/
    begin += length + 1;

    length = (unsigned)chunkLength < begin ? 0 : (unsigned)chunkLength - begin;

    if(compressed) {
      unsigned char* str = 0;
      size_t size = 0;
      zlibsettings.max_output_size = decoder->max_text_size;
      /*will fail if zlib error, e.g. if length is too small*/
      error = zlib_decompress(&str, &size, 0, &data[begin],
                              length, &zlibsettings);
      /*error: compressed text larger than  decoder->max_text_size*/
      if(error && size > zlibsettings.max_output_size) error = 112;
      if(!error) error = lodepng_add_itext_sized(info, key, langtag, transkey, (char*)str, size);
      lodepng_free(str);
    } else {
      error = lodepng_add_itext_sized(info, key, langtag, transkey, (const char*)(data + begin), length);
    }

    break;
  }

  lodepng_free(key);
  lodepng_free(langtag);
  lodepng_free(transkey);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq 0x20(%rsi), %rax
movq %rax, 0x60(%rsp)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movaps %xmm1, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
cmpq $0x5, %rcx
jae 0x798d
pushq $0x1e
jmp 0x79c9
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
pushq $-0x50
popq %r12
leal 0x50(%r12), %ebp
cmpq %r13, %rbp
jae 0x79b3
cmpb $0x0, (%r15,%rbp)
je 0x79b3
incl %r12d
jmp 0x799d
leal 0x53(%r12), %eax
cmpq %r13, %rax
jae 0x79c7
cmpl $-0x4f, %r12d
jae 0x79f8
pushq $0x59
jmp 0x79c9
pushq $0x4b
popq %rbx
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
callq 0x2260
movq %r12, %rdi
callq 0x2260
movq %r14, %rdi
callq 0x2260
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, 0x18(%rsp)
addl $0x51, %r12d
movq %r12, %rdi
callq 0x2280
testq %rax, %rax
je 0x7a44
movq %r14, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x4a08
movq 0x10(%rsp), %rdi
movb $0x0, (%rdi,%rbp)
xorl %r14d, %r14d
cmpb $0x0, 0x2(%r15,%rbp)
je 0x7a51
pushq $0x48
popq %rbx
xorl %r12d, %r12d
jmp 0x79d2
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
pushq $0x53
popq %rbx
jmp 0x79d2
movb (%r15,%r12), %al
movb %al, 0xf(%rsp)
movq 0x18(%rsp), %rbp
movl %ebp, %ebp
cmpq %r13, %rbp
jae 0x7a73
cmpb $0x0, (%r15,%rbp)
je 0x7a73
incl %r14d
incl %ebp
jmp 0x7a5e
leal 0x1(%r14), %edi
callq 0x2280
testq %rax, %rax
je 0x7b96
movq %rax, %r12
movq 0x18(%rsp), %rax
leaq (%r15,%rax), %rsi
movl %r14d, %r14d
movq %r12, %rdi
movq %r14, %rdx
callq 0x4a08
xorl %eax, %eax
movq %r12, 0x18(%rsp)
movb $0x0, (%r12,%r14)
incl %ebp
movl %ebp, %r12d
movl %r12d, %r12d
cmpq %r13, %r12
jae 0x7ac6
cmpb $0x0, (%r15,%r12)
je 0x7ac6
incl %eax
incl %r12d
jmp 0x7ab0
leal 0x1(%rax), %edi
movq %rax, 0x30(%rsp)
callq 0x2280
testq %rax, %rax
je 0x7ba6
movq %rax, %r14
movl %ebp, %esi
addq %r15, %rsi
movl 0x30(%rsp), %ebp
movq %rax, %rdi
movq %rbp, %rdx
callq 0x4a08
movb $0x0, (%r14,%rbp)
incl %r12d
subl %r12d, %r13d
movl $0x0, %eax
cmovbl %eax, %r13d
cmpb $0x0, 0xf(%rsp)
je 0x7bbb
leaq 0x28(%rsp), %rdi
andq $0x0, (%rdi)
leaq 0x38(%rsp), %rbp
andq $0x0, (%rbp)
movq 0x40(%rbx), %rax
leaq 0x40(%rsp), %rbx
movq %rax, 0x8(%rbx)
movl %r12d, %eax
addq %rax, %r15
movl %r13d, %r8d
movq %rbp, %rsi
xorl %edx, %edx
movq %r15, %rcx
movq %rbx, %r9
callq 0xb6ed
movq (%rbp), %r9
cmpq 0x8(%rbx), %r9
pushq $0x70
popq %rbx
cmovbel %eax, %ebx
testl %eax, %eax
movq 0x18(%rsp), %r12
je 0x7b66
testl %ebx, %ebx
jne 0x7b82
movq 0x28(%rsp), %r8
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x4dd4
movl %eax, %ebx
movq 0x28(%rsp), %rdi
callq 0x2260
movq 0x10(%rsp), %rdi
jmp 0x79d2
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
jmp 0x7a4c
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
pushq $0x53
popq %rbx
movq 0x18(%rsp), %r12
jmp 0x79d2
movl %r12d, %eax
addq %rax, %r15
movl %r13d, %r9d
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq 0x18(%rsp), %r12
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
callq 0x4dd4
movq %rbx, %rdi
movl %eax, %ebx
jmp 0x79d2