// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
cmpq $0x5, %rcx
jae 0x8bc1
movl $0x1e, %ebx
jmp 0x8c06
movq %rcx, %r13
movq %rdx, %r15
movq %rdi, %rbp
movl $0x1, %r14d
xorl %r12d, %r12d
cmpb $0x0, (%r15,%r12)
je 0x8be5
movl %r14d, %r12d
incl %r14d
cmpq %r13, %r12
jb 0x8bd3
decl %r14d
leal 0x3(%r14), %ecx
cmpq %r13, %rcx
jae 0x8c01
leal -0x50(%r14), %eax
cmpl $-0x4f, %eax
jae 0x8c33
movl $0x59, %ebx
jmp 0x8c06
movl $0x4b, %ebx
xorl %edi, %edi
xorl %r12d, %r12d
xorl %ebp, %ebp
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %rbp, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x18(%rsp)
movq %rsi, 0x38(%rsp)
movl %r14d, %ebx
incq %rbx
movq %rbx, %rdi
callq 0x1140
testq %rax, %rax
je 0x8c88
movq %rbp, 0x28(%rsp)
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1130
movq 0x10(%rsp), %rdi
movb $0x0, (%rdi,%r12)
xorl %ebp, %ebp
cmpb $0x0, 0x2(%r15,%r12)
je 0x8c94
movl $0x48, %ebx
xorl %r12d, %r12d
jmp 0x8c0d
xorl %edi, %edi
xorl %r12d, %r12d
xorl %ebp, %ebp
jmp 0x8de6
movb (%r15,%rbx), %bl
leal 0x4(%r14), %eax
movq 0x18(%rsp), %rcx
cmpb $0x0, (%r15,%rcx)
je 0x8cb2
leal (%rax,%rbp), %ecx
incl %ebp
cmpq %r13, %rcx
jb 0x8ca1
leal 0x1(%rbp), %edi
movq %rdi, 0x20(%rsp)
callq 0x1140
testq %rax, %rax
je 0x8ddc
movq %rax, %r12
movb %bl, 0xf(%rsp)
movl %ebp, %ebx
testl %ebp, %ebp
movq 0x18(%rsp), %rax
je 0x8cee
leaq (%r15,%rax), %rsi
movq %r12, %rdi
movq %rbx, %rdx
callq 0x1130
movq 0x18(%rsp), %rax
movb $0x0, (%r12,%rbx)
movq 0x20(%rsp), %rdx
addl %eax, %edx
xorl %ebx, %ebx
cmpq %r13, %rdx
jae 0x8d1e
leal (%r14,%rbp), %eax
addl $0x5, %eax
xorl %ebx, %ebx
movq %rdx, %rcx
cmpb $0x0, (%r15,%rcx)
je 0x8d1e
leal (%rax,%rbx), %ecx
incl %ebx
cmpq %r13, %rcx
jb 0x8d0d
movq %rdx, 0x20(%rsp)
leal 0x1(%rbx), %r14d
movq %r14, %rdi
callq 0x1140
testq %rax, %rax
je 0x8ddf
movq %rax, %rbp
movq %r14, 0x18(%rsp)
movl %ebx, %r14d
testl %ebx, %ebx
movq 0x20(%rsp), %rbx
je 0x8d5b
leaq (%r15,%rbx), %rsi
movq %rbp, %rdi
movq %r14, %rdx
callq 0x1130
movb $0x0, (%rbp,%r14)
movq 0x18(%rsp), %rcx
addl %ebx, %ecx
xorl %eax, %eax
subl %ecx, %r13d
cmovbl %eax, %r13d
cmpb $0x0, 0xf(%rsp)
je 0x8df0
xorl %eax, %eax
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movl %ecx, %eax
addq %rax, %r15
movl %r13d, %r8d
xorl %edx, %edx
movq %r15, %rcx
movq 0x38(%rsp), %r9
callq 0xd38d
movl %eax, %ebx
testl %eax, %eax
jne 0x8dc8
movq 0x30(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x5e90
movl %eax, %ebx
movq 0x30(%rsp), %rdi
callq 0x1030
movq 0x10(%rsp), %rdi
jmp 0x8c0d
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
movl $0x53, %ebx
jmp 0x8c0d
movl %ecx, %eax
addq %rax, %r15
movl %r13d, %r9d
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x5e90
movq %rbx, %rdi
movl %eax, %ebx
jmp 0x8c0d