// File: /workspace/github_cpp_makefile_star2_O1/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 0x61f2c
movq %rdx, %r13
movq %rsi, %r14
movq 0x18(%rbx), %r9
testq %r9, %r9
je 0x61e0e
movdqu (%rbx), %xmm0
pxor %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %eax
testb %al, %al
jne 0x61e0e
movl 0xc(%rbx), %r8d
cmpl $0x2, %r8d
movq %rbx, 0x8(%rsp)
jb 0x61d95
leaq 0x115fd(%rip), %rax     # 0x73338
cmpb $0x0, 0x10(%rbx)
leaq 0x129cc(%rip), %r10     # 0x74712
cmovneq %rax, %r10
testq %r13, %r13
leaq 0x3238d(%rip), %r11     # 0x940e1
cmovneq %r13, %r11
movd %xmm0, %esi
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %edx
pshufd $0xee, %xmm0, %xmm0     # xmm0 = xmm0[2,3,2,3]
movd %xmm0, %ecx
subq $0x8, %rsp
leaq 0x31e76(%rip), %rbx     # 0x93bef
leaq 0x34fa3(%rip), %rdi     # 0x96d23
xorl %eax, %eax
pushq %r11
pushq %rbx
movq 0x20(%rsp), %rbx
pushq %r10
callq 0xbb52
addq $0x20, %rsp
movl 0x4(%rbx), %ebp
imull (%rbx), %ebp
imull 0x8(%rbx), %ebp
movl $0x100000, %r12d        # imm = 0x100000
cmpl %r12d, %ebp
cmovbl %ebp, %r12d
movq %r14, %r15
movq %r14, 0x10(%rsp)
testq %r14, %r14
jne 0x61dcb
leaq 0x31d6d(%rip), %rsi     # 0x93b2d
movq %r13, %rdi
callq 0x3ceb3
movq %rax, %r15
movq 0x18(%rbx), %r14
movl (%rbx), %eax
movl %eax, (%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x4(%rsp)
movl 0x8(%rbx), %r13d
movq %rbx, %rdi
callq 0x61fc8
movsd (%rax), %xmm0
cmpl $0x2, %r13d
jb 0x61e1e
leaq 0x34fb3(%rip), %rsi     # 0x96dab
movq %r15, %rdi
movl (%rsp), %edx
movl 0x4(%rsp), %ecx
movl %r13d, %r8d
movb $0x1, %al
callq 0x4740
jmp 0x61e36
movq %r14, %rdi
movq %r13, %rsi
callq 0x5f9f0
jmp 0x61ecf
leaq 0x34f96(%rip), %rsi     # 0x96dbb
movq %r15, %rdi
movl (%rsp), %edx
movl 0x4(%rsp), %ecx
movb $0x1, %al
callq 0x4740
leaq 0x18(%rsp), %rdi
movl %r12d, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1de54
movl (%rbx), %eax
movl 0x4(%rbx), %ecx
imulq %rax, %rcx
movl 0x8(%rbx), %ebx
imulq %rcx, %rbx
testq %rbx, %rbx
je 0x61eac
cmpq %r12, %rbx
movq %r12, %r13
cmovbq %rbx, %r13
movq 0x30(%rsp), %rdi
testl %ebp, %ebp
je 0x61e9c
xorl %eax, %eax
xorl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsd2ss (%r14,%rcx,8), %xmm0
movss %xmm0, (%rdi,%rcx,4)
incq %rcx
addq $-0x8, %rax
cmpq %rcx, %r13
jne 0x61e7f
subq %rax, %r14
movq %r13, %rsi
movq %r15, %rdx
callq 0x620c5
subq %r13, %rbx
jg 0x61e68
cmpb $0x0, 0x28(%rsp)
jne 0x61ec2
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x61ec2
callq 0x4680
cmpq $0x0, 0x10(%rsp)
movq 0x8(%rsp), %rbx
je 0x61ee1
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0x61f1c
movq 0x4b0bb(%rip), %rax     # 0xacfa8
cmpq %r15, (%rax)
je 0x61ecf
movq 0x4b08f(%rip), %rax     # 0xacf88
cmpq %r15, (%rax)
je 0x61ecf
movq %r15, %rdi
callq 0x4540
testl %eax, %eax
je 0x61ecf
leaq 0x31bbb(%rip), %rdi     # 0x93acc
movl %eax, %esi
xorl %eax, %eax
callq 0xbb52
jmp 0x61ecf
leaq 0x31b7f(%rip), %rdi     # 0x93aa2
xorl %eax, %eax
callq 0xbb52
jmp 0x61ecf
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 0x113eb(%rip), %rax     # 0x73338
leaq 0x127be(%rip), %r10     # 0x74712
cmpb $0x0, 0x10(%rbx)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x31c88(%rip), %r11     # 0x93bef
leaq 0x34d5d(%rip), %rsi     # 0x96ccb
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%rbx)
callq 0xc196
addq $0x20, %rsp
leaq 0x4ac96(%rip), %rsi     # 0xacc20
movq 0x4b03f(%rip), %rdx     # 0xacfd0
movq %r14, %rdi
callq 0x4900
movq %rax, %rbx
movq %r14, %rdi
callq 0x43b0
jmp 0x61fbf
movq %rax, %rbx
cmpb $0x0, 0x28(%rsp)
jne 0x61fbf
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x61fbf
callq 0x4680
movq %rbx, %rdi
callq 0x4950
nop