// File: /workspace/github_cpp_makefile_star2_O1/aleperno[P]Datos/main.cpp
// Function: main
int main( int argc, char* args[] ) {

	//Se le pasará como argumento el archivo labeledTrainData.tsv (preparseado).
	char* learningPath = args[1];

	// path de análisis
	char* testPath = args[2];

	//El valor con el que se inicializara los pesos del perceptron
	float init = atoi(args[3]);

	// Metodo Perceptron
	unsigned int hash_size = pow(2,25);
	float learning_rate = 0.1 * log(2);
	HashingPerceptron* perceptron = new HashingPerceptron(learningPath,3, learning_rate ,hash_size,init);

	//Levanto y parseo el archivo a analizar
	//Parser* parser = new Parser();

	//ifstream testfile;
	//testfile.open(testPath);

	/*
	vector<string> id_reviews;
	vector<float> scoresP;
	//Utilizo para normalizar los resultados del perceptron
	printf("Comienzo a evaluar el set de prueba\n");
	if(testfile.is_open())
	{
		string linea;
		while( getline(testfile,linea) )
		{
			vector<string> tokenized_columns = parser->tokenizeColumns(linea);
			vector<string> tokenized_words = parser->tokenizeReviews(tokenized_columns[1]); //TODO cero porque solo son strings

			id_reviews.push_back(tokenized_columns[0]);

			float score = perceptron->rate(tokenized_words);
			scoresP.push_back(score);
		}
	}
	*/
	//delete parser;
	vector<pair<string,float>> result = perceptron->rate(testPath);
	//Imprimo los resultados
	ofstream outfile("popcorn.csv");
	outfile << "\"id\",\"sentiment\"" << endl;

	for (unsigned int i=0; i < result.size(); i++)
	{
		outfile << result[i].first +"," << result[i].second <<endl;
	}
	outfile.close();

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq 0x8(%rsi), %r15
movq 0x10(%rsi), %rbx
movq 0x18(%rsi), %rdi
callq 0x3370
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0xa0, %edi
callq 0x3230
movq %rax, %r14
movss 0x65ab(%rip), %xmm0     # 0xa004
movq %rax, %rdi
movq %r15, %rsi
movl $0x3, %edx
movl $0x2000000, %ecx        # imm = 0x2000000
movss -0x2c(%rbp), %xmm1
callq 0x6cc6
leaq -0x48(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x7a2e
leaq 0x6585(%rip), %rsi      # 0xa00e
leaq -0x268(%rbp), %rdi
movl $0x10, %edx
callq 0x3260
leaq 0x6579(%rip), %rsi      # 0xa01a
leaq -0x268(%rbp), %rbx
movl $0x10, %edx
movq %rbx, %rdi
callq 0x3290
movq -0x268(%rbp), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
leaq -0x268(%rbp), %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq -0x48(%rbp), %rax
cmpq %rax, -0x40(%rbp)
je 0x3bbb
movl $0x1, %r14d
leaq -0x58(%rbp), %r13
xorl %ecx, %ecx
leaq -0x68(%rbp), %rbx
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
leaq (%rcx,%rcx,4), %r12
movq %r13, -0x68(%rbp)
movq (%rax,%r12,8), %rsi
movq 0x8(%rax,%r12,8), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3cb2
movq %rbx, %rdi
leaq 0x64d6(%rip), %rsi      # 0xa008
callq 0x3430
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x268(%rbp), %rdi
callq 0x3290
movq -0x48(%rbp), %rcx
xorps %xmm0, %xmm0
cvtss2sd 0x20(%rcx,%r12,8), %xmm0
movq %rax, %rdi
callq 0x3380
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x3b99
callq 0x3210
movl %r14d, %ecx
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0x3b0c
leaq -0x268(%rbp), %rdi
callq 0x3310
movq 0xa402(%rip), %rax      # 0xdfd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x260(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x268(%rbp,%rcx)
callq 0x31f0
leaq -0x170(%rbp), %rdi
callq 0x3110
leaq -0x48(%rbp), %rdi
callq 0x3c64
xorl %eax, %eax
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3c52
movq %rax, %rbx
movq %r14, %rdi
callq 0x3210
jmp 0x3c5b
jmp 0x3c2e
movq %rax, %rbx
jmp 0x3c46
jmp 0x3c35
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x3c46
callq 0x3210
leaq -0x268(%rbp), %rdi
callq 0x3330
leaq -0x48(%rbp), %rdi
callq 0x3c64
movq %rbx, %rdi
callq 0x33e0
nop