// File: /workspace/github_cpp_makefile_star2_O3/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 0x20f0
movl %eax, %edi
callq 0x2100
movq 0x39da(%rip), %rax      # 0x6fd0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x2, 0x8(%rax,%rdx)
movq -0x18(%rcx), %rcx
orl $0x404, 0x18(%rax,%rcx) # imm = 0x404
movl $0x28, %edi
callq 0x2130
movq %rax, %rbx
leaq 0x3b02(%rip), %rsi      # 0x7128
leaq 0x3b1b(%rip), %rdx      # 0x7148
leaq 0x98(%rsp), %rdi
callq 0x3c09
leaq 0x3ae7(%rip), %rsi      # 0x7128
leaq 0x3b20(%rip), %rdx      # 0x7168
leaq 0x78(%rsp), %rdi
callq 0x3c09
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
movl $0x2, %ecx
callq 0x2c04
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x368d
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36ae
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2140
movl $0x28, %edi
callq 0x2130
movq %rax, %r14
leaq 0x3a66(%rip), %rsi      # 0x7128
leaq 0x3abf(%rip), %rdx      # 0x7188
leaq 0x58(%rsp), %rdi
callq 0x3c09
leaq 0x3a4e(%rip), %rsi      # 0x7128
leaq 0x3ac7(%rip), %rdx      # 0x71a8
leaq 0x38(%rsp), %rdi
callq 0x3c09
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r14, %rdi
movl $0x2, %ecx
callq 0x2c04
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x371d
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3738
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2140
movl $0x50, %edi
callq 0x2130
movq %rax, %r15
movq %rbx, %rdi
callq 0x3022
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3026
movq %r15, %rdi
movl %ebp, %esi
movl $0x12c, %edx            # imm = 0x12C
movl %eax, %ecx
callq 0x3c64
movq %rbx, %rdi
callq 0x301e
movl %eax, %ebp
movq 0x3857(%rip), %r12      # 0x6fd0
leaq 0x1a9e(%rip), %rsi      # 0x521e
movl $0xc, %edx
movq %r12, %rdi
callq 0x2150
movq %r12, %rdi
movl %ebp, %esi
callq 0x21b0
movq %rax, %r12
leaq 0x1a8a(%rip), %rsi      # 0x522b
movl $0x9, %edx
movq %rax, %rdi
callq 0x2150
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
rdtsc
movq %rdx, 0x18(%rsp)
movl %eax, 0x8(%rsp)
testl %ebp, %ebp
jle 0x381f
xorl %r12d, %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x302a
movq %rax, %r13
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3036
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movsd 0x1976(%rip), %xmm0     # 0x5188
callq 0x3f9e
incl %r12d
cmpl %r12d, %ebp
jne 0x37e8
rdtsc
movq %rdx, 0x28(%rsp)
movl %eax, (%rsp)
movq %r14, %rdi
callq 0x301e
movl %eax, %r13d
movq 0x3795(%rip), %r12      # 0x6fd0
leaq 0x19f3(%rip), %rsi      # 0x5235
movl $0xb, %edx
movq %r12, %rdi
callq 0x2150
movq %r12, %rdi
movl %r13d, %esi
callq 0x21b0
movq %rax, %r12
leaq 0x19c7(%rip), %rsi      # 0x522b
movl $0x9, %edx
movq %rax, %rdi
callq 0x2150
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
rdtsc
movq %rdx, 0x20(%rsp)
movl %eax, 0x10(%rsp)
testl %r13d, %r13d
movq %rbx, 0x30(%rsp)
jle 0x38f2
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r14, %rdi
movl %ebp, %esi
callq 0x302a
movq %r15, %rdi
movq %rax, %rsi
callq 0x3ea2
movq %r14, %rdi
movq %rax, %rsi
callq 0x304e
movl %eax, %ebx
movq %r14, %rdi
movl %ebp, %esi
callq 0x3042
xorl %ecx, %ecx
cmpl %eax, %ebx
sete %cl
addl %ecx, %r12d
incl %ebp
cmpl %ebp, %r13d
jne 0x38b3
jmp 0x38f5
xorl %r12d, %r12d
movq 0x20(%rsp), %rax
negl %eax
shlq $0x20, %rax
movq %rax, 0x20(%rsp)
movl 0x10(%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 0x368a(%rip), %rbp      # 0x6fd0
leaq 0x18f4(%rip), %rsi      # 0x5241
movl $0x9, %edx
movq %rbp, %rdi
callq 0x2150
movq %rbp, %rdi
movl %r12d, %esi
callq 0x21b0
movq %rax, %rbp
leaq 0x18dc(%rip), %rsi      # 0x524b
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
movq %rbp, %rdi
movl %r13d, %esi
callq 0x21b0
movq %rax, %rbp
leaq 0x18bc(%rip), %rsi      # 0x524d
movl $0x2, %edx
movq %rax, %rdi
callq 0x2150
cvtsi2sd %r12d, %xmm0
mulsd 0x17e5(%rip), %xmm0     # 0x5190
cvtsi2sd %r13d, %xmm1
divsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0x21a0
movq %rax, %r12
leaq 0x188a(%rip), %rsi      # 0x5250
movl $0x2, %edx
movq %rax, %rdi
callq 0x2150
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
leaq 0x1851(%rip), %rsi      # 0x5253
movl $0xa, %edx
movq 0x35c2(%rip), %r12      # 0x6fd0
movq %r12, %rdi
callq 0x2150
subq 0x8(%rsp), %rbx
movq (%rsp), %rax
addq 0x28(%rsp), %rax
addq %rbx, %rax
movq %rax, %xmm1
punpckldq 0x176c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1774(%rip), %xmm1     # 0x51b0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %r12, %rdi
movq %r12, %rbx
callq 0x21a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
leaq 0x17da(%rip), %rsi      # 0x525e
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2150
movq 0x20(%rsp), %rax
subq 0x10(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, %xmm1
punpckldq 0x16f3(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x16fb(%rip), %xmm1     # 0x51b0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x21a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20b0
movq %r15, %rdi
callq 0x3e2a
movl $0x50, %esi
movq %r15, %rdi
callq 0x2140
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x2faa
movl $0x28, %esi
movq %rbx, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x2faa
movl $0x28, %esi
movq %r14, %rdi
callq 0x2140
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b6e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3b6e
movq %rax, %r12
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b8e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3b8e
movq %rax, %r12
movl $0x28, %esi
movq %r14, %rdi
jmp 0x3bfc
movq %rax, %r12
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bc1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3bc1
movq %rax, %r12
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3be7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3be7
movq %rax, %r12
movl $0x28, %esi
movq %rbx, %rdi
jmp 0x3bfc
movq %rax, %r12
movl $0x50, %esi
movq %r15, %rdi
callq 0x2140
movq %r12, %rdi
callq 0x21c0