// File: /workspace/github_c_makefile_star2_O1/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 0x8a41
movl $0x1e, %ebx
jmp 0x8a81
movq %rcx, %r13
movq %rdx, %r15
movq %rdi, %r14
movl $0x1, %ebx
xorl %r12d, %r12d
cmpb $0x0, (%r15,%r12)
je 0x8a63
movl %ebx, %r12d
incl %ebx
cmpq %r13, %r12
jb 0x8a52
decl %ebx
leal 0x3(%rbx), %ebp
cmpq %r13, %rbp
jae 0x8a7c
leal -0x50(%rbx), %eax
cmpl $-0x4f, %eax
jae 0x8aaf
movl $0x59, %ebx
jmp 0x8a81
movl $0x4b, %ebx
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, 0x38(%rsp)
movl %ebx, %edi
incq %rdi
movq %rdi, 0x18(%rsp)
callq 0x1140
testq %rax, %rax
je 0x8aff
movq %rax, %rdi
movq %r14, 0x28(%rsp)
testl %ebx, %ebx
je 0x8ae5
movq %rdi, %r14
movq %r15, %rsi
movq %r12, %rdx
callq 0x1130
movq %r14, %rdi
movb $0x0, (%rdi,%r12)
xorl %r14d, %r14d
cmpb $0x0, 0x2(%r15,%r12)
je 0x8b0c
movl $0x48, %ebx
xorl %r12d, %r12d
jmp 0x8a89
xorl %edi, %edi
xorl %r12d, %r12d
xorl %r14d, %r14d
jmp 0x8c72
cmpq %r13, %rbp
jae 0x8b2d
leal 0x4(%rbx), %eax
xorl %r14d, %r14d
movq %rbp, %rcx
cmpb $0x0, (%r15,%rcx)
je 0x8b2d
leal (%rax,%r14), %ecx
incl %r14d
cmpq %r13, %rcx
jb 0x8b1a
movq %rdi, 0x10(%rsp)
movq 0x18(%rsp), %rax
movb (%r15,%rax), %al
movb %al, 0xf(%rsp)
leal 0x1(%r14), %edi
movq %rdi, 0x18(%rsp)
callq 0x1140
testq %rax, %rax
je 0x8c67
movq %rax, %r12
movl %r14d, %eax
testl %r14d, %r14d
je 0x8b7c
leaq (%r15,%rbp), %rsi
movq %r12, %rdi
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdx
callq 0x1130
movq 0x20(%rsp), %rax
movb $0x0, (%r12,%rax)
movq 0x18(%rsp), %rdx
addl %ebp, %edx
xorl %ebp, %ebp
cmpq %r13, %rdx
jae 0x8bac
leal (%rbx,%r14), %eax
addl $0x5, %eax
xorl %ebp, %ebp
movq %rdx, %rcx
cmpb $0x0, (%r15,%rcx)
je 0x8bac
leal (%rax,%rbp), %ecx
incl %ebp
cmpq %r13, %rcx
jb 0x8b9b
movq %rdx, 0x18(%rsp)
leal 0x1(%rbp), %ebx
movq %rbx, %rdi
callq 0x1140
testq %rax, %rax
je 0x8c6a
movq %rax, %r14
movq %rbx, 0x20(%rsp)
movl %ebp, %ebx
testl %ebp, %ebp
movq 0x18(%rsp), %rbp
je 0x8be7
leaq (%r15,%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1130
movb $0x0, (%r14,%rbx)
movq 0x20(%rsp), %rcx
addl %ebp, %ecx
xorl %eax, %eax
subl %ecx, %r13d
cmovbl %eax, %r13d
cmpb $0x0, 0xf(%rsp)
je 0x8c7c
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 0xd574
movl %eax, %ebx
testl %eax, %eax
jne 0x8c53
movq 0x30(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x5bb1
movl %eax, %ebx
movq 0x30(%rsp), %rdi
callq 0x1030
movq 0x10(%rsp), %rdi
jmp 0x8a89
xorl %r12d, %r12d
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
movl $0x53, %ebx
jmp 0x8a89
movl %ecx, %eax
addq %rax, %r15
movl %r13d, %r9d
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %r15, %r8
callq 0x5bb1
movq %rbx, %rdi
movl %eax, %ebx
jmp 0x8a89