// File: /workspace/github_c_makefile_star2_O3/Joy-Division[P]tools-mgs/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;
  ucvector decoded;
  ucvector_init(&decoded);

  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*/

    key[length] = 0;
    for(i = 0; i != length; ++i) key[i] = (char)data[i];

    /*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*/

    langtag[length] = 0;
    for(i = 0; i != length; ++i) langtag[i] = (char)data[begin + i];

    /*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*/

    transkey[length] = 0;
    for(i = 0; i != length; ++i) transkey[i] = (char)data[begin + i];

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

    length = chunkLength < begin ? 0 : chunkLength - begin;

    if(compressed)
    {
      /*will fail if zlib error, e.g. if length is too small*/
      error = zlib_decompress(&decoded.data, &decoded.size,
                              (unsigned char*)(&data[begin]),
                              length, zlibsettings);
      if(error) break;
      if(decoded.allocsize < decoded.size) decoded.allocsize = decoded.size;
      ucvector_push_back(&decoded, 0);
    }
    else
    {
      if(!ucvector_resize(&decoded, length + 1)) CERROR_BREAK(error, 83 /*alloc fail*/);

      decoded.data[length] = 0;
      for(i = 0; i != length; ++i) decoded.data[i] = data[begin + i];
    }

    error = lodepng_add_itext(info, key, langtag, transkey, (char*)decoded.data);

    break;
  }

  lodepng_free(key);
  lodepng_free(langtag);
  lodepng_free(transkey);
  ucvector_cleanup(&decoded);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpq $0x5, %rcx
jae 0xba58
movl $0x1e, %ebx
jmp 0xba95
movq %rcx, %r14
movq %rdx, %r12
movl $0x1, %ebx
xorl %r13d, %r13d
cmpb $0x0, (%r12,%r13)
je 0xba77
movl %ebx, %r13d
incl %ebx
cmpq %r14, %r13
jb 0xba66
decl %ebx
leal 0x3(%rbx), %ebp
cmpq %r14, %rbp
jae 0xba90
leal -0x50(%rbx), %eax
cmpl $-0x4f, %eax
jae 0xbad5
movl $0x59, %ebx
jmp 0xba95
movl $0x4b, %ebx
xorl %edi, %edi
xorl %r13d, %r13d
xorl %r15d, %r15d
callq 0x1030
movq %r13, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0x20(%rsp), %rdi
callq 0x1030
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movl %ebx, %r15d
leaq 0x1(%r15), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1100
testq %rax, %rax
je 0xbb2a
movb $0x0, (%rax,%r13)
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x10f0
xorl %r15d, %r15d
cmpb $0x0, 0x2(%r12,%r13)
je 0xbb37
movl $0x48, %ebx
xorl %r13d, %r13d
movq 0x10(%rsp), %rdi
jmp 0xba9d
xorl %edi, %edi
xorl %r13d, %r13d
xorl %r15d, %r15d
jmp 0xbc4a
movq 0x18(%rsp), %rax
movb (%r12,%rax), %al
movb %al, 0xf(%rsp)
leal 0x4(%rbx), %eax
movq %rbp, %rcx
cmpb $0x0, (%r12,%rcx)
je 0xbb5d
leal (%rax,%r15), %ecx
incl %r15d
cmpq %r14, %rcx
jb 0xbb4a
leal 0x1(%r15), %edi
movq %rdi, 0x18(%rsp)
callq 0x1100
testq %rax, %rax
je 0xbc3f
movq %rax, %r13
movl %r15d, %eax
movb $0x0, (%r13,%rax)
testl %r15d, %r15d
je 0xbb9b
xorl %ecx, %ecx
leal (%rcx,%rbp), %edx
movb (%r12,%rdx), %dl
movb %dl, (%r13,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0xbb87
movq 0x18(%rsp), %rdx
addl %ebp, %edx
xorl %ebp, %ebp
cmpq %r14, %rdx
jae 0xbbc6
leal (%r15,%rbx), %eax
addl $0x5, %eax
xorl %ebp, %ebp
movq %rdx, %rcx
cmpb $0x0, (%r12,%rcx)
je 0xbbc6
leal (%rax,%rbp), %ecx
incl %ebp
cmpq %r14, %rcx
jb 0xbbb5
movq %rdx, %rbx
leal 0x1(%rbp), %edi
movq %rdi, 0x18(%rsp)
callq 0x1100
testq %rax, %rax
je 0xbc42
movq %rax, %r15
movl %ebp, %eax
movb $0x0, (%r15,%rax)
testl %ebp, %ebp
movq %rbx, %rsi
je 0xbc01
xorl %ecx, %ecx
leal (%rsi,%rcx), %edx
movb (%r12,%rdx), %dl
movb %dl, (%r15,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0xbbee
movq 0x18(%rsp), %rbp
addl %esi, %ebp
xorl %ebx, %ebx
subq %rbp, %r14
cmovaeq %r14, %rbx
cmpb $0x0, 0xf(%rsp)
je 0xbc54
leaq 0x28(%rsp), %rsi
addq %rbp, %r12
movl %ebx, %ecx
leaq 0x20(%rsp), %rdi
movq %r12, %rdx
movq 0x40(%rsp), %r8
callq 0xbdc4
testl %eax, %eax
je 0xbc9d
movl %eax, %ebx
jmp 0xbb20
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
movl $0x53, %ebx
jmp 0xba9d
leal 0x1(%rbx), %r14d
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0xa7a0
testl %eax, %eax
je 0xbc45
movq %r14, 0x28(%rsp)
movq 0x20(%rsp), %r8
movl %ebx, %eax
movb $0x0, (%r8,%rax)
testq %rax, %rax
je 0xbcd9
movl %ebx, %eax
xorl %ecx, %ecx
movq 0x38(%rsp), %rdi
leal (%rcx,%rbp), %edx
movb (%r12,%rdx), %dl
movb %dl, (%r8,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0xbc88
jmp 0xbcde
movq 0x28(%rsp), %r14
cmpq %r14, 0x30(%rsp)
jae 0xbcae
movq %r14, 0x30(%rsp)
incq %r14
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0xa7a0
movq (%r12), %r8
testl %eax, %eax
je 0xbcd9
movq %r14, 0x28(%rsp)
movb $0x0, -0x1(%r8,%r14)
movq 0x20(%rsp), %r8
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x4fb3
movq %rbx, %rdi
movl %eax, %ebx
jmp 0xba9d