// File: /workspace/github_c_makefile_star2_O0/aap[P]pdp11/lodepng.c
// Function: readChunk_iTXt
static unsigned readChunk_iTXt(LodePNGInfo* info, const LodePNGDecoderSettings* decoder,
                               const unsigned char* data, size_t chunkLength) {
  unsigned error = 0;
  unsigned i;

  /*copy the object to change parameters in it*/
  LodePNGDecompressSettings zlibsettings = decoder->zlibsettings;

  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;
      zlibsettings.max_output_size = decoder->max_text_size;
      /*will fail if zlib error, e.g. if length is too small*/
      error = zlib_decompress(&str, &size, 0, &data[begin],
                              length, &zlibsettings);
      /*error: compressed text larger than  decoder->max_text_size*/
      if(error && size > zlibsettings.max_output_size) error = 112;
      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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movl $0x28, %edx
callq 0x2170
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
cmpl $0x0, -0x24(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x10e8e
jmp 0x111ea
cmpq $0x5, -0x20(%rbp)
jae 0x10ea1
movl $0x1e, -0x24(%rbp)
jmp 0x111ea
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x89(%rbp)
jae 0x10ed2
movq -0x18(%rbp), %rax
movl -0x54(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x10ede
jmp 0x10eeb
jmp 0x10ee0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x10ea8
movl -0x54(%rbp), %eax
addl $0x3, %eax
movl %eax, %eax
cmpq -0x20(%rbp), %rax
jb 0x10f05
movl $0x4b, -0x24(%rbp)
jmp 0x111ea
cmpl $0x1, -0x54(%rbp)
jb 0x10f11
cmpl $0x4f, -0x54(%rbp)
jbe 0x10f1d
movl $0x59, -0x24(%rbp)
jmp 0x111ea
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x9810
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x10f43
movl $0x53, -0x24(%rbp)
jmp 0x111ea
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0xb820
movq -0x68(%rbp), %rax
movl -0x54(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movl -0x54(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
movl -0x54(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x10f94
movl $0x48, -0x24(%rbp)
jmp 0x111ea
movl -0x54(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x8a(%rbp)
jae 0x10fd4
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
testb $0x1, %al
jne 0x10fe0
jmp 0x10ff4
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x10faa
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x9810
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x1101a
movl $0x53, -0x24(%rbp)
jmp 0x111ea
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x58(%rbp), %eax
addq %rax, %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0xb820
movq -0x70(%rbp), %rax
movl -0x54(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x8b(%rbp)
jae 0x11080
movq -0x18(%rbp), %rax
movl -0x28(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x8b(%rbp)
movb -0x8b(%rbp), %al
testb $0x1, %al
jne 0x1108c
jmp 0x110a0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x11056
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x9810
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x110c6
movl $0x53, -0x24(%rbp)
jmp 0x111ea
movq -0x78(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x58(%rbp), %eax
addq %rax, %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0xb820
movq -0x78(%rbp), %rax
movl -0x54(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rax
cmpl -0x58(%rbp), %eax
jae 0x11108
xorl %eax, %eax
movl %eax, -0x90(%rbp)
jmp 0x11115
movq -0x20(%rbp), %rax
subl -0x58(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x111c0
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rcx
movl -0x58(%rbp), %eax
addq %rax, %rcx
movl -0x54(%rbp), %eax
movl %eax, %r8d
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x50(%rbp), %r9
callq 0x1add0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x1118c
movq -0x88(%rbp), %rax
cmpq -0x48(%rbp), %rax
jbe 0x1118c
movl $0x70, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x111b5
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %r8
movq -0x88(%rbp), %r9
callq 0xc0b0
movl %eax, -0x24(%rbp)
movq -0x80(%rbp), %rdi
callq 0xa2f0
jmp 0x111e8
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %r8
movl -0x58(%rbp), %eax
addq %rax, %r8
movl -0x54(%rbp), %eax
movl %eax, %r9d
callq 0xc0b0
movl %eax, -0x24(%rbp)
jmp 0x111ea
movq -0x68(%rbp), %rdi
callq 0xa2f0
movq -0x70(%rbp), %rdi
callq 0xa2f0
movq -0x78(%rbp), %rdi
callq 0xa2f0
movl -0x24(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)