// File: /workspace/github_cpp_makefile_star2_O2/jpbalarini[P]otsus/./framework/CImage.cpp
// Function: CImage::load_float_RGB(char*)
void CImage::load_float_RGB(char *filename) {
  int num_channels;
  size_t dummy;
  
  CFramework *fw = CFramework::get_framework();

  FILE *infile = fopen(filename, "rb");
  if (!infile) {
    PRINT_ERROR("CImage: error opening float RGB file %s\n!", filename);
    exit(-1);
  }

  dummy = fread(&this->Nx, sizeof(this->Nx), 1, infile);
  dummy += fread(&this->Ny, sizeof(this->Ny), 1, infile);
  dummy += fread(&num_channels, sizeof(num_channels), 1, infile);
  dummy = dummy; // To prevent the warning

  this->bits = 16;
  PRINT_VERBOSE("CImage load RGB (%dx%d), %d channels, in I_%d\n",
    this->Nx, this->Ny, num_channels, this->id);

  int id_data_all;
  float *data_ALL = fw->create_array(num_channels*this->Nx*this->Ny, id_data_all);
  dummy = fread(data_ALL, sizeof(float), num_channels*this->Nx*this->Ny, infile);
  fclose(infile);

  // Create data channels
  create_channels(num_channels, Nx, Ny);

  int idx_data = 0;
  for (int ch = 0; ch < num_channels; ch++) {
    float *m = this->get_channel(ch);
    for (int y = 0; y < Ny; y++) {
        for (int x = 0; x < Nx; x++) {
          m[y*this->Nx+x] = data_ALL[idx_data];
          idx_data++;
        }
    }
  }

  fw->delete_matrix(id_data_all);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x38d6
movq %rax, %r14
leaq 0x3695(%rip), %rsi      # 0x8110
movq %r15, %rdi
callq 0x3320
testq %rax, %rax
je 0x4be6
movq %rax, %r12
pushq $0x4
popq %r15
pushq $0x1
popq %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x3410
leaq 0x4(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x3410
leaq 0x14(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x3410
movl $0x10, 0x8(%rbx)
leaq 0x77eb(%rip), %rax      # 0xc2c9
movslq (%rbp), %r13
cmpb $0x1, (%rax)
jne 0x4b01
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %r8d
leaq 0x38d7(%rip), %rdi      # 0x83ce
movl %r13d, %ecx
xorl %eax, %eax
callq 0x3070
movl (%rbx), %esi
imull %r13d, %esi
imull 0x4(%rbx), %esi
leaq 0x4(%rsp), %rdx
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0x39fc
movq %rax, %r15
movslq (%rbx), %rax
imulq %r13, %rax
movslq 0x4(%rbx), %rdx
imulq %rax, %rdx
pushq $0x4
popq %rsi
movq %r15, %rdi
movq %r12, %rcx
callq 0x3410
movq %r12, %rdi
callq 0x3270
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4724
xorl %r12d, %r12d
testl %r13d, %r13d
movl $0x0, %r14d
cmovgl %r13d, %r14d
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpl %r14d, %ebp
je 0x4bc9
movq %rbx, %rdi
movl %ebp, %esi
callq 0x598a
movl 0x4(%rbx), %ecx
movslq (%rbx), %rdx
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
testl %ecx, %ecx
cmovlel %r12d, %ecx
shlq $0x2, %rdx
xorl %edi, %edi
cmpq %rcx, %rdi
je 0x4bc5
movslq %r13d, %r8
leaq (%r15,%r8,4), %r9
xorl %r8d, %r8d
cmpq %r8, %rsi
je 0x4bba
movss (%r9,%r8,4), %xmm0
movss %xmm0, (%rax,%r8,4)
incq %r8
jmp 0x4ba4
addl %r8d, %r13d
incq %rdi
addq %rdx, %rax
jmp 0x4b95
incl %ebp
jmp 0x4b6a
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdi
callq 0x3812
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x73d3(%rip), %rbx      # 0xbfc0
movq (%rbx), %rdi
leaq 0x3490(%rip), %rsi      # 0x8087
leaq 0x36ca(%rip), %rcx      # 0x82c8
movl $0xb0, %edx
xorl %eax, %eax
callq 0x33c0
movq (%rbx), %rdi
leaq 0x3790(%rip), %rsi      # 0x83a4
movq %r15, %rdx
xorl %eax, %eax
callq 0x33c0
pushq $-0x1
popq %rdi
callq 0x3340