// File: /workspace/github_c_makefile_star2_O0/kopytjuk[P]wasm-image-converter/src/converter.cpp
// Function: image_to_char_array(boost::gil::image<boost::gil::pixel<unsigned char, boost::gil::layout<boost::mp11::mp_list<boost::gil::red_t, boost::gil::green_t, boost::gil::blue_t>, boost::mp11::mp_list<std::integral_constant<int, 0>, std::integral_constant<int, 1>, std::integral_constant<int, 2>>>>, false, std::allocator<unsigned char>>&, ImageType, char**, int&)
void image_to_char_array(rgb8_image_t &img, ImageType type, char **arr, int &size){

  stringstream arr_stream(ios_base::in | ios_base::out | ios_base::binary);

  switch (type) {
    case JpegImage:
      write_view(arr_stream, view(img), jpeg_tag() );
      break;
    case PngImage:
      write_view(arr_stream, view(img), png_tag() );
      break;
    default:
      cout << "Cannot write to output image type! Exiting." << endl;
      break;
  }

  arr_stream.seekg(0, ios::end);

  size = arr_stream.tellg();

  cout << "Allocating " << to_string(size/1024) << "KB for the output image."<< endl;

  // allocate memory for file
  *arr = new char [size];

  arr_stream.seekg (0, ios::beg);
  arr_stream.read (*arr, size);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x8, %edi
movl $0x10, %esi
callq 0x70a0
movl %eax, %edi
movl $0x4, %esi
callq 0x70a0
movl %eax, %esi
leaq -0x1a8(%rbp), %rdi
callq 0x5430
movl -0xc(%rbp), %eax
movl %eax, -0x1ec(%rbp)
testl %eax, %eax
je 0x6bde
jmp 0x6b82
movl -0x1ec(%rbp), %eax
subl $0x1, %eax
jne 0x6c12
jmp 0x6b93
movq -0x8(%rbp), %rdi
callq 0x7360
movq %rax, -0x1f8(%rbp)
jmp 0x6ba5
movq -0x1f8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x1a8(%rbp), %rdi
leaq -0x1b5(%rbp), %rdx
callq 0x72c0
jmp 0x6bc5
jmp 0x6c45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x6dd4
movq -0x8(%rbp), %rdi
callq 0x7360
movq %rax, -0x200(%rbp)
jmp 0x6bf0
movq -0x200(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
leaq -0x1a8(%rbp), %rdi
leaq -0x1b6(%rbp), %rdx
callq 0x7370
jmp 0x6c10
jmp 0x6c45
movq 0x2d3b7(%rip), %rdi     # 0x33fd0
leaq 0x1b605(%rip), %rsi     # 0x22225
callq 0x5570
movq %rax, -0x208(%rbp)
jmp 0x6c2e
movq -0x208(%rbp), %rdi
movq 0x2d374(%rip), %rsi     # 0x33fb0
callq 0x55d0
jmp 0x6c43
jmp 0x6c45
xorl %eax, %eax
movl %eax, %esi
leaq -0x1a8(%rbp), %rdi
movl $0x2, %edx
callq 0x56f0
jmp 0x6c5c
leaq -0x1a8(%rbp), %rdi
callq 0x5970
movq %rdx, -0x218(%rbp)
movq %rax, -0x210(%rbp)
jmp 0x6c78
movq -0x218(%rbp), %rax
movq -0x210(%rbp), %rcx
movq %rcx, -0x1c8(%rbp)
movq %rax, -0x1c0(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x7410
movq %rax, -0x220(%rbp)
jmp 0x6ca9
movq -0x220(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq 0x2d311(%rip), %rdi     # 0x33fd0
leaq 0x1b58b(%rip), %rsi     # 0x22251
callq 0x5570
movq %rax, -0x228(%rbp)
jmp 0x6cd4
movq -0x20(%rbp), %rax
movl (%rax), %esi
movl %esi, %eax
addl $0x3ff, %eax            # imm = 0x3FF
testl %esi, %esi
cmovsl %eax, %esi
sarl $0xa, %esi
leaq -0x1e8(%rbp), %rdi
callq 0x6220
jmp 0x6cf7
movq -0x228(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x5510
movq %rax, -0x230(%rbp)
jmp 0x6d13
movq -0x230(%rbp), %rdi
leaq 0x1b53c(%rip), %rsi     # 0x2225d
callq 0x5570
movq %rax, -0x238(%rbp)
jmp 0x6d2f
movq -0x238(%rbp), %rdi
movq 0x2d273(%rip), %rsi     # 0x33fb0
callq 0x55d0
jmp 0x6d44
leaq -0x1e8(%rbp), %rdi
callq 0x5390
movq -0x20(%rbp), %rax
movslq (%rax), %rdi
callq 0x5040
movq %rax, -0x240(%rbp)
jmp 0x6d65
movq -0x240(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
xorl %edx, %edx
movl %edx, %esi
leaq -0x1a8(%rbp), %rdi
callq 0x56f0
jmp 0x6d85
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x20(%rbp), %rax
movslq (%rax), %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x56b0
jmp 0x6da1
leaq -0x1a8(%rbp), %rdi
callq 0x5420
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x5390
leaq -0x1a8(%rbp), %rdi
callq 0x5420
movq -0x1b0(%rbp), %rdi
callq 0x59b0
nopl (%rax)