// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::_save_pfm(_IO_FILE*, char const*) const
const CImg<T>& _save_pfm(std::FILE *const file, const char *const filename) const {
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_pfm(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(file,filename); return *this; }
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_pfm(): Instance is volumetric, only the first slice will be saved in file '%s'.",
                   cimg_instance,
                   filename?filename:"(FILE*)");
      if (_spectrum>3)
        cimg::warn(_cimg_instance
                   "save_pfm(): image instance is multispectral, only the three first channels will be saved "
                   "in file '%s'.",
                   cimg_instance,
                   filename?filename:"(FILE*)");

      std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
      const T
        *ptr_r = data(0,0,0,0),
        *ptr_g = (_spectrum>=2)?data(0,0,0,1):0,
        *ptr_b = (_spectrum>=3)?data(0,0,0,2):0;
      const unsigned int buf_size = cimg::min(1024*1024U,_width*_height*(_spectrum==1?1:3));

      std::fprintf(nfile,"P%c\n%u %u\n1.0\n",
                   (_spectrum==1?'f':'F'),_width,_height);

      switch (_spectrum) {
      case 1 : { // Scalar image
        CImg<floatT> buf(buf_size);
        for (long to_write = (long)_width*_height; to_write>0; ) {
          const unsigned long N = cimg::min((unsigned long)to_write,buf_size);
          float *ptrd = buf._data;
          for (unsigned long i = N; i>0; --i) *(ptrd++) = (float)*(ptr_r++);
          if (!cimg::endianness()) cimg::invert_endianness(buf._data,buf_size);
          cimg::fwrite(buf._data,N,nfile);
          to_write-=N;
        }
      } break;
      case 2 : { // RG image
        CImg<floatT> buf(buf_size);
        for (long to_write = (long)_width*_height; to_write>0; ) {
          const unsigned int N = cimg::min((unsigned int)to_write,buf_size/3);
          float *ptrd = buf._data;
          for (unsigned long i = N; i>0; --i) {
            *(ptrd++) = (float)*(ptr_r++);
            *(ptrd++) = (float)*(ptr_g++);
            *(ptrd++) = 0;
          }
          if (!cimg::endianness()) cimg::invert_endianness(buf._data,buf_size);
          cimg::fwrite(buf._data,3*N,nfile);
          to_write-=N;
        }
      } break;
      default : { // RGB image
        CImg<floatT> buf(buf_size);
        for (long to_write = (long)_width*_height; to_write>0; ) {
          const unsigned int N = cimg::min((unsigned int)to_write,buf_size/3);
          float *ptrd = buf._data;
          for (unsigned long i = N; i>0; --i) {
            *(ptrd++) = (float)*(ptr_r++);
            *(ptrd++) = (float)*(ptr_g++);
            *(ptrd++) = (float)*(ptr_b++);
          }
          if (!cimg::endianness()) cimg::invert_endianness(buf._data,buf_size);
          cimg::fwrite(buf._data,3*N,nfile);
          to_write-=N;
        }
      }
      }
      if (!file) cimg::fclose(nfile);
      return *this;
    }

// Assembly:
subq $0x208, %rsp            # imm = 0x208
movq %rdi, 0x1f8(%rsp)
movq %rsi, 0x1f0(%rsp)
movq %rdx, 0x1e8(%rsp)
movq 0x1f8(%rsp), %rax
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0x1f0(%rsp)
jne 0xa1809
cmpq $0x0, 0x1e8(%rsp)
jne 0xa1809
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0xc8(%rsp), %rax
movq %rcx, 0x98(%rsp)
movl (%rax), %ecx
movl %ecx, 0xa0(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0xa4(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0xa8(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0xac(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0xb0(%rsp)
movb 0x10(%rax), %dl
leaq 0x4728b(%rip), %rcx     # 0xe89d2
leaq 0x28393(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xb8(%rsp)
callq 0x118f0
movq %rax, 0xc0(%rsp)
jmp 0xa176c
movl 0xac(%rsp), %r9d
movl 0xa8(%rsp), %r8d
movl 0xa4(%rsp), %ecx
movl 0xa0(%rsp), %edx
movq 0x98(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %r10
movq 0xc0(%rsp), %r11
movq %rsp, %rax
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x4aa39(%rip), %rsi     # 0xec1f8
xorl %eax, %eax
callq 0x12220
jmp 0xa17c8
movq 0x98(%rsp), %rdi
leaq 0x5e389(%rip), %rsi     # 0xffb60
leaq -0x8f37e(%rip), %rdx    # 0x12460
callq 0x5920
movq 0x98(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
callq 0x53a0
jmp 0xa2165
movq 0xc8(%rsp), %rdi
callq 0x10320
testb $0x1, %al
jne 0xa181c
jmp 0xa1846
movq 0x1f0(%rsp), %rdi
movq 0x1e8(%rsp), %rsi
callq 0x9c310
movq 0xc8(%rsp), %rax
movq %rax, 0x200(%rsp)
jmp 0xa2155
movq 0xc8(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jbe 0xa1926
movq 0xc8(%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0x70(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x74(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x78(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x7c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x80(%rsp)
movb 0x10(%rax), %dl
leaq 0x28250(%rip), %rax     # 0xc9ae1
leaq 0x4713a(%rip), %rcx     # 0xe89d2
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x88(%rsp)
callq 0x118f0
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x1e8(%rsp)
je 0xa18ce
movq 0x1e8(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0xa18dc
leaq 0x47bb5(%rip), %rax     # 0xe948a
movq %rax, 0x68(%rsp)
jmp 0xa18dc
movq 0x90(%rsp), %r10
movq 0x88(%rsp), %r11
movq 0x80(%rsp), %r9
movl 0x7c(%rsp), %r8d
movl 0x78(%rsp), %ecx
movl 0x74(%rsp), %edx
movl 0x70(%rsp), %esi
movq 0x68(%rsp), %rax
leaq 0x4a93f(%rip), %rdi     # 0xec250
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x117e0
movq 0xc8(%rsp), %rax
cmpl $0x3, 0xc(%rax)
jbe 0xa19f4
movq 0xc8(%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0x40(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x44(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x48(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x4c(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x50(%rsp)
movb 0x10(%rax), %dl
leaq 0x28173(%rip), %rax     # 0xc9ae1
leaq 0x4705d(%rip), %rcx     # 0xe89d2
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x58(%rsp)
callq 0x118f0
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x1e8(%rsp)
je 0xa19a5
movq 0x1e8(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0xa19b3
leaq 0x47ade(%rip), %rax     # 0xe948a
movq %rax, 0x38(%rsp)
jmp 0xa19b3
movq 0x60(%rsp), %r10
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r9
movl 0x4c(%rsp), %r8d
movl 0x48(%rsp), %ecx
movl 0x44(%rsp), %edx
movl 0x40(%rsp), %esi
movq 0x38(%rsp), %rax
leaq 0x4a8f4(%rip), %rdi     # 0xec2d3
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x117e0
cmpq $0x0, 0x1f0(%rsp)
je 0xa1a0e
movq 0x1f0(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0xa1a27
movq 0x1e8(%rsp), %rdi
leaq 0x474e3(%rip), %rsi     # 0xe8f00
callq 0x654a0
movq %rax, 0x30(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, 0x1d0(%rsp)
xorl %r8d, %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x73790
movq %rax, %rcx
movq 0xc8(%rsp), %rax
movq %rcx, 0x1c8(%rsp)
cmpl $0x2, 0xc(%rax)
jb 0xa1a86
movq 0xc8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x1, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x28(%rsp)
jmp 0xa1a8f
xorl %eax, %eax
movq %rax, 0x28(%rsp)
jmp 0xa1a8f
movq 0xc8(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x1c0(%rsp)
cmpl $0x3, 0xc(%rax)
jb 0xa1aca
movq 0xc8(%rsp), %rdi
xorl %ecx, %ecx
movl $0x2, %r8d
movl %ecx, %esi
movl %ecx, %edx
callq 0x73790
movq %rax, 0x20(%rsp)
jmp 0xa1ad3
xorl %eax, %eax
movq %rax, 0x20(%rsp)
jmp 0xa1ad3
movq 0xc8(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movl $0x100000, 0x1b0(%rsp) # imm = 0x100000
movl (%rcx), %eax
movl 0x4(%rcx), %edx
imull %edx, %eax
movl 0xc(%rcx), %ecx
subl $0x1, %ecx
setne %cl
movzbl %cl, %edx
movl %edx, %ecx
leal 0x1(%rcx,%rcx), %ecx
imull %ecx, %eax
movl %eax, 0x1ac(%rsp)
leaq 0x1b0(%rsp), %rdi
leaq 0x1ac(%rsp), %rsi
callq 0x23ba0
movl %eax, %ecx
movq 0xc8(%rsp), %rax
movl %ecx, 0x1b4(%rsp)
movq 0x1d0(%rsp), %rdi
movl 0xc(%rax), %ecx
subl $0x1, %ecx
sete %cl
movzbl %cl, %edx
shll $0x5, %edx
orl $0x46, %edx
movl (%rax), %ecx
movl 0x4(%rax), %r8d
leaq 0x4a804(%rip), %rsi     # 0xec368
xorl %eax, %eax
callq 0x5750
movq 0xc8(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x1c(%rsp)
subl $0x1, %eax
je 0xa1b93
jmp 0xa1b81
movl 0x1c(%rsp), %eax
subl $0x2, %eax
je 0xa1d19
jmp 0xa1f19
movl 0x1b4(%rsp), %esi
leaq 0x188(%rsp), %rdi
movl $0x1, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x31ac0
movq 0xc8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x180(%rsp)
cmpq $0x0, 0x180(%rsp)
jle 0xa1d07
movq 0x180(%rsp), %rax
movq %rax, 0x170(%rsp)
leaq 0x170(%rsp), %rdi
leaq 0x1b4(%rsp), %rsi
callq 0x30ea0
movq %rax, 0x178(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x178(%rsp), %rax
movq %rax, 0x160(%rsp)
cmpq $0x0, 0x160(%rsp)
jbe 0xa1c83
movq 0x1c8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1c8(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x168(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x168(%rsp)
movss %xmm0, (%rax)
movq 0x160(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x160(%rsp)
jmp 0xa1c28
callq 0x43af0
testb $0x1, %al
jne 0xa1ca2
movq 0x1a0(%rsp), %rdi
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0x7aaa0
movq 0x1a0(%rsp), %rdi
movq 0x178(%rsp), %rsi
movq 0x1d0(%rsp), %rdx
callq 0xa13e0
jmp 0xa1cc1
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x180(%rsp)
jmp 0xa1bcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x31710
jmp 0xa2165
leaq 0x188(%rsp), %rdi
callq 0x31710
jmp 0xa212d
movl 0x1b4(%rsp), %esi
leaq 0x140(%rsp), %rdi
movl $0x1, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x31ac0
movq 0xc8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0x138(%rsp)
cmpq $0x0, 0x138(%rsp)
jle 0xa1f07
movq 0x138(%rsp), %rax
movl %eax, 0x130(%rsp)
movl 0x1b4(%rsp), %eax
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, 0x12c(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x12c(%rsp), %rsi
callq 0x23ba0
movl %eax, 0x134(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x120(%rsp)
movl 0x134(%rsp), %eax
movq %rax, 0x118(%rsp)
cmpq $0x0, 0x118(%rsp)
jbe 0xa1e7c
movq 0x1c8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1c8(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x120(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x120(%rsp)
movss %xmm0, (%rax)
movq 0x1c0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1c0(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x120(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x120(%rsp)
movss %xmm0, (%rax)
movq 0x120(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0x120(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq 0x118(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x118(%rsp)
jmp 0xa1dc2
callq 0x43af0
testb $0x1, %al
jne 0xa1e9b
movq 0x158(%rsp), %rdi
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0x7aaa0
movq 0x158(%rsp), %rdi
movl 0x134(%rsp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, %esi
movq 0x1d0(%rsp), %rdx
callq 0xa13e0
jmp 0xa1ec0
movl 0x134(%rsp), %eax
movl %eax, %ecx
movq 0x138(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x138(%rsp)
jmp 0xa1d52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x31710
jmp 0xa2165
leaq 0x140(%rsp), %rdi
callq 0x31710
jmp 0xa212d
movl 0x1b4(%rsp), %esi
leaq 0xf8(%rsp), %rdi
movl $0x1, %r8d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x31ac0
movq 0xc8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
imulq %rcx, %rax
movq %rax, 0xf0(%rsp)
cmpq $0x0, 0xf0(%rsp)
jle 0xa2120
movq 0xf0(%rsp), %rax
movl %eax, 0xe8(%rsp)
movl 0x1b4(%rsp), %eax
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, 0xe4(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x23ba0
movl %eax, 0xec(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0xd8(%rsp)
movl 0xec(%rsp), %eax
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
jbe 0xa2098
movq 0x1c8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1c8(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0xd8(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0xd8(%rsp)
movss %xmm0, (%rax)
movq 0x1c0(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1c0(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0xd8(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0xd8(%rsp)
movss %xmm0, (%rax)
movq 0x1b8(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x1b8(%rsp)
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0xd8(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, 0xd8(%rsp)
movss %xmm0, (%rax)
movq 0xd0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0xd0(%rsp)
jmp 0xa1fc2
callq 0x43af0
testb $0x1, %al
jne 0xa20b7
movq 0x110(%rsp), %rdi
movl 0x1b4(%rsp), %eax
movl %eax, %esi
callq 0x7aaa0
movq 0x110(%rsp), %rdi
movl 0xec(%rsp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, %esi
movq 0x1d0(%rsp), %rdx
callq 0xa13e0
jmp 0xa20dc
movl 0xec(%rsp), %eax
movl %eax, %ecx
movq 0xf0(%rsp), %rax
subq %rcx, %rax
movq %rax, 0xf0(%rsp)
jmp 0xa1f52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x31710
jmp 0xa2165
leaq 0xf8(%rsp), %rdi
callq 0x31710
cmpq $0x0, 0x1f0(%rsp)
jne 0xa2145
movq 0x1d0(%rsp), %rdi
callq 0x5c6f0
movq 0xc8(%rsp), %rax
movq %rax, 0x200(%rsp)
movq 0x200(%rsp), %rax
addq $0x208, %rsp            # imm = 0x208
retq
movq 0x1e0(%rsp), %rdi
callq 0x5970
nopw %cs:(%rax,%rax)
nopl (%rax)