// File: /workspace/github_cpp_makefile_star2_O1/Slexis-Works[P]texture-packing/PPMImage.cpp
// Function: PPMImage::saveRectangle(unsigned int, unsigned int, RGBColor, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void PPMImage::saveRectangle(coord w, coord h, RGBColor col, std::string path) {
	assert(w > 0 && h > 0);

	std::stringstream colStream;
	colStream << (int)col.r << ' ' << (int)col.g << ' ' << (int)col.b << ' ';
	std::string colString = colStream.str();
	std::ofstream file(path);

	file << "P3" << std::endl
		<< w << ' ' << h << std::endl
		<< "255" << std::endl;

	for (coord y=0 ; y<h ; ++y) {
		for (coord x=0 ; x<w ; ++x) {
			file << colString;
		}
		file << std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x3b0, %rsp            # imm = 0x3B0
testl %edi, %edi
je 0x314f
movl %esi, %ebx
testl %esi, %esi
je 0x314f
movq %rcx, %r14
movl %edx, %r15d
movl %edi, %ebp
leaq 0x228(%rsp), %rdi
callq 0x20b0
leaq 0x238(%rsp), %rdi
movzbl %r15b, %esi
callq 0x21b0
leaq 0x28(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
andl $0xffffff, %r15d        # imm = 0xFFFFFF
movl %r15d, %ecx
shrl $0x8, %ecx
movzbl %cl, %esi
movq %rax, %rdi
callq 0x21b0
leaq 0x28(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
shrl $0x10, %r15d
movq %rax, %rdi
movl %r15d, %esi
callq 0x21b0
leaq 0x28(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
leaq 0x240(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2190
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movl $0x10, %edx
callq 0x21e0
leaq 0x30d2(%rip), %rsi      # 0x6084
leaq 0x28(%rsp), %r14
movl $0x2, %edx
movq %r14, %rdi
callq 0x2150
movq 0x28(%rsp), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movl %ebp, %esi
movq %rax, %rdi
callq 0x2090
leaq 0x7(%rsp), %rsi
movb $0x20, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
movl %ebx, %esi
movq %rax, %rdi
callq 0x2090
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
movq %rax, %r15
leaq 0x3031(%rip), %rsi      # 0x6080
movl $0x3, %edx
movq %rax, %rdi
callq 0x2150
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
xorl %r15d, %r15d
movl %ebp, %r12d
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x2150
decl %r12d
jne 0x3089
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2120
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20a0
incl %r15d
cmpl %ebx, %r15d
jne 0x3086
movq 0x5ef8(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x2100
leaq 0x120(%rsp), %rdi
callq 0x2050
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x311e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2140
movq 0x5e93(%rip), %rsi      # 0x8fb8
leaq 0x228(%rsp), %rdi
callq 0x20d0
leaq 0x2a8(%rsp), %rdi
callq 0x2050
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f31(%rip), %rdi      # 0x6087
leaq 0x2f13(%rip), %rsi      # 0x6070
leaq 0x2f32(%rip), %rcx      # 0x6096
movl $0x43, %edx
callq 0x2080
movq %rax, %rbx
jmp 0x318b
jmp 0x3175
movq %rax, %rbx
jmp 0x31a6
jmp 0x317e
jmp 0x317e
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2160
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x31a6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2140
movq 0x5e0b(%rip), %rsi      # 0x8fb8
leaq 0x228(%rsp), %rdi
callq 0x20d0
leaq 0x2a8(%rsp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21c0
nop