// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::_save_rgba(_IO_FILE*, char const*) const
const CImg<T>& _save_rgba(std::FILE *const file, const char *const filename) const {
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_rgba(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(file,filename); return *this; }
      if (_spectrum!=4)
        cimg::warn(_cimg_instance
                   "save_rgba(): image instance has not exactly 4 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[4*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,
        *ptr4 = _spectrum>3?data(0,0,0,3):0;
      switch (_spectrum) {
      case 1 : { // Scalar images
        for (unsigned long k = 0; k<wh; ++k) {
          const unsigned char val = (unsigned char)*(ptr1++);
          *(nbuffer++) = val;
          *(nbuffer++) = val;
          *(nbuffer++) = val;
          *(nbuffer++) = 255;
        }
      } break;
      case 2 : { // RG images
        for (unsigned long k = 0; k<wh; ++k) {
          *(nbuffer++) = (unsigned char)(*(ptr1++));
          *(nbuffer++) = (unsigned char)(*(ptr2++));
          *(nbuffer++) = 0;
          *(nbuffer++) = 255;
        }
      } break;
      case 3 : { // RGB images
        for (unsigned long k = 0; k<wh; ++k) {
          *(nbuffer++) = (unsigned char)(*(ptr1++));
          *(nbuffer++) = (unsigned char)(*(ptr2++));
          *(nbuffer++) = (unsigned char)(*(ptr3++));
          *(nbuffer++) = 255;
        }
      } break;
      default : { // RGBA images
        for (unsigned long k = 0; k<wh; ++k) {
          *(nbuffer++) = (unsigned char)(*(ptr1++));
          *(nbuffer++) = (unsigned char)(*(ptr2++));
          *(nbuffer++) = (unsigned char)(*(ptr3++));
          *(nbuffer++) = (unsigned char)(*(ptr4++));
        }
      }
      }
      cimg::fwrite(buffer,4*wh,nfile);
      if (!file) cimg::fclose(nfile);
      delete[] buffer;
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq %rsi, %rax
orq %rdx, %rax
je 0x4745b
movq %rdx, %r12
movq %rsi, %r14
movq %rbx, %rdi
callq 0x8dc8
testb %al, %al
je 0x47247
movq %r14, %rdi
movq %r12, %rsi
callq 0x465c3
jmp 0x47449
movl 0xc(%rbx), %r8d
cmpl $0x4, %r8d
je 0x472a4
leaq 0xd590(%rip), %rax      # 0x547e8
leaq 0xe963(%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 0x2e2ea(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2de13(%rip), %r15     # 0x7509f
leaq 0x30b7f(%rip), %rdi     # 0x77e12
xorl %eax, %eax
pushq %r11
pushq %r15
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movq %r14, %rax
movq %r14, 0x8(%rsp)
testq %r14, %r14
jne 0x472c0
leaq 0x2dd25(%rip), %rsi     # 0x74fdd
movq %r12, %rdi
callq 0x2dca5
movq %rax, 0x10(%rsp)
movl (%rbx), %r13d
movl 0x4(%rbx), %r15d
movq %r15, %rbp
imulq %r13, %rbp
leaq (,%rbp,4), %rdi
movq %rdi, %r14
callq 0x4040
movq %rax, %r12
movq 0x18(%rbx), %rax
movl 0xc(%rbx), %edi
cmpl $0x2, %edi
jb 0x4733f
movl 0x8(%rbx), %ecx
jne 0x473bc
imulq %r13, %r15
imulq %rcx, %r15
leaq (%rax,%r15,8), %rcx
xorl %edx, %edx
movq 0x10(%rsp), %r13
movq %r14, %rsi
movq 0x8(%rsp), %r14
cmpq %rdx, %rbp
je 0x47429
cvttsd2si (%rax,%rdx,8), %edi
movb %dil, (%r12,%rdx,4)
cvttsd2si (%rcx,%rdx,8), %edi
movb %dil, 0x1(%r12,%rdx,4)
movw $0xff00, 0x2(%r12,%rdx,4) # imm = 0xFF00
incq %rdx
jmp 0x47316
xorl %ecx, %ecx
xorl %edx, %edx
xorl %r9d, %r9d
movq %r14, %rsi
movq 0x8(%rsp), %r14
cmpl $0x1, %edi
movq 0x10(%rsp), %r13
jne 0x47381
xorl %ecx, %ecx
cmpq %rcx, %rbp
je 0x47429
cvttsd2si (%rax,%rcx,8), %edx
movb %dl, (%r12,%rcx,4)
movb %dl, 0x1(%r12,%rcx,4)
movb %dl, 0x2(%r12,%rcx,4)
movb $-0x1, 0x3(%r12,%rcx,4)
incq %rcx
jmp 0x4735a
xorl %edi, %edi
cmpq %rdi, %rbp
je 0x47429
cvttsd2si (%rax,%rdi,8), %r8d
movb %r8b, (%r12,%rdi,4)
cvttsd2si (%rdx,%rdi,8), %r8d
movb %r8b, 0x1(%r12,%rdi,4)
cvttsd2si (%rcx,%rdi,8), %r8d
movb %r8b, 0x2(%r12,%rdi,4)
cvttsd2si (%r9,%rdi,8), %r8d
movb %r8b, 0x3(%r12,%rdi,4)
incq %rdi
jmp 0x47383
cmpl $0x3, %edi
movq %r14, %rsi
jbe 0x473df
imulq %rbp, %rcx
leaq (%rax,%rcx,8), %rdx
imulq $0x18, %rcx, %r9
shlq $0x4, %rcx
addq %rax, %rcx
addq %rax, %r9
jmp 0x47349
imulq %r13, %r15
imulq %rcx, %r15
movq %r15, %rcx
shlq $0x4, %rcx
movq %r12, %rdx
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
subq $0x1, %rbp
jb 0x47429
cvttsd2si (%rax), %edi
movb %dil, (%rdx)
cvttsd2si (%rax,%r15,8), %edi
movb %dil, 0x1(%rdx)
cvttsd2si (%rax,%rcx), %edi
addq $0x8, %rax
movb %dil, 0x2(%rdx)
movb $-0x1, 0x3(%rdx)
addq $0x4, %rdx
jmp 0x473fb
movq %r12, %rdi
movq %r13, %rdx
callq 0x46d25
testq %r14, %r14
jne 0x47441
movq %r13, %rdi
callq 0x2a2f8
movq %r12, %rdi
callq 0x4670
movq %rbx, %rax
addq $0x18, %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 0xd36c(%rip), %rax      # 0x547e8
leaq 0xe73f(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2dc09(%rip), %r11     # 0x7509f
leaq 0x3091c(%rip), %rsi     # 0x77db9
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%rbx)
callq 0x9d52
addq $0x20, %rsp
leaq 0x487a7(%rip), %rsi     # 0x8fc60
movq 0x48b18(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4950
nop