// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, 0xa8(%rsp)
movq %rsi, 0xb0(%rsp)
movq %rdi, %rbx
leaq 0x100(%rsp), %r14
movq %r14, %rdi
callq 0x22b0
movq (%rbx), %rsi
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x21a0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rbx
andq $0x0, 0x10(%rbx)
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, (%rbx)
movb $0x0, (%rax)
leaq 0x100(%rsp), %r14
leaq 0xe0(%rsp), %r15
movq 0x100(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x120(%rsp,%rax)
jne 0x2669
movq %r14, %rdi
movq %r15, %rsi
callq 0x20a0
movq 0xe0(%rsp), %rax
movq 0xe8(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x33c8
jmp 0x2627
leaq 0x100(%rsp), %rdi
callq 0x20b0
movq 0x30(%rsp), %rdi
leaq 0x5982(%rip), %rsi      # 0x8004
callq 0x33f4
testb %al, %al
je 0x26ab
movq 0x992e(%rip), %rdi      # 0xbfc0
leaq 0x596f(%rip), %rsi      # 0x8008
callq 0x2270
movq %rax, %rdi
callq 0x2140
jmp 0x29f3
leaq 0x30(%rsp), %rdi
movq (%rdi), %rsi
callq 0x33fe
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x2710
movb (%rax,%rdx), %sil
cmpb $0x20, %sil
sete %dil
movsbl %sil, %esi
addl $-0x30, %esi
cmpl $0xa, %esi
setb %sil
orb %dil, %sil
incq %rdx
testb %sil, %sil
jne 0x26c6
movq 0x98c9(%rip), %rdi      # 0xbfc0
leaq 0x592b(%rip), %rsi      # 0x8029
callq 0x2270
movq %rax, %rdi
callq 0x2140
jmp 0x29f3
leaq 0x5933(%rip), %rsi      # 0x804a
leaq 0xc0(%rsp), %rdi
leaq 0x88(%rsp), %rdx
callq 0x3404
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movq 0x30(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x24fc
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %r14
xorl %r15d, %r15d
leaq 0x88(%rsp), %rbp
movq %rax, 0x8(%rsp)
cmpq %r14, %r13
je 0x27f7
movq %rbp, %rdi
movq %r13, %rsi
callq 0x22e0
testl %r15d, %r15d
je 0x27c6
cmpl $0x1, %r15d
je 0x27ae
cmpl $0x2, %r15d
jne 0x27e0
movb $0x1, %bl
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x343f
pushq $0x3
popq %rax
movl %eax, %r15d
jmp 0x27e2
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x343f
movq %rax, 0x8(%rsp)
movb $0x1, %bl
pushq $0x2
jmp 0x27da
movq %rbp, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x343f
movl %eax, %r12d
movb $0x1, %bl
pushq $0x1
popq %rax
movl %eax, %r15d
jmp 0x27e2
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0x2120
addq $0x20, %r13
testb %bl, %bl
jne 0x2776
jmp 0x29d2
leaq 0x30(%rsp), %rdi
movq (%rdi), %rsi
callq 0x33fe
leaq 0x10(%rsp), %rdi
callq 0x345c
xorl %edi, %edi
movq %r12, %rbx
testl %ebx, %ebx
cmovlel %edi, %ebx
leaq 0x70(%rsp), %rbp
leaq 0x88(%rsp), %r14
leaq 0x50(%rsp), %r13
cmpq %rbx, %rdi
je 0x28d9
movq %rdi, 0xb8(%rsp)
shlq $0x5, %rdi
addq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x24fc
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %r12
cmpq %r12, %r15
je 0x289e
movq %r14, %rdi
movq %r15, %rsi
callq 0x22e0
movq 0x88(%rsp), %rdi
xorl %esi, %esi
callq 0x23b8
movss %xmm0, 0x50(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3e10
movq %r14, %rdi
callq 0x2120
addq $0x20, %r15
jmp 0x2860
movq 0xb0(%rsp), %rdi
movq %rbp, %rsi
callq 0x3464
leaq 0x10(%rsp), %rdi
callq 0x345c
movq 0x70(%rsp), %rax
cmpq %rax, 0x78(%rsp)
je 0x28c9
movq %rax, 0x78(%rsp)
movq 0xb8(%rsp), %rdi
incq %rdi
jmp 0x282a
leaq 0x30(%rsp), %r14
subl $0x1, %ebx
jb 0x28f2
movq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x33fe
jmp 0x28de
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
testl %eax, %eax
cmovlel %r15d, %eax
movq %rax, 0x8(%rsp)
leaq 0x88(%rsp), %r13
leaq 0x4c(%rsp), %rbp
cmpq 0x8(%rsp), %r15
je 0x29c8
movq %r15, %rdi
shlq $0x5, %rdi
addq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x24fc
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r14
cmpq %r14, %r12
je 0x2995
movq %r13, %rdi
movq %r12, %rsi
callq 0x22e0
movq 0x88(%rsp), %rdi
xorl %esi, %esi
callq 0x23b8
cvttss2si %xmm0, %eax
movl %eax, 0x4c(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4208
movq %r13, %rdi
callq 0x2120
addq $0x20, %r12
jmp 0x2955
movq 0xa8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3490
leaq 0x10(%rsp), %rdi
callq 0x345c
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x29c0
movq %rax, 0x58(%rsp)
incq %r15
jmp 0x2922
leaq 0x50(%rsp), %rdi
callq 0x41d4
leaq 0x70(%rsp), %rdi
callq 0x3dac
leaq 0x10(%rsp), %rdi
callq 0x34bc
leaq 0xc0(%rsp), %rdi
callq 0x2120
leaq 0xe0(%rsp), %rdi
callq 0x2120
leaq 0x30(%rsp), %rdi
callq 0x34bc
leaq 0x100(%rsp), %rdi
callq 0x20c0
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2a6a
jmp 0x2a6a
jmp 0x2a44
jmp 0x2a44
jmp 0x2a44
movq %rax, %rbx
jmp 0x2ab7
jmp 0x2a6f
jmp 0x2a44
jmp 0x2a6a
jmp 0x2a6a
jmp 0x2a49
jmp 0x2a6a
movq %rax, %rbx
jmp 0x2aa0
movq %rax, %rbx
jmp 0x2a5e
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2120
leaq 0x50(%rsp), %rdi
callq 0x41d4
jmp 0x2a7f
movq %rax, %rbx
jmp 0x2a7f
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x2120
leaq 0x70(%rsp), %rdi
callq 0x3dac
leaq 0x10(%rsp), %rdi
callq 0x34bc
leaq 0xc0(%rsp), %rdi
callq 0x2120
leaq 0xe0(%rsp), %rdi
callq 0x2120
leaq 0x30(%rsp), %rdi
callq 0x34bc
leaq 0x100(%rsp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2380