// File: /workspace/github_cpp_makefile_star2_O2/mhe[P]raytracerframework_cpp/raytracer.cpp
// Function: Raytracer::readScene(char*)
bool Raytracer::readScene(char* inputFilename)
{
	// Initialize a new scene
	scene = new Scene();

	// Open file stream for reading and have the YAML module parse it
	std::ifstream fin(inputFilename);
	if (!fin) {
		cerr << "Error: unable to open " << inputFilename << " for reading." << endl;;
		return false;
	}
	try {
		YAML::Parser parser(fin);
		if (parser) {
	        YAML::Node doc;
	        parser.GetNextDocument(doc);
		
			// Read scene configuration options
			scene->setEye(parseTriple(doc["Eye"]));
		
			// Read and parse the scene objects
			const YAML::Node& sceneObjects = doc["Objects"];
			if (sceneObjects.GetType() != YAML::CT_SEQUENCE) {
				cerr << "Error: expected a sequence of objects." << endl;
				return false;
			}
			for(YAML::Iterator it=sceneObjects.begin();it!=sceneObjects.end();++it) {
				Object *obj = parseObject(*it);
				// Only add object if it is recognized
				if (obj) {
					scene->addObject(obj);
				} else {
					cerr << "Warning: found object of unknown type, ignored." << endl;
				}
			}
		
			// Read and parse light definitions
			const YAML::Node& sceneLights = doc["Lights"];
			if (sceneObjects.GetType() != YAML::CT_SEQUENCE) {
				cerr << "Error: expected a sequence of lights." << endl;
				return false;
			}
			for(YAML::Iterator it=sceneLights.begin();it!=sceneLights.end();++it) {
				scene->addLight(parseLight(*it));
			}
	    }
		if (parser) {
			cerr << "Warning: unexpected YAML document, ignored." << endl;
		}
	} catch(YAML::ParserException& e) {
	    std::cerr << "Error at line " << e.line + 1 << ", col " << e.column + 1 << ": " << e.msg << std::endl;
		return false;
	}

	cout << "YAML parsing results: " << scene->getNumObjects() << " objects read." << endl;
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
movq %rsi, %r14
movq %rdi, %rbx
movl $0x398, %edi            # imm = 0x398
callq 0x42a0
andl $0x0, (%rax)
andl $0x0, 0x328(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x380(%rax)
andq $0x0, 0x390(%rax)
movq %rax, (%rbx)
leaq -0x2f8(%rbp), %r15
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x4560
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x2d8(%rbp,%rax)
je 0xf2e9
movq 0x1ed3c(%rip), %rdi     # 0x2dff0
leaq 0x13284(%rip), %rsi     # 0x2253f
callq 0x4280
movq %rax, %rdi
movq %r14, %rsi
callq 0x4280
leaq 0x13284(%rip), %rsi     # 0x22556
movq %rax, %rdi
callq 0x4280
movq %rax, %rdi
callq 0x4120
xorl %ebx, %ebx
jmp 0xf583
leaq -0x98(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x1ac04
leaq -0x98(%rbp), %rdi
callq 0x1acfc
testb %al, %al
je 0xf513
leaq -0xf0(%rbp), %rdi
callq 0x19ec2
leaq -0x98(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x1ad0c
movq (%rbx), %r14
leaq 0x1322b(%rip), %rsi     # 0x22564
leaq -0xf0(%rbp), %rdi
callq 0xf7ee
leaq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0xef7a
movq -0x48(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x58(%rbp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x1837a
leaq 0x131f7(%rip), %rsi     # 0x22568
leaq -0xf0(%rbp), %rdi
callq 0xf7ee
movq %rax, %r14
movq %rax, %rdi
callq 0x1a580
cmpl $0x2, %eax
jne 0xf412
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x1a5ce
leaq -0x38(%rbp), %r15
leaq -0x30(%rbp), %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a66a
movq %r12, %rdi
movq %r15, %rsi
callq 0x18fd3
movl %eax, %r13d
movq %r15, %rdi
callq 0x18dac
testb %r13b, %r13b
je 0xf43e
movq %r12, %rdi
callq 0x18e30
movq %rax, %rsi
callq 0xf09a
testq %rax, %rax
je 0xf3ed
movq (%rbx), %rdi
movq %rax, %rsi
callq 0x1834c
jmp 0xf408
movq 0x1ebfc(%rip), %rdi     # 0x2dff0
leaq 0x1319c(%rip), %rsi     # 0x22597
callq 0x4280
movq %rax, %rdi
callq 0x4120
movq %r12, %rdi
callq 0x18dc4
jmp 0xf3a5
movq 0x1ebd7(%rip), %rdi     # 0x2dff0
leaq 0x13150(%rip), %rsi     # 0x22570
callq 0x4280
movq %rax, %rdi
callq 0x4120
leaq -0xf0(%rbp), %rdi
callq 0x19ef2
jmp 0xf5a3
leaq -0x30(%rbp), %rdi
callq 0x18dac
leaq 0x13179(%rip), %rsi     # 0x225c7
leaq -0xf0(%rbp), %rdi
callq 0xf7ee
movq %rax, %r15
movq %r14, %rdi
callq 0x1a580
movl %eax, %r14d
cmpl $0x2, %eax
jne 0xf4d3
leaq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x1a5ce
movl %r14d, -0x3c(%rbp)
leaq -0x38(%rbp), %r12
leaq -0x30(%rbp), %r13
movq %r12, %rdi
movq %r15, %rsi
callq 0x1a66a
movq %r13, %rdi
movq %r12, %rsi
callq 0x18fd3
movl %eax, %r14d
movq %r12, %rdi
callq 0x18dac
testb %r14b, %r14b
je 0xf4f0
movq (%rbx), %r14
movq %r13, %rdi
callq 0x18e30
movq %rax, %rsi
callq 0xf1b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1835e
movq %r13, %rdi
callq 0x18dc4
jmp 0xf485
movq 0x1eb16(%rip), %rdi     # 0x2dff0
leaq 0x130ed(%rip), %rsi     # 0x225ce
callq 0x4280
movq %rax, %rdi
callq 0x4120
jmp 0xf4fd
leaq -0x30(%rbp), %rdi
callq 0x18dac
movl -0x3c(%rbp), %r14d
leaq -0xf0(%rbp), %rdi
callq 0x19ef2
cmpl $0x2, %r14d
jne 0xf5a3
leaq -0x98(%rbp), %rdi
callq 0x1acfc
testb %al, %al
je 0xf53e
movq 0x1eac6(%rip), %rdi     # 0x2dff0
leaq 0x130c3(%rip), %rsi     # 0x225f4
callq 0x4280
movq %rax, %rdi
callq 0x4120
leaq -0x98(%rbp), %rdi
callq 0x1acc4
movq 0x1ea7f(%rip), %rdi     # 0x2dfd0
leaq 0x130de(%rip), %rsi     # 0x22636
callq 0x4280
movq (%rbx), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x41c0
leaq 0x130dc(%rip), %rsi     # 0x2264d
movq %rax, %rdi
callq 0x4280
movb $0x1, %bl
movq %rax, %rdi
callq 0x4120
leaq -0x2f8(%rbp), %rdi
callq 0x40a0
movl %ebx, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x98(%rbp), %rdi
callq 0x1acc4
jmp 0xf2e2
jmp 0xf5c6
jmp 0xf5c6
jmp 0xf5ce
jmp 0xf5c6
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf62f
jmp 0xf5c6
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf617
movq %rdx, %r14
movq %rax, %rbx
jmp 0xf623
jmp 0xf608
jmp 0xf5de
jmp 0xf608
jmp 0xf608
movq %rdx, %r14
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x18dac
jmp 0xf60e
movq %rax, %rbx
leaq -0x2f8(%rbp), %rdi
callq 0x40a0
movq %rbx, %rdi
callq 0x4530
jmp 0xf608
movq %rdx, %r14
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x18dac
leaq -0xf0(%rbp), %rdi
callq 0x19ef2
leaq -0x98(%rbp), %rdi
callq 0x1acc4
cmpl $0x1, %r14d
jne 0xf5f2
movq %rbx, %rdi
callq 0x40f0
movq %rax, %rbx
movq 0x1e9a9(%rip), %rdi     # 0x2dff0
leaq 0x12fd2(%rip), %rsi     # 0x22620
callq 0x4280
movl 0x8(%rbx), %esi
incl %esi
movq %rax, %rdi
callq 0x4500
leaq 0x12fc8(%rip), %rsi     # 0x2262f
movq %rax, %rdi
callq 0x4280
movl 0xc(%rbx), %esi
incl %esi
movq %rax, %rdi
callq 0x4500
leaq 0x12b72(%rip), %rsi     # 0x221f5
movq %rax, %rdi
callq 0x4280
addq $0x10, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4120
callq 0x44c0
jmp 0xf2e2
jmp 0xf5ef
movq %rax, %rbx
callq 0x44c0
jmp 0xf5f2
movq %rax, %rdi
callq 0xf89e