// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rdi, %rbx
movq %rsi, %rax
orq %rdx, %rax
je 0x5f3ef
movq %rdx, %r15
movq %rsi, %r13
movq 0x18(%rbx), %r9
testq %r9, %r9
sete %al
movl (%rbx), %esi
movl 0x4(%rbx), %ebp
testl %esi, %esi
sete %cl
orb %al, %cl
testl %ebp, %ebp
sete %al
movl 0x8(%rbx), %r14d
testl %r14d, %r14d
sete %dil
orb %al, %dil
orb %cl, %dil
movl 0xc(%rbx), %r8d
testl %r8d, %r8d
sete %al
orb %dil, %al
cmpb $0x1, %al
jne 0x5f1f4
movq %r13, %rdi
movq %r15, %rsi
callq 0x5ce0e
jmp 0x5f392
cmpl $0x2, %r8d
movq %rbx, 0x10(%rsp)
movq %r15, 0x18(%rsp)
jb 0x5f25d
leaq 0xf65d(%rip), %rax      # 0x6e868
leaq 0x10a30(%rip), %r10     # 0x6fc42
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
testq %r15, %r15
leaq 0x303ed(%rip), %r11     # 0x8f611
cmovneq %r15, %r11
subq $0x8, %rsp
leaq 0x2feec(%rip), %rbx     # 0x8f11f
leaq 0x33019(%rip), %rdi     # 0x92253
movl %ebp, %edx
movl %r14d, %ecx
xorl %eax, %eax
pushq %r11
pushq %rbx
movq 0x28(%rsp), %rbx
pushq %r10
callq 0xbb10
addq $0x20, %rsp
movl (%rbx), %esi
movl 0x4(%rbx), %ebp
movl 0x8(%rbx), %r14d
movl %ebp, 0xc(%rsp)
movl %esi, 0x8(%rsp)
imull %esi, %ebp
imull %r14d, %ebp
movl $0x100000, %r12d        # imm = 0x100000
cmpl %r12d, %ebp
cmovbl %ebp, %r12d
movq %r13, %r15
movq %r13, 0x20(%rsp)
testq %r13, %r13
jne 0x5f2ab
leaq 0x2fdd0(%rip), %rsi     # 0x8f05d
movq 0x18(%rsp), %rdi
callq 0x3b111
movq %rax, %r15
movl 0x8(%rbx), %r14d
movl (%rbx), %eax
movl %eax, 0x8(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%rbx), %r13
movq %rbx, %rdi
callq 0x5f48a
movsd (%rax), %xmm0
cmpl $0x2, %r14d
jb 0x5f2df
leaq 0x33013(%rip), %rsi     # 0x922db
movq %r15, %rdi
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
movl %r14d, %r8d
movb $0x1, %al
callq 0x4750
jmp 0x5f2f8
leaq 0x33005(%rip), %rsi     # 0x922eb
movq %r15, %rdi
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
movb $0x1, %al
callq 0x4750
leaq 0x28(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1de60
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %ebx
imulq %rcx, %rbx
testq %rbx, %rbx
je 0x5f36f
cmpq %r12, %rbx
movq %r12, %r14
cmovbq %rbx, %r14
movq 0x40(%rsp), %rdi
testl %ebp, %ebp
je 0x5f35f
xorl %eax, %eax
xorl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsd2ss (%r13,%rcx,8), %xmm0
movss %xmm0, (%rdi,%rcx,4)
incq %rcx
addq $-0x8, %rax
cmpq %rcx, %r14
jne 0x5f341
subq %rax, %r13
movq %r14, %rsi
movq %r15, %rdx
callq 0x5f576
subq %r14, %rbx
jg 0x5f32a
cmpb $0x0, 0x38(%rsp)
jne 0x5f385
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5f385
callq 0x4690
cmpq $0x0, 0x20(%rsp)
movq 0x10(%rsp), %rbx
je 0x5f3a4
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0x5f3df
movq 0x48bf8(%rip), %rax     # 0xa7fa8
cmpq %r15, (%rax)
je 0x5f392
movq 0x48bcc(%rip), %rax     # 0xa7f88
cmpq %r15, (%rax)
je 0x5f392
movq %r15, %rdi
callq 0x4550
testl %eax, %eax
je 0x5f392
leaq 0x2fc28(%rip), %rdi     # 0x8effc
movl %eax, %esi
xorl %eax, %eax
callq 0xbb10
jmp 0x5f392
leaq 0x2fbec(%rip), %rdi     # 0x8efd2
xorl %eax, %eax
callq 0xbb10
jmp 0x5f392
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 0xf458(%rip), %rax      # 0x6e868
leaq 0x1082b(%rip), %r10     # 0x6fc42
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2fcf5(%rip), %r11     # 0x8f11f
leaq 0x32dca(%rip), %rsi     # 0x921fb
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%rbx)
callq 0xc16a
addq $0x20, %rsp
leaq 0x48803(%rip), %rsi     # 0xa7c50
movq 0x48b7c(%rip), %rdx     # 0xa7fd0
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x43c0
jmp 0x5f482
movq %rax, %rbx
cmpb $0x0, 0x38(%rsp)
jne 0x5f482
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5f482
callq 0x4690
movq %rbx, %rdi
callq 0x4960