// File: /workspace/github_cpp_makefile_star2_O1/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 0x39e6(%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 0x3b0e(%rip), %rsi      # 0x7128
leaq 0x3b27(%rip), %rdx      # 0x7148
leaq 0x98(%rsp), %rdi
callq 0x3bfd
leaq 0x3af3(%rip), %rsi      # 0x7128
leaq 0x3b2c(%rip), %rdx      # 0x7168
leaq 0x78(%rsp), %rdi
callq 0x3bfd
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 0x3681
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36a2
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2140
movl $0x28, %edi
callq 0x2130
movq %rax, %r14
leaq 0x3a72(%rip), %rsi      # 0x7128
leaq 0x3acb(%rip), %rdx      # 0x7188
leaq 0x58(%rsp), %rdi
callq 0x3bfd
leaq 0x3a5a(%rip), %rsi      # 0x7128
leaq 0x3ad3(%rip), %rdx      # 0x71a8
leaq 0x38(%rsp), %rdi
callq 0x3bfd
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 0x3711
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2140
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x372c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2140
movl $0x50, %edi
callq 0x2130
movq %rax, %r15
movq %rbx, %rdi
callq 0x3020
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3024
movq %r15, %rdi
movl %ebp, %esi
movl $0x12c, %edx            # imm = 0x12C
movl %eax, %ecx
callq 0x3c58
movq %rbx, %rdi
callq 0x301c
movl %eax, %ebp
movq 0x3863(%rip), %r12      # 0x6fd0
leaq 0x1aaa(%rip), %rsi      # 0x521e
movl $0xc, %edx
movq %r12, %rdi
callq 0x2150
movq %r12, %rdi
movl %ebp, %esi
callq 0x21b0
movq %rax, %r12
leaq 0x1a96(%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 0x3813
xorl %r12d, %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3028
movq %rax, %r13
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3034
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movsd 0x1982(%rip), %xmm0     # 0x5188
callq 0x3f92
incl %r12d
cmpl %r12d, %ebp
jne 0x37dc
rdtsc
movq %rdx, 0x28(%rsp)
movl %eax, (%rsp)
movq %r14, %rdi
callq 0x301c
movl %eax, %r13d
movq 0x37a1(%rip), %r12      # 0x6fd0
leaq 0x19ff(%rip), %rsi      # 0x5235
movl $0xb, %edx
movq %r12, %rdi
callq 0x2150
movq %r12, %rdi
movl %r13d, %esi
callq 0x21b0
movq %rax, %r12
leaq 0x19d3(%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 0x38e6
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r14, %rdi
movl %ebp, %esi
callq 0x3028
movq %r15, %rdi
movq %rax, %rsi
callq 0x3e96
movq %r14, %rdi
movq %rax, %rsi
callq 0x304c
movl %eax, %ebx
movq %r14, %rdi
movl %ebp, %esi
callq 0x3040
xorl %ecx, %ecx
cmpl %eax, %ebx
sete %cl
addl %ecx, %r12d
incl %ebp
cmpl %ebp, %r13d
jne 0x38a7
jmp 0x38e9
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 0x3696(%rip), %rbp      # 0x6fd0
leaq 0x1900(%rip), %rsi      # 0x5241
movl $0x9, %edx
movq %rbp, %rdi
callq 0x2150
movq %rbp, %rdi
movl %r12d, %esi
callq 0x21b0
movq %rax, %rbp
leaq 0x18e8(%rip), %rsi      # 0x524b
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
movq %rbp, %rdi
movl %r13d, %esi
callq 0x21b0
movq %rax, %rbp
leaq 0x18c8(%rip), %rsi      # 0x524d
movl $0x2, %edx
movq %rax, %rdi
callq 0x2150
cvtsi2sd %r12d, %xmm0
mulsd 0x17f1(%rip), %xmm0     # 0x5190
cvtsi2sd %r13d, %xmm1
divsd %xmm1, %xmm0
movq %rbp, %rdi
callq 0x21a0
movq %rax, %r12
leaq 0x1896(%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 0x185d(%rip), %rsi      # 0x5253
movl $0xa, %edx
movq 0x35ce(%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 0x1778(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1780(%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 0x17e6(%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 0x16ff(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1707(%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 0x3e1e
movl $0x50, %esi
movq %r15, %rdi
callq 0x2140
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x2fa8
movl $0x28, %esi
movq %rbx, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x2fa8
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 0x3b62
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3b62
movq %rax, %r12
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b82
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3b82
movq %rax, %r12
movl $0x28, %esi
movq %r14, %rdi
jmp 0x3bf0
movq %rax, %r12
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bb5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3bb5
movq %rax, %r12
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bdb
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2140
jmp 0x3bdb
movq %rax, %r12
movl $0x28, %esi
movq %rbx, %rdi
jmp 0x3bf0
movq %rax, %r12
movl $0x50, %esi
movq %r15, %rdi
callq 0x2140
movq %r12, %rdi
callq 0x21c0