// File: /workspace/github_cpp_makefile_star2_O3/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 0x5d7ad
movq %rdx, %r12
movq %rsi, %rbp
movq 0x18(%r15), %r9
testq %r9, %r9
sete %al
movl (%r15), %esi
movl 0x4(%r15), %edx
testl %esi, %esi
sete %dil
orb %al, %dil
testl %edx, %edx
sete %al
movl 0x8(%r15), %ecx
testl %ecx, %ecx
sete %r10b
orb %al, %r10b
orb %dil, %r10b
movl 0xc(%r15), %r8d
testl %r8d, %r8d
sete %al
orb %r10b, %al
cmpb $0x1, %al
jne 0x5d217
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5ce0e
jmp 0x5d765
cmpl $0x2, %ecx
jb 0x5d267
leaq 0x11645(%rip), %rax     # 0x6e868
leaq 0x12a18(%rip), %r10     # 0x6fc42
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
testq %r12, %r12
leaq 0x323d4(%rip), %r11     # 0x8f611
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x31ed3(%rip), %rbx     # 0x8f11f
leaq 0x34852(%rip), %rdi     # 0x91aa5
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0xbb10
addq $0x20, %rsp
movl 0xc(%r15), %r8d
cmpl $0x4, %r8d
jb 0x5d2c3
leaq 0x115f4(%rip), %rax     # 0x6e868
leaq 0x129c7(%rip), %r10     # 0x6fc42
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 0x32374(%rip), %r11     # 0x8f611
cmovneq %r12, %r11
subq $0x8, %rsp
leaq 0x31e73(%rip), %rbx     # 0x8f11f
leaq 0x34875(%rip), %rdi     # 0x91b28
xorl %eax, %eax
pushq %r11
pushq %rbx
pushq %r10
callq 0xbb10
addq $0x20, %rsp
movq %rbp, %rax
testq %rbp, %rbp
jne 0x5d2da
leaq 0x31d8b(%rip), %rsi     # 0x8f05d
movq %r12, %rdi
callq 0x3b111
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %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 0x5d81e
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 0x4a80
addq %rax, %r12
subq %rax, %rbx
cmpq %rax, %r13
jne 0x5d3f2
testq %rbx, %rbx
jne 0x5d3be
testq %rbx, %rbx
je 0x5d40d
leaq 0x34807(%rip), %rdi     # 0x91c05
movl $0x36, %edx
movq %r12, %rsi
xorl %eax, %eax
callq 0xbb10
movl (%r15), %eax
movl 0x4(%r15), %ecx
leal -0x1(%rcx), %r13d
imull %eax, %r13d
shlq $0x3, %r13
addq 0x18(%r15), %r13
movl 0xc(%r15), %edx
cmpl $0x2, %edx
movq 0x8(%rsp), %r14
movq %rbp, 0x58(%rsp)
jb 0x5d551
movl 0x8(%r15), %esi
movq %rax, %rbx
imulq %rcx, %rbx
imulq %rsi, %rbx
leaq (,%rbx,8), %r12
addq %r13, %r12
cmpl $0x2, %edx
jne 0x5d558
testl %ecx, %ecx
jle 0x5d75d
movl 0x4(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movl $0xff, %ebx
xorl %ecx, %ecx
movl %ecx, (%rsp)
testl %eax, %eax
jle 0x5d4b8
xorl %ebp, %ebp
xorl %edi, %edi
movq %r14, %rsi
callq 0x4640
cvttsd2si (%r12), %edi
addq $0x8, %r12
andl %ebx, %edi
movq %r14, %rsi
callq 0x4640
cvttsd2si (%r13), %edi
addq $0x8, %r13
andl %ebx, %edi
movq %r14, %rsi
callq 0x4640
incl %ebp
cmpl (%r15), %ebp
jl 0x5d47f
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %edx
je 0x5d52e
movq 0x10(%rsp), %rbx
xorl %ebp, %ebp
movl $0x3f00000, %eax        # imm = 0x3F00000
cmpq %rax, %rbx
movl $0x3f00000, %r14d       # imm = 0x3F00000
cmovbq %rbx, %r14
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a80
addq %rax, %rbp
subq %rax, %rbx
cmpq %rax, %r14
jne 0x5d502
testq %rbx, %rbx
jne 0x5d4c9
testq %rbx, %rbx
movq 0x8(%rsp), %r14
movl $0xff, %ebx
movl (%rsp), %edx
je 0x5d52e
leaq 0x346ea(%rip), %rdi     # 0x91c05
movq %rbp, %rsi
movl %edx, %ebp
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xbb10
movl %ebp, %edx
movl (%r15), %eax
leal (%rax,%rax), %ecx
shlq $0x3, %rcx
subq %rcx, %r13
subq %rcx, %r12
incl %edx
cmpl 0x4(%r15), %edx
movl %edx, %ecx
jl 0x5d476
jmp 0x5d75d
xorl %r12d, %r12d
xorl %ebx, %ebx
jmp 0x5d55f
shlq $0x4, %rbx
addq %r13, %rbx
cmpl $0x1, %edx
jne 0x5d64d
testl %ecx, %ecx
jle 0x5d75d
movl 0x4(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movl $0x3f00000, %ebx        # imm = 0x3F00000
xorl %r12d, %r12d
movl %r12d, (%rsp)
testl %eax, %eax
jle 0x5d5c4
xorl %r14d, %r14d
movq 0x8(%rsp), %r12
cvttsd2si (%r13), %eax
addq $0x8, %r13
movzbl %al, %ebp
movl %ebp, %edi
movq %r12, %rsi
callq 0x4640
movl %ebp, %edi
movq %r12, %rsi
callq 0x4640
movl %ebp, %edi
movq %r12, %rsi
callq 0x4640
incl %r14d
cmpl (%r15), %r14d
jl 0x5d591
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %r12d
je 0x5d629
movq 0x10(%rsp), %r12
xorl %ebp, %ebp
cmpq %rbx, %r12
movl $0x3f00000, %r14d       # imm = 0x3F00000
cmovbq %r12, %r14
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a80
addq %rax, %rbp
subq %rax, %r12
cmpq %rax, %r14
jne 0x5d60a
testq %r12, %r12
jne 0x5d5d6
testq %r12, %r12
movl (%rsp), %r12d
je 0x5d629
leaq 0x345eb(%rip), %rdi     # 0x91c05
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xbb10
movl (%r15), %eax
leal (%rax,%rax), %ecx
shlq $0x3, %rcx
subq %rcx, %r13
incl %r12d
cmpl 0x4(%r15), %r12d
movq 0x8(%rsp), %r14
jl 0x5d581
jmp 0x5d75d
testl %ecx, %ecx
jle 0x5d75d
movl 0x4(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movl $0xff, %ecx
xorl %edx, %edx
movq %r15, 0x60(%rsp)
movl %edx, (%rsp)
testl %eax, %eax
jle 0x5d6c3
xorl %ebp, %ebp
cvttsd2si (%rbx), %edi
addq $0x8, %rbx
andl %ecx, %edi
movq %r14, %rsi
callq 0x4640
cvttsd2si (%r12), %edi
addq $0x8, %r12
movl $0xff, %eax
andl %eax, %edi
movq %r14, %rsi
callq 0x4640
cvttsd2si (%r13), %edi
addq $0x8, %r13
movl $0xff, %eax
andl %eax, %edi
movq %r14, %rsi
callq 0x4640
movl $0xff, %ecx
incl %ebp
cmpl (%r15), %ebp
jl 0x5d673
cmpl $0x0, 0x4(%rsp)
movl (%rsp), %edx
je 0x5d739
movq 0x10(%rsp), %r15
xorl %ebp, %ebp
movl $0x3f00000, %eax        # imm = 0x3F00000
cmpq %rax, %r15
movl $0x3f00000, %r14d       # imm = 0x3F00000
cmovbq %r15, %r14
leaq 0x1c(%rsp,%rbp), %rdi
movl $0x1, %esi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq 0x4a80
addq %rax, %rbp
subq %rax, %r15
cmpq %rax, %r14
jne 0x5d70d
testq %r15, %r15
jne 0x5d6d4
testq %r15, %r15
movq 0x60(%rsp), %r15
movq 0x8(%rsp), %r14
movl (%rsp), %edx
je 0x5d739
leaq 0x344df(%rip), %rdi     # 0x91c05
movq %rbp, %rsi
movl %edx, %ebp
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0xbb10
movl %ebp, %edx
movl (%r15), %eax
leal (%rax,%rax), %ecx
shlq $0x3, %rcx
subq %rcx, %r13
subq %rcx, %r12
subq %rcx, %rbx
incl %edx
cmpl 0x4(%r15), %edx
movl $0xff, %ecx
jl 0x5d66a
cmpq $0x0, 0x58(%rsp)
je 0x5d777
movq %r15, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4a82a(%rip), %rax     # 0xa7fa8
cmpq %r14, (%rax)
je 0x5d765
movq 0x4a7fe(%rip), %rax     # 0xa7f88
cmpq %r14, (%rax)
je 0x5d765
movq %r14, %rdi
callq 0x4550
testl %eax, %eax
je 0x5d765
leaq 0x3185a(%rip), %rdi     # 0x8effc
movl %eax, %esi
xorl %eax, %eax
callq 0xbb10
jmp 0x5d765
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 0x11098(%rip), %rax     # 0x6e868
leaq 0x1246b(%rip), %r10     # 0x6fc42
cmpb $0x0, 0x10(%r15)
cmovneq %rax, %r10
subq $0x8, %rsp
leaq 0x31934(%rip), %r11     # 0x8f11f
leaq 0x3425b(%rip), %rsi     # 0x91a4d
movq %r14, %rdi
xorl %eax, %eax
pushq %r11
pushq %r10
pushq 0x18(%r15)
callq 0xc16a
addq $0x20, %rsp
leaq 0x4a441(%rip), %rsi     # 0xa7c50
movq 0x4a7ba(%rip), %rdx     # 0xa7fd0
movq %r14, %rdi
callq 0x4910
movl $0x4008, %edi           # imm = 0x4008
callq 0x4210
movq %rax, %rbx
subq $0x8, %rsp
leaq 0x34381(%rip), %rsi     # 0x91bb7
leaq 0x1cfca(%rip), %rcx     # 0x7a807
leaq 0x330ee(%rip), %r8      # 0x90932
leaq 0x28(%rsp), %r9
movl $0x36, %edx
movq %rax, %rdi
xorl %eax, %eax
pushq $0x0
callq 0xc16a
addq $0x10, %rsp
leaq 0x4a3eb(%rip), %rsi     # 0xa7c50
movq 0x4a764(%rip), %rdx     # 0xa7fd0
movq %rbx, %rdi
callq 0x4910
movq %rax, %r15
movq %rbx, %rdi
jmp 0x5d882
movq %rax, %r15
movq %r14, %rdi
callq 0x43c0
movq %r15, %rdi
callq 0x4960
nop