// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %rsi, %rax
orq %rdx, %rax
je 0x60380
movq %rdx, %r12
movq %rsi, %rbp
movq 0x18(%r15), %r9
testq %r9, %r9
je 0x6012b
movdqu (%r15), %xmm0
pxor %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
movmskps %xmm1, %eax
testb %al, %al
jne 0x6012b
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
movd %xmm1, %ecx
cmpl $0x2, %ecx
jb 0x5fe2a
leaq 0x1355f(%rip), %rax     # 0x73338
leaq 0x14932(%rip), %r10     # 0x74712
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
testq %r12, %r12
leaq 0x342ee(%rip), %r11     # 0x940e1
cmovneq %r12, %r11
movl 0xc(%r15), %r8d
movd %xmm0, %esi
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %edx
subq $0x8, %rsp
leaq 0x33ddc(%rip), %rbx     # 0x93bef
leaq 0x3675b(%rip), %rdi     # 0x96575
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0xbb52
addq $0x20, %rsp
movl 0xc(%r15), %r8d
cmpl $0x4, %r8d
jb 0x5fe8a
leaq 0x134fd(%rip), %rax     # 0x73338
leaq 0x148d0(%rip), %r10     # 0x74712
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 0x3427d(%rip), %r11     # 0x940e1
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x33d7c(%rip), %rbx     # 0x93bef
leaq 0x3677e(%rip), %rdi     # 0x965f8
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0xbb52
addq $0x20, %rsp
movq %rbp, %rax
testq %rbp, %rbp
jne 0x5fea1
leaq 0x33c94(%rip), %rsi     # 0x93b2d
movq %r12, %rdi
callq 0x3ceb3
pxor %xmm0, %xmm0
movdqa %xmm0, 0x40(%rsp)
movdqa %xmm0, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
movq $0x0, 0x4e(%rsp)
movl $0x0, 0x1c(%rsp)
movl (%r15), %edx
movl 0x4(%r15), %ecx
leal (%rdx,%rdx,2), %edi
movl %edi, %esi
negl %esi
andl $0x3, %esi
movl %esi, 0x4(%rsp)
addl %esi, %edi
imull %ecx, %edi
movw $0x4d42, 0x20(%rsp)     # imm = 0x4D42
leal 0x36(%rdi), %ebx
movb %bl, 0x22(%rsp)
movb %bh, 0x23(%rsp)
movl %ebx, %esi
shrl $0x10, %esi
movb %sil, 0x24(%rsp)
shrl $0x18, %ebx
movb %bl, 0x25(%rsp)
movb $0x36, 0x2a(%rsp)
movb $0x28, 0x2e(%rsp)
movb %dl, 0x32(%rsp)
movb %dh, 0x33(%rsp)
movl %edx, %esi
shrl $0x10, %esi
movb %sil, 0x34(%rsp)
shrl $0x18, %edx
movb %dl, 0x35(%rsp)
movb %cl, 0x36(%rsp)
movb %ch, 0x37(%rsp)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x38(%rsp)
shrl $0x18, %ecx
movb %cl, 0x39(%rsp)
movl $0x180001, 0x3a(%rsp)   # imm = 0x180001
movq %rdi, %rdx
movb %dl, 0x42(%rsp)
movb %dh, 0x43(%rsp)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0x44(%rsp)
shrl $0x18, %edx
movb %dl, 0x45(%rsp)
movb $0x1, %cl
movb %cl, 0x47(%rsp)
movb %cl, 0x4b(%rsp)
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x603dd
movl $0x36, %ebx
xorl %r12d, %r12d
movl $0x3f00000, %r14d       # imm = 0x3F00000
cmpq %r14, %rbx
movl $0x3f00000, %r13d       # imm = 0x3F00000
cmovbq %rbx, %r13
leaq 0x20(%rsp,%r12), %rdi
movl $0x1, %esi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a70
addq %rax, %r12
subq %rax, %rbx
cmpq %rax, %r13
jne 0x5ffbd
testq %rbx, %rbx
jne 0x5ff89
testq %rbx, %rbx
je 0x5ffd8
leaq 0x3670c(%rip), %rdi     # 0x966d5
movl $0x36, %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0xbb52
movl (%r15), %eax
movl 0x4(%r15), %edx
leal -0x1(%rdx), %r14d
imull %eax, %r14d
shlq $0x3, %r14
addq 0x18(%r15), %r14
movl 0x8(%r15), %esi
movl 0xc(%r15), %ecx
imulq %rdx, %rax
imulq %rsi, %rax
xorl %ebx, %ebx
leaq (%r14,%rax,8), %r12
cmpl $0x2, %ecx
cmovbq %rbx, %r12
movq 0x8(%rsp), %r13
jbe 0x6001d
shlq $0x4, %rax
addq %r14, %rax
movq %rax, %rbx
movl 0x4(%r15), %eax
cmpl $0x1, %ecx
movq %rbp, 0x58(%rsp)
je 0x6013b
cmpl $0x2, %ecx
jne 0x60220
testl %eax, %eax
jle 0x60330
movl 0x4(%rsp), %eax
movq %rax, 0x10(%rsp)
movl $0xff, %ebx
xorl %eax, %eax
movl %eax, (%rsp)
cmpl $0x0, (%r15)
jle 0x60093
xorl %ebp, %ebp
xorl %edi, %edi
movq %r13, %rsi
callq 0x4630
cvttsd2si (%r12), %edi
addq $0x8, %r12
andl %ebx, %edi
movq %r13, %rsi
callq 0x4630
cvttsd2si (%r14), %edi
addq $0x8, %r14
andl %ebx, %edi
movq %r13, %rsi
callq 0x4630
incl %ebp
cmpl (%r15), %ebp
jl 0x6005b
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %ecx
je 0x60109
movq 0x10(%rsp), %rbx
xorl %ebp, %ebp
movl $0x3f00000, %eax        # imm = 0x3F00000
cmpq %rax, %rbx
movl $0x3f00000, %r13d       # imm = 0x3F00000
cmovbq %rbx, %r13
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a70
addq %rax, %rbp
subq %rax, %rbx
cmpq %rax, %r13
jne 0x600dd
testq %rbx, %rbx
jne 0x600a4
testq %rbx, %rbx
movq 0x8(%rsp), %r13
movl $0xff, %ebx
movl (%rsp), %ecx
je 0x60109
leaq 0x365df(%rip), %rdi     # 0x966d5
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
movl %ecx, %ebp
callq 0xbb52
movl %ebp, %ecx
movl (%r15), %eax
addl %eax, %eax
shlq $0x3, %rax
subq %rax, %r14
subq %rax, %r12
incl %ecx
cmpl 0x4(%r15), %ecx
movl %ecx, %eax
jl 0x60050
jmp 0x60330
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5f9f0
jmp 0x60338
testl %eax, %eax
jle 0x60330
movl 0x4(%rsp), %eax
movq %rax, 0x10(%rsp)
movl $0x3f00000, %ebx        # imm = 0x3F00000
xorl %r12d, %r12d
movl %r12d, (%rsp)
cmpl $0x0, (%r15)
jle 0x60198
xorl %r13d, %r13d
movq 0x8(%rsp), %r12
cvttsd2si (%r14), %eax
addq $0x8, %r14
movzbl %al, %ebp
movl %ebp, %edi
movq %r12, %rsi
callq 0x4630
movl %ebp, %edi
movq %r12, %rsi
callq 0x4630
movl %ebp, %edi
movq %r12, %rsi
callq 0x4630
incl %r13d
cmpl (%r15), %r13d
jl 0x60166
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %r12d
je 0x601fd
movq 0x10(%rsp), %r12
xorl %ebp, %ebp
cmpq %rbx, %r12
movl $0x3f00000, %r13d       # imm = 0x3F00000
cmovbq %r12, %r13
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a70
addq %rax, %rbp
subq %rax, %r12
cmpq %rax, %r13
jne 0x601de
testq %r12, %r12
jne 0x601aa
testq %r12, %r12
movl (%rsp), %r12d
je 0x601fd
leaq 0x364e7(%rip), %rdi     # 0x966d5
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xbb52
movl (%r15), %eax
addl %eax, %eax
shlq $0x3, %rax
subq %rax, %r14
incl %r12d
cmpl 0x4(%r15), %r12d
movq 0x8(%rsp), %r13
jl 0x60154
jmp 0x60330
testl %eax, %eax
jle 0x60330
movl 0x4(%rsp), %eax
movq %rax, 0x10(%rsp)
movl $0xff, %eax
xorl %ecx, %ecx
movq %r15, 0x60(%rsp)
movl %ecx, (%rsp)
cmpl $0x0, (%r15)
jle 0x60297
xorl %ebp, %ebp
cvttsd2si (%rbx), %edi
addq $0x8, %rbx
andl %eax, %edi
movq %r13, %rsi
callq 0x4630
cvttsd2si (%r12), %edi
addq $0x8, %r12
movl $0xff, %eax
andl %eax, %edi
movq %r13, %rsi
callq 0x4630
cvttsd2si (%r14), %edi
addq $0x8, %r14
movl $0xff, %eax
andl %eax, %edi
movq %r13, %rsi
callq 0x4630
movl $0xff, %eax
incl %ebp
cmpl (%r15), %ebp
jl 0x60248
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %ecx
je 0x6030d
movq 0x10(%rsp), %r15
xorl %ebp, %ebp
movl $0x3f00000, %eax        # imm = 0x3F00000
cmpq %rax, %r15
movl $0x3f00000, %r13d       # imm = 0x3F00000
cmovbq %r15, %r13
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a70
addq %rax, %rbp
subq %rax, %r15
cmpq %rax, %r13
jne 0x602e1
testq %r15, %r15
jne 0x602a8
testq %r15, %r15
movq 0x60(%rsp), %r15
movq 0x8(%rsp), %r13
movl (%rsp), %ecx
je 0x6030d
leaq 0x363db(%rip), %rdi     # 0x966d5
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
movl %ecx, %ebp
callq 0xbb52
movl %ebp, %ecx
movl (%r15), %eax
addl %eax, %eax
shlq $0x3, %rax
subq %rax, %r14
subq %rax, %r12
subq %rax, %rbx
incl %ecx
cmpl 0x4(%r15), %ecx
movl $0xff, %eax
jl 0x6023d
cmpq $0x0, 0x58(%rsp)
je 0x6034a
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4cc57(%rip), %rax     # 0xacfa8
cmpq %r13, (%rax)
je 0x60338
movq 0x4cc2b(%rip), %rax     # 0xacf88
cmpq %r13, (%rax)
je 0x60338
movq %r13, %rdi
callq 0x4540
testl %eax, %eax
je 0x60338
leaq 0x33757(%rip), %rdi     # 0x93acc
movl %eax, %esi
xorl %eax, %eax
callq 0xbb52
jmp 0x60338
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 0x12f95(%rip), %rax     # 0x73338
leaq 0x14368(%rip), %r10     # 0x74712
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x33831(%rip), %r11     # 0x93bef
leaq 0x36158(%rip), %rsi     # 0x9651d
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%r15)
callq 0xc196
addq $0x20, %rsp
jmp 0x6041f
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %r14
subq $0x8, %rsp
leaq 0x36292(%rip), %rsi     # 0x96687
leaq 0x1eedb(%rip), %rcx     # 0x7f2d7
leaq 0x34fff(%rip), %r8      # 0x95402
leaq 0x28(%rsp), %r9
movl $0x36, %edx
movq %rax, %rdi
xorl %eax, %eax
pushq 0x10(%rsp)
callq 0xc196
addq $0x10, %rsp
leaq 0x4c7fa(%rip), %rsi     # 0xacc20
movq 0x4cba3(%rip), %rdx     # 0xacfd0
movq %r14, %rdi
callq 0x4900
jmp 0x60437
movq %rax, %rbx
movq %r14, %rdi
callq 0x43b0
movq %rbx, %rdi
callq 0x4950