// File: drummyfish[P]flowchart/src/lodepng.cpp
// Function: addChunk_iTXt(ucvector*, unsigned int, char const*, char const*, char const*, char const*, LodePNGCompressSettings*)
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]);
  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
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 0x3100
movq %rax, -0x60(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xa980
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xb56f
movq -0x18(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x4840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb53b
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4840
movl -0xc(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
leaq -0x50(%rbp), %rdi
movzbl %al, %esi
callq 0x4840
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4840
movq $0x0, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xb5dd
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x4840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb5a9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4840
movq $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xb624
movq -0x28(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x4840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb5f0
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x4840
cmpl $0x0, -0xc(%rbp)
je 0xb6a6
leaq -0x78(%rbp), %rdi
callq 0xa980
leaq -0x78(%rbp), %rdi
leaq -0x78(%rbp), %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq 0x10(%rbp), %r8
callq 0xc440
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0xb69b
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x70(%rbp), %rax
jae 0xb699
movq -0x78(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x4840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb66c
jmp 0xb69b
leaq -0x78(%rbp), %rdi
callq 0x10950
jmp 0xb6e4
movq $0x0, -0x58(%rbp)
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xb6e2
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movzbl (%rax,%rcx), %esi
callq 0x4840
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0xb6ae
jmp 0xb6e4
cmpl $0x0, -0x34(%rbp)
jne 0xb705
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0x13c6f(%rip), %rsi     # 0x1f36c
callq 0x13550
movl %eax, -0x34(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x10950
movl -0x34(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)