// File: /workspace/github_c_makefile_star2_O2/tditlu[P]shadetabler/src/lodepng/lodepng.c
// Function: readChunk_iTXt
static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,
                               const unsigned char* data, size_t chunkLength) {
  unsigned error = 0;
  unsigned i;

  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;
      /*will fail if zlib error, e.g. if length is too small*/
      error = zlib_decompress(&str, &size, 0, &data[begin],
                              length, zlibsettings);
      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, (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 $0x38, %rsp
cmpq $0x5, %rcx
jae 0x76ad
pushq $0x1e
jmp 0x76e6
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %r13
pushq $-0x50
popq %r12
leal 0x50(%r12), %ebx
cmpq %r14, %rbx
jae 0x76d0
cmpb $0x0, (%r15,%rbx)
je 0x76d0
incl %r12d
jmp 0x76ba
leal 0x53(%r12), %ebp
cmpq %r14, %rbp
jae 0x76e4
cmpl $-0x4f, %r12d
jae 0x7715
pushq $0x59
jmp 0x76e6
pushq $0x4b
popq %rbx
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r13d, %r13d
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %r13, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, 0x28(%rsp)
addl $0x51, %r12d
movq %r12, %rdi
callq 0x1130
testq %rax, %rax
je 0x7761
movq %r13, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x4a33
movq 0x8(%rsp), %rdi
movb $0x0, (%rdi,%rbx)
xorl %r13d, %r13d
cmpb $0x0, 0x2(%r15,%rbx)
je 0x776e
pushq $0x48
popq %rbx
xorl %r12d, %r12d
jmp 0x76ef
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x788a
movb (%r15,%r12), %al
movb %al, 0x7(%rsp)
movl %ebp, %ebx
movl %ebx, %ebx
cmpq %r14, %rbx
jae 0x778d
cmpb $0x0, (%r15,%rbx)
je 0x778d
incl %r13d
incl %ebx
jmp 0x7778
leal 0x1(%r13), %edi
callq 0x1130
testq %rax, %rax
je 0x787f
movq %rax, %r12
leaq (%r15,%rbp), %rsi
movl %r13d, %r13d
movq %rax, %rdi
movq %r13, %rdx
callq 0x4a33
xorl %eax, %eax
movb $0x0, (%r12,%r13)
incl %ebx
movl %ebx, %ebp
movl %ebp, %ebp
cmpq %r14, %rbp
jae 0x77d3
cmpb $0x0, (%r15,%rbp)
je 0x77d3
incl %eax
incl %ebp
jmp 0x77bf
leal 0x1(%rax), %edi
movq %rax, 0x20(%rsp)
callq 0x1130
testq %rax, %rax
je 0x7882
movq %rax, %r13
movl %ebx, %esi
addq %r15, %rsi
movl 0x20(%rsp), %ebx
movq %rax, %rdi
movq %rbx, %rdx
callq 0x4a33
movb $0x0, (%r13,%rbx)
incl %ebp
subl %ebp, %r14d
movl $0x0, %eax
cmovbl %eax, %r14d
cmpb $0x0, 0x7(%rsp)
je 0x7892
leaq 0x18(%rsp), %rdi
andq $0x0, (%rdi)
leaq 0x30(%rsp), %rsi
andq $0x0, (%rsi)
movl %ebp, %eax
addq %rax, %r15
movl %r14d, %r8d
xorl %edx, %edx
movq %r15, %rcx
movq 0x28(%rsp), %r9
callq 0xb7c0
movl %eax, %ebx
testl %eax, %eax
jne 0x786b
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %r9
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x4df7
movl %eax, %ebx
movq 0x18(%rsp), %rdi
callq 0x1030
movq 0x8(%rsp), %rdi
jmp 0x76ef
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x8(%rsp), %rdi
pushq $0x53
popq %rbx
jmp 0x76ef
movl %ebp, %eax
addq %rax, %r15
movl %r14d, %r9d
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x4df7
movq %rbx, %rdi
movl %eax, %ebx
jmp 0x76ef