// File: mlugo2[P]SunshineGPU/inc/main.h
// Function: object_file_interface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>*, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>*)
void object_file_interface(std::string fileName, 
	std::vector<std::vector<float> > *vertex, 
	std::vector<std::vector<int> > *face)
{
	// Opening file
	std::ifstream myFile;
	myFile.open(fileName.data());

	// Read file into vector for easier processing
	std::vector<std::string> data;
	std::string line;
	while( myFile.good() )
	{
		getline(myFile, line);
		line[line.length()] = '\0';
		data.push_back(line);
	}

	myFile.close();

	// Validate file
	if ( data[0] != "OFF" )
	{
		std::cout << "ERORR(1): incorrect file format." << std::endl;
		return;
	}

	// Header not needed anymore
	data.erase(data.begin());

	// Check that they are numbers
	// #verticies #faces #edges
	for ( auto i : data[0] )
	{
		// Skip over spaces
		if ( i == ' ')
			continue;
		
		if (!isdigit(i))
		{
			std::cout << "ERORR(2): incorrect file format." << std::endl;
			return;
		}
	}


	// Now to get all the data out..
	std::string delims = " \t";
	std::vector<std::string> tempData;
	std::vector<float> temp;

	// Get the number of vertices, faces, and edges
	// in that order.
	tokenize(data[0], tempData, delims);
	int vertNum;
	int faceNum;
	int edgeNum;

	int index = 0;
	for ( auto i : tempData )
	{
		switch(index)
		{
			case 0: vertNum = stoi(i); index++; break;
			case 1: faceNum = stoi(i); index++; break;
			case 2: edgeNum = stoi(i); index++; break;
			default: return;
		}
	}

	// Erase more of the header
	data.erase(data.begin());
	tempData.clear();

	// Go through the rows of vertex data
	for (int i = 0; i < vertNum; ++i)
	{
		tokenize(data[i], tempData, delims);

		for ( auto j : tempData )
		{
			temp.push_back( std::strtof((j).c_str(), 0) );
		}

		vertex->push_back(temp);

		tempData.clear();
		temp.clear();
	}

	for (int i = 0; i < vertNum; ++i)
		data.erase(data.begin());


	std::vector<int> int_temp;
	for ( int i = 0; i < faceNum; ++i )
	{
		tokenize(data[i], tempData, delims);

		for ( auto j : tempData )
		{
			int_temp.push_back( (int)strtof((j).c_str(), 0) );
		}

		face->push_back(int_temp);

		tempData.clear();
		int_temp.clear();
	}

}

// Assembly:
subq $0x4b8, %rsp            # imm = 0x4B8
movq %rdi, 0x88(%rsp)
movq %rdi, 0x4b0(%rsp)
movq %rsi, 0x4a8(%rsp)
movq %rdx, 0x4a0(%rsp)
leaq 0x298(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x3390
movq 0x88(%rsp), %rdi
callq 0x3190
movq 0x90(%rsp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x31f0
jmp 0x3800
leaq 0x270(%rsp), %rdi
callq 0x51a0
leaq 0x250(%rsp), %rdi
callq 0x33c0
movq 0x298(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x298(%rsp,%rax), %rdi
callq 0x3450
movb %al, 0x87(%rsp)
jmp 0x383c
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x384c
jmp 0x38df
leaq 0x298(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x30b0
jmp 0x3863
leaq 0x250(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x3400
movq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x34f0
movq %rax, 0x78(%rsp)
jmp 0x3889
movq 0x78(%rsp), %rax
movb $0x0, (%rax)
leaq 0x270(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x51b0
jmp 0x38a8
jmp 0x381a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x420b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x41f1
leaq 0x298(%rsp), %rdi
callq 0x30c0
jmp 0x38ee
xorl %eax, %eax
movl %eax, %esi
leaq 0x270(%rsp), %rdi
callq 0x5250
movq %rax, %rdi
leaq 0x116fb(%rip), %rsi     # 0x15004
callq 0x5220
movb %al, 0x6f(%rsp)
jmp 0x3914
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x391e
jmp 0x395b
movq 0x1869b(%rip), %rdi     # 0x1bfc0
leaq 0x116dc(%rip), %rsi     # 0x15008
callq 0x3300
movq %rax, 0x60(%rsp)
jmp 0x3938
movq 0x60(%rsp), %rdi
movq 0x18664(%rip), %rsi     # 0x1bfa8
callq 0x3340
jmp 0x394b
movl $0x1, 0x24c(%rsp)
jmp 0x418e
leaq 0x270(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x52e0
movq %rax, 0x238(%rsp)
leaq 0x240(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x5310
movq 0x50(%rsp), %rdi
movq 0x240(%rsp), %rsi
callq 0x5270
movq %rax, 0x58(%rsp)
jmp 0x39a3
movq 0x58(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0x270(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5250
movq %rax, 0x228(%rsp)
movq 0x228(%rsp), %rdi
callq 0x3280
movq %rax, 0x220(%rsp)
movq 0x228(%rsp), %rdi
callq 0x31a0
movq %rax, 0x218(%rsp)
leaq 0x220(%rsp), %rdi
leaq 0x218(%rsp), %rsi
callq 0x5350
testb $0x1, %al
jne 0x3a11
jmp 0x3a99
leaq 0x220(%rsp), %rdi
callq 0x5390
movb (%rax), %al
movb %al, 0x217(%rsp)
movsbl 0x217(%rsp), %eax
cmpl $0x20, %eax
jne 0x3a36
jmp 0x3a87
movsbl 0x217(%rsp), %edi
callq 0x32a0
cmpl $0x0, %eax
jne 0x3a85
movq 0x18571(%rip), %rdi     # 0x1bfc0
leaq 0x115d3(%rip), %rsi     # 0x15029
callq 0x3300
movq %rax, 0x48(%rsp)
jmp 0x3a62
movq 0x48(%rsp), %rdi
movq 0x1853a(%rip), %rsi     # 0x1bfa8
callq 0x3340
jmp 0x3a75
movl $0x1, 0x24c(%rsp)
jmp 0x418e
jmp 0x3a87
leaq 0x220(%rsp), %rdi
callq 0x53a0
jmp 0x39f3
leaq 0x1ef(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x34a0
movq 0x40(%rsp), %rdx
leaq 0x11593(%rip), %rsi     # 0x1504a
leaq 0x1f0(%rsp), %rdi
callq 0x53c0
jmp 0x3ac6
leaq 0x1ef(%rsp), %rdi
callq 0x3360
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x51a0
leaq 0x1b8(%rsp), %rdi
callq 0x5480
xorl %eax, %eax
movl %eax, %esi
leaq 0x270(%rsp), %rdi
callq 0x5250
movq 0x38(%rsp), %rsi
movq %rax, %rdi
leaq 0x1f0(%rsp), %rdx
callq 0x3680
jmp 0x3b1a
movl $0x0, 0x1a8(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x52e0
movq %rax, 0x198(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x5490
movq %rax, 0x190(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x54c0
testb $0x1, %al
jne 0x3b7d
jmp 0x3d2e
leaq 0x198(%rsp), %rdi
callq 0x5500
movq %rax, %rsi
leaq 0x170(%rsp), %rdi
callq 0x3130
jmp 0x3b9c
movl 0x1a8(%rsp), %eax
movl %eax, 0x34(%rsp)
testl %eax, %eax
je 0x3c0d
jmp 0x3bad
movl 0x34(%rsp), %eax
subl $0x1, %eax
je 0x3c70
jmp 0x3bbc
movl 0x34(%rsp), %eax
subl $0x2, %eax
je 0x3caa
jmp 0x3ce4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x1ef(%rsp), %rdi
callq 0x3360
jmp 0x41f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x41ca
xorl %eax, %eax
movl %eax, %esi
leaq 0x170(%rsp), %rdi
movl $0xa, %edx
callq 0x5510
movl %eax, 0x30(%rsp)
jmp 0x3c29
movl 0x30(%rsp), %eax
movl %eax, 0x1b4(%rsp)
movl 0x1a8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0x3cf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x31e0
jmp 0x41ca
xorl %eax, %eax
movl %eax, %esi
leaq 0x170(%rsp), %rdi
movl $0xa, %edx
callq 0x5510
movl %eax, 0x2c(%rsp)
jmp 0x3c8c
movl 0x2c(%rsp), %eax
movl %eax, 0x1b0(%rsp)
movl 0x1a8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0x3cf1
xorl %eax, %eax
movl %eax, %esi
leaq 0x170(%rsp), %rdi
movl $0xa, %edx
callq 0x5510
movl %eax, 0x28(%rsp)
jmp 0x3cc6
movl 0x28(%rsp), %eax
movl %eax, 0x1ac(%rsp)
movl 0x1a8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0x3cf1
movl $0x1, 0x24c(%rsp)
jmp 0x3cfc
movl $0x0, 0x24c(%rsp)
leaq 0x170(%rsp), %rdi
callq 0x31e0
movl 0x24c(%rsp), %eax
testl %eax, %eax
jne 0x4167
jmp 0x3d1a
jmp 0x3d1c
leaq 0x198(%rsp), %rdi
callq 0x5560
jmp 0x3b5f
leaq 0x270(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x52e0
movq %rax, 0x160(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x5310
movq 0x18(%rsp), %rdi
movq 0x168(%rsp), %rsi
callq 0x5270
movq %rax, 0x20(%rsp)
jmp 0x3d76
movq 0x20(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x5580
movl $0x0, 0x154(%rsp)
movl 0x154(%rsp), %eax
cmpl 0x1b4(%rsp), %eax
jge 0x3f1a
movslq 0x154(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0x5250
movq %rax, %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
callq 0x3680
jmp 0x3dde
leaq 0x1d0(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rdi
callq 0x52e0
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rdi
callq 0x5490
movq %rax, 0x138(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x54c0
testb $0x1, %al
jne 0x3e36
jmp 0x3ed3
leaq 0x140(%rsp), %rdi
callq 0x5500
movq %rax, %rsi
leaq 0x118(%rsp), %rdi
callq 0x3130
jmp 0x3e55
leaq 0x118(%rsp), %rdi
callq 0x3120
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3508
movss %xmm0, 0x114(%rsp)
leaq 0x1b8(%rsp), %rdi
leaq 0x114(%rsp), %rsi
callq 0x55a0
jmp 0x3e8e
leaq 0x118(%rsp), %rdi
callq 0x31e0
leaq 0x140(%rsp), %rdi
callq 0x5560
jmp 0x3e18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x31e0
jmp 0x41ca
movq 0x4a8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x55d0
jmp 0x3eea
leaq 0x1d0(%rsp), %rdi
callq 0x5580
leaq 0x1b8(%rsp), %rdi
callq 0x5640
movl 0x154(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x154(%rsp)
jmp 0x3d9b
movl $0x0, 0x110(%rsp)
movl 0x110(%rsp), %eax
cmpl 0x1b4(%rsp), %eax
jge 0x3f9d
leaq 0x270(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x52e0
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x5310
movq 0x8(%rsp), %rdi
movq 0x108(%rsp), %rsi
callq 0x5270
movq %rax, 0x10(%rsp)
jmp 0x3f7d
movq 0x10(%rsp), %rax
movq %rax, 0xf8(%rsp)
movl 0x110(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x110(%rsp)
jmp 0x3f25
leaq 0xe0(%rsp), %rdi
callq 0x5660
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
cmpl 0x1b0(%rsp), %eax
jge 0x414f
movslq 0xdc(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0x5250
movq %rax, %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x1f0(%rsp), %rdx
callq 0x3680
jmp 0x3ff8
leaq 0x1d0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x52e0
movq %rax, 0xc8(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x5490
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x54c0
testb $0x1, %al
jne 0x4050
jmp 0x4108
leaq 0xc8(%rsp), %rdi
callq 0x5500
movq %rax, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x3130
jmp 0x406f
leaq 0xa0(%rsp), %rdi
callq 0x3120
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3508
cvttss2si %xmm0, %eax
movl %eax, 0x9c(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0x9c(%rsp), %rsi
callq 0x5670
jmp 0x40aa
leaq 0xa0(%rsp), %rdi
callq 0x31e0
leaq 0xc8(%rsp), %rdi
callq 0x5560
jmp 0x4032
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
jmp 0x41bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x290(%rsp)
movl %eax, 0x28c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x31e0
jmp 0x41bd
movq 0x4a0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x56a0
jmp 0x411f
leaq 0x1d0(%rsp), %rdi
callq 0x5580
leaq 0xe0(%rsp), %rdi
callq 0x5710
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x3fb5
leaq 0xe0(%rsp), %rdi
callq 0x5730
movl $0x0, 0x24c(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0x5790
leaq 0x1d0(%rsp), %rdi
callq 0x57f0
leaq 0x1f0(%rsp), %rdi
callq 0x31e0
leaq 0x250(%rsp), %rdi
callq 0x31e0
leaq 0x270(%rsp), %rdi
callq 0x57f0
leaq 0x298(%rsp), %rdi
callq 0x30d0
addq $0x4b8, %rsp            # imm = 0x4B8
retq
leaq 0xe0(%rsp), %rdi
callq 0x5730
leaq 0x1b8(%rsp), %rdi
callq 0x5790
leaq 0x1d0(%rsp), %rdi
callq 0x57f0
leaq 0x1f0(%rsp), %rdi
callq 0x31e0
leaq 0x250(%rsp), %rdi
callq 0x31e0
leaq 0x270(%rsp), %rdi
callq 0x57f0
leaq 0x298(%rsp), %rdi
callq 0x30d0
movq 0x290(%rsp), %rdi
callq 0x3490
nopw %cs:(%rax,%rax)