// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::save_magick(char const*, unsigned int) const
const CImg<T>& save_magick(const char *const filename, const unsigned int bytes_per_pixel=0) const {
      if (!filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_magick(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(0,filename); return *this; }

#ifdef cimg_use_magick
      double stmin, stmax = (double)max_min(stmin);
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance is volumetric, only the first slice will be saved in file '%s'.",
                   cimg_instance,
                   filename);

      if (_spectrum>3)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance is multispectral, only the three first channels will be "
                   "saved in file '%s'.",
                   cimg_instance,
                   filename);

      if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
        cimg::warn(_cimg_instance
                   "save_magick(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.",
                   cimg_instance,
                   filename,stmin,stmax);

      Magick::Image image(Magick::Geometry(_width,_height),"black");
      image.type(Magick::TrueColorType);
      image.depth(bytes_per_pixel?(8*bytes_per_pixel):(stmax>=256?16:8));
      const T
        *ptr_r = data(0,0,0,0),
        *ptr_g = _spectrum>1?data(0,0,0,1):0,
        *ptr_b = _spectrum>2?data(0,0,0,2):0;
      Magick::PixelPacket *pixels = image.getPixels(0,0,_width,_height);
      switch (_spectrum) {
      case 1 : // Scalar images
        for (unsigned long off = (unsigned long)_width*_height; off; --off) {
          pixels->red = pixels->green = pixels->blue = (Magick::Quantum)*(ptr_r++);
          ++pixels;
        }
        break;
      case 2 : // RG images
        for (unsigned long off = (unsigned long)_width*_height; off; --off) {
          pixels->red = (Magick::Quantum)*(ptr_r++);
          pixels->green = (Magick::Quantum)*(ptr_g++);
          pixels->blue = 0; ++pixels;
        }
        break;
      default : // RGB images
        for (unsigned long off = (unsigned long)_width*_height; off; --off) {
          pixels->red = (Magick::Quantum)*(ptr_r++);
          pixels->green = (Magick::Quantum)*(ptr_g++);
          pixels->blue = (Magick::Quantum)*(ptr_b++);
          ++pixels;
        }
      }
      image.syncPixels();
      image.write(filename);
      return *this;
#else
      cimg::unused(bytes_per_pixel);
      throw CImgIOException(_cimg_instance
                            "save_magick(): Unable to save file '%s' unless libMagick++ is enabled.",
                            cimg_instance,
                            filename);
#endif
    }

// Assembly:
pushq %rbx
subq $0xb0, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movl %edx, 0x9c(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0xa0(%rsp)
jne 0xb47e4
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x50(%rsp)
movl (%rax), %ecx
movl %ecx, 0x58(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x5c(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x60(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x64(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x68(%rsp)
movb 0x10(%rax), %dl
leaq 0x3428c(%rip), %rcx     # 0xe89d2
leaq 0x15394(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x70(%rsp)
callq 0x118f0
movq %rax, 0x78(%rsp)
jmp 0xb4765
movl 0x64(%rsp), %r9d
movl 0x60(%rsp), %r8d
movl 0x5c(%rsp), %ecx
movl 0x58(%rsp), %edx
movq 0x50(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %r10
movq 0x78(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x38724(%rip), %rsi     # 0xecec4
xorl %eax, %eax
callq 0x12220
jmp 0xb47a9
movq 0x50(%rsp), %rdi
leaq 0x4b3ab(%rip), %rsi     # 0xffb60
leaq -0xa235c(%rip), %rdx    # 0x12460
callq 0x5920
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x53a0
jmp 0xb4915
movq 0x80(%rsp), %rdi
callq 0x10320
testb $0x1, %al
jne 0xb47f7
jmp 0xb4819
movq 0xa0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x9c310
movq 0x80(%rsp), %rax
addq $0xb0, %rsp
popq %rbx
retq
xorl %eax, %eax
leaq 0x9c(%rsp), %rdi
callq 0x5be30
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x20(%rsp)
movl (%rax), %ecx
movl %ecx, 0x28(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x2c(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x30(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x34(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x38(%rsp)
movb 0x10(%rax), %dl
leaq 0x34162(%rip), %rcx     # 0xe89d2
leaq 0x1526a(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x40(%rsp)
callq 0x118f0
movq %rax, 0x48(%rsp)
jmp 0xb488f
movl 0x34(%rsp), %r9d
movl 0x30(%rsp), %r8d
movl 0x2c(%rsp), %ecx
movl 0x28(%rsp), %edx
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %r10
movq 0x48(%rsp), %r11
movq 0xa0(%rsp), %rbx
movq %rsp, %rax
movq %rbx, 0x18(%rax)
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x38649(%rip), %rsi     # 0xecf1f
xorl %eax, %eax
callq 0x5c880
jmp 0xb48df
movq 0x20(%rsp), %rdi
leaq 0x4b385(%rip), %rsi     # 0xffc70
leaq -0x57e32(%rip), %rdx    # 0x5cac0
callq 0x5920
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x53a0
movq 0x90(%rsp), %rdi
callq 0x5970
nopw %cs:(%rax,%rax)
nopl (%rax)