// File: /workspace/github_cpp_makefile_star2_O1/phillip-h[P]fractal-gen/lodepng.cpp
// Function: readChunk_zTXt(LodePNGInfo*, LodePNGDecompressSettings const*, unsigned char const*, unsigned long)
static unsigned readChunk_zTXt(LodePNGInfo* info, const LodePNGDecompressSettings* zlibsettings,
                               const unsigned char* data, size_t chunkLength)
{
  unsigned error = 0;
  unsigned i;

  unsigned length, string2_begin;
  char *key = 0;
  ucvector decoded;

  ucvector_init(&decoded);

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

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

    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 = chunkLength - string2_begin;
    /*will fail if zlib error, e.g. if length is too small*/
    error = zlib_decompress(&decoded.data, &decoded.size,
                            (unsigned char*)(&data[string2_begin]),
                            length, zlibsettings);
    if(error) break;
    ucvector_push_back(&decoded, 0);

    error = lodepng_add_text(info, key, (char*)decoded.data);

    break;
  }

  lodepng_free(key);
  ucvector_cleanup(&decoded);

  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r15
movq %rdx, %r13
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
testq %rcx, %rcx
je 0xef2e
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpb $0x0, (%r13,%r14)
je 0xef34
incl %r12d
movq %r12, %r14
cmpq %r15, %r12
jb 0xef19
jmp 0xef34
xorl %r12d, %r12d
xorl %r14d, %r14d
leal 0x2(%r12), %ebx
movl $0x4b, %ebp
cmpq %r15, %rbx
jae 0xefb2
leal -0x50(%r12), %eax
cmpl $-0x4f, %eax
jae 0xef54
movl $0x59, %ebp
jmp 0xefb2
movq %rsi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movl %r12d, %eax
movq %rax, 0x28(%rsp)
leaq 0x1(%rax), %rdi
movq %rdi, 0x30(%rsp)
callq 0x21e0
testq %rax, %rax
je 0xefad
movq %rax, %rdi
movb $0x0, (%rax,%r14)
testl %r12d, %r12d
je 0xef99
movq %rdi, %r14
movq %r13, %rsi
movq 0x28(%rsp), %rdx
callq 0x2100
movq %r14, %rdi
movq 0x30(%rsp), %rax
cmpb $0x0, (%r13,%rax)
je 0xefdd
movl $0x48, %ebp
jmp 0xefb4
movl $0x53, %ebp
xorl %edi, %edi
callq 0x21b0
vxorps %xmm0, %xmm0, %xmm0
vmovups %xmm0, 0x8(%rsp)
movq (%rsp), %rdi
callq 0x21b0
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r15, %rbx
ja 0xefb4
movq %rdi, %r14
subl %ebx, %r15d
leaq 0x8(%rsp), %rsi
addq %rbx, %r13
movq 0x20(%rsp), %r8
movq 0x8(%r8), %rax
movq %rsp, %rdi
movq %r13, %rdx
movq %r15, %rcx
testq %rax, %rax
je 0xf00b
callq *%rax
jmp 0xf010
callq 0x6e3b
movl %eax, %ebp
testl %eax, %eax
je 0xf01b
movq %r14, %rdi
jmp 0xefb4
movq %rsp, %rdi
movq 0x8(%rdi), %rbx
incq %rbx
movq %rbx, %rsi
callq 0xd9d0
testl %eax, %eax
je 0xf03f
movq %rbx, 0x8(%rsp)
movq (%rsp), %rax
movb $0x0, -0x1(%rax,%rbx)
movq (%rsp), %rdx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x7882
movq %r14, %rdi
movl %eax, %ebp
jmp 0xefb4