// File: /workspace/github_c_makefile_star2_O0/tditlu[P]shadetabler/src/lodepng/lodepng.c
// Function: addChunk_iTXt
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
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5bb0
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5bb0
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5bb0
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5bb0
movq %rax, -0x78(%rbp)
cmpq $0x1, -0x68(%rbp)
jb 0xfa67
cmpq $0x4f, -0x68(%rbp)
jbe 0xfa73
movl $0x59, -0x4(%rbp)
jmp 0xfc8f
cmpl $0x0, -0x14(%rbp)
je 0xfa95
movq -0x38(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq 0x10(%rbp), %r8
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x170a0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0xfb0a
movq -0x68(%rbp), %rax
addq $0x3, %rax
addq -0x70(%rbp), %rax
addq $0x1, %rax
addq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xfacd
movq -0x58(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0xfad8
movq -0x60(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rsi
movq -0x80(%rbp), %rax
movl %eax, %edx
leaq -0x48(%rbp), %rdi
leaq 0xbaa4(%rip), %rcx      # 0x1b5a6
callq 0x14120
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0xfc80
movq $0x8, -0x88(%rbp)
movq -0x48(%rbp), %rdi
addq -0x88(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x6440
movq -0x68(%rbp), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb $0x0, (%rax,%rcx)
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %dl
movq -0x48(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x88(%rbp)
movb %dl, (%rax,%rcx)
movq -0x48(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rdi
addq -0x88(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x6440
movq -0x70(%rbp), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rdi
addq -0x88(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x6440
movq -0x78(%rbp), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb $0x0, (%rax,%rcx)
cmpl $0x0, -0x14(%rbp)
je 0xfc5f
movq -0x48(%rbp), %rdi
addq -0x88(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
callq 0x6440
jmp 0xfc77
movq -0x48(%rbp), %rdi
addq -0x88(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x6440
movq -0x48(%rbp), %rdi
callq 0x5d00
movq -0x50(%rbp), %rdi
callq 0x5060
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)