// File: /workspace/github_cpp_makefile_star2_O1/hamikm[P]Raytracer/src/driver.cc
// Function: main
int main(int argc, char **argv) {

	if (argc != 4 && argc != 3) {
		usage(argv[0]);
		return 1;
	}
	int width = atoi(argv[1]);
	int height = atoi(argv[2]);
	bool shadowsOn = false;
	if(argc == 4) {
		stringstream ss;
		ss << argv[3];
		if(ss.str() == "-s") {
			shadowsOn = true;
		}
		else {
			usage(argv[0]);
			return 1;
		}
	}

	/* Make the string-readerFunction mappings. */
	readerFuncs["sphere"] = readSphere;
	readerFuncs["plane"] = readPlane;
	readerFuncs["cylinder"] = readCylinder;

	scene3d scene(shadowsOn);
	sp_camerad cam;
	string type;

	while (cin >> type) {

		// If the type is mapped to a shape reader function...
		if (readerFuncs.find(type) != readerFuncs.end()) {
			sp_shape3d shape;
			shape = readerFuncs[type](cin);
			scene.addShape(shape);
		}
		// Otherwise if it's a light...
		else if (type == "light") {
			sp_lightd light;
			light = readLight(cin);
			scene.addPointLight(light);
		}
		// Otherwise if it's a spot light...
		else if (type == "spotlight") {
			sp_spotlightd slight;
			slight = readSpotLight(cin);
			scene.addSpotLight(slight);
		}
		// Otherwise if it's an area light...
		else if (type == "arealight") {
			sp_arealightd alight;
			alight = readAreaLight(cin);
			scene.addAreaLight(alight);
		}
		// Otherwise if the type is camera...
		else if (type == "camera") {
			cam = readCamera(cin);
		}
		// Otherwise if we see the scene description's end...
		else if (type == "end") {
			break;
		}
		// Otherwise if the "type" is a comment start character...
		// Note that comments must begin with a # AND a space, like "# ",
		// and that the "# " must be at the beginning of the line.
		else if (type == "#") {
			string throwaway;
			getline(cin, throwaway);
		}
		// Otherwise we have an unrecognized type, which is an error.
		else {
			cerr << "ERROR: \"" << type << "\" is not a recognized scene " <<
					"description type." << endl;
			return 1;
		}
	}

	/* Render width x height image of this scene. */
	scene.renderPPM(*cam, width, height, cout);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %rbx
movl %edi, %r14d
leal -0x5(%r14), %eax
cmpl $-0x3, %eax
ja 0x3d41
movq (%rbx), %rdi
callq 0x3b19
movl $0x1, %ebx
jmp 0x4352
movq 0x8(%rbx), %rdi
callq 0x3240
movl %eax, -0x78(%rbp)
movq 0x10(%rbx), %rdi
callq 0x3240
movl %eax, -0x74(%rbp)
cmpl $0x4, %r14d
jne 0x3d93
leaq -0x280(%rbp), %rdi
callq 0x3130
leaq -0x270(%rbp), %r14
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x3d9b
movq %r15, %rdi
callq 0x30b0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x31f0
jmp 0x3dbb
xorl %r12d, %r12d
jmp 0x3e49
movq -0x270(%rbp), %rax
movq -0x18(%rax), %rax
addq %rax, %r14
movl -0x250(%rbp,%rax), %esi
orl $0x1, %esi
movq %r14, %rdi
callq 0x3280
leaq -0x268(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x3250
leaq 0x537c(%rip), %rsi      # 0x9151
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x3070
movl %eax, %r14d
testl %eax, %eax
sete %r12b
movq (%r15), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x3e0b
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
testl %r14d, %r14d
je 0x3e1f
movq (%rbx), %rdi
movl $0x1, %ebx
callq 0x3b19
jmp 0x3e21
xorl %ebx, %ebx
movq 0xa188(%rip), %rsi      # 0xdfb0
leaq -0x280(%rbp), %rdi
callq 0x3150
leaq -0x200(%rbp), %rdi
callq 0x3080
testl %r14d, %r14d
jne 0x4352
leaq -0x270(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x53d8(%rip), %rsi      # 0x9233
leaq 0x53d7(%rip), %rdx      # 0x9239
leaq -0x280(%rbp), %rdi
callq 0x7504
leaq 0xa32b(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x5330
leaq -0x9dc(%rip), %rcx      # 0x34ac
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3ea6
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0x280(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x5383(%rip), %rsi      # 0x923a
leaq 0x5381(%rip), %rdx      # 0x923f
callq 0x7504
leaq 0xa2d6(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x5330
leaq -0x873(%rip), %rcx      # 0x366a
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3efb
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0x280(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x5334(%rip), %rsi      # 0x9240
leaq 0x5335(%rip), %rdx      # 0x9248
callq 0x7504
leaq 0xa281(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x5330
leaq -0x9c2(%rip), %rcx      # 0x3570
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f50
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
xorl %eax, %eax
leaq -0x280(%rbp), %r15
movq %rax, 0x40(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movb %r12b, 0x48(%r15)
movaps %xmm0, -0xb0(%rbp)
leaq -0x88(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq 0xa041(%rip), %r12      # 0xdfd8
leaq -0x98(%rbp), %r13
leaq 0xa1fb(%rip), %rbx      # 0xe1a0
leaq 0xa1fc(%rip), %r14      # 0xe1a8
movq %r12, %rdi
movq %r13, %rsi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x42d5
movq %rbx, %rdi
movq %r13, %rsi
callq 0x78e6
cmpq %r14, %rax
je 0x4069
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x53b0
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq *(%rax)
movups -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x581c
leaq -0x48(%rbp), %rdi
callq 0x581c
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
testq %rax, %rax
je 0x4040
lock
incl 0x8(%rax)
movq %r15, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x5430
leaq -0xe8(%rbp), %rdi
callq 0x581c
leaq -0x38(%rbp), %rdi
callq 0x581c
jmp 0x3fac
movq %r13, %rdi
leaq 0x51e4(%rip), %rsi      # 0x9257
callq 0x3070
testl %eax, %eax
je 0x414d
movq %r13, %rdi
leaq 0x51bf(%rip), %rsi      # 0x9249
callq 0x3070
testl %eax, %eax
je 0x41c0
movq %r13, %rdi
leaq 0x51b2(%rip), %rsi      # 0x9253
callq 0x3070
testl %eax, %eax
je 0x4233
movq %r13, %rdi
leaq 0x51a5(%rip), %rsi      # 0x925d
callq 0x3070
testl %eax, %eax
je 0x42a6
movq %r13, %rdi
leaq 0x5195(%rip), %rsi      # 0x9264
callq 0x3070
testl %eax, %eax
je 0x42d5
movq %r13, %rdi
leaq 0x5182(%rip), %rsi      # 0x9268
callq 0x3070
testl %eax, %eax
jne 0x4366
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %edx
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
callq 0x32c0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3fac
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x3fac
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x372e
movups -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x581c
leaq -0x48(%rbp), %rdi
callq 0x581c
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
testq %rax, %rax
je 0x41a5
lock
incl 0x8(%rax)
movq %r15, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5462
leaq -0xd8(%rbp), %rdi
jmp 0x4056
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x37dd
movups -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x581c
leaq -0x48(%rbp), %rdi
callq 0x581c
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
testq %rax, %rax
je 0x4218
lock
incl 0x8(%rax)
movq %r15, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x5490
leaq -0xc8(%rbp), %rdi
jmp 0x4056
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x391b
movups -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x581c
leaq -0x48(%rbp), %rdi
callq 0x581c
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
testq %rax, %rax
je 0x428b
lock
incl 0x8(%rax)
movq %r15, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x54c2
leaq -0xb8(%rbp), %rdi
jmp 0x4056
leaq -0x40(%rbp), %rdi
callq 0x3a5a
movups -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movups %xmm1, -0x40(%rbp)
movaps -0xb0(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0xb0(%rbp)
leaq -0x68(%rbp), %rdi
jmp 0x4056
movq -0xb0(%rbp), %rsi
testq %rsi, %rsi
je 0x43d5
xorl %ebx, %ebx
movq 0x9cda(%rip), %r8       # 0xdfc8
leaq -0x280(%rbp), %rdi
movl -0x78(%rbp), %edx
movl -0x74(%rbp), %ecx
callq 0x559e
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4322
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x581c
leaq -0x250(%rbp), %rdi
callq 0x58f6
leaq -0x268(%rbp), %rdi
callq 0x5948
leaq -0x280(%rbp), %rdi
callq 0x599a
movl %ebx, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9c83(%rip), %rdi      # 0xdff0
leaq 0x4ef6(%rip), %rsi      # 0x926a
movl $0x8, %edx
callq 0x31f0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq 0x9c5d(%rip), %rdi      # 0xdff0
callq 0x31f0
movq %rax, %r14
leaq 0x4ed1(%rip), %rsi      # 0x9273
movl $0x1c, %edx
movq %rax, %rdi
callq 0x31f0
leaq 0x4eda(%rip), %rsi      # 0x9290
movl $0x11, %edx
movq %r14, %rdi
callq 0x31f0
movl $0x1, %ebx
movq %r14, %rdi
callq 0x30c0
jmp 0x4300
leaq 0x57a7(%rip), %rdi      # 0x9b83
leaq 0x57a8(%rip), %rsi      # 0x9b8b
leaq 0x5e6b(%rip), %rcx      # 0xa255
movl $0x2d2, %edx            # imm = 0x2D2
callq 0x30f0
jmp 0x4432
jmp 0x44b6
jmp 0x4403
jmp 0x442a
jmp 0x4403
jmp 0x442a
movq %rax, %rbx
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x4501
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x4501
movq %rax, %rbx
jmp 0x4501
movq %rax, %rbx
movq 0x9b74(%rip), %rsi      # 0xdfb0
leaq -0x280(%rbp), %rdi
callq 0x3150
leaq -0x200(%rbp), %rdi
callq 0x3080
jmp 0x4501
jmp 0x44b6
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x44ad
jmp 0x44bb
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x44ad
jmp 0x44bb
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x44c7
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x44c7
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x44ad
jmp 0x44bb
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x581c
jmp 0x44be
jmp 0x44b6
movq %rax, %rbx
jmp 0x44c7
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x581c
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x44e9
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x581c
leaq -0x280(%rbp), %rdi
callq 0x57f2
movq %rbx, %rdi
callq 0x32a0