// File: /workspace/github_c_makefile_star2_O1/kopytjuk[P]wasm-image-converter/src/main.cpp
// Function: main
int main ( int argc, char *argv[] )
{
  string input_filename(argv[1]);
  string output_filename(argv[2]);

  int insize = utils::filesize(input_filename);
  cout << insize << endl;

  char *indata = new char[insize];

  utils::print_first_bytes(indata, 10);

  string inext = utils::getExtension(input_filename);
  ImageType intype = resolveImageType(inext);

  utils::read_file_to_char_array(input_filename, indata, insize);


  utils::print_first_bytes(indata, 10);

  // output

  char *outdata;
  int outsize;

  string outext = utils::getExtension(output_filename);
  ImageType outtype = resolveImageType(outext);

  convert_image(&indata, insize, intype, &outdata, outsize, outtype);

  cout << "Output file: " << to_string(outsize) << "B" << endl;

  utils::write_char_array_to_file(output_filename, outdata, outsize);

  cout << "Done!" << endl;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x529a
movq 0x10(%rbx), %rsi
leaq -0x70(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x529a
leaq -0x1a8(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x1b8(%rbp), %rdi
callq 0x534a
leaq -0x1b8(%rbp), %rdi
callq 0xdc6d
movl %eax, %ebx
movq -0x1b8(%rbp), %rdi
cmpq %r14, %rdi
je 0x4cc1
movq -0x1a8(%rbp), %rsi
incq %rsi
callq 0x4530
movl %ebx, -0x24(%rbp)
movq 0xf30d(%rip), %rdi      # 0x13fd8
movl %ebx, %esi
callq 0x4860
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x44f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4060
movq %rax, %rdi
callq 0x43b0
movslq -0x24(%rbp), %rdi
callq 0x4040
movq %rax, -0x30(%rbp)
movq %rax, %rdi
movl $0xa, %esi
callq 0xdb0d
leaq -0x188(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x198(%rbp), %rdi
callq 0x534a
leaq -0xb8(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0xdb79
movq -0x198(%rbp), %rdi
cmpq %r14, %rdi
je 0x4d66
movq -0x188(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x168(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x178(%rbp), %rdi
callq 0x534a
leaq -0x178(%rbp), %rdi
callq 0x5480
movl %eax, %ebx
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x4db7
movq -0x168(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x148(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x158(%rbp), %rdi
callq 0x534a
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0x158(%rbp), %rdi
callq 0xda78
movq -0x158(%rbp), %rdi
cmpq %r14, %rdi
je 0x4e07
movq -0x148(%rbp), %rsi
incq %rsi
callq 0x4530
movq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0xdb0d
leaq -0x108(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %rdi
callq 0x534a
leaq -0x138(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0xdb79
movq -0x118(%rbp), %rdi
cmpq %r14, %rdi
je 0x4e65
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0xe8(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf8(%rbp), %rdi
callq 0x534a
leaq -0xf8(%rbp), %rdi
callq 0x5480
movl %eax, %r14d
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x4eb7
movq -0xe8(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x30(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x98(%rbp), %rcx
leaq -0x28(%rbp), %r8
movl %ebx, %edx
movl %r14d, %r9d
callq 0x54d7
movq 0xf0fd(%rip), %rdi      # 0x13fd8
leaq 0x9122(%rip), %rsi      # 0xe004
movl $0xd, %edx
callq 0x45a0
movl -0x28(%rbp), %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0x4f4f
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0x4f46
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x4f4c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x4f4f
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x4f13
addl $-0x3, %r15d
jmp 0x4f4f
addl $-0x2, %r15d
jmp 0x4f4f
decl %r15d
shrl $0x1f, %ebx
leal (%r15,%rbx), %esi
leaq -0x80(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0x90(%rbp), %rdi
movl $0x2d, %edx
callq 0x45c0
addq -0x90(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x52d7
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq 0xf03e(%rip), %rdi      # 0x13fd8
callq 0x45a0
movq %rax, %rbx
leaq 0x9069(%rip), %rsi      # 0xe012
movl $0x1, %edx
movq %rax, %rdi
callq 0x45a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x44f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4060
movq %rax, %rdi
callq 0x43b0
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x4ff5
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0xc8(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x534a
movq -0x98(%rbp), %rsi
movl -0x28(%rbp), %edx
leaq -0xd8(%rbp), %rdi
callq 0xdbbe
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5048
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x4530
movq 0xef89(%rip), %rbx      # 0x13fd8
leaq 0x8fbe(%rip), %rsi      # 0xe014
movl $0x5, %edx
movq %rbx, %rdi
callq 0x45a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x44f0
movsbl %al, %esi
movq 0xef57(%rip), %rdi      # 0x13fd8
callq 0x4060
movq %rax, %rdi
callq 0x43b0
leaq -0x128(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x50ad
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x50cc
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x50e5
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x50fe
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x4530
xorl %eax, %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5222
movq -0xc8(%rbp), %rsi
jmp 0x5210
jmp 0x521f
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r15, %rdi
je 0x5222
movq -0xe8(%rbp), %rsi
jmp 0x5210
movq %rax, %rbx
movq -0x118(%rbp), %rdi
cmpq %r14, %rdi
je 0x5241
movq -0x108(%rbp), %rsi
jmp 0x5239
jmp 0x51f8
movq %rax, %rbx
movq -0x158(%rbp), %rdi
cmpq %r14, %rdi
je 0x5241
movq -0x148(%rbp), %rsi
jmp 0x5239
movq %rax, %rbx
movq -0x178(%rbp), %rdi
cmpq %r14, %rdi
je 0x5241
movq -0x168(%rbp), %rsi
jmp 0x5239
movq %rax, %rbx
movq -0x198(%rbp), %rdi
cmpq %r14, %rdi
je 0x5260
movq -0x188(%rbp), %rsi
jmp 0x5258
jmp 0x521a
movq %rax, %rbx
movq -0x1b8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5260
movq -0x1a8(%rbp), %rsi
jmp 0x5258
movq %rax, %rbx
jmp 0x5279
jmp 0x521a
movq %rax, %rbx
jmp 0x5241
movq %rax, %rbx
movq -0x90(%rbp), %rdi
cmpq %r12, %rdi
je 0x5222
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x4530
jmp 0x5222
movq %rax, %rbx
jmp 0x5260
movq %rax, %rbx
leaq -0x128(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5241
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5260
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5279
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x4530
leaq -0x40(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5292
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x4530
movq %rbx, %rdi
callq 0x48b0