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

      double stmin, stmax = (double)max_min(stmin);
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_pnm(): 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_pnm(): Instance is multispectral, only the three first channels will be saved in file '%s'.",
                   cimg_instance,
                   filename?filename:"(FILE*)");
      if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
        cimg::warn(_cimg_instance
                   "save_pnm(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.",
                   cimg_instance,
                   stmin,stmax,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 long buf_size = cimg::min(1024*1024UL,_width*_height*(_spectrum==1?1UL:3UL));

      std::fprintf(nfile,"P%c\n%u %u\n%u\n",
                   (_spectrum==1?'5':'6'),_width,_height,stmax<256?255:(stmax<4096?4095:65535));

      switch (_spectrum) {
      case 1 : { // Scalar image
        if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PGM 8 bits
          CImg<ucharT> 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);
            unsigned char *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) *(ptrd++) = (unsigned char)*(ptr_r++);
            cimg::fwrite(buf._data,N,nfile);
            to_write-=N;
          }
        } else { // Binary PGM 16 bits
          CImg<ushortT> 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);
            unsigned short *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) *(ptrd++) = (unsigned short)*(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
        if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PPM 8 bits
          CImg<ucharT> 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/3);
            unsigned char *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) {
              *(ptrd++) = (unsigned char)*(ptr_r++);
              *(ptrd++) = (unsigned char)*(ptr_g++);
              *(ptrd++) = 0;
            }
            cimg::fwrite(buf._data,3*N,nfile);
            to_write-=N;
          }
        } else {             // Binary PPM 16 bits
          CImg<ushortT> 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/3);
            unsigned short *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) {
              *(ptrd++) = (unsigned short)*(ptr_r++);
              *(ptrd++) = (unsigned short)*(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
        if (bytes_per_pixel==1 || (!bytes_per_pixel && stmax<256)) { // Binary PPM 8 bits
          CImg<ucharT> 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/3);
            unsigned char *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) {
              *(ptrd++) = (unsigned char)*(ptr_r++);
              *(ptrd++) = (unsigned char)*(ptr_g++);
              *(ptrd++) = (unsigned char)*(ptr_b++);
            }
            cimg::fwrite(buf._data,3*N,nfile);
            to_write-=N;
          }
        } else {             // Binary PPM 16 bits
          CImg<ushortT> 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/3);
            unsigned short *ptrd = buf._data;
            for (unsigned long i = N; i>0; --i) {
              *(ptrd++) = (unsigned short)*(ptr_r++);
              *(ptrd++) = (unsigned short)*(ptr_g++);
              *(ptrd++) = (unsigned short)*(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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r15
movq %rsi, %rax
orq %rdx, %rax
je 0x47c6f
movl %ecx, %r13d
movq %rdx, %r12
movq %rsi, %r14
movq %r15, %rdi
callq 0x8dc8
testb %al, %al
je 0x47656
movq %r14, %rdi
movq %r12, %rsi
callq 0x465c3
jmp 0x47c5d
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x47d1a
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movl 0x8(%r15), %ecx
cmpl $0x2, %ecx
jb 0x476cc
leaq 0xd16b(%rip), %rax      # 0x547e8
leaq 0xe53e(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
testq %r12, %r12
movl (%r15), %esi
movl 0x4(%r15), %edx
movl 0xc(%r15), %r8d
movq 0x18(%r15), %r9
leaq 0x2dec1(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2d9ea(%rip), %rbx     # 0x7509f
leaq 0x308f0(%rip), %rdi     # 0x77fac
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movl 0xc(%r15), %r8d
cmpl $0x4, %r8d
jb 0x4772c
leaq 0xd10b(%rip), %rax      # 0x547e8
leaq 0xe4de(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
testq %r12, %r12
movl (%r15), %esi
movl 0x4(%r15), %edx
movl 0x8(%r15), %ecx
movq 0x18(%r15), %r9
leaq 0x2de61(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2d98a(%rip), %rbx     # 0x7509f
leaq 0x30913(%rip), %rdi     # 0x7802f
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movsd 0x40(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x4779e
leaq 0xd0a5(%rip), %rax      # 0x547e8
cmpb $0x0, 0x10(%r15)
leaq 0xe473(%rip), %r10      # 0x55bc2
cmovneq %rax, %r10
testq %r12, %r12
movl (%r15), %esi
movl 0x4(%r15), %edx
movl 0x8(%r15), %ecx
movl 0xc(%r15), %r8d
movq 0x18(%r15), %r9
leaq 0x2ddf7(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2d920(%rip), %rbx     # 0x7509f
leaq 0x30938(%rip), %rdi     # 0x780be
movsd 0x38(%rsp), %xmm1
movb $0x2, %al
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
jmp 0x477ce
cmpl $0x1, %r13d
sete %al
movsd 0x30(%rsp), %xmm1
ucomisd 0xc8dd(%rip), %xmm1     # 0x54090
setae %cl
testb %cl, %al
jne 0x4773c
movsd 0x30(%rsp), %xmm1
ucomisd 0xc8d0(%rip), %xmm1     # 0x54098
jae 0x4773c
movq %r14, 0x8(%rsp)
movq %r14, 0x38(%rsp)
testq %r14, %r14
jne 0x477f1
leaq 0x2d7f9(%rip), %rsi     # 0x74fdd
movq %r12, %rdi
callq 0x2dca5
movq %rax, 0x8(%rsp)
movq 0x18(%r15), %r14
movl (%r15), %ecx
movl 0x4(%r15), %r8d
movl 0xc(%r15), %eax
cmpl $0x2, %eax
movq %r15, (%rsp)
jb 0x4782a
movl 0x8(%r15), %edx
movq %r8, %rbx
imulq %rcx, %rbx
imulq %rdx, %rbx
leaq (%r14,%rbx,8), %rbp
cmpl $0x2, %eax
je 0x4782c
shlq $0x4, %rbx
addq %r14, %rbx
jmp 0x4782e
xorl %ebp, %ebp
xorl %ebx, %ebx
movl %r8d, %esi
imull %ecx, %esi
xorl %edx, %edx
cmpl $0x1, %eax
setne %dl
leaq 0x1(,%rdx,2), %r12
imulq %rsi, %r12
movl $0x100000, %eax         # imm = 0x100000
cmpq %rax, %r12
cmovaeq %rax, %r12
addl $0x35, %edx
movsd 0xc841(%rip), %xmm0     # 0x540a0
movsd 0x30(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movl $0xfff, %eax            # imm = 0xFFF
movl $0xffff, %esi           # imm = 0xFFFF
cmoval %eax, %esi
movsd 0xc812(%rip), %xmm0     # 0x54090
ucomisd %xmm1, %xmm0
seta %r15b
movl $0xff, %r9d
cmovbel %esi, %r9d
leaq 0x308ac(%rip), %rsi     # 0x78143
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x4750
movq (%rsp), %rax
movl 0xc(%rax), %eax
cmpl $0x1, %r13d
sete %dl
testl %r13d, %r13d
sete %cl
andb %r15b, %cl
orb %dl, %cl
cmpl $0x2, %eax
je 0x4793d
cmpl $0x1, %eax
jne 0x479cf
testb %cl, %cl
je 0x47a69
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0xbbfa
movq (%rsp), %r15
movl (%r15), %eax
movl 0x4(%r15), %ebx
imulq %rax, %rbx
testq %rbx, %rbx
jle 0x47c15
cmpq %r12, %rbx
movq %r12, %r13
cmovbq %rbx, %r13
movq 0x28(%rsp), %rax
xorl %ecx, %ecx
cmpq %rcx, %r13
je 0x47926
cvttsd2si (%r14), %edx
addq $0x8, %r14
movb %dl, (%rax,%rcx)
incq %rcx
jmp 0x47910
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
callq 0x46d25
subq %r13, %rbx
jmp 0x478f6
pushq $0x3
popq %rsi
movl %r12d, %eax
xorl %edx, %edx
divl %esi
movl %eax, %r13d
testb %cl, %cl
je 0x47add
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0xbbfa
movq (%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ebx
imulq %rax, %rbx
testq %rbx, %rbx
jle 0x47c2d
cmpq %r13, %rbx
movq %r13, %r15
cmovbq %rbx, %r15
movq 0x28(%rsp), %rax
leaq (%r15,%r15,2), %rsi
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0x479bb
cvttsd2si (%r14), %edx
addq $0x8, %r14
movb %dl, (%rax,%rcx)
cvttsd2si (%rbp), %edx
addq $0x8, %rbp
movb %dl, 0x1(%rax,%rcx)
movb $0x0, 0x2(%rax,%rcx)
addq $0x3, %rcx
jmp 0x47992
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rdx
callq 0x46d25
subq %r15, %rbx
jmp 0x47974
pushq $0x3
popq %rsi
movl %r12d, %eax
xorl %edx, %edx
divl %esi
movl %eax, %r13d
testb %cl, %cl
je 0x47b6e
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0xbbfa
movq (%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %r15d
imulq %rax, %r15
testq %r15, %r15
jle 0x47c31
cmpq %r13, %r15
movq %r13, %r12
cmovbq %r15, %r12
movq 0x28(%rsp), %rax
leaq (%r12,%r12,2), %rsi
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0x47a55
cvttsd2si (%r14), %edx
addq $0x8, %r14
movb %dl, (%rax,%rcx)
cvttsd2si (%rbp), %edx
movb %dl, 0x1(%rax,%rcx)
cvttsd2si (%rbx), %edx
addq $0x8, %rbp
addq $0x8, %rbx
movb %dl, 0x2(%rax,%rcx)
addq $0x3, %rcx
jmp 0x47a25
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rdx
callq 0x46d25
subq %r12, %r15
jmp 0x47a07
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0x3b1a8
movq (%rsp), %r15
movl (%r15), %eax
movl 0x4(%r15), %ebx
imulq %rax, %rbx
testq %rbx, %rbx
jle 0x47c21
cmpq %r12, %rbx
movq %r12, %r13
cmovbq %rbx, %r13
movq 0x28(%rsp), %rdi
xorl %eax, %eax
cmpq %rax, %r13
je 0x47abe
cvttsd2si (%r14), %ecx
addq $0x8, %r14
movw %cx, (%rdi,%rax,2)
incq %rax
jmp 0x47aa7
movq %r12, %rsi
callq 0x37dec
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
callq 0x47e16
subq %r13, %rbx
jmp 0x47a8d
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0x3b1a8
movq (%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ebx
imulq %rax, %rbx
testq %rbx, %rbx
jle 0x47c2f
cmpq %r13, %rbx
movq %r13, %r15
cmovbq %rbx, %r15
movq 0x28(%rsp), %rdi
imulq $0x6, %r15, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x47b4e
movsd (%r14), %xmm0
addq $0x8, %r14
movhpd (%rbp), %xmm0           # xmm0 = xmm0[0],mem[0]
addq $0x8, %rbp
cvttpd2dq %xmm0, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, (%rdi,%rcx)
andw $0x0, 0x4(%rdi,%rcx)
addq $0x6, %rcx
jmp 0x47b1d
movq %r12, %rsi
callq 0x37dec
movq 0x28(%rsp), %rdi
leaq (%r15,%r15,2), %rsi
movq 0x8(%rsp), %rdx
callq 0x47e16
subq %r15, %rbx
jmp 0x47aff
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r12d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0x3b1a8
movq (%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %r15d
imulq %rax, %r15
movq %r13, 0x30(%rsp)
testq %r15, %r15
jle 0x47c3d
cmpq %r13, %r15
cmovbq %r15, %r13
movq 0x28(%rsp), %rdi
imulq $0x6, %r13, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x47be9
movsd (%r14), %xmm0
movhpd (%rbp), %xmm0           # xmm0 = xmm0[0],mem[0]
addq $0x8, %r14
cvttpd2dq %xmm0, %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, (%rdi,%rcx)
cvttsd2si (%rbx), %edx
addq $0x8, %rbp
addq $0x8, %rbx
movw %dx, 0x4(%rdi,%rcx)
addq $0x6, %rcx
jmp 0x47bb1
movq %r12, %rsi
callq 0x37dec
movq 0x28(%rsp), %rdi
leaq (,%r13,2), %rsi
addq %r13, %rsi
movq 0x8(%rsp), %rdx
callq 0x47e16
subq %r13, %r15
movq 0x30(%rsp), %r13
jmp 0x47b96
leaq 0x10(%rsp), %rdi
callq 0xb8ae
jmp 0x47c4b
leaq 0x10(%rsp), %rdi
callq 0x37e06
jmp 0x47c4b
jmp 0x47c31
jmp 0x47c3d
leaq 0x10(%rsp), %rdi
callq 0xb8ae
jmp 0x47c47
leaq 0x10(%rsp), %rdi
callq 0x37e06
movq (%rsp), %r15
cmpq $0x0, 0x38(%rsp)
jne 0x47c5d
movq 0x8(%rsp), %rdi
callq 0x2a2f8
movq %r15, %rax
addq $0x48, %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 (%r15), %edx
movl 0x4(%r15), %ecx
movl 0x8(%r15), %r8d
movl 0xc(%r15), %r9d
leaq 0xcb56(%rip), %rax      # 0x547e8
leaq 0xdf29(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2d3f2(%rip), %r11     # 0x7509f
leaq 0x302a0(%rip), %rsi     # 0x77f54
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%r15)
callq 0x9d52
addq $0x20, %rsp
leaq 0x47f8f(%rip), %rsi     # 0x8fc60
movq 0x48300(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
jmp 0x47d11
jmp 0x47cf3
jmp 0x47d04
jmp 0x47cf3
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x37e06
jmp 0x47d11
jmp 0x47d04
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xb8ae
movq %rbx, %rdi
callq 0x4950
nop