// File: 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
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rcx, -0x3e8(%rbp)
movw %dx, %ax
movw %ax, -0x3(%rbp)
shrl $0x10, %edx
movb %dl, %al
movb %al, -0x1(%rbp)
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rcx, -0x18(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x8(%rbp)
movb %al, -0x3d9(%rbp)
jbe 0x3926
cmpl $0x0, -0xc(%rbp)
seta %al
movb %al, -0x3d9(%rbp)
movb -0x3d9(%rbp), %al
testb $0x1, %al
jne 0x3932
jmp 0x3934
jmp 0x3953
leaq 0x677b(%rip), %rdi      # 0xa0b6
leaq 0x6732(%rip), %rsi      # 0xa074
movl $0x43, %edx
leaq 0x6777(%rip), %rcx      # 0xa0c5
callq 0x20b0
leaq -0x1a0(%rbp), %rdi
callq 0x20d0
leaq -0x190(%rbp), %rdi
movzbl -0x3(%rbp), %esi
callq 0x2280
movq %rax, -0x3f0(%rbp)
jmp 0x3978
movq -0x3f0(%rbp), %rdi
movl $0x20, %esi
callq 0x21e0
movq %rax, -0x3f8(%rbp)
jmp 0x3992
movq -0x3f8(%rbp), %rdi
movzbl -0x2(%rbp), %esi
callq 0x2280
movq %rax, -0x400(%rbp)
jmp 0x39ab
movq -0x400(%rbp), %rdi
movl $0x20, %esi
callq 0x21e0
movq %rax, -0x408(%rbp)
jmp 0x39c5
movq -0x408(%rbp), %rdi
movzbl -0x1(%rbp), %esi
callq 0x2280
movq %rax, -0x410(%rbp)
jmp 0x39de
movq -0x410(%rbp), %rdi
movl $0x20, %esi
callq 0x21e0
jmp 0x39f1
leaq -0x1d0(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x2150
jmp 0x3a06
movq -0x3e8(%rbp), %rsi
leaq -0x3d0(%rbp), %rdi
movl $0x10, %edx
callq 0x22c0
jmp 0x3a20
leaq 0x668c(%rip), %rsi      # 0xa0b3
leaq -0x3d0(%rbp), %rdi
callq 0x2160
movq %rax, -0x418(%rbp)
jmp 0x3a3c
movq -0x418(%rbp), %rdi
movq 0xb57e(%rip), %rsi      # 0xefc8
callq 0x2190
movq %rax, -0x420(%rbp)
jmp 0x3a58
movq -0x420(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x2200
movq %rax, -0x428(%rbp)
jmp 0x3a70
movq -0x428(%rbp), %rdi
movl $0x20, %esi
callq 0x21e0
movq %rax, -0x430(%rbp)
jmp 0x3a8a
movq -0x430(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x2200
movq %rax, -0x438(%rbp)
jmp 0x3aa2
movq -0x438(%rbp), %rdi
movq 0xb518(%rip), %rsi      # 0xefc8
callq 0x2190
movq %rax, -0x440(%rbp)
jmp 0x3abe
movq -0x440(%rbp), %rdi
leaq 0x65e3(%rip), %rsi      # 0xa0af
callq 0x2160
movq %rax, -0x448(%rbp)
jmp 0x3ada
movq -0x448(%rbp), %rdi
movq 0xb4e0(%rip), %rsi      # 0xefc8
callq 0x2190
jmp 0x3aef
movl $0x0, -0x3d4(%rbp)
movl -0x3d4(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x3bbb
movl $0x0, -0x3d8(%rbp)
movl -0x3d8(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x3b90
leaq -0x3d0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x2140
jmp 0x3b32
jmp 0x3b34
movl -0x3d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3d8(%rbp)
jmp 0x3b12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x3bf4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x3be8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x2220
jmp 0x3be8
movq 0xb431(%rip), %rsi      # 0xefc8
leaq -0x3d0(%rbp), %rdi
callq 0x2190
jmp 0x3ba5
jmp 0x3ba7
movl -0x3d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3d4(%rbp)
jmp 0x3af9
leaq -0x3d0(%rbp), %rdi
callq 0x2220
leaq -0x1d0(%rbp), %rdi
callq 0x20a0
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
leaq -0x1d0(%rbp), %rdi
callq 0x20a0
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
movq -0x1a8(%rbp), %rdi
callq 0x2290
nopl (%rax)