// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x8f00
cmpl $0x0, -0x24(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xeab5
jmp 0xee50
cmpq $0x5, -0x20(%rbp)
jae 0xeac8
movl $0x1e, -0x24(%rbp)
jmp 0xee50
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x69(%rbp)
jae 0xeaf3
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0xeafc
jmp 0xeb09
jmp 0xeafe
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xeacf
movl -0x2c(%rbp), %eax
addl $0x3, %eax
movl %eax, %eax
cmpq -0x20(%rbp), %rax
jb 0xeb23
movl $0x4b, -0x24(%rbp)
jmp 0xee50
cmpl $0x1, -0x2c(%rbp)
jb 0xeb2f
cmpl $0x4f, -0x2c(%rbp)
jbe 0xeb3b
movl $0x59, -0x24(%rbp)
jmp 0xee50
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x13b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xeb61
movl $0x53, -0x24(%rbp)
jmp 0xee50
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xeb9a
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xeb73
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xebce
movl $0x48, -0x24(%rbp)
jmp 0xee50
movl -0x2c(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x6a(%rbp)
jae 0xec08
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
testb $0x1, %al
jne 0xec11
jmp 0xec25
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xebe4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x13b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xec4b
movl $0x53, -0x24(%rbp)
jmp 0xee50
movq -0x48(%rbp), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xec89
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x48(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xec5d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x6b(%rbp)
jae 0xecc6
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x6b(%rbp)
movb -0x6b(%rbp), %al
testb $0x1, %al
jne 0xeccf
jmp 0xece3
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xeca2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x13b0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xed09
movl $0x53, -0x24(%rbp)
jmp 0xee50
movq -0x50(%rbp), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xed47
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x50(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xed1b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
addl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
cmpq %rcx, %rax
jae 0xed67
xorl %eax, %eax
movq %rax, -0x78(%rbp)
jmp 0xed75
movq -0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0xedd3
leaq -0x68(%rbp), %rdi
leaq -0x68(%rbp), %rsi
addq $0x8, %rsi
movq -0x18(%rbp), %rdx
movl -0x30(%rbp), %eax
addq %rax, %rdx
movl -0x2c(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %r8
callq 0xf060
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xedb4
jmp 0xee50
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0xedc6
movq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
callq 0x2660
jmp 0xee34
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdi
callq 0xaa50
cmpl $0x0, %eax
jne 0xedf4
movl $0x53, -0x24(%rbp)
jmp 0xee50
movq -0x68(%rbp), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xee32
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x68(%rbp), %rax
movl -0x28(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xee06
jmp 0xee34
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x68(%rbp), %r8
callq 0x3720
movl %eax, -0x24(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1e60
movq -0x48(%rbp), %rdi
callq 0x1e60
movq -0x50(%rbp), %rdi
callq 0x1e60
leaq -0x68(%rbp), %rdi
callq 0xf0d0
movl -0x24(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq