// File: /workspace/github_cpp_makefile_star2_O3/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
vxorps %xmm0, %xmm0, %xmm0
movq %rcx, %r15
movq %rdx, %r13
movq $0x0, 0x10(%rsp)
vmovaps %xmm0, (%rsp)
testq %rcx, %rcx
je 0xebeb
xorl %r12d, %r12d
xorl %eax, %eax
cmpb $0x0, (%r13,%r12)
je 0xebf0
incl %eax
movq %rax, %r12
cmpq %r15, %rax
jb 0xebd7
jmp 0xebf0
xorl %eax, %eax
xorl %r12d, %r12d
leal 0x2(%rax), %ebx
cmpq %r15, %rbx
jae 0xec07
leal -0x50(%rax), %ecx
cmpl $-0x4f, %ecx
jae 0xec3b
movl $0x59, %ebp
jmp 0xec0c
movl $0x4b, %ebp
xorl %r14d, %r14d
movq %r14, %rdi
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
movq %rdi, 0x20(%rsp)
movl %eax, %ebp
leaq 0x1(%rbp), %rdi
movq %rsi, 0x28(%rsp)
movq %rdi, 0x30(%rsp)
callq 0x21e0
testq %rax, %rax
je 0xeca8
movq %rax, %r14
movb $0x0, (%rax,%r12)
movq %rax, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2100
movq 0x30(%rsp), %rax
movl $0x48, %ebp
cmpb $0x0, (%r13,%rax)
jne 0xec0f
movq 0x28(%rsp), %r8
subl %ebx, %r15d
addq %rbx, %r13
leaq 0x8(%rsp), %rsi
movq %rsp, %rdi
movq %r13, %rdx
movq %r15, %rcx
movq 0x8(%r8), %rax
testq %rax, %rax
je 0xecb2
callq *%rax
jmp 0xecb7
movl $0x53, %ebp
jmp 0xec0c
callq 0x6e34
movl %eax, %ebp
testl %eax, %eax
jne 0xec0f
movq %rsp, %rdi
movq 0x8(%rdi), %rbx
incq %rbx
movq %rbx, %rsi
callq 0xd905
testl %eax, %eax
je 0xece5
movq %rbx, 0x8(%rsp)
movq (%rsp), %rax
movb $0x0, -0x1(%rax,%rbx)
movq (%rsp), %rdx
movq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x7892
movl %eax, %ebp
jmp 0xec0f