// File: mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: addChunk_iTXt(ucvector*, unsigned int, char const*, char const*, char const*, char const*, LodeZlib_DeflateSettings*)
static unsigned addChunk_iTXt(ucvector* out, unsigned compressed, const char* keyword, const char* langtag, const char* transkey, const char* textstring, LodeZlib_DeflateSettings* zlibsettings)
{
  unsigned error = 0;
  ucvector data, compressed_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]);
  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_init(&compressed_data);
    error = LodePNG_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]);
      for(i = 0; textstring[i] != 0; i++) ucvector_push_back(&data, (unsigned char)textstring[i]);
    }
  }
  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
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5180
movq %rax, -0x78(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x25960
movq $0x0, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x2b60f
movq -0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b5db
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x25570
movl -0xc(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
leaq -0x50(%rbp), %rdi
movzbl %al, %esi
callq 0x25570
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x25570
movq $0x0, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq -0x70(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x2b67d
movq -0x20(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b649
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x25570
movq $0x0, -0x70(%rbp)
movq -0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x2b6c4
movq -0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b690
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x25570
cmpl $0x0, -0xc(%rbp)
je 0x2b77d
leaq -0x68(%rbp), %rdi
callq 0x25960
leaq -0x68(%rbp), %rdi
leaq -0x68(%rbp), %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq 0x10(%rbp), %r8
callq 0x317d0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x2b77b
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0x2b73d
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b710
movq $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x2b779
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b745
jmp 0x2b77b
jmp 0x2b7bb
movq $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x2b7b9
movq -0x30(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x25570
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2b785
jmp 0x2b7bb
cmpl $0x0, -0x34(%rbp)
jne 0x2b7dc
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0x203a2(%rip), %rsi     # 0x4bb76
callq 0x31760
movl %eax, -0x34(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x25990
movl -0x34(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)