// File: 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:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x138(%rsp)
movq %rsi, 0x130(%rsp)
movq %rdx, 0x128(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0x130(%rsp)
jne 0x9e15d
cmpq $0x0, 0x128(%rsp)
jne 0x9e15d
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0x78(%rsp)
movl (%rax), %ecx
movl %ecx, 0x80(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x84(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x88(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x8c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x90(%rsp)
movb 0x10(%rax), %dl
leaq 0x4a92e(%rip), %rcx     # 0xe89d2
leaq 0x2ba36(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x98(%rsp)
callq 0x118f0
movq %rax, 0xa0(%rsp)
jmp 0x9e0c9
movl 0x8c(%rsp), %r9d
movl 0x88(%rsp), %r8d
movl 0x84(%rsp), %ecx
movl 0x80(%rsp), %edx
movq 0x78(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %r10
movq 0xa0(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x4dbd7(%rip), %rsi     # 0xebcf0
xorl %eax, %eax
callq 0x12220
jmp 0x9e122
movq 0x78(%rsp), %rdi
leaq 0x61a32(%rip), %rsi     # 0xffb60
leaq -0x8bcd5(%rip), %rdx    # 0x12460
callq 0x5920
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x120(%rsp)
movl %eax, 0x11c(%rsp)
callq 0x53a0
jmp 0x9e84e
movq 0xa8(%rsp), %rdi
callq 0x10320
testb $0x1, %al
jne 0x9e170
jmp 0x9e19a
movq 0x130(%rsp), %rdi
movq 0x128(%rsp), %rsi
callq 0x9c310
movq 0xa8(%rsp), %rax
movq %rax, 0x140(%rsp)
jmp 0x9e83e
movq 0xa8(%rsp), %rax
cmpl $0x4, 0xc(%rax)
je 0x9e268
movq 0xa8(%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0x50(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x54(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x58(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x5c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x60(%rsp)
movb 0x10(%rax), %dl
leaq 0x2b8ff(%rip), %rax     # 0xc9ae1
leaq 0x4a7e9(%rip), %rcx     # 0xe89d2
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x68(%rsp)
callq 0x118f0
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x128(%rsp)
je 0x9e219
movq 0x128(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x9e227
leaq 0x4b26a(%rip), %rax     # 0xe948a
movq %rax, 0x48(%rsp)
jmp 0x9e227
movq 0x70(%rsp), %r10
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r9
movl 0x5c(%rsp), %r8d
movl 0x58(%rsp), %ecx
movl 0x54(%rsp), %edx
movl 0x50(%rsp), %esi
movq 0x48(%rsp), %rax
leaq 0x4daf6(%rip), %rdi     # 0xebd49
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x117e0
cmpq $0x0, 0x130(%rsp)
je 0x9e282
movq 0x130(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x9e29b
movq 0x128(%rsp), %rdi
leaq 0x4ac6f(%rip), %rsi     # 0xe8f00
callq 0x654a0
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rax, 0x110(%rsp)
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rdi
shlq $0x2, %rdi
callq 0x5040
movq 0xa8(%rsp), %rdi
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0xf8(%rsp)
xorl %r8d, %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x73790
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0xf0(%rsp)
cmpl $0x1, 0xc(%rax)
jbe 0x9e33c
movq 0xa8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x38(%rsp)
jmp 0x9e345
xorl %eax, %eax
movq %rax, 0x38(%rsp)
jmp 0x9e345
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xe8(%rsp)
cmpl $0x2, 0xc(%rax)
jbe 0x9e380
movq 0xa8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x2, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x30(%rsp)
jmp 0x9e389
xorl %eax, %eax
movq %rax, 0x30(%rsp)
jmp 0x9e389
movq 0xa8(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0xe0(%rsp)
cmpl $0x3, 0xc(%rax)
jbe 0x9e3c4
movq 0xa8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x3, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x28(%rsp)
jmp 0x9e3cd
xorl %eax, %eax
movq %rax, 0x28(%rsp)
jmp 0x9e3cd
movq 0xa8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
movl 0xc(%rax), %eax
movl %eax, 0x24(%rsp)
subl $0x1, %eax
je 0x9e411
jmp 0x9e3f0
movl 0x24(%rsp), %eax
subl $0x2, %eax
je 0x9e4ed
jmp 0x9e3ff
movl 0x24(%rsp), %eax
subl $0x3, %eax
je 0x9e5cc
jmp 0x9e6c6
movq $0x0, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
cmpq 0x108(%rsp), %rax
jae 0x9e4e8
movq 0xf0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xf0(%rsp)
cvttsd2si (%rax), %eax
movb %al, 0xcf(%rsp)
movb 0xcf(%rsp), %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movb 0xcf(%rsp), %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movb 0xcf(%rsp), %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xf8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xf8(%rsp)
movb $-0x1, (%rax)
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0x9e41d
jmp 0x9e7d8
movq $0x0, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0x108(%rsp), %rax
jae 0x9e5c7
movq 0xf0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xf0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xe8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe8(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xf8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xf8(%rsp)
movb $0x0, (%rax)
movq 0xf8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xf8(%rsp)
movb $-0x1, (%rax)
movq 0xc0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc0(%rsp)
jmp 0x9e4f9
jmp 0x9e7d8
movq $0x0, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
cmpq 0x108(%rsp), %rax
jae 0x9e6c1
movq 0xf0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xf0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xe8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe8(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xe0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xf8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xf8(%rsp)
movb $-0x1, (%rax)
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x9e5d8
jmp 0x9e7d8
movq $0x0, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
cmpq 0x108(%rsp), %rax
jae 0x9e7d6
movq 0xf0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xf0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xe8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe8(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xe0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xd8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xd8(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xf8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xf8(%rsp)
movb %cl, (%rax)
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0x9e6d2
jmp 0x9e7d8
movq 0x100(%rsp), %rdi
movq 0x108(%rsp), %rsi
shlq $0x2, %rsi
movq 0x110(%rsp), %rdx
callq 0x9d390
cmpq $0x0, 0x130(%rsp)
jne 0x9e811
movq 0x110(%rsp), %rdi
callq 0x5c6f0
movq 0x100(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x9e82e
movq 0x18(%rsp), %rdi
callq 0x5680
movq 0xa8(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
movq 0x120(%rsp), %rdi
callq 0x5970
nopl (%rax,%rax)