// File: /workspace/github_cpp_makefile_star2_O2/ghulette[P]neural-net-openmp/main.cpp
// Function: main
int main(int argc, char * const argv[]) {
	using namespace std;
	
	srand((unsigned)time(0));
	cout.precision(2);
	cout.setf(ios::fixed | ios::showpoint);
	
	DataSet *train = new DataSet(IDX_DIR + TRAINING_IMAGES, IDX_DIR + TRAINING_LABELS, OUTPUT_ENC);
	DataSet *test = new DataSet(IDX_DIR + TESTING_IMAGES, IDX_DIR + TESTING_LABELS, OUTPUT_ENC);
	NeuralNet *nn = new NeuralNet(train->image_vector_length(), NUM_HIDDEN_NODES, train->label_vector_length());
	
	int train_len = train->length();
	cout << "Training on " << train_len << " examples" << endl;
	ticks train_start = getticks();
	for(int i=0; i < train_len; i++) {
		nn->train(train->image_vector(i), train->label_vector(i), ETA);
	}
	ticks train_end = getticks();
	
	int test_len = test->length();
	cout << "Testing on " << test_len << " examples" << endl;
	ticks test_start = getticks();
	int correct = 0;
	for(int i=0; i < test_len; i++) {
		int guess = test->label_for_vector(nn->run(test->image_vector(i)));
		int answer = test->label(i);
		if(guess == answer) {
			correct ++;
		}
	}
	ticks test_end = getticks();
	
	cout << "Correct: " << correct << "/" << test_len << " (" << 100 * double(correct)/test_len << "%)" << endl;
	cout << "Training: " << elapsed(train_end, train_start) << endl;
	cout << "Testing: " << elapsed(test_end, test_start) << endl;
	
	delete nn;
	delete train;
	delete test;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
xorl %edi, %edi
callq 0x20e0
movl %eax, %edi
callq 0x20f0
movq 0x3152(%rip), %rax      # 0x5fd0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x2, 0x8(%rax,%rdx)
movq -0x18(%rcx), %rcx
orl $0x404, 0x18(%rax,%rcx) # imm = 0x404
pushq $0x28
popq %rdi
callq 0x2110
movq %rax, %rbx
leaq 0x3274(%rip), %rsi      # 0x6120
leaq 0x328d(%rip), %rdx      # 0x6140
leaq 0x98(%rsp), %rdi
callq 0x3335
leaq 0x3259(%rip), %rsi      # 0x6120
leaq 0x3292(%rip), %rdx      # 0x6160
leaq 0x78(%rsp), %rdi
callq 0x3335
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
pushq $0x2
popq %rcx
movq %rbx, %rdi
callq 0x27f0
leaq 0x78(%rsp), %rdi
callq 0x21f8
leaq 0x98(%rsp), %rdi
callq 0x21f8
pushq $0x28
popq %rdi
callq 0x2110
movq %rax, %r14
leaq 0x3207(%rip), %rsi      # 0x6120
leaq 0x3260(%rip), %rdx      # 0x6180
leaq 0x58(%rsp), %rdi
callq 0x3335
leaq 0x31ef(%rip), %rsi      # 0x6120
leaq 0x3268(%rip), %rdx      # 0x61a0
leaq 0x38(%rsp), %rdi
callq 0x3335
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
pushq $0x2
popq %rcx
movq %r14, %rdi
callq 0x27f0
leaq 0x38(%rsp), %rdi
callq 0x21f8
leaq 0x58(%rsp), %rdi
callq 0x21f8
pushq $0x50
popq %rdi
callq 0x2110
movq %rax, %r15
movq %rbx, %rdi
callq 0x2ae8
movl %eax, %ebp
movq %rbx, %rdi
callq 0x2aec
movq %r15, %rdi
movl %ebp, %esi
movl $0x12c, %edx            # imm = 0x12C
movl %eax, %ecx
callq 0x3404
movq %rbx, %rdi
callq 0x2ae4
movl %eax, %ebp
movq 0x3026(%rip), %rdi      # 0x5fd0
leaq 0x1222(%rip), %rsi      # 0x41d3
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x2190
leaq 0x1219(%rip), %rsi      # 0x41e0
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2090
rdtsc
movl %eax, 0x8(%rsp)
movq %rdx, 0x18(%rsp)
xorl %r12d, %r12d
testl %ebp, %ebp
cmovlel %r12d, %ebp
cmpl %r12d, %ebp
je 0x3024
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2af0
movq %rax, %r13
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2afc
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movsd 0x1126(%rip), %xmm0     # 0x4140
callq 0x36ba
incl %r12d
jmp 0x2feb
movq %rbx, 0x30(%rsp)
rdtsc
movq %rdx, 0x28(%rsp)
movl %eax, (%rsp)
movq %r14, %rdi
callq 0x2ae4
movl %eax, %ebp
movq 0x2f8c(%rip), %rdi      # 0x5fd0
leaq 0x119f(%rip), %rsi      # 0x41ea
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x2190
leaq 0x117f(%rip), %rsi      # 0x41e0
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2090
rdtsc
movl %eax, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
xorl %r12d, %r12d
testl %ebp, %ebp
movl $0x0, %ebx
movl %ebp, 0x24(%rsp)
cmovgl %ebp, %ebx
xorl %r13d, %r13d
cmpl %r13d, %ebx
je 0x30d2
movq %r14, %rdi
movl %r13d, %esi
callq 0x2af0
movq %r15, %rdi
movq %rax, %rsi
callq 0x35f2
movq %r14, %rdi
movq %rax, %rsi
callq 0x2b14
movl %eax, %ebp
movq %r14, %rdi
movl %r13d, %esi
callq 0x2b08
xorl %ecx, %ecx
cmpl %eax, %ebp
sete %cl
addl %ecx, %r12d
incl %r13d
jmp 0x3090
movq 0x10(%rsp), %r13
negl %r13d
shlq $0x20, %r13
movl 0x20(%rsp), %eax
movq %rax, 0x10(%rsp)
shlq $0x20, 0x28(%rsp)
movl (%rsp), %eax
movq %rax, (%rsp)
movq 0x18(%rsp), %rbx
negl %ebx
shlq $0x20, %rbx
movl 0x8(%rsp), %eax
movq %rax, 0x8(%rsp)
rdtsc
movl %eax, %eax
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, 0x18(%rsp)
movq 0x2eb1(%rip), %rdi      # 0x5fd0
leaq 0x10d0(%rip), %rsi      # 0x41f6
callq 0x2100
movq %rax, %rdi
movl %r12d, %esi
callq 0x2190
leaq 0x1036(%rip), %rsi      # 0x4173
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
movl 0x24(%rsp), %ebp
movl %ebp, %esi
callq 0x2190
leaq 0x10a6(%rip), %rsi      # 0x4200
movq %rax, %rdi
callq 0x2100
cvtsi2sd %r12d, %xmm0
mulsd 0xfd9(%rip), %xmm0      # 0x4148
cvtsi2sd %ebp, %xmm1
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2180
leaq 0x107d(%rip), %rsi      # 0x4203
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2090
leaq 0x1069(%rip), %rsi      # 0x4206
movq 0x2e2c(%rip), %r12      # 0x5fd0
movq %r12, %rdi
callq 0x2100
subq 0x8(%rsp), %rbx
movq (%rsp), %rcx
addq 0x28(%rsp), %rcx
addq %rbx, %rcx
movq %rcx, %xmm1
punpckldq 0xf86(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xf8e(%rip), %xmm1      # 0x4160
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2090
leaq 0x101c(%rip), %rsi      # 0x4211
movq %r12, %rdi
callq 0x2100
subq 0x10(%rsp), %r13
addq 0x18(%rsp), %r13
movq %r13, %xmm1
punpckldq 0xf3c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xf44(%rip), %xmm1      # 0x4160
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2090
movq %r15, %rdi
callq 0x357a
pushq $0x50
popq %rsi
movq %r15, %rdi
callq 0x2120
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x2a78
pushq $0x28
popq %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2120
movq %r14, %rdi
callq 0x2a78
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0x38(%rsp), %rdi
callq 0x21f8
jmp 0x32a0
movq %rax, %r12
leaq 0x58(%rsp), %rdi
callq 0x21f8
jmp 0x32af
movq %rax, %r12
pushq $0x28
popq %rsi
movq %r14, %rdi
jmp 0x32ec
movq %rax, %r12
leaq 0x78(%rsp), %rdi
callq 0x21f8
jmp 0x32c9
movq %rax, %r12
leaq 0x98(%rsp), %rdi
callq 0x21f8
jmp 0x32db
movq %rax, %r12
pushq $0x28
popq %rsi
movq %rbx, %rdi
jmp 0x32ec
movq %rax, %r12
pushq $0x50
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %r12, %rdi
callq 0x21a0
nop