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

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

  unsigned length, string2_begin;
  char *key = 0;
  unsigned char* str = 0;
  size_t size = 0;

  while(!error) /*not really a while loop, only used to break on error*/ {
    for(length = 0; length < chunkLength && data[length] != 0; ++length) ;
    if(length + 2 >= chunkLength) CERROR_BREAK(error, 75); /*no null termination, 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;

    if(data[length + 1] != 0) CERROR_BREAK(error, 72); /*the 0 byte indicating compression must be 0*/

    string2_begin = length + 2;
    if(string2_begin > chunkLength) CERROR_BREAK(error, 75); /*no null termination, corrupt?*/

    length = (unsigned)chunkLength - string2_begin;
    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[string2_begin],
                            length, &zlibsettings);
    /*error: compressed text larger than  decoder->max_text_size*/
    if(error && size > zlibsettings.max_output_size) error = 112;
    if(error) break;
    error = lodepng_add_text_sized(info, key, (char*)str, size);
    break;
  }

  lodepng_free(key);
  lodepng_free(str);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
movq 0x20(%rsi), %rax
movq %rax, 0x40(%rsp)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movaps %xmm1, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
xorl %ebx, %ebx
movq %rbx, (%rsp)
movq %rbx, 0x18(%rsp)
movl $0x0, %ebp
testq %rcx, %rcx
je 0xc85c
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpb $0x0, (%r15,%rbp)
je 0xc85c
incl %ebx
movq %rbx, %rbp
cmpq %r14, %rbx
jb 0xc84b
leal 0x2(%rbx), %r12d
cmpq %r14, %r12
jae 0xc874
leal -0x50(%rbx), %eax
cmpl $-0x4f, %eax
jae 0xc87d
movl $0x59, %ebx
jmp 0xc8ca
xorl %edi, %edi
movl $0x4b, %ebx
jmp 0xc8cc
movq %rdi, 0x8(%rsp)
movl %ebx, %edi
incq %rdi
movq %rdi, 0x10(%rsp)
callq 0x2190
testq %rax, %rax
je 0xc8c5
movq %rax, %rdi
testl %ebx, %ebx
je 0xc8ae
movq %rdi, %rbx
movq %r15, %rsi
movq %rbp, %rdx
callq 0x2160
movq %rbx, %rdi
movb $0x0, (%rdi,%rbp)
movq 0x10(%rsp), %rax
cmpb $0x0, (%r15,%rax)
je 0xc8eb
movl $0x48, %ebx
jmp 0xc8cc
movl $0x53, %ebx
xorl %edi, %edi
callq 0x2030
movq (%rsp), %rdi
callq 0x2030
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r14, %r12
ja 0xc876
movq %rdi, %rbp
subl %r12d, %r14d
movq 0x40(%r13), %rax
leaq 0x20(%rsp), %rbx
movq %rax, 0x8(%rbx)
addq %r12, %r15
movq %rsp, %rdi
leaq 0x18(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
movq %r15, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x11c1f
movq (%r12), %rcx
cmpq 0x8(%rbx), %rcx
movl $0x70, %ebx
cmovbel %eax, %ebx
testl %eax, %eax
cmovel %eax, %ebx
testl %ebx, %ebx
je 0xc93f
movq %rbp, %rdi
jmp 0xc8cc
movq (%rsp), %rdx
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x98ab
movq %rbp, %rdi
movl %eax, %ebx
jmp 0xc8cc