// File: Slexis-Works[P]texture-packing/testPPM.cpp
// Function: main
int main() {
	/*PPMImage img(30, 20);

	img.drawPix(1, 1, Yellow);
	img.drawPix(0, 0, Blue);
	img.drawPix(2, 0, Red);

	img.fillRect(20, 10, 9, 9, Green);

	img.saveImage("test.ppm");

	PPMImage::saveRectangle(30, 40, Green, "testSaveRectangle.ppm");

	PPMImage rectanglesBefore(200, 150), rectanglesAfter(200, 150);
	Rectangle rectR(10, 10, 40, 10, Red),
			rectG(15, 30, 20, 20, Green),
			rectB(1, 140, 198, 9, Blue);
	rectR.drawOn(rectanglesBefore);
	rectG.drawOn(rectanglesBefore);
	rectB.drawOn(rectanglesBefore);

	std::cout << "rectR and rectG " << (rectR.collides(rectG)?"overlap":"are separated") << std::endl;

	std::cout << "Flipping rectR..." << std::endl;
	rectR.flip();
	std::cout << "rectR and rectG " << (rectR.collides(rectG)?"overlap":"are separated") << std::endl;

	rectR.drawOn(rectanglesAfter);
	rectG.drawOn(rectanglesAfter);
	rectB.drawOn(rectanglesAfter);

	rectanglesBefore.saveImage("rectanglesBefore.ppm");
	rectanglesAfter.saveImage("rectanglesAfter.ppm");*/

	PPMImage shelvesImg(256, 256);

	Rectangle
		r11(50,100,Green),
		r12(90,80,Red),
		r13(200,10,Black), // Sera pas ajouté, trop large
		r14(10,85,Black), // Non plus, trop haut
		r15(100,30,Blue),
		r21(15,64,Red),
		r22(80,35,Green),
		r23(20,35,Blue),
		r24(40,36,Black); // Trop haut


	Shelf s1(256, 0, r11);
	s1.putRect(r12);
	s1.putRect(r13);
	s1.putRect(r14);
	s1.putRect(r15);
	Shelf s2(256, 100, r21);
	s2.putRect(r22);
	s2.putRect(r23);
	s2.putRect(r24);

	std::cout << "Drawing first shelf" << std::endl;
	s1.drawOn(shelvesImg);
	std::cout << "Drawing second shelf" << std::endl;
	s2.drawOn(shelvesImg);
	std::cout << "Saving image" << std::endl;

	shelvesImg.saveImage("shelves.ppm");

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movl $0x0, -0x4(%rbp)
movb $-0x1, -0x23(%rbp)
movb $-0x1, -0x22(%rbp)
movb $-0x1, -0x21(%rbp)
movb -0x21(%rbp), %al
movb %al, -0x26(%rbp)
movw -0x23(%rbp), %ax
movw %ax, -0x28(%rbp)
movzbl -0x26(%rbp), %eax
shll $0x10, %eax
movzwl -0x28(%rbp), %ecx
orl %eax, %ecx
leaq -0x20(%rbp), %rdi
movl $0x100, %edx            # imm = 0x100
movl %edx, %esi
callq 0x3180
movb $0x0, -0x3f(%rbp)
movb $-0x1, -0x3e(%rbp)
movb $0x0, -0x3d(%rbp)
movb -0x3d(%rbp), %al
movb %al, -0x42(%rbp)
movw -0x3f(%rbp), %ax
movw %ax, -0x44(%rbp)
movzbl -0x42(%rbp), %eax
shll $0x10, %eax
movzwl -0x44(%rbp), %ecx
orl %eax, %ecx
leaq -0x3c(%rbp), %rdi
movl $0x32, %esi
movl $0x64, %edx
callq 0x3c70
jmp 0x26a5
movb $-0x1, -0x6b(%rbp)
movb $0x0, -0x6a(%rbp)
movb $0x0, -0x69(%rbp)
movb -0x69(%rbp), %al
movb %al, -0x6e(%rbp)
movw -0x6b(%rbp), %ax
movw %ax, -0x70(%rbp)
movzbl -0x6e(%rbp), %eax
shll $0x10, %eax
movzwl -0x70(%rbp), %ecx
orl %eax, %ecx
leaq -0x68(%rbp), %rdi
movl $0x5a, %esi
movl $0x50, %edx
callq 0x3c70
jmp 0x26e1
movb $0x0, -0x87(%rbp)
movb $0x0, -0x86(%rbp)
movb $0x0, -0x85(%rbp)
movb -0x85(%rbp), %al
movb %al, -0x8a(%rbp)
movw -0x87(%rbp), %ax
movw %ax, -0x8c(%rbp)
movzbl -0x8a(%rbp), %eax
shll $0x10, %eax
movzwl -0x8c(%rbp), %ecx
orl %eax, %ecx
leaq -0x84(%rbp), %rdi
movl $0xc8, %esi
movl $0xa, %edx
callq 0x3c70
jmp 0x273b
movb $0x0, -0xa3(%rbp)
movb $0x0, -0xa2(%rbp)
movb $0x0, -0xa1(%rbp)
movb -0xa1(%rbp), %al
movb %al, -0xa6(%rbp)
movw -0xa3(%rbp), %ax
movw %ax, -0xa8(%rbp)
movzbl -0xa6(%rbp), %eax
shll $0x10, %eax
movzwl -0xa8(%rbp), %ecx
orl %eax, %ecx
leaq -0xa0(%rbp), %rdi
movl $0xa, %esi
movl $0x55, %edx
callq 0x3c70
jmp 0x2795
movb $0x0, -0xbf(%rbp)
movb $0x0, -0xbe(%rbp)
movb $-0x1, -0xbd(%rbp)
movb -0xbd(%rbp), %al
movb %al, -0xc2(%rbp)
movw -0xbf(%rbp), %ax
movw %ax, -0xc4(%rbp)
movzbl -0xc2(%rbp), %eax
shll $0x10, %eax
movzwl -0xc4(%rbp), %ecx
orl %eax, %ecx
leaq -0xbc(%rbp), %rdi
movl $0x64, %esi
movl $0x1e, %edx
callq 0x3c70
jmp 0x27ef
movb $-0x1, -0xdb(%rbp)
movb $0x0, -0xda(%rbp)
movb $0x0, -0xd9(%rbp)
movb -0xd9(%rbp), %al
movb %al, -0xde(%rbp)
movw -0xdb(%rbp), %ax
movw %ax, -0xe0(%rbp)
movzbl -0xde(%rbp), %eax
shll $0x10, %eax
movzwl -0xe0(%rbp), %ecx
orl %eax, %ecx
leaq -0xd8(%rbp), %rdi
movl $0xf, %esi
movl $0x40, %edx
callq 0x3c70
jmp 0x2849
movb $0x0, -0xf7(%rbp)
movb $-0x1, -0xf6(%rbp)
movb $0x0, -0xf5(%rbp)
movb -0xf5(%rbp), %al
movb %al, -0xfa(%rbp)
movw -0xf7(%rbp), %ax
movw %ax, -0xfc(%rbp)
movzbl -0xfa(%rbp), %eax
shll $0x10, %eax
movzwl -0xfc(%rbp), %ecx
orl %eax, %ecx
leaq -0xf4(%rbp), %rdi
movl $0x50, %esi
movl $0x23, %edx
callq 0x3c70
jmp 0x28a3
movb $0x0, -0x113(%rbp)
movb $0x0, -0x112(%rbp)
movb $-0x1, -0x111(%rbp)
movb -0x111(%rbp), %al
movb %al, -0x116(%rbp)
movw -0x113(%rbp), %ax
movw %ax, -0x118(%rbp)
movzbl -0x116(%rbp), %eax
shll $0x10, %eax
movzwl -0x118(%rbp), %ecx
orl %eax, %ecx
leaq -0x110(%rbp), %rdi
movl $0x14, %esi
movl $0x23, %edx
callq 0x3c70
jmp 0x28fd
movb $0x0, -0x12f(%rbp)
movb $0x0, -0x12e(%rbp)
movb $0x0, -0x12d(%rbp)
movb -0x12d(%rbp), %al
movb %al, -0x132(%rbp)
movw -0x12f(%rbp), %ax
movw %ax, -0x134(%rbp)
movzbl -0x132(%rbp), %eax
shll $0x10, %eax
movzwl -0x134(%rbp), %ecx
orl %eax, %ecx
leaq -0x12c(%rbp), %rdi
movl $0x28, %esi
movl $0x24, %edx
callq 0x3c70
jmp 0x2957
leaq -0x160(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %edx, %edx
leaq -0x3c(%rbp), %rcx
callq 0x3f10
jmp 0x2970
leaq -0x160(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3fc0
jmp 0x2982
leaq -0x160(%rbp), %rdi
leaq -0x84(%rbp), %rsi
callq 0x3fc0
jmp 0x2997
leaq -0x160(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3fc0
jmp 0x29ac
leaq -0x160(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
callq 0x3fc0
jmp 0x29c1
leaq -0x188(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x64, %edx
leaq -0xd8(%rbp), %rcx
callq 0x3f10
jmp 0x29e0
leaq -0x188(%rbp), %rdi
leaq -0xf4(%rbp), %rsi
callq 0x3fc0
jmp 0x29f5
leaq -0x188(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3fc0
jmp 0x2a0a
leaq -0x188(%rbp), %rdi
leaq -0x12c(%rbp), %rsi
callq 0x3fc0
jmp 0x2a1f
movq 0xc5b2(%rip), %rdi      # 0xefd8
leaq 0x75d7(%rip), %rsi      # 0xa004
callq 0x2160
movq %rax, -0x1b8(%rbp)
jmp 0x2a3b
movq -0x1b8(%rbp), %rdi
movq 0xc57f(%rip), %rsi      # 0xefc8
callq 0x2190
jmp 0x2a50
leaq -0x160(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4180
jmp 0x2a62
movq 0xc56f(%rip), %rdi      # 0xefd8
leaq 0x75a8(%rip), %rsi      # 0xa018
callq 0x2160
movq %rax, -0x1c0(%rbp)
jmp 0x2a7e
movq -0x1c0(%rbp), %rdi
movq 0xc53c(%rip), %rsi      # 0xefc8
callq 0x2190
jmp 0x2a93
leaq -0x188(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x4180
jmp 0x2aa5
movq 0xc52c(%rip), %rdi      # 0xefd8
leaq 0x757a(%rip), %rsi      # 0xa02d
callq 0x2160
movq %rax, -0x1c8(%rbp)
jmp 0x2ac1
movq -0x1c8(%rbp), %rdi
movq 0xc4f9(%rip), %rsi      # 0xefc8
callq 0x2190
jmp 0x2ad6
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x22a0
movq -0x1d0(%rbp), %rdx
leaq 0x7543(%rip), %rsi      # 0xa03a
leaq -0x1a8(%rbp), %rdi
callq 0x2bf0
jmp 0x2b05
leaq -0x20(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x33e0
jmp 0x2b17
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
leaq -0x1a9(%rbp), %rdi
callq 0x21b0
movl $0x0, -0x4(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x2ca0
leaq -0x160(%rbp), %rdi
callq 0x2ca0
leaq -0x20(%rbp), %rdi
callq 0x3270
movl -0x4(%rbp), %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bcb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bbf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2bb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x20a0
leaq -0x1a9(%rbp), %rdi
callq 0x21b0
leaq -0x188(%rbp), %rdi
callq 0x2ca0
leaq -0x160(%rbp), %rdi
callq 0x2ca0
leaq -0x20(%rbp), %rdi
callq 0x3270
movq -0x50(%rbp), %rdi
callq 0x2290
nopl (%rax)