// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::_save_rgb(_IO_FILE*, char const*) const
const CImg<T>& _save_rgb(std::FILE *const file, const char *const filename) const {
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_rgb(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(file,filename); return *this; }
      if (_spectrum!=3)
        cimg::warn(_cimg_instance
                   "save_rgb(): image instance has not exactly 3 channels, for file '%s'.",
                   cimg_instance,
                   filename?filename:"(FILE*)");

      std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
      const unsigned long wh = (unsigned long)_width*_height;
      unsigned char *const buffer = new unsigned char[3*wh], *nbuffer = buffer;
      const T
        *ptr1 = data(0,0,0,0),
        *ptr2 = _spectrum>1?data(0,0,0,1):0,
        *ptr3 = _spectrum>2?data(0,0,0,2):0;
      switch (_spectrum) {
      case 1 : { // Scalar image
        for (unsigned long k = 0; k<wh; ++k) {
          const unsigned char val = (unsigned char)*(ptr1++);
          *(nbuffer++) = val;
          *(nbuffer++) = val;
          *(nbuffer++) = val;
        }
      } break;
      case 2 : { // RG image
        for (unsigned long k = 0; k<wh; ++k) {
          *(nbuffer++) = (unsigned char)(*(ptr1++));
          *(nbuffer++) = (unsigned char)(*(ptr2++));
          *(nbuffer++) = 0;
        }
      } break;
      default : { // RGB image
        for (unsigned long k = 0; k<wh; ++k) {
          *(nbuffer++) = (unsigned char)(*(ptr1++));
          *(nbuffer++) = (unsigned char)(*(ptr2++));
          *(nbuffer++) = (unsigned char)(*(ptr3++));
        }
      }
      }
      cimg::fwrite(buffer,3*wh,nfile);
      if (!file) cimg::fclose(nfile);
      delete[] buffer;
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, %rax
orq %rdx, %rax
je 0x47188
movq %rdx, %r12
movq %rsi, %r14
movq %rbx, %rdi
callq 0x8dc8
testb %al, %al
je 0x46ffc
movq %r14, %rdi
movq %r12, %rsi
callq 0x465c3
jmp 0x47176
movl 0xc(%rbx), %r8d
cmpl $0x3, %r8d
je 0x47059
leaq 0xd7db(%rip), %rax      # 0x547e8
leaq 0xebae(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
testq %r12, %r12
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movl 0x8(%rbx), %ecx
movq 0x18(%rbx), %r9
leaq 0x2e535(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2e05e(%rip), %r15     # 0x7509f
leaq 0x30cfd(%rip), %rdi     # 0x77d45
xorl %eax, %eax
pushq %r11
pushq %r15
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movq %r14, %rax
testq %r14, %r14
jne 0x47070
leaq 0x2df75(%rip), %rsi     # 0x74fdd
movq %r12, %rdi
callq 0x2dca5
movq %rax, (%rsp)
movl (%rbx), %r13d
movl 0x4(%rbx), %r15d
movq %r15, %rbp
imulq %r13, %rbp
leaq (,%rbp,2), %rdi
addq %rbp, %rdi
movq %rdi, %r12
callq 0x4040
movq %rax, %r10
movq 0x18(%rbx), %rax
movl 0xc(%rbx), %edi
cmpl $0x2, %edi
jb 0x470de
movl 0x8(%rbx), %ecx
jne 0x470e4
imulq %r13, %r15
imulq %rcx, %r15
movq %r10, %rcx
movq %r12, %rsi
subq $0x1, %rbp
jb 0x4714f
cvttsd2si (%rax), %edx
movb %dl, (%rcx)
cvttsd2si (%rax,%r15,8), %edx
addq $0x8, %rax
movb %dl, 0x1(%rcx)
movb $0x0, 0x2(%rcx)
addq $0x3, %rcx
jmp 0x470b7
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x470f3
imulq %rbp, %rcx
leaq (%rax,%rcx,8), %rdx
shlq $0x4, %rcx
addq %rax, %rcx
movq %r12, %rsi
cmpl $0x1, %edi
jne 0x4711e
xorl %ecx, %ecx
movq %r10, %rdx
cmpq %rcx, %rbp
je 0x4714f
cvttsd2si (%rax,%rcx,8), %edi
movb %dil, (%rdx)
movb %dil, 0x1(%rdx)
movb %dil, 0x2(%rdx)
addq $0x3, %rdx
incq %rcx
jmp 0x47100
xorl %r9d, %r9d
movq %r10, %rdi
cmpq %r9, %rbp
je 0x4714f
cvttsd2si (%rax,%r9,8), %r8d
movb %r8b, (%rdi)
cvttsd2si (%rdx,%r9,8), %r8d
movb %r8b, 0x1(%rdi)
cvttsd2si (%rcx,%r9,8), %r8d
movb %r8b, 0x2(%rdi)
addq $0x3, %rdi
incq %r9
jmp 0x47124
movq %r10, %rdi
movq (%rsp), %r15
movq %r15, %rdx
movq %r10, %r12
callq 0x46d25
testq %r14, %r14
jne 0x4716e
movq %r15, %rdi
callq 0x2a2f8
movq %r12, %rdi
callq 0x4670
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
movl (%rbx), %edx
movl 0x4(%rbx), %ecx
movl 0x8(%rbx), %r8d
movl 0xc(%rbx), %r9d
leaq 0xd63f(%rip), %rax      # 0x547e8
leaq 0xea12(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2dedc(%rip), %r11     # 0x7509f
leaq 0x30b23(%rip), %rsi     # 0x77ced
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%rbx)
callq 0x9d52
addq $0x20, %rsp
leaq 0x48a7a(%rip), %rsi     # 0x8fc60
movq 0x48deb(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4950