// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/go.c
// Function: valid_go
void valid_go(char *cfgfile, char *weightfile, int multi, char *filename)
{
    srand(time(0));
    char *base = basecfg(cfgfile);
    printf("%s\n", base);
    network *net = load_network(cfgfile, weightfile, 0);
    set_batch_network(net, 1);
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);

    float *board = calloc(19*19*3, sizeof(float));
    float *move = calloc(19*19+2, sizeof(float));
    // moves m = load_go_moves("/home/pjreddie/backup/go.test");
    moves m = load_go_moves(filename);

    int N = m.n;
    int i,j;
    int correct = 0;
    for (i = 0; i <N; ++i) {
        char *b = m.data[i];
        int player = b[0] - '0';
        //int result = b[1] - '0';
        int row = b[2];
        int col = b[3];
        int truth = col + 19*row;
        string_to_board(b+4, board);
        if(player > 0) for(j = 0; j < 19*19; ++j) board[19*19*2 + j] = 1;
        predict_move2(net, board, move, multi);
        int index = max_index(move, 19*19+1);
        if(index == truth) ++correct;
        printf("%d Accuracy %f\n", i, (float) correct/(i+1));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r13
movl %edx, 0xc(%rsp)
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %r15, %rdi
callq 0xef02
movq %rax, %rdi
callq 0x30b0
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x316bc
movq %rax, %r14
movq %rax, %rdi
movl $0x1, %esi
callq 0x320a7
cvtss2sd 0x34(%r14), %xmm0
cvtss2sd 0x38(%r14), %xmm1
movq %r14, 0x28(%rsp)
cvtss2sd 0x3c(%r14), %xmm2
leaq 0x12e29(%rip), %rdi     # 0x59fd0
movb $0x3, %al
callq 0x3160
movl $0x43b, %edi            # imm = 0x43B
movl $0x4, %esi
callq 0x3250
movq %rax, %r15
movl $0x16b, %edi            # imm = 0x16B
movl $0x4, %esi
callq 0x3250
movq %rax, 0x20(%rsp)
movq %r13, %rdi
callq 0x45371
movq %rax, 0x18(%rsp)
testl %edx, %edx
jle 0x4737c
movl %edx, %eax
movq %rax, 0x10(%rsp)
pshufd $0xf5, 0x13237(%rip), %xmm0 # xmm0 = mem[1,1,3,3]
movdqa %xmm0, 0x30(%rsp)
xorl %ebp, %ebp
movq 0x18(%rsp), %rax
movq (%rax,%rbp,8), %rdi
movb (%rdi), %r12b
movsbl 0x2(%rdi), %r13d
movsbl 0x3(%rdi), %r14d
addq $0x4, %rdi
movq %r15, %rsi
callq 0x4541c
cmpb $0x31, %r12b
movdqa 0xde61(%rip), %xmm4     # 0x55090
movdqa 0x131f9(%rip), %xmm5    # 0x5a430
movdqa 0x30(%rsp), %xmm6
movdqa 0xdf3b(%rip), %xmm7     # 0x55180
jl 0x47306
xorl %eax, %eax
movdqa 0xde2b(%rip), %xmm0     # 0x55080
movdqa 0xdf13(%rip), %xmm1     # 0x55170
movdqa %xmm0, %xmm2
pxor %xmm4, %xmm2
movdqa %xmm5, %xmm3
pcmpgtd %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm6, %xmm2
pand %xmm3, %xmm2
movd %xmm2, %ecx
testb $0x1, %cl
je 0x4728f
movl $0x3f800000, 0xb48(%r15,%rax,4) # imm = 0x3F800000
pextrw $0x4, %xmm2, %ecx
testb $0x1, %cl
je 0x472a5
movl $0x3f800000, 0xb4c(%r15,%rax,4) # imm = 0x3F800000
movdqa %xmm1, %xmm2
pxor %xmm4, %xmm2
movdqa %xmm5, %xmm3
pcmpgtd %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm2     # xmm2 = xmm2[1,1,3,3]
pcmpeqd %xmm6, %xmm2
pand %xmm3, %xmm2
pextrw $0x0, %xmm2, %ecx
testb $0x1, %cl
je 0x472d8
movl $0x3f800000, 0xb50(%r15,%rax,4) # imm = 0x3F800000
pextrw $0x4, %xmm2, %ecx
testb $0x1, %cl
je 0x472ee
movl $0x3f800000, 0xb54(%r15,%rax,4) # imm = 0x3F800000
addq $0x4, %rax
paddq %xmm7, %xmm0
paddq %xmm7, %xmm1
cmpq $0x16c, %rax            # imm = 0x16C
jne 0x4725d
leal (%r13,%r13,8), %eax
leal (%r13,%rax,2), %r12d
addl %r14d, %r12d
movq 0x28(%rsp), %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
movl 0xc(%rsp), %ecx
callq 0x45f5c
movq %r14, %rdi
movl $0x16a, %esi            # imm = 0x16A
callq 0xfa87
xorl %ecx, %ecx
cmpl %r12d, %eax
sete %cl
addl %ecx, %ebx
xorps %xmm0, %xmm0
cvtsi2ss %ebx, %xmm0
leaq 0x1(%rbp), %r14
xorps %xmm1, %xmm1
cvtsi2ss %r14d, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x13238(%rip), %rdi     # 0x5a59d
movl %ebp, %esi
movb $0x1, %al
callq 0x3160
movq %r14, %rbp
cmpq 0x10(%rsp), %r14
jne 0x47201
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq