// File: 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:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0x120(%rsp)
jne 0x9dabd
cmpq $0x0, 0x118(%rsp)
jne 0x9dabd
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 0x4afce(%rip), %rcx     # 0xe89d2
leaq 0x2c0d6(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x98(%rsp)
callq 0x118f0
movq %rax, 0xa0(%rsp)
jmp 0x9da29
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 0x4e1ab(%rip), %rsi     # 0xebc24
xorl %eax, %eax
callq 0x12220
jmp 0x9da82
movq 0x78(%rsp), %rdi
leaq 0x620d2(%rip), %rsi     # 0xffb60
leaq -0x8b635(%rip), %rdx    # 0x12460
callq 0x5920
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x110(%rsp)
movl %eax, 0x10c(%rsp)
callq 0x53a0
jmp 0x9dff2
movq 0xa8(%rsp), %rdi
callq 0x10320
testb $0x1, %al
jne 0x9dad0
jmp 0x9dafa
movq 0x120(%rsp), %rdi
movq 0x118(%rsp), %rsi
callq 0x9c310
movq 0xa8(%rsp), %rax
movq %rax, 0x130(%rsp)
jmp 0x9dfe2
movq 0xa8(%rsp), %rax
cmpl $0x3, 0xc(%rax)
je 0x9dbc8
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 0x2bf9f(%rip), %rax     # 0xc9ae1
leaq 0x4ae89(%rip), %rcx     # 0xe89d2
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x68(%rsp)
callq 0x118f0
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x118(%rsp)
je 0x9db79
movq 0x118(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x9db87
leaq 0x4b90a(%rip), %rax     # 0xe948a
movq %rax, 0x48(%rsp)
jmp 0x9db87
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 0x4e0c9(%rip), %rdi     # 0xebc7c
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x117e0
cmpq $0x0, 0x120(%rsp)
je 0x9dbe2
movq 0x120(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x9dbfb
movq 0x118(%rsp), %rdi
leaq 0x4b30f(%rip), %rsi     # 0xe8f00
callq 0x654a0
movq %rax, 0x40(%rsp)
movq 0xa8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rax, 0x100(%rsp)
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0xf8(%rsp)
imulq $0x3, 0xf8(%rsp), %rdi
callq 0x5040
movq 0xa8(%rsp), %rdi
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0xe8(%rsp)
xorl %r8d, %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x73790
movq %rax, %rcx
movq 0xa8(%rsp), %rax
movq %rcx, 0xe0(%rsp)
cmpl $0x1, 0xc(%rax)
jbe 0x9dc99
movq 0xa8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x38(%rsp)
jmp 0x9dca2
xorl %eax, %eax
movq %rax, 0x38(%rsp)
jmp 0x9dca2
movq 0xa8(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
cmpl $0x2, 0xc(%rax)
jbe 0x9dcdd
movq 0xa8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x2, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x30(%rsp)
jmp 0x9dce6
xorl %eax, %eax
movq %rax, 0x30(%rsp)
jmp 0x9dce6
movq 0xa8(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
movl 0xc(%rax), %eax
movl %eax, 0x2c(%rsp)
subl $0x1, %eax
je 0x9dd1b
jmp 0x9dd09
movl 0x2c(%rsp), %eax
subl $0x2, %eax
je 0x9dddd
jmp 0x9dea2
movq $0x0, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jae 0x9ddd8
movq 0xe0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe0(%rsp)
cvttsd2si (%rax), %eax
movb %al, 0xc7(%rsp)
movb 0xc7(%rsp), %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movb 0xc7(%rsp), %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movb 0xc7(%rsp), %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movq 0xc8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xc8(%rsp)
jmp 0x9dd27
jmp 0x9df7f
movq $0x0, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jae 0x9de9d
movq 0xe0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xe8(%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 0xe8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movq 0xe8(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xe8(%rsp)
movb $0x0, (%rax)
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x9dde9
jmp 0x9df7f
movq $0x0, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jae 0x9df7d
movq 0xe0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xe0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xe8(%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 0xe8(%rsp), %rax
movq %rax, %rdx
incq %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movq 0xd0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xd0(%rsp)
cvttsd2si (%rax), %eax
movb %al, %cl
movq 0xe8(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xe8(%rsp)
movb %cl, (%rax)
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0x9deae
jmp 0x9df7f
movq 0xf0(%rsp), %rdi
imulq $0x3, 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
callq 0x9d390
cmpq $0x0, 0x120(%rsp)
jne 0x9dfb5
movq 0x100(%rsp), %rdi
callq 0x5c6f0
movq 0xf0(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x9dfd2
movq 0x20(%rsp), %rdi
callq 0x5680
movq 0xa8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
movq 0x110(%rsp), %rdi
callq 0x5970
nop