// File: /workspace/github_cpp_makefile_star2_O3/lvandeve[P]lodepng/lodepng.cpp
// Function: addChunk_iTXt(ucvector*, unsigned int, char const*, char const*, char const*, char const*, LodePNGCompressSettings*)
static unsigned addChunk_iTXt(ucvector* out, unsigned compress, const char* keyword, const char* langtag,
                              const char* transkey, const char* textstring, LodePNGCompressSettings* zlibsettings) {
  unsigned error = 0;
  unsigned char* chunk = 0;
  unsigned char* compressed = 0;
  size_t compressedsize = 0;
  size_t textsize = lodepng_strlen(textstring);
  size_t keysize = lodepng_strlen(keyword), langsize = lodepng_strlen(langtag), transsize = lodepng_strlen(transkey);

  if(keysize < 1 || keysize > 79) return 89; /*error: invalid keyword size*/

  if(compress) {
    error = zlib_compress(&compressed, &compressedsize,
                          (const unsigned char*)textstring, textsize, zlibsettings);
  }
  if(!error) {
    size_t size = keysize + 3 + langsize + 1 + transsize + 1 + (compress ? compressedsize : textsize);
    error = lodepng_chunk_init(&chunk, out, size, "iTXt");
  }
  if(!error) {
    size_t pos = 8;
    lodepng_memcpy(chunk + pos, keyword, keysize);
    pos += keysize;
    chunk[pos++] = 0; /*null termination char*/
    chunk[pos++] = (compress ? 1 : 0); /*compression flag*/
    chunk[pos++] = 0; /*compression method: 0*/
    lodepng_memcpy(chunk + pos, langtag, langsize);
    pos += langsize;
    chunk[pos++] = 0; /*null termination char*/
    lodepng_memcpy(chunk + pos, transkey, transsize);
    pos += transsize;
    chunk[pos++] = 0; /*null termination char*/
    if(compress) {
      lodepng_memcpy(chunk + pos, compressed, compressedsize);
    } else {
      lodepng_memcpy(chunk + pos, textstring, textsize);
    }
    lodepng_chunk_generate_crc(chunk);
  }

  lodepng_free(compressed);
  return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r10
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq $-0x1, %r11
cmpb $0x0, 0x1(%r9,%r11)
leaq 0x1(%r11), %r11
jne 0xcd22
xorl %ebp, %ebp
cmpb $0x0, (%rdx,%rbp)
leaq 0x1(%rbp), %rbp
jne 0xcd30
movq $-0x2, %r14
subq %rbp, %r14
leaq 0xa(%rbp), %r13
movq $-0x1, %r15
incq %r13
decq %r14
cmpb $0x0, 0x1(%rcx,%r15)
leaq 0x1(%r15), %r15
jne 0xcd4f
leaq -0x1(%rbp), %rax
movq %rax, 0x50(%rsp)
movq $-0x1, %r12
movq %r13, %rbx
decq %r14
incq %rbx
cmpb $0x0, 0x1(%r10,%r12)
leaq 0x1(%r12), %r12
jne 0xcd74
leaq -0x51(%rbp), %r8
movl $0x59, %eax
cmpq $-0x4f, %r8
jb 0xcece
movq %rdi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %r11, %rdx
movl %esi, 0x4(%rsp)
testl %esi, %esi
movq %r9, 0x20(%rsp)
movq %r11, 0x28(%rsp)
je 0xcde9
leaq 0x10(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq %r9, %rdx
movq %r11, %rcx
movq 0x90(%rsp), %r8
callq 0xd394
testl %eax, %eax
jne 0xce06
movq 0x8(%rsp), %rdx
subq %r14, %rdx
leaq 0x67aa2(%rip), %rcx     # 0x74895
leaq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0xebd0
testl %eax, %eax
je 0xce0d
movl %eax, %ebx
jmp 0xcec2
movq 0x18(%rsp), %r14
leaq 0x8(%r14), %rdi
movq 0x40(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x21e0
xorl %eax, %eax
movl 0x4(%rsp), %ecx
testl %ecx, %ecx
movb %al, 0x7(%r14,%rbp)
setne 0x8(%r14,%rbp)
movb %al, 0x9(%r14,%rbp)
testq %r15, %r15
je 0xce5b
leaq (%r14,%rbp), %rdi
addq $0xa, %rdi
movq 0x30(%rsp), %rsi
movq %r15, %rdx
callq 0x21e0
movl 0x4(%rsp), %ecx
movb $0x0, -0x1(%r14,%r13)
testq %r12, %r12
je 0xce7d
addq %r14, %r13
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x21e0
movl 0x4(%rsp), %ecx
movb $0x0, -0x1(%r14,%rbx)
testl %ecx, %ecx
je 0xce9e
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0xceb8
movq 0x10(%rsp), %rsi
addq %r14, %rbx
movq %rbx, %rdi
jmp 0xceb3
movq 0x28(%rsp), %rdx
testq %rdx, %rdx
je 0xceb8
addq %r14, %rbx
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x54f4
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
callq 0x22a0
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq