// File: /workspace/github_c_makefile_star2_O1/Joy-Division[P]tools-mgs/lodepng/lodepng.c
// Function: addChunk_zTXt
static unsigned addChunk_zTXt(ucvector* out, const char* keyword, const char* textstring,
                              LodePNGCompressSettings* zlibsettings)
{
  unsigned error = 0;
  ucvector data, compressed;
  size_t i, textsize = strlen(textstring);

  ucvector_init(&data);
  ucvector_init(&compressed);
  for(i = 0; keyword[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)keyword[i]);
  if(i < 1 || i > 79) return 89; /*error: invalid keyword size*/
  ucvector_push_back(&data, 0); /*0 termination char*/
  ucvector_push_back(&data, 0); /*compression method: 0*/

  error = zlib_compress(&compressed.data, &compressed.size,
                        (unsigned char*)textstring, textsize, zlibsettings);
  if(!error)
  {
    for(i = 0; i != compressed.size; ++i) ucvector_push_back(&data, compressed.data[i]);
    error = addChunk(out, "zTXt", data.data, data.size);
  }

  ucvector_cleanup(&compressed);
  ucvector_cleanup(&data);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x50(%rsp)
movq %rsi, %rbx
movq %rdi, 0x48(%rsp)
movq %rdx, 0x38(%rsp)
movq %rdx, %rdi
callq 0x1090
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movb (%rbx), %r14b
testb %r14b, %r14b
je 0x9616
movq $-0x1, %r12
xorl %edx, %edx
xorl %r13d, %r13d
xorl %edi, %edi
movq %rbx, 0x40(%rsp)
leaq 0x1(%r13), %r15
cmpq %r15, %rdx
jae 0x95de
movq %r13, 0x8(%rsp)
leaq (%rdx,%rdx), %rax
leaq (%r15,%r15,2), %rbp
shrq %rbp
cmpq %r15, %rax
cmovbq %r15, %rbp
movq %rbp, %rsi
movq %rdi, %r13
movq %rdx, %rbx
callq 0x1120
testq %rax, %rax
je 0x95e2
xorl %ecx, %ecx
movq %rax, %rdi
movq %rbp, %rdx
movq 0x8(%rsp), %r13
jmp 0x95ef
xorl %ecx, %ecx
jmp 0x95f4
movb $0x1, %cl
movq %r13, %rdi
movq 0x8(%rsp), %r13
movq %rbx, %rdx
movq 0x40(%rsp), %rbx
testb %cl, %cl
jne 0x9600
movb %r14b, -0x1(%rdi,%r15)
movq %r15, %r13
movb 0x2(%rbx,%r12), %r14b
incq %r12
testb %r14b, %r14b
jne 0x959c
cmpq $0x4f, %r12
setae %al
jmp 0x961f
movb $0x1, %al
xorl %edi, %edi
xorl %r13d, %r13d
xorl %edx, %edx
testb %al, %al
jne 0x97dd
leaq 0x1(%r13), %r14
cmpq %r14, %rdx
jae 0x965f
leaq (%rdx,%rdx), %rax
leaq (%r14,%r14,2), %rbx
shrq %rbx
cmpq %r14, %rax
cmovbq %r14, %rbx
movq %rbx, %rsi
movq %rdi, %r15
movq %rdx, %r12
callq 0x1120
testq %rax, %rax
je 0x9663
xorl %ecx, %ecx
movq %rax, %rdi
movq %rbx, %rdx
jmp 0x966b
xorl %ecx, %ecx
jmp 0x966b
movb $0x1, %cl
movq %r15, %rdi
movq %r12, %rdx
testb %cl, %cl
jne 0x9678
movb $0x0, -0x1(%rdi,%r14)
movq %r14, %r13
leaq 0x1(%r13), %r14
cmpq %r14, %rdx
jae 0x96b0
leaq (%rdx,%rdx), %rax
leaq (%r14,%r14,2), %rbx
shrq %rbx
cmpq %r14, %rax
cmovbq %r14, %rbx
movq %rbx, %rsi
movq %rdi, %r15
movq %rdx, %r12
callq 0x1120
testq %rax, %rax
je 0x96b4
xorl %ecx, %ecx
movq %rax, %rdi
movq %rbx, %rdx
jmp 0x96bc
xorl %ecx, %ecx
jmp 0x96bc
movb $0x1, %cl
movq %r15, %rdi
movq %r12, %rdx
testb %cl, %cl
jne 0x96c9
movb $0x0, -0x1(%rdi,%r14)
movq %r14, %r13
movq %rdx, %rbx
movq %rdi, %r15
leaq 0x18(%rsp), %r14
movq 0x50(%rsp), %r8
movq 0x18(%r8), %rax
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
testq %rax, %rax
je 0x96f8
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq *%rax
jmp 0x9707
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0x3e1e
testl %eax, %eax
jne 0x97bb
cmpq $0x0, 0x18(%rsp)
je 0x9789
xorl %r14d, %r14d
movq %r15, %r8
movq 0x10(%rsp), %rax
movb (%rax,%r14), %bpl
leaq 0x1(%r13), %r15
cmpq %r15, %rbx
jae 0x9763
movq %r13, 0x8(%rsp)
leaq (%rbx,%rbx), %rax
leaq (%r15,%r15,2), %r12
shrq %r12
cmpq %r15, %rax
cmovbq %r15, %r12
movq %r8, %rdi
movq %r12, %rsi
movq %r8, %r13
callq 0x1120
testq %rax, %rax
je 0x9767
xorl %ecx, %ecx
movq %rax, %r8
movq %r12, %rbx
jmp 0x976c
xorl %ecx, %ecx
jmp 0x9771
movb $0x1, %cl
movq %r13, %r8
movq 0x8(%rsp), %r13
testb %cl, %cl
jne 0x977d
movb %bpl, -0x1(%r8,%r15)
movq %r15, %r13
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x971d
jmp 0x978c
movq %r15, %r8
movq 0x48(%rsp), %r14
leaq 0x8(%r14), %rsi
leaq 0x61e1(%rip), %rcx      # 0xf97d
movq %r14, %rdi
movl %r13d, %edx
movq %r8, %r15
callq 0x4357
testl %eax, %eax
jne 0x97b6
movq 0x8(%r14), %rax
movq %rax, 0x10(%r14)
leaq 0x18(%rsp), %r14
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq 0x10(%rsp), %rdi
callq 0x1030
movq $0x0, 0x10(%rsp)
movq %r15, %rdi
callq 0x1030
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq