// File: /workspace/github_cpp_makefile_star2_O1/Reputeless[P]PerlinNoise/example.cpp
// Function: Image::saveBMP(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool saveBMP(const std::string& path)
	{
		const std::int32_t  rowSize = m_width * 3 + m_width % 4;
		const std::uint32_t bmpsize = rowSize * m_height;
		const BMPHeader header =
		{
			0x4d42,
			static_cast<std::uint32_t>(bmpsize + sizeof(BMPHeader)),
			0, 0, sizeof(BMPHeader), 40,
			m_width, m_height, 1, 24,
			0, bmpsize, 0, 0, 0, 0
		};

		if (std::ofstream ofs{ path, std::ios_base::binary })
		{
			ofs.write(reinterpret_cast<const char*>(&header), sizeof(header));

			std::vector<std::uint8_t> line(rowSize);

			for (std::int32_t y = m_height - 1; -1 < y; --y)
			{
				size_t pos = 0;

				for (std::int32_t x = 0; x < m_width; ++x)
				{
					const RGB& col = m_data[static_cast<std::size_t>(y) * m_width + x];
					line[pos++] = ToUint8(col.b);
					line[pos++] = ToUint8(col.g);
					line[pos++] = ToUint8(col.r);
				}

				ofs.write(reinterpret_cast<const char*>(line.data()), line.size());
			}

			return true;
		}
		else
		{
			return false;
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rdi, %rbx
movl 0x18(%rdi), %eax
movl 0x1c(%rdi), %ecx
leal (%rax,%rax,2), %edx
leal 0x3(%rax), %edi
testl %eax, %eax
cmovnsl %eax, %edi
andl $-0x4, %edi
movl %eax, %r12d
subl %edi, %r12d
addl %edx, %r12d
movl %r12d, %edx
imull %ecx, %edx
movw $0x4d42, -0x7e(%rbp)    # imm = 0x4D42
leal 0x36(%rdx), %edi
movl %edi, -0x7c(%rbp)
movl $0x0, -0x78(%rbp)
movabsq $0x2800000036, %rdi     # imm = 0x2800000036
movq %rdi, -0x74(%rbp)
movl %eax, -0x6c(%rbp)
movl %ecx, -0x68(%rbp)
movq $0x180001, -0x64(%rbp)  # imm = 0x180001
movl %edx, -0x5c(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x58(%rbp)
leaq -0x280(%rbp), %r14
movq %r14, %rdi
movl $0x4, %edx
callq 0x2240
movq (%r14), %rax
movq -0x18(%rax), %rax
movl -0x260(%rbp,%rax), %r15d
testb $0x5, %r15b
jne 0x354e
leaq -0x280(%rbp), %rdi
leaq -0x7e(%rbp), %rsi
movl $0x36, %edx
callq 0x2170
movslq %r12d, %rsi
leaq -0x48(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x367a
movl 0x1c(%rbx), %r12d
leaq (%r12,%r12,2), %rax
leaq -0x18(,%rax,8), %r13
xorpd %xmm1, %xmm1
movsd 0xbf1(%rip), %xmm2      # 0x4020
movsd 0xc21(%rip), %xmm3      # 0x4058
movsd 0xbe9(%rip), %xmm4      # 0x4028
testl %r12d, %r12d
jle 0x3539
movl 0x18(%rbx), %edx
testl %edx, %edx
jle 0x34fe
movl $0x1, %eax
xorl %ecx, %ecx
movslq %edx, %rdx
imulq %r13, %rdx
addq (%rbx), %rdx
movsd 0x8(%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x3487
movb $-0x1, %sil
ucomisd %xmm2, %xmm0
jae 0x3489
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
jmp 0x3489
xorl %esi, %esi
movq -0x48(%rbp), %rdi
movb %sil, -0x1(%rdi,%rax)
movsd (%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x34b4
movb $-0x1, %sil
ucomisd %xmm2, %xmm0
jae 0x34b6
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
jmp 0x34b6
xorl %esi, %esi
movq -0x48(%rbp), %rdi
movb %sil, (%rdi,%rax)
movsd -0x8(%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x34e0
movb $-0x1, %dl
ucomisd %xmm2, %xmm0
jae 0x34e2
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %edx
jmp 0x34e2
xorl %edx, %edx
movq -0x48(%rbp), %rsi
movb %dl, 0x1(%rsi,%rax)
incq %rcx
movslq 0x18(%rbx), %rdx
addq $0x3, %rax
cmpq %rdx, %rcx
jl 0x345a
decq %r12
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
subq %rsi, %rdx
addq $-0x18, %r13
movq %r14, %rdi
callq 0x2170
movsd 0xb08(%rip), %xmm4      # 0x4028
movsd 0xb30(%rip), %xmm3      # 0x4058
movsd 0xaf0(%rip), %xmm2      # 0x4020
xorpd %xmm1, %xmm1
jmp 0x343f
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x354e
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2150
testb $0x5, %r15b
sete %bl
movq 0x2a6c(%rip), %rax      # 0x5fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x278(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x280(%rbp,%rcx)
callq 0x2110
leaq -0x188(%rbp), %rdi
callq 0x2040
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x35a1
movq %rax, %rbx
jmp 0x35be
movq %rax, %rbx
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x35be
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2150
leaq -0x280(%rbp), %rdi
callq 0x21a0
movq %rbx, %rdi
callq 0x2220