// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movl %edi, %ebx
leal -0x5(%rbx), %eax
cmpl $-0x3, %eax
ja 0x3d35
movq (%r14), %rdi
callq 0x3b0e
movl $0x1, %r14d
jmp 0x4348
movq 0x8(%r14), %rdi
callq 0x3240
movl %eax, -0x78(%rbp)
movq 0x10(%r14), %rdi
callq 0x3240
movl %eax, -0x74(%rbp)
cmpl $0x4, %ebx
jne 0x3e35
leaq -0x280(%rbp), %rdi
callq 0x3130
leaq -0x270(%rbp), %r15
movq 0x18(%r14), %r12
testq %r12, %r12
je 0x3d8a
movq %r12, %rdi
callq 0x30b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x31f0
jmp 0x3daa
movq -0x270(%rbp), %rax
movq -0x18(%rax), %rax
addq %rax, %r15
movl -0x250(%rbp,%rax), %esi
orl $0x1, %esi
movq %r15, %rdi
callq 0x3280
leaq -0x268(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x3250
leaq 0x538d(%rip), %rsi      # 0x9151
leaq -0x98(%rbp), %r12
movq %r12, %rdi
callq 0x3070
movl %eax, %r15d
movq (%r12), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x3df5
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
testl %r15d, %r15d
je 0x3e0a
movq (%r14), %rdi
movl $0x1, %r14d
callq 0x3b0e
jmp 0x3e0d
xorl %r14d, %r14d
movq 0xa19c(%rip), %rsi      # 0xdfb0
leaq -0x280(%rbp), %rdi
callq 0x3150
leaq -0x200(%rbp), %rdi
callq 0x3080
testl %r15d, %r15d
jne 0x4348
leaq -0x270(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x53ec(%rip), %rsi      # 0x9233
leaq 0x53eb(%rip), %rdx      # 0x9239
leaq -0x280(%rbp), %rdi
callq 0x7456
leaq 0xa33f(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x528e
leaq -0x9c8(%rip), %rcx      # 0x34ac
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3e92
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0x280(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x5397(%rip), %rsi      # 0x923a
leaq 0x5395(%rip), %rdx      # 0x923f
callq 0x7456
leaq 0xa2ea(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x528e
leaq -0x85f(%rip), %rcx      # 0x366a
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3ee7
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0x280(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x5348(%rip), %rsi      # 0x9240
leaq 0x5349(%rip), %rdx      # 0x9248
callq 0x7456
leaq 0xa295(%rip), %rdi      # 0xe1a0
leaq -0x280(%rbp), %rsi
callq 0x528e
leaq -0x9ae(%rip), %rcx      # 0x3570
movq %rcx, (%rax)
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f3c
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
xorl %eax, %eax
cmpl $0x4, %ebx
leaq -0x280(%rbp), %r13
movq %rax, 0x40(%r13)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r13)
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
sete 0x48(%r13)
leaq -0xa8(%rbp), %rcx
movaps %xmm0, -0x8(%rcx)
leaq -0x88(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq 0xa04c(%rip), %r12      # 0xdfd8
leaq -0x98(%rbp), %rbx
leaq 0xa206(%rip), %r15      # 0xe1a0
leaq 0xa207(%rip), %r14      # 0xe1a8
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x42ca
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7832
cmpq %r14, %rax
je 0x405e
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x530e
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq *(%rax)
movaps -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x576e
leaq -0x48(%rbp), %rdi
callq 0x576e
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
testq %rax, %rax
je 0x4035
lock
incl 0x8(%rax)
movq %r13, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x538e
leaq -0xe8(%rbp), %rdi
callq 0x576e
leaq -0x38(%rbp), %rdi
callq 0x576e
jmp 0x3fa1
movq %rbx, %rdi
leaq 0x51ef(%rip), %rsi      # 0x9257
callq 0x3070
testl %eax, %eax
je 0x4142
movq %rbx, %rdi
leaq 0x51ca(%rip), %rsi      # 0x9249
callq 0x3070
testl %eax, %eax
je 0x41b5
movq %rbx, %rdi
leaq 0x51bd(%rip), %rsi      # 0x9253
callq 0x3070
testl %eax, %eax
je 0x4228
movq %rbx, %rdi
leaq 0x51b0(%rip), %rsi      # 0x925d
callq 0x3070
testl %eax, %eax
je 0x429b
movq %rbx, %rdi
leaq 0x51a0(%rip), %rsi      # 0x9264
callq 0x3070
testl %eax, %eax
je 0x42ca
movq %rbx, %rdi
leaq 0x518d(%rip), %rsi      # 0x9268
callq 0x3070
testl %eax, %eax
jne 0x435d
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 0x3fa1
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x3fa1
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x372e
movaps -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x576e
leaq -0x48(%rbp), %rdi
callq 0x576e
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
testq %rax, %rax
je 0x419a
lock
incl 0x8(%rax)
movq %r13, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x53c0
leaq -0xd8(%rbp), %rdi
jmp 0x404b
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x37dd
movaps -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x576e
leaq -0x48(%rbp), %rdi
callq 0x576e
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
testq %rax, %rax
je 0x420d
lock
incl 0x8(%rax)
movq %r13, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x53ee
leaq -0xc8(%rbp), %rdi
jmp 0x404b
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3910
movaps -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x50(%rbp)
movaps -0x40(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x576e
leaq -0x48(%rbp), %rdi
callq 0x576e
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
testq %rax, %rax
je 0x4280
lock
incl 0x8(%rax)
movq %r13, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x5420
leaq -0xb8(%rbp), %rdi
jmp 0x404b
leaq -0x40(%rbp), %rdi
callq 0x3a4f
movaps -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x40(%rbp)
movaps -0xb0(%rbp), %xmm1
movups %xmm1, -0x70(%rbp)
movaps %xmm0, -0xb0(%rbp)
leaq -0x68(%rbp), %rdi
jmp 0x404b
movq -0xb0(%rbp), %rsi
testq %rsi, %rsi
je 0x43cd
xorl %r14d, %r14d
movq 0x9ce4(%rip), %r8       # 0xdfc8
leaq -0x280(%rbp), %rdi
movl -0x78(%rbp), %edx
movl -0x74(%rbp), %ecx
callq 0x54f4
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x4318
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x576e
leaq -0x250(%rbp), %rdi
callq 0x5848
leaq -0x268(%rbp), %rdi
callq 0x58a0
leaq -0x280(%rbp), %rdi
callq 0x58f8
movl %r14d, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9c8c(%rip), %rdi      # 0xdff0
leaq 0x4eff(%rip), %rsi      # 0x926a
movl $0x8, %edx
callq 0x31f0
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq 0x9c66(%rip), %rdi      # 0xdff0
callq 0x31f0
movq %rax, %rbx
leaq 0x4eda(%rip), %rsi      # 0x9273
movl $0x1c, %edx
movq %rax, %rdi
callq 0x31f0
leaq 0x4ee3(%rip), %rsi      # 0x9290
movl $0x11, %edx
movq %rbx, %rdi
callq 0x31f0
movl $0x1, %r14d
movq %rbx, %rdi
callq 0x30c0
jmp 0x42f6
leaq 0x57af(%rip), %rdi      # 0x9b83
leaq 0x57b0(%rip), %rsi      # 0x9b8b
leaq 0x5e73(%rip), %rcx      # 0xa255
movl $0x2d2, %edx            # imm = 0x2D2
callq 0x30f0
jmp 0x442a
jmp 0x44ae
jmp 0x43fb
jmp 0x4422
jmp 0x43fb
jmp 0x4422
movq %rax, %rbx
movq -0x280(%rbp), %rdi
cmpq %r14, %rdi
je 0x44f9
movq -0x270(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x44f9
movq %rax, %rbx
jmp 0x44f9
movq %rax, %rbx
movq 0x9b7c(%rip), %rsi      # 0xdfb0
leaq -0x280(%rbp), %rdi
callq 0x3150
leaq -0x200(%rbp), %rdi
callq 0x3080
jmp 0x44f9
jmp 0x44ae
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x44a5
jmp 0x44b3
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x44a5
jmp 0x44b3
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x44bf
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x31d0
jmp 0x44bf
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x44a5
jmp 0x44b3
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
callq 0x576e
jmp 0x44b6
jmp 0x44ae
movq %rax, %rbx
jmp 0x44bf
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x576e
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x44e1
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x31d0
leaq -0xa8(%rbp), %rdi
callq 0x576e
leaq -0x280(%rbp), %rdi
callq 0x5744
movq %rbx, %rdi
callq 0x32a0