// File: /workspace/github_cpp_makefile_star2_O2/manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>::_save_bmp(_IO_FILE*, char const*) const
const CImg<T>& _save_bmp(std::FILE *const file, const char *const filename) const {
      if (!file && !filename)
        throw CImgArgumentException(_cimg_instance
                                    "save_bmp(): Specified filename is (null).",
                                    cimg_instance);
      if (is_empty()) { cimg::fempty(file,filename); return *this; }
      if (_depth>1)
        cimg::warn(_cimg_instance
                   "save_bmp(): 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_bmp(): 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");
      unsigned char header[54] = { 0 }, align_buf[4] = { 0 };
      const unsigned int
        align = (4 - (3*_width)%4)%4,
        buf_size = (3*_width + align)*height(),
        file_size = 54 + buf_size;
      header[0] = 'B'; header[1] = 'M';
      header[0x02] = file_size&0xFF;
      header[0x03] = (file_size>>8)&0xFF;
      header[0x04] = (file_size>>16)&0xFF;
      header[0x05] = (file_size>>24)&0xFF;
      header[0x0A] = 0x36;
      header[0x0E] = 0x28;
      header[0x12] = _width&0xFF;
      header[0x13] = (_width>>8)&0xFF;
      header[0x14] = (_width>>16)&0xFF;
      header[0x15] = (_width>>24)&0xFF;
      header[0x16] = _height&0xFF;
      header[0x17] = (_height>>8)&0xFF;
      header[0x18] = (_height>>16)&0xFF;
      header[0x19] = (_height>>24)&0xFF;
      header[0x1A] = 1;
      header[0x1B] = 0;
      header[0x1C] = 24;
      header[0x1D] = 0;
      header[0x22] = buf_size&0xFF;
      header[0x23] = (buf_size>>8)&0xFF;
      header[0x24] = (buf_size>>16)&0xFF;
      header[0x25] = (buf_size>>24)&0xFF;
      header[0x27] = 0x1;
      header[0x2B] = 0x1;
      cimg::fwrite(header,54,nfile);

      const T
        *ptr_r = data(0,_height-1,0,0),
        *ptr_g = (_spectrum>=2)?data(0,_height-1,0,1):0,
        *ptr_b = (_spectrum>=3)?data(0,_height-1,0,2):0;

      switch (_spectrum) {
      case 1 : {
        cimg_forY(*this,y) {
          cimg_forX(*this,x) {
            const unsigned char val = (unsigned char)*(ptr_r++);
            std::fputc(val,nfile); std::fputc(val,nfile); std::fputc(val,nfile);
          }
          cimg::fwrite(align_buf,align,nfile);
          ptr_r-=2*_width;
        }
      } break;
      case 2 : {
        cimg_forY(*this,y) {
          cimg_forX(*this,x) {
            std::fputc(0,nfile);
            std::fputc((unsigned char)(*(ptr_g++)),nfile);
            std::fputc((unsigned char)(*(ptr_r++)),nfile);
          }
          cimg::fwrite(align_buf,align,nfile);
          ptr_r-=2*_width; ptr_g-=2*_width;
        }
      } break;
      default : {
        cimg_forY(*this,y) {
          cimg_forX(*this,x) {
            std::fputc((unsigned char)(*(ptr_b++)),nfile);
            std::fputc((unsigned char)(*(ptr_g++)),nfile);
            std::fputc((unsigned char)(*(ptr_r++)),nfile);
          }
          cimg::fwrite(align_buf,align,nfile);
          ptr_r-=2*_width; ptr_g-=2*_width; ptr_b-=2*_width;
        }
      }
      }
      if (!file) cimg::fclose(nfile);
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r13
movq %rsi, %rax
orq %rdx, %rax
je 0x46ca0
movq %rdx, %r12
movq %rsi, %r14
movq %r13, %rdi
callq 0x8dc8
testb %al, %al
je 0x468e7
movq %r14, %rdi
movq %r12, %rsi
callq 0x465c3
jmp 0x46c8e
movl 0x8(%r13), %ecx
cmpl $0x2, %ecx
jb 0x46947
leaq 0xdef1(%rip), %rax      # 0x547e8
leaq 0xf2c4(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
testq %r12, %r12
movl (%r13), %esi
movl 0x4(%r13), %edx
movl 0xc(%r13), %r8d
movq 0x18(%r13), %r9
leaq 0x2ec46(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2e76f(%rip), %rbx     # 0x7509f
leaq 0x310c4(%rip), %rdi     # 0x779fb
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movl 0xc(%r13), %r8d
cmpl $0x4, %r8d
jb 0x469a8
leaq 0xde90(%rip), %rax      # 0x547e8
leaq 0xf263(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
testq %r12, %r12
movl (%r13), %esi
movl 0x4(%r13), %edx
movl 0x8(%r13), %ecx
movq 0x18(%r13), %r9
leaq 0x2ebe5(%rip), %r11     # 0x75567
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x2e70e(%rip), %rbx     # 0x7509f
leaq 0x310e6(%rip), %rdi     # 0x77a7e
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0x97a7
addq $0x20, %rsp
movq %r14, %r15
movq %r14, 0x28(%rsp)
testq %r14, %r14
jne 0x469c7
leaq 0x2e621(%rip), %rsi     # 0x74fdd
movq %r12, %rdi
callq 0x2dca5
movq %rax, %r15
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
andq $0x0, 0x2e(%rdi)
movaps %xmm0, (%rdi)
andl $0x0, 0x14(%rsp)
movl (%r13), %edx
movl 0x4(%r13), %ecx
leal (%rdx,%rdx,2), %eax
movl %eax, %r12d
negl %r12d
andl $0x3, %r12d
addl %r12d, %eax
imull %ecx, %eax
movw $0x4d42, (%rdi)         # imm = 0x4D42
leal 0x36(%rax), %ebx
movb %bl, 0x2(%rdi)
movb %bh, 0x33(%rsp)
movl %ebx, %esi
shrl $0x10, %esi
movb %sil, 0x4(%rdi)
shrl $0x18, %ebx
movb %bl, 0x5(%rdi)
movb $0x36, 0xa(%rdi)
movb $0x28, 0xe(%rdi)
movb %dl, 0x12(%rdi)
movb %dh, 0x43(%rsp)
movl %edx, %esi
shrl $0x10, %esi
movb %sil, 0x14(%rdi)
shrl $0x18, %edx
movb %dl, 0x15(%rdi)
movb %cl, 0x16(%rdi)
movb %ch, 0x47(%rsp)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x18(%rdi)
shrl $0x18, %ecx
movb %cl, 0x19(%rdi)
movl $0x180001, 0x1a(%rdi)   # imm = 0x180001
movb %al, 0x22(%rdi)
movb %ah, 0x53(%rsp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x24(%rdi)
shrl $0x18, %eax
movb %al, 0x25(%rdi)
movb $0x1, %al
movb %al, 0x27(%rdi)
movb %al, 0x2b(%rdi)
pushq $0x36
popq %rsi
movq %r15, %rdx
callq 0x46d25
movl (%r13), %eax
movl 0x4(%r13), %ecx
leal -0x1(%rcx), %r14d
imull %eax, %r14d
shlq $0x3, %r14
addq 0x18(%r13), %r14
movl 0xc(%r13), %edx
cmpl $0x2, %edx
movq %r13, 0x8(%rsp)
jb 0x46b50
movq %rax, %rsi
imulq %rcx, %rsi
movl 0x8(%r13), %r13d
imulq %rsi, %r13
leaq (%r14,%r13,8), %rbp
cmpl $0x2, %edx
jne 0x46b57
movl %r12d, %edx
movq %rdx, 0x18(%rsp)
xorl %r13d, %r13d
movl $0xff, %r12d
cmpl %ecx, %r13d
jge 0x46c79
xorl %ebx, %ebx
cmpl %eax, %ebx
jge 0x46b22
xorl %edi, %edi
movq %r15, %rsi
callq 0x4620
cvttsd2si (%rbp), %edi
addq $0x8, %rbp
andl %r12d, %edi
movq %r15, %rsi
callq 0x4620
cvttsd2si (%r14), %edi
addq $0x8, %r14
andl %r12d, %edi
movq %r15, %rsi
callq 0x4620
incl %ebx
movq 0x8(%rsp), %rax
movl (%rax), %eax
jmp 0x46ae1
leaq 0x14(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x46d25
movq 0x8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
leal (%rax,%rax), %edx
shlq $0x3, %rdx
subq %rdx, %r14
subq %rdx, %rbp
incl %r13d
jmp 0x46ad6
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x46b5e
shlq $0x4, %r13
addq %r14, %r13
movl %r12d, %esi
movq %rsi, 0x18(%rsp)
cmpl $0x1, %edx
jne 0x46be0
xorl %r12d, %r12d
leaq 0x14(%rsp), %r13
cmpl %ecx, %r12d
jge 0x46c79
xorl %ebx, %ebx
cmpl %eax, %ebx
jge 0x46bb7
cvttsd2si (%r14), %eax
addq $0x8, %r14
movzbl %al, %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x4620
movl %ebp, %edi
movq %r15, %rsi
callq 0x4620
movl %ebp, %edi
movq %r15, %rsi
callq 0x4620
incl %ebx
movq 0x8(%rsp), %rax
movl (%rax), %eax
jmp 0x46b7e
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x46d25
movq 0x8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
leal (%rax,%rax), %edx
shlq $0x3, %rdx
subq %rdx, %r14
incl %r12d
jmp 0x46b73
xorl %edx, %edx
movl $0xff, %r12d
cmpl %ecx, %edx
jge 0x46c79
movl %edx, 0x24(%rsp)
xorl %ebx, %ebx
cmpl %eax, %ebx
jge 0x46c42
cvttsd2si (%r13), %edi
addq $0x8, %r13
andl %r12d, %edi
movq %r15, %rsi
callq 0x4620
cvttsd2si (%rbp), %edi
addq $0x8, %rbp
andl %r12d, %edi
movq %r15, %rsi
callq 0x4620
cvttsd2si (%r14), %edi
addq $0x8, %r14
andl %r12d, %edi
movq %r15, %rsi
callq 0x4620
incl %ebx
movq 0x8(%rsp), %rax
movl (%rax), %eax
jmp 0x46bf6
leaq 0x14(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
callq 0x46d25
movq 0x8(%rsp), %rcx
movl (%rcx), %eax
movl 0x4(%rcx), %ecx
leal (%rax,%rax), %edx
shlq $0x3, %rdx
subq %rdx, %r14
subq %rdx, %rbp
subq %rdx, %r13
movl 0x24(%rsp), %edx
incl %edx
jmp 0x46be8
cmpq $0x0, 0x28(%rsp)
jne 0x46c89
movq %r15, %rdi
callq 0x2a2f8
movq 0x8(%rsp), %r13
movq %r13, %rax
addq $0x68, %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 (%r13), %edx
movl 0x4(%r13), %ecx
movl 0x8(%r13), %r8d
movl 0xc(%r13), %r9d
leaq 0xdb24(%rip), %rax      # 0x547e8
leaq 0xeef7(%rip), %r10      # 0x55bc2
cmpb $0x0, 0x10(%r13)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x2e3c0(%rip), %r11     # 0x7509f
leaq 0x30cbd(%rip), %rsi     # 0x779a3
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%r13)
callq 0x9d52
addq $0x20, %rsp
leaq 0x48f5d(%rip), %rsi     # 0x8fc60
movq 0x492ce(%rip), %rdx     # 0x8ffd8
movq %r14, %rdi
callq 0x4910
movq %rax, %rbx
movq %r14, %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4950