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

  ucvector_init(&data);

  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); /*null termination char*/
  ucvector_push_back(&data, compressed ? 1 : 0); /*compression flag*/
  ucvector_push_back(&data, 0); /*compression method*/
  for(i = 0; langtag[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)langtag[i]);
  ucvector_push_back(&data, 0); /*null termination char*/
  for(i = 0; transkey[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)transkey[i]);
  ucvector_push_back(&data, 0); /*null termination char*/

  if(compressed)
  {
    ucvector compressed_data;
    ucvector_init(&compressed_data);
    error = zlib_compress(&compressed_data.data, &compressed_data.size,
                          (unsigned char*)textstring, textsize, zlibsettings);
    if(!error)
    {
      for(i = 0; i != compressed_data.size; ++i) ucvector_push_back(&data, compressed_data.data[i]);
    }
    ucvector_cleanup(&compressed_data);
  }
  else /*not compressed*/
  {
    for(i = 0; textstring[i] != 0; ++i) ucvector_push_back(&data, (unsigned char)textstring[i]);
  }

  if(!error) error = addChunk(out, "iTXt", data.data, data.size);
  ucvector_cleanup(&data);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x30(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %r14
movl %esi, 0x14(%rsp)
movq %rdi, 0x60(%rsp)
movq %r9, 0x38(%rsp)
movq %r9, %rdi
callq 0x1090
movq %rax, 0x28(%rsp)
movb (%r14), %r13b
testb %r13b, %r13b
je 0xa5aa
movq $-0x1, %rbx
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %edi, %edi
movq %r14, 0x20(%rsp)
leaq 0x1(%r15), %r12
cmpq %r12, %rcx
jae 0xa140
leaq (%rcx,%rcx), %rax
leaq (%r12,%r12,2), %rbp
shrq %rbp
cmpq %r12, %rax
cmovbq %r12, %rbp
movq %rbp, %rsi
movq %rdi, %r14
movq %r15, 0x8(%rsp)
movq %rcx, %r15
callq 0x1130
movq %r15, %rcx
movq 0x8(%rsp), %r15
movq %r14, %rdi
movq 0x20(%rsp), %r14
testq %rax, %rax
jne 0xa146
jmp 0xa154
movq %rdi, %rax
movq %rcx, %rbp
movb %r13b, -0x1(%rax,%r12)
movq %rbp, %rcx
movq %rax, %rdi
movq %r12, %r15
movb 0x2(%r14,%rbx), %r13b
incq %rbx
testb %r13b, %r13b
jne 0xa0fb
cmpq $0x4e, %rbx
ja 0xa5aa
leaq 0x1(%r15), %r14
cmpq %r14, %rcx
jae 0xa1a7
leaq (%rcx,%rcx), %rax
leaq (%r14,%r14,2), %rbp
shrq %rbp
cmpq %r14, %rax
cmovbq %r14, %rbp
movq %rbp, %rsi
movq %rdi, %rbx
movq %rcx, %r12
callq 0x1130
testq %rax, %rax
jne 0xa1ad
movq %r14, %rdx
movq %r15, %r14
movq %rbx, %rdi
movq %r12, %rcx
jmp 0xa1bf
movq %rdi, %rax
movq %rcx, %rbp
movb $0x0, (%rax,%r15)
addq $0x2, %r15
movq %r15, %rdx
movq %rbp, %rcx
movq %rax, %rdi
cmpl $0x0, 0x14(%rsp)
setne %bl
cmpq %rdx, %rcx
jae 0xa205
leaq (%rcx,%rcx), %rax
leaq (%rdx,%rdx,2), %rbp
shrq %rbp
cmpq %rdx, %rax
cmovbq %rdx, %rbp
movq %rbp, %rsi
movq %rdi, %r15
movq %rcx, %r12
movq %rdx, %r13
callq 0x1130
movq %r13, %rdx
testq %rax, %rax
jne 0xa20b
movq %rdx, %rbx
movq %r14, %rdx
movq %r15, %rdi
movq %r12, %rcx
jmp 0xa219
movq %rdi, %rax
movq %rcx, %rbp
movb %bl, -0x1(%rax,%rdx)
leaq 0x1(%rdx), %rbx
movq %rbp, %rcx
movq %rax, %rdi
cmpq %rbx, %rcx
jae 0xa256
leaq (%rcx,%rcx), %rax
leaq (%rbx,%rbx,2), %rbp
shrq %rbp
cmpq %rbx, %rax
cmovbq %rbx, %rbp
movq %rbp, %rsi
movq %rdi, %r14
movq %rcx, %r15
movq %rdx, %r12
callq 0x1130
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %rdi
testq %rax, %rax
movq 0x18(%rsp), %rsi
jne 0xa261
jmp 0xa26f
movq %rdi, %rax
movq %rcx, %rbp
movq 0x18(%rsp), %rsi
movb $0x0, -0x1(%rax,%rbx)
movq %rbp, %rcx
movq %rax, %rdi
movq %rbx, %rdx
movb (%rsi), %bl
testb %bl, %bl
je 0xa2db
incq %rsi
leaq 0x1(%rdx), %r14
cmpq %r14, %rcx
jae 0xa2be
leaq (%rcx,%rcx), %rax
leaq (%r14,%r14,2), %rbp
shrq %rbp
cmpq %r14, %rax
cmovbq %r14, %rbp
movq %rsi, 0x18(%rsp)
movq %rbp, %rsi
movq %rdi, %r15
movq %rcx, %r12
movq %rdx, %r13
callq 0x1130
movq 0x18(%rsp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %rdi
testq %rax, %rax
jne 0xa2c4
jmp 0xa2d2
movq %rdi, %rax
movq %rcx, %rbp
movb %bl, -0x1(%rax,%r14)
movq %rbp, %rcx
movq %rax, %rdi
movq %r14, %rdx
movb (%rsi), %bl
incq %rsi
testb %bl, %bl
jne 0xa278
leaq 0x1(%rdx), %rbx
cmpq %rbx, %rcx
jae 0xa31c
leaq (%rcx,%rcx), %rax
leaq (%rbx,%rbx,2), %r13
shrq %r13
cmpq %rbx, %rax
cmovbq %rbx, %r13
movq %r13, %rsi
movq %rdi, %r14
movq %rcx, %r15
movq %rdx, %r12
callq 0x1130
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %rdi
testq %rax, %rax
movq 0x30(%rsp), %r15
jne 0xa327
jmp 0xa335
movq %rdi, %rax
movq %rcx, %r13
movq 0x30(%rsp), %r15
movb $0x0, -0x1(%rax,%rbx)
movq %r13, %rcx
movq %rax, %rdi
movq %rbx, %rdx
movb (%r15), %bl
testb %bl, %bl
je 0xa39d
incq %r15
leaq 0x1(%rdx), %r14
cmpq %r14, %rcx
jae 0xa37f
leaq (%rcx,%rcx), %rax
leaq (%r14,%r14,2), %r13
shrq %r13
cmpq %r14, %rax
cmovbq %r14, %r13
movq %r13, %rsi
movq %rdi, 0x8(%rsp)
movq %rcx, %r12
movq %rdx, %rbp
callq 0x1130
movq %rbp, %rdx
movq %r12, %rcx
movq 0x8(%rsp), %rdi
testq %rax, %rax
jne 0xa385
jmp 0xa393
movq %rdi, %rax
movq %rcx, %r13
movb %bl, -0x1(%rax,%r14)
movq %r13, %rcx
movq %rax, %rdi
movq %r14, %rdx
movb (%r15), %bl
incq %r15
testb %bl, %bl
jne 0xa33f
leaq 0x1(%rdx), %r14
cmpq %r14, %rcx
jae 0xa3e6
leaq (%rcx,%rcx), %rax
leaq (%r14,%r14,2), %rbx
shrq %rbx
cmpq %r14, %rax
cmovbq %r14, %rbx
movq %rbx, %rsi
movq %rdi, %r15
movq %rcx, %r12
movq %rdx, %r13
callq 0x1130
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r9
testq %rax, %rax
movq 0x38(%rsp), %r13
movq 0xa0(%rsp), %r8
jne 0xa3f9
jmp 0xa408
movq %rdi, %rax
movq %rcx, %rbx
movq 0x38(%rsp), %r13
movq 0xa0(%rsp), %r8
movb $0x0, -0x1(%rax,%r14)
movq %rbx, %rcx
movq %rax, %r9
movq %r14, %rdx
cmpl $0x0, 0x14(%rsp)
je 0xa44d
movq %rdx, %r15
movq %rcx, %rbp
movq %r9, %r14
xorps %xmm0, %xmm0
leaq 0x48(%rsp), %rsi
movaps %xmm0, -0x8(%rsi)
movq $0x0, 0x8(%rsi)
movq 0x18(%r8), %rax
leaq 0x40(%rsp), %rdi
movq %r13, %rdx
testq %rax, %rax
je 0xa4c5
movq 0x28(%rsp), %rcx
callq *%rax
jmp 0xa4cf
movb (%r13), %bpl
testb %bpl, %bpl
je 0xa575
incq %r13
leaq 0x1(%rdx), %r14
cmpq %r14, %rcx
jae 0xa4a0
leaq (%rcx,%rcx), %rax
leaq (%r14,%r14,2), %rbx
shrq %rbx
cmpq %r14, %rax
cmovbq %r14, %rbx
movq %r9, %rdi
movq %rbx, %rsi
movq %r9, %r15
movq %rcx, %r12
movq %rdx, 0x8(%rsp)
callq 0x1130
movq 0x8(%rsp), %rdx
movq %r12, %rcx
movq %r15, %r9
testq %rax, %rax
jne 0xa4a6
jmp 0xa4b4
movq %r9, %rax
movq %rcx, %rbx
movb %bpl, -0x1(%rax,%r14)
movq %rbx, %rcx
movq %rax, %r9
movq %r14, %rdx
movb (%r13), %bpl
incq %r13
testb %bpl, %bpl
jne 0xa45d
jmp 0xa575
movq 0x28(%rsp), %rcx
callq 0x44b8
testl %eax, %eax
movq %r14, %rcx
movq %r15, %r13
movl %eax, 0x20(%rsp)
jne 0xa550
cmpq $0x0, 0x48(%rsp)
je 0xa550
xorl %r12d, %r12d
movq 0x40(%rsp), %rax
movb (%rax,%r12), %sil
leaq 0x1(%r13), %r14
cmpq %r14, %rbp
jae 0xa532
leaq (,%rbp,2), %rax
leaq (%r14,%r14,2), %r15
shrq %r15
cmpq %r14, %rax
cmovbq %r14, %r15
movq %rcx, %rdi
movb %sil, 0x8(%rsp)
movq %r15, %rsi
movq %rcx, %rbx
callq 0x1130
movb 0x8(%rsp), %sil
movq %rbx, %rcx
testq %rax, %rax
jne 0xa538
jmp 0xa546
movq %rcx, %rax
movq %rbp, %r15
movb %sil, -0x1(%rax,%r14)
movq %r15, %rbp
movq %rax, %rcx
movq %r14, %r13
incq %r12
cmpq 0x48(%rsp), %r12
jne 0xa4e8
xorps %xmm0, %xmm0
leaq 0x48(%rsp), %rax
movups %xmm0, (%rax)
movq 0x40(%rsp), %rdi
movq %rcx, %rbx
callq 0x1030
movq %r13, %rdx
movq %rbx, %r9
cmpl $0x0, 0x20(%rsp)
jne 0xa5a2
movq 0x60(%rsp), %rbx
leaq 0x8(%rbx), %rsi
leaq 0x54dd(%rip), %rcx      # 0xfa62
movq %rbx, %rdi
movq %r9, %r14
movq %r9, %r8
callq 0x4a14
testl %eax, %eax
jne 0xa59f
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
movq %r14, %r9
movq %r9, %rdi
callq 0x1030
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq