// File: /workspace/github_cpp_makefile_star2_O2/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), %ecx
movl 0x1c(%rdi), %edi
leal (%rcx,%rcx,2), %r9d
pushq $0x4
popq %r8
movl %ecx, %eax
cltd
idivl %r8d
movl %edx, %r14d
addl %r9d, %r14d
movl %r14d, %eax
imull %edi, %eax
movw $0x4d42, -0x7e(%rbp)    # imm = 0x4D42
leal 0x36(%rax), %edx
movl %edx, -0x7c(%rbp)
andl $0x0, -0x78(%rbp)
movabsq $0x2800000036, %rdx     # imm = 0x2800000036
movq %rdx, -0x74(%rbp)
movl %ecx, -0x6c(%rbp)
movl %edi, -0x68(%rbp)
movq $0x180001, -0x64(%rbp)  # imm = 0x180001
movl %eax, -0x5c(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x58(%rbp)
leaq -0x280(%rbp), %r15
movq %r15, %rdi
movl %r8d, %edx
callq 0x2270
movq (%r15), %rax
movq -0x18(%rax), %rax
movl -0x260(%rbp,%rax), %r15d
testb $0x5, %r15b
jne 0x2e48
leaq -0x280(%rbp), %rdi
leaq -0x7e(%rbp), %rsi
pushq $0x36
popq %rdx
callq 0x21a0
movl %r15d, -0x30(%rbp)
movslq %r14d, %rsi
leaq -0x48(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x30f4
movl 0x1c(%rbx), %r12d
imulq $0x18, %r12, %r13
addq $-0x18, %r13
pushq $0x1
popq %r15
xorpd %xmm1, %xmm1
movsd 0x1303(%rip), %xmm2     # 0x4038
movsd 0x1313(%rip), %xmm3     # 0x4050
movsd 0x12db(%rip), %xmm4     # 0x4020
leaq -0x280(%rbp), %r14
testl %r12d, %r12d
jle 0x2e3b
decq %r12
movq %r15, %rax
xorl %ecx, %ecx
movslq 0x18(%rbx), %rdx
cmpq %rdx, %rcx
jge 0x2e03
imulq %r13, %rdx
addq (%rbx), %rdx
movsd 0x8(%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x2d94
movb $-0x1, %sil
ucomisd %xmm2, %xmm0
jae 0x2d96
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
jmp 0x2d96
xorl %esi, %esi
movq -0x48(%rbp), %rdi
movb %sil, -0x1(%rdi,%rax)
movsd (%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x2dc1
movb $-0x1, %sil
ucomisd %xmm2, %xmm0
jae 0x2dc3
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %esi
jmp 0x2dc3
xorl %esi, %esi
movq -0x48(%rbp), %rdi
movb %sil, (%rdi,%rax)
movsd -0x8(%rdx,%rax,8), %xmm0
ucomisd %xmm0, %xmm1
jae 0x2ded
movb $-0x1, %dl
ucomisd %xmm2, %xmm0
jae 0x2def
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %edx
jmp 0x2def
xorl %edx, %edx
movq -0x48(%rbp), %rsi
movb %dl, 0x1(%rsi,%rax)
incq %rcx
addq $0x3, %rax
jmp 0x2d5d
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
subq %rsi, %rdx
addq $-0x18, %r13
movq %r14, %rdi
callq 0x21a0
movsd 0x11fe(%rip), %xmm4     # 0x4020
movsd 0x1226(%rip), %xmm3     # 0x4050
movsd 0x1206(%rip), %xmm2     # 0x4038
xorpd %xmm1, %xmm1
jmp 0x2d4c
leaq -0x48(%rbp), %rdi
callq 0x319a
movl -0x30(%rbp), %r15d
testb $0x5, %r15b
sete %bl
leaq -0x280(%rbp), %rdi
callq 0x21d0
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e71
movq %rax, %rbx
jmp 0x2e82
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x319a
leaq -0x280(%rbp), %rdi
callq 0x21d0
movq %rbx, %rdi
callq 0x2250