// File: /workspace/github_cpp_makefile_star2_O2/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 $0x248, %rsp            # imm = 0x248
movq %rsi, %r14
movl %edi, %ebx
leal -0x5(%rbx), %eax
cmpl $-0x3, %eax
ja 0x3bb8
movq (%r14), %rdi
callq 0x3abb
pushq $0x1
popq %r12
jmp 0x404b
movq 0x8(%r14), %rdi
callq 0x3270
movl %eax, -0x58(%rbp)
movq 0x10(%r14), %rdi
callq 0x3270
movl %eax, -0x54(%rbp)
cmpl $0x4, %ebx
jne 0x3c4e
leaq -0x270(%rbp), %rdi
callq 0x3130
leaq -0x260(%rbp), %rdi
movq 0x18(%r14), %rsi
callq 0x31d0
leaq -0x258(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3280
leaq 0x553a(%rip), %rsi      # 0x9145
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
callq 0x4b1e
movl %eax, %r15d
movq %r12, %rdi
callq 0x30c0
xorl %r12d, %r12d
testb %r15b, %r15b
jne 0x3c39
movq (%r14), %rdi
callq 0x3abb
pushq $0x1
popq %r12
leaq -0x270(%rbp), %rdi
callq 0x3160
testb %r15b, %r15b
je 0x404b
leaq 0x55d2(%rip), %rsi      # 0x9227
leaq -0x270(%rbp), %rdi
leaq -0xe0(%rbp), %rdx
callq 0x4b98
leaq 0xb541(%rip), %rdi      # 0xf1b0
leaq -0x270(%rbp), %rsi
callq 0x4b2e
leaq -0x7f6(%rip), %rcx      # 0x348c
movq %rcx, (%rax)
leaq -0x270(%rbp), %rdi
callq 0x30c0
leaq 0x5596(%rip), %rsi      # 0x922e
leaq -0x270(%rbp), %rdi
leaq -0xe0(%rbp), %rdx
callq 0x4b98
leaq 0xb4fe(%rip), %rdi      # 0xf1b0
leaq -0x270(%rbp), %rsi
callq 0x4b2e
leaq -0x686(%rip), %rcx      # 0x363f
movq %rcx, (%rax)
leaq -0x270(%rbp), %rdi
callq 0x30c0
leaq 0x5559(%rip), %rsi      # 0x9234
leaq -0x270(%rbp), %rdi
leaq -0xe0(%rbp), %rdx
callq 0x4b98
leaq 0xb4bb(%rip), %rdi      # 0xf1b0
leaq -0x270(%rbp), %rsi
callq 0x4b2e
leaq -0x7bc(%rip), %rcx      # 0x354c
movq %rcx, (%rax)
leaq -0x270(%rbp), %r14
movq %r14, %rdi
callq 0x30c0
andq $0x0, 0x40(%r14)
cmpl $0x4, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
sete 0x48(%r14)
leaq -0x70(%rbp), %rcx
leaq -0xd0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, (%rcx)
movb $0x0, (%rax)
movq 0xb27a(%rip), %r15      # 0xefd8
leaq -0xe0(%rbp), %r13
leaq 0xb444(%rip), %rbx      # 0xf1b0
leaq -0xc0(%rbp), %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x3210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4002
movq %rbx, %rdi
movq %r13, %rsi
callq 0x72b0
leaq 0xb416(%rip), %rcx      # 0xf1b8
cmpq %rcx, %rax
je 0x3e17
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4bd4
movq %r14, %rdi
movq %r15, %rsi
callq *(%rax)
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x4c3e
leaq -0xb8(%rbp), %rdi
callq 0x5092
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
testq %rax, %rax
je 0x3df8
lock
incl 0x8(%rax)
leaq -0x270(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4c78
leaq -0xa8(%rbp), %rdi
jmp 0x3f6b
movq %r13, %rdi
leaq 0x542a(%rip), %rsi      # 0x924b
callq 0x4b1e
testb %al, %al
je 0x3e8f
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r14, %rdi
callq 0x36ff
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x4ca8
leaq -0xb8(%rbp), %rdi
callq 0x5092
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0xa0(%rbp)
movq %rax, -0x98(%rbp)
testq %rax, %rax
je 0x3e70
lock
incl 0x8(%rax)
leaq -0x270(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4ce2
leaq -0x98(%rbp), %rdi
jmp 0x3f6b
movq %r13, %rdi
leaq 0x53a4(%rip), %rsi      # 0x923d
callq 0x4b1e
testb %al, %al
je 0x3f04
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r14, %rdi
callq 0x3791
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x4d10
leaq -0xb8(%rbp), %rdi
callq 0x5092
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x90(%rbp)
movq %rax, -0x88(%rbp)
testq %rax, %rax
je 0x3ee8
lock
incl 0x8(%rax)
leaq -0x270(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x4d4a
leaq -0x88(%rbp), %rdi
jmp 0x3f6b
movq %r13, %rdi
leaq 0x5339(%rip), %rsi      # 0x9247
callq 0x4b1e
testb %al, %al
je 0x3f7e
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq %r14, %rdi
callq 0x38c9
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x4d7c
leaq -0xb8(%rbp), %rdi
callq 0x5092
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq %rax, -0x78(%rbp)
testq %rax, %rax
je 0x3f57
lock
incl 0x8(%rax)
leaq -0x270(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x4db6
leaq -0x78(%rbp), %rdi
callq 0x5092
leaq -0x48(%rbp), %rdi
callq 0x5092
jmp 0x3d73
movq %r13, %rdi
leaq 0x52c9(%rip), %rsi      # 0x9251
callq 0x4b1e
testb %al, %al
je 0x3fab
leaq -0x50(%rbp), %r12
movq %r12, %rdi
callq 0x3a07
leaq -0x70(%rbp), %rdi
movq %r12, %rsi
callq 0x4e6e
jmp 0x3f70
movq %r13, %rdi
leaq 0x52a3(%rip), %rsi      # 0x9258
callq 0x4b1e
testb %al, %al
jne 0x4002
movq %r13, %rdi
leaq 0x5294(%rip), %rsi      # 0x925c
callq 0x4b1e
testb %al, %al
je 0x4060
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq %r15, %rdi
leaq -0x50(%rbp), %r12
movq %r12, %rsi
callq 0x3050
movq %r12, %rdi
callq 0x30c0
jmp 0x3d73
leaq -0x70(%rbp), %rdi
callq 0x503c
xorl %r12d, %r12d
movq 0xafb3(%rip), %r8       # 0xefc8
leaq -0x270(%rbp), %rdi
movq %rax, %rsi
movl -0x58(%rbp), %edx
movl -0x54(%rbp), %ecx
callq 0x4ea8
leaq -0xe0(%rbp), %rdi
callq 0x30c0
leaq -0x68(%rbp), %rdi
callq 0x5092
leaq -0x270(%rbp), %rdi
callq 0x5068
movl %r12d, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xaf89(%rip), %rdi      # 0xeff0
leaq 0x51f0(%rip), %rsi      # 0x925e
callq 0x31d0
pushq $0x1
popq %r12
leaq -0xe0(%rbp), %rsi
movq %rax, %rdi
callq 0x31b0
leaq 0x51da(%rip), %rsi      # 0x9267
movq %rax, %rdi
callq 0x31d0
leaq 0x51e8(%rip), %rsi      # 0x9284
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x30d0
jmp 0x402a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x30c0
jmp 0x4145
jmp 0x40e7
jmp 0x4134
jmp 0x40ce
jmp 0x40e2
jmp 0x40ce
jmp 0x40e2
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
callq 0x30c0
jmp 0x4166
movq %rax, %rbx
jmp 0x4166
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
callq 0x3160
jmp 0x4166
jmp 0x4134
jmp 0x4139
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
jmp 0x412b
jmp 0x4139
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
jmp 0x412b
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
jmp 0x412b
jmp 0x4139
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x5092
jmp 0x413c
jmp 0x4134
movq %rax, %rbx
jmp 0x4145
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x5092
leaq -0xe0(%rbp), %rdi
callq 0x30c0
leaq -0x68(%rbp), %rdi
callq 0x5092
leaq -0x270(%rbp), %rdi
callq 0x5068
movq %rbx, %rdi
callq 0x32d0