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

      const unsigned long buf_size = cimg::min(1024*1024LU,_width*_height*_depth);
      std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
      const T *ptr = data(0,0,0,0);

      if (!cimg::type<T>::is_float() && sizeof(T)==1 && _depth<2) // Can be saved as regular PNM file.
        _save_pnm(file,filename,0);
      else if (!cimg::type<T>::is_float() && sizeof(T)==1) { // Save as extended P5 file: Binary byte-valued 3d.
        std::fprintf(nfile,"P5\n%u %u %u\n255\n",_width,_height,_depth);
        CImg<ucharT> buf(buf_size);
        for (long to_write = (long)_width*_height*_depth; 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++);
          cimg::fwrite(buf._data,N,nfile);
          to_write-=N;
        }
      } else if (!cimg::type<T>::is_float()) { // Save as P8: Binary int32-valued 3d.
        if (_depth>1) std::fprintf(nfile,"P8\n%u %u %u\n%d\n",_width,_height,_depth,(int)max());
        else std::fprintf(nfile,"P8\n%u %u\n%d\n",_width,_height,(int)max());
        CImg<intT> buf(buf_size);
        for (long to_write = (long)_width*_height*_depth; to_write>0; ) {
          const unsigned long N = cimg::min((unsigned long)to_write,buf_size);
          int *ptrd = buf._data;
          for (unsigned long i = N; i>0; --i) *(ptrd++) = (int)*(ptr++);
          cimg::fwrite(buf._data,N,nfile);
          to_write-=N;
        }
      } else { // Save as P9: Binary float-valued 3d.
        if (_depth>1) std::fprintf(nfile,"P9\n%u %u %u\n%g\n",_width,_height,_depth,(double)max());
        else std::fprintf(nfile,"P9\n%u %u\n%g\n",_width,_height,(double)max());
        CImg<floatT> buf(buf_size);
        for (long to_write = (long)_width*_height*_depth; 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++);
          cimg::fwrite(buf._data,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 $0x38, %rsp
movq %rdi, %rbx
movq %rsi, %rax
orq %rdx, %rax
je 0x480d7
movq %rdx, %r13
movq %rsi, %r12
movq %rbx, %rdi
callq 0x8dc8
testb %al, %al
je 0x47f57
movq %r12, %rdi
movq %r13, %rsi
callq 0x465c3
jmp 0x480c5
movl 0xc(%rbx), %r8d
cmpl $0x2, %r8d
jb 0x47fb4
leaq 0xc880(%rip), %rax      # 0x547e8
leaq 0xdc53(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
testq %r13, %r13
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movl 0x8(%rbx), %ecx
movq 0x18(%rbx), %r9
leaq 0x2d5da(%rip), %r11     # 0x75567
cmovneq %r13, %r11
subq $0x8, %rsp
leaq 0x2d103(%rip), %r14     # 0x7509f
leaq 0x30206(%rip), %rdi     # 0x781a9
xorl %eax, %eax
pushq %r11
pushq %r14
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movl %ecx, %r15d
imull %r14d, %r15d
movl 0x8(%rbx), %ebp
imull %ebp, %r15d
movl $0x100000, %eax         # imm = 0x100000
cmpl %eax, %r15d
cmovael %eax, %r15d
movq %r12, 0x10(%rsp)
testq %r12, %r12
jne 0x47ff9
leaq 0x2cff8(%rip), %rsi     # 0x74fdd
movq %r13, %rdi
callq 0x2dca5
movq %rax, %r12
movl (%rbx), %r14d
movl 0x4(%rbx), %ecx
movl 0x8(%rbx), %ebp
movl %ecx, 0xc(%rsp)
movq 0x18(%rbx), %r13
movq %rbx, %rdi
callq 0x48166
movsd (%rax), %xmm0
cmpl $0x2, %ebp
jb 0x4802f
leaq 0x30218(%rip), %rsi     # 0x78231
movq %r12, %rdi
movl %r14d, %edx
movl 0xc(%rsp), %ecx
movl %ebp, %r8d
movb $0x1, %al
callq 0x4750
jmp 0x48047
leaq 0x3020b(%rip), %rsi     # 0x78241
movq %r12, %rdi
movl %r14d, %edx
movl 0xc(%rsp), %ecx
movb $0x1, %al
callq 0x4750
leaq 0x18(%rsp), %rdi
pushq $0x1
popq %rcx
movl %r15d, %esi
movl %ecx, %edx
movl %ecx, %r8d
callq 0x17dbc
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %ebp
imulq %rcx, %rbp
testq %rbp, %rbp
jle 0x480ab
cmpq %r15, %rbp
movq %r15, %r14
cmovbq %rbp, %r14
movq 0x30(%rsp), %rdi
xorl %eax, %eax
cmpq %rax, %r14
je 0x4809b
cvtsd2ss (%r13), %xmm0
addq $0x8, %r13
movss %xmm0, (%rdi,%rax,4)
incq %rax
jmp 0x48082
movq %r14, %rsi
movq %r12, %rdx
callq 0x48243
subq %r14, %rbp
jmp 0x4806c
leaq 0x18(%rsp), %rdi
callq 0x17c20
cmpq $0x0, 0x10(%rsp)
jne 0x480c5
movq %r12, %rdi
callq 0x2a2f8
movq %rbx, %rax
addq $0x38, %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 (%rbx), %edx
movl 0x4(%rbx), %ecx
movl 0x8(%rbx), %r8d
movl 0xc(%rbx), %r9d
leaq 0xc6f0(%rip), %rax      # 0x547e8
leaq 0xdac3(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2cf8d(%rip), %r11     # 0x7509f
leaq 0x30038(%rip), %rsi     # 0x78151
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%rbx)
callq 0x9d52
addq $0x20, %rsp
leaq 0x47b2b(%rip), %rsi     # 0x8fc60
movq 0x47e9c(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
jmp 0x4815e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x17c20
movq %rbx, %rdi
callq 0x4950