// File: Lut99[P]RayTracer/src/lib/LodePNG.cpp
// Function: lodepng_add_itext(LodePNGInfo*, char const*, char const*, char const*, char const*)
unsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag,
                           const char* transkey, const char* str) {
  char** new_keys = (char**)(lodepng_realloc(info->itext_keys, sizeof(char*) * (info->itext_num + 1)));
  char** new_langtags = (char**)(lodepng_realloc(info->itext_langtags, sizeof(char*) * (info->itext_num + 1)));
  char** new_transkeys = (char**)(lodepng_realloc(info->itext_transkeys, sizeof(char*) * (info->itext_num + 1)));
  char** new_strings = (char**)(lodepng_realloc(info->itext_strings, sizeof(char*) * (info->itext_num + 1)));
  if(!new_keys || !new_langtags || !new_transkeys || !new_strings) {
    lodepng_free(new_keys);
    lodepng_free(new_langtags);
    lodepng_free(new_transkeys);
    lodepng_free(new_strings);
    return 83; /*alloc fail*/
  }

  ++info->itext_num;
  info->itext_keys = new_keys;
  info->itext_langtags = new_langtags;
  info->itext_transkeys = new_transkeys;
  info->itext_strings = new_strings;

  info->itext_keys[info->itext_num - 1] = alloc_string(key);
  info->itext_langtags[info->itext_num - 1] = alloc_string(langtag);
  info->itext_transkeys[info->itext_num - 1] = alloc_string(transkey);
  info->itext_strings[info->itext_num - 1] = alloc_string(str);

  return 0;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq 0x68(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
callq 0x13f5e0
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movq 0x70(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
callq 0x13f5e0
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
callq 0x13f5e0
movq %rax, 0x10(%rsp)
movq 0x48(%rsp), %rax
movq 0x80(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
callq 0x13f5e0
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0x140220
cmpq $0x0, 0x18(%rsp)
je 0x140220
cmpq $0x0, 0x10(%rsp)
je 0x140220
cmpq $0x0, 0x8(%rsp)
jne 0x140255
movq 0x20(%rsp), %rdi
callq 0x13e2d0
movq 0x18(%rsp), %rdi
callq 0x13e2d0
movq 0x10(%rsp), %rdi
callq 0x13e2d0
movq 0x8(%rsp), %rdi
callq 0x13e2d0
movl $0x53, 0x54(%rsp)
jmp 0x140348
movq 0x48(%rsp), %rax
movq 0x60(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x60(%rax)
movq 0x20(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x68(%rax)
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x70(%rax)
movq 0x10(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x8(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x80(%rax)
movq 0x40(%rsp), %rdi
callq 0x13ffd0
movq %rax, %rdx
movq 0x48(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x48(%rsp), %rcx
movq 0x60(%rcx), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x38(%rsp), %rdi
callq 0x13ffd0
movq %rax, %rdx
movq 0x48(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x48(%rsp), %rcx
movq 0x60(%rcx), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x30(%rsp), %rdi
callq 0x13ffd0
movq %rax, %rdx
movq 0x48(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x48(%rsp), %rcx
movq 0x60(%rcx), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rdi
callq 0x13ffd0
movq %rax, %rdx
movq 0x48(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x48(%rsp), %rcx
movq 0x60(%rcx), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)