// File: /workspace/github_cpp_makefile_star2_O1/drummyfish[P]flowchart/src/bitmap_image.hpp
// Function: bitmap_image::save_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool save_image(const std::string& file_name)
   {
      std::ofstream stream(file_name.c_str(),std::ios::binary);

      if (!stream)
      {
         //std::cout << "bitmap_image::save_image(): Error - Could not open file "  << file_name << " for writing!" << std::endl;
         return false;
      }

      bitmap_file_header bfh;
      bitmap_information_header bih;

      bih.width            = width_;
      bih.height           = height_;
      bih.bit_count        = static_cast<unsigned short>(bytes_per_pixel_ << 3);
      bih.clr_important    =  0;
      bih.clr_used         =  0;
      bih.compression      =  0;
      bih.planes           =  1;
      bih.size             = 40;
      bih.x_pels_per_meter =  0;
      bih.y_pels_per_meter =  0;
      bih.size_image       = (((bih.width * bytes_per_pixel_) + 3) & 0x0000FFFC) * bih.height;

      bfh.type      = 19778;
      bfh.size      = 55 + bih.size_image;
      bfh.reserved1 = 0;
      bfh.reserved2 = 0;
      bfh.off_bits  = bih.struct_size() + bfh.struct_size();

      write_bfh(stream,bfh);
      write_bih(stream,bih);

      unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
      char padding_data[4] = {0x0,0x0,0x0,0x0};

      for (unsigned int i = 0; i < height_; ++i)
      {
         unsigned char* data_ptr = data_ + (row_increment_ * (height_ - i - 1));
         stream.write(reinterpret_cast<char*>(data_ptr),sizeof(unsigned char) * bytes_per_pixel_ * width_);
         stream.write(padding_data,padding);
      }

      stream.close();

      return true;
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %rbx
movq (%rsi), %rsi
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movl $0x4, %edx
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
jne 0xec64
movl %eax, 0x8(%rsp)
movl 0x30(%rbx), %eax
movl %eax, 0x14(%rsp)
movl 0x34(%rbx), %ecx
movl %ecx, 0x18(%rsp)
movl 0x28(%rbx), %edx
leal (,%rdx,8), %esi
movw %si, 0x1e(%rsp)
movl $0x0, 0x20(%rsp)
movw $0x1, 0x1c(%rsp)
movl $0x28, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
imull %eax, %edx
addl $0x3, %edx
andl $0xfffc, %edx           # imm = 0xFFFC
imull %ecx, %edx
movl %edx, 0x24(%rsp)
leaq 0x38(%rsp), %rsi
movw $0x4d42, (%rsi)         # imm = 0x4D42
addl $0x37, %edx
movl %edx, 0x4(%rsi)
movabsq $0x3600000000, %rax     # imm = 0x3600000000
movq %rax, 0x8(%rsi)
leaq 0x48(%rsp), %rdi
movl $0x2, %edx
callq 0x2260
leaq 0x3c(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x40(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x2, %edx
callq 0x2260
leaq 0x42(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x2, %edx
callq 0x2260
leaq 0x44(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x4, %edx
callq 0x2260
leaq 0x14(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x18(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x1c(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x2, %edx
callq 0x2260
leaq 0x1e(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x2, %edx
callq 0x2260
leaq 0x20(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x24(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x2c(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x30(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
leaq 0x34(%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x4, %edx
callq 0x2260
movl 0x30(%rbx), %r14d
movl $0x0, 0xc(%rsp)
movl 0x34(%rbx), %esi
testl %esi, %esi
je 0xec56
andl $0x3, %r14d
xorl %r13d, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x48(%rsp), %r15
leaq 0xc(%rsp), %r12
addl %ebp, %esi
imull 0x38(%rbx), %esi
addq 0x20(%rbx), %rsi
movl 0x28(%rbx), %eax
movl 0x30(%rbx), %edx
imulq %rax, %rdx
movq %r15, %rdi
callq 0x2260
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2260
incl %r13d
movl 0x34(%rbx), %esi
decl %ebp
cmpl %esi, %r13d
jb 0xec1f
leaq 0x48(%rsp), %rdi
callq 0x22a0
movl 0x8(%rsp), %eax
testb $0x5, %al
sete %bl
movq 0x9360(%rip), %rax      # 0x17fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x50(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x48(%rsp,%rcx)
callq 0x2160
leaq 0x140(%rsp), %rdi
callq 0x20a0
movl %ebx, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xecb3
jmp 0xecb3
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x22c0
movq %rbx, %rdi
callq 0x2340