// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/go.c
// Function: test_go
void test_go(char *cfg, char *weights, int multi)
{
    int i;
    network *net = load_network(cfg, weights, 0);
    set_batch_network(net, 1);
    srand(time(0));
    float *board = calloc(19*19*3, sizeof(float));
    flip_board(board);
    float *move = calloc(19*19+1, sizeof(float));
    int color = 1;
    while(1){
        float result = predict_move2(net, board, move, multi);
        printf("%.2f%% Win Chance\n", (result+1)/2*100);

        int indexes[nind];
        int row, col;
        top_k(move, 19*19+1, nind, indexes);
        print_board(stderr, board, color, indexes);
        for(i = 0; i < nind; ++i){
            int index = indexes[i];
            row = index / 19;
            col = index % 19;
            if(row == 19){
                printf("%d: Pass, %.2f%%\n", i+1, move[index]*100);
            } else {
                printf("%d: %c %d, %.2f%%\n", i+1, col + 'A' + 1*(col > 7 && noi), (inverted)?19 - row : row+1, move[index]*100);
            }
        }
        //if(color == 1) printf("\u25EF Enter move: ");
        //else printf("\u25C9 Enter move: ");
        if(color == 1) printf("X Enter move: ");
        else printf("O Enter move: ");

        char c;
        char *line = fgetl(stdin);
        int picked = 1;
        int dnum = sscanf(line, "%d", &picked);
        int cnum = sscanf(line, "%c", &c);
        if (strlen(line) == 0 || dnum) {
            --picked;
            if (picked < nind){
                int index = indexes[picked];
                row = index / 19;
                col = index % 19;
                if(row < 19){
                    move_go(board, 1, row, col);
                }
            }
        } else if (cnum){
            if (c <= 'T' && c >= 'A'){
                int num = sscanf(line, "%c %d", &c, &row);
                row = (inverted)?19 - row : row-1;
                col = c - 'A';
                if (col > 7 && noi) col -= 1;
                if (num == 2) move_go(board, 1, row, col);
            } else if (c == 'p') {
                // Pass
            } else if(c=='b' || c == 'w'){
                char g;
                int num = sscanf(line, "%c %c %d", &g, &c, &row);
                row = (inverted)?19 - row : row-1;
                col = c - 'A';
                if (col > 7 && noi) col -= 1;
                if (num == 3) {
                    int mc = (g == 'b') ? 1 : -1;
                    if (mc == color) {
                        board[row*19 + col] = 1;
                    } else {
                        board[19*19 + row*19 + col] = 1;
                    }
                }
            } else if(c == 'c'){
                char g;
                int num = sscanf(line, "%c %c %d", &g, &c, &row);
                row = (inverted)?19 - row : row-1;
                col = c - 'A';
                if (col > 7 && noi) col -= 1;
                if (num == 3) {
                    board[row*19 + col] = 0;
                    board[19*19 + row*19 + col] = 0;
                }
            }
        }
        free(line);
        flip_board(board);
        color = -color;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, -0x44(%rbp)
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x316bc
movq %rax, -0x50(%rbp)
movq %rax, %rdi
movl $0x1, %esi
callq 0x320a7
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movl $0x43b, %edi            # imm = 0x43B
movl $0x4, %esi
callq 0x3250
movq %rax, %r15
movss 0xca4b(%rip), %xmm2     # 0x55008
movss (%r15,%rbx,4), %xmm0
movss 0x5a4(%r15,%rbx,4), %xmm1
movss %xmm1, (%r15,%rbx,4)
movss %xmm0, 0x5a4(%r15,%rbx,4)
movaps %xmm2, %xmm0
subss 0xb48(%r15,%rbx,4), %xmm0
movss %xmm0, 0xb48(%r15,%rbx,4)
incq %rbx
cmpq $0x169, %rbx            # imm = 0x169
jne 0x485bd
movl $0x16a, %edi            # imm = 0x16A
movl $0x4, %esi
callq 0x3250
movq %rax, %r12
movl $0x1, %r14d
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movl -0x44(%rbp), %ecx
callq 0x45f5c
addss 0xc9d6(%rip), %xmm0     # 0x55008
mulss 0xcc2a(%rip), %xmm0     # 0x55264
mulss 0xcc32(%rip), %xmm0     # 0x55274
cvtss2sd %xmm0, %xmm0
leaq 0x12323(%rip), %rdi     # 0x5a970
movb $0x1, %al
callq 0x3160
movq %rsp, -0x58(%rbp)
movq %rsp, %rbx
addq $-0x30, %rbx
movq %rbx, %rsp
movq %r12, %rdi
movl $0x16a, %esi            # imm = 0x16A
movl $0xa, %edx
movq %rbx, %rcx
callq 0xf0cd
movq 0x2397a(%rip), %rax     # 0x6bff8
movq (%rax), %rdi
movq %r15, %rsi
movl %r14d, %edx
movq %rbx, %rcx
callq 0x45d3f
xorl %r13d, %r13d
movslq (%rbx,%r13,4), %rax
imulq $0x6bca1af3, %rax, %rcx # imm = 0x6BCA1AF3
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
movl %ecx, -0x30(%rbp)
leal -0x169(%rax), %edx
cmpl $0x12, %edx
ja 0x486e0
incq %r13
movss (%r12,%rax,4), %xmm0
mulss 0xcbab(%rip), %xmm0     # 0x55274
cvtss2sd %xmm0, %xmm0
leaq 0x122af(%rip), %rdi     # 0x5a983
movl %r13d, %esi
movb $0x1, %al
callq 0x3160
jmp 0x4873f
leal (%rcx,%rcx,8), %edx
leal (%rcx,%rdx,2), %edx
movl %eax, %esi
subl %edx, %esi
incq %r13
cmpl $0x8, %esi
setge %dl
cmpl $0x0, 0x23c26(%rip)     # 0x6c320
setne %dil
andb %dl, %dil
movl $0x13, %edx
subl %ecx, %edx
incl %ecx
cmpl $0x0, 0x23c0b(%rip)     # 0x6c31c
cmovnel %edx, %ecx
movzbl %dil, %edx
leal 0x41(%rsi,%rdx), %edx
movss (%r12,%rax,4), %xmm0
mulss 0xcb4a(%rip), %xmm0     # 0x55274
cvtss2sd %xmm0, %xmm0
leaq 0x12260(%rip), %rdi     # 0x5a995
movl %r13d, %esi
movb $0x1, %al
callq 0x3160
cmpq $0xa, %r13
jne 0x48692
movl %r14d, -0x40(%rbp)
cmpl $0x1, %r14d
leaq 0x1225f(%rip), %rdi     # 0x5a9b7
leaq 0x12249(%rip), %rax     # 0x5a9a8
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x3160
movq 0x23867(%rip), %rax     # 0x6bfd8
movq (%rax), %rdi
callq 0xe948
movq %rax, %r13
movl $0x1, -0x38(%rbp)
movq %rax, %rdi
leaq 0x125f6(%rip), %rsi     # 0x5ad83
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x3320
movl %eax, %r14d
movq %r13, %rdi
leaq 0x12221(%rip), %rsi     # 0x5a9c6
leaq -0x29(%rbp), %rdx
xorl %eax, %eax
callq 0x3320
movq %r13, %rdi
testl %r14d, %r14d
jne 0x48846
cmpb $0x0, (%rdi)
je 0x48846
testl %eax, %eax
movl -0x40(%rbp), %r14d
je 0x4889a
movzbl -0x29(%rbp), %eax
leal -0x41(%rax), %ecx
cmpb $0x13, %cl
ja 0x488ff
movq %rdi, %rbx
leaq 0x121e1(%rip), %rsi     # 0x5a9cc
leaq -0x29(%rbp), %rdx
leaq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x3320
movq %rbx, %rdi
movl -0x30(%rbp), %edx
movl $0x13, %ecx
subl %edx, %ecx
decl %edx
cmpl $0x0, 0x23b0c(%rip)     # 0x6c31c
cmovnel %ecx, %edx
movl %edx, -0x30(%rbp)
cmpl $0x2, %eax
jne 0x4889a
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %cl
cmpl $0x0, 0x23af4(%rip)     # 0x6c320
setne %sil
andb %cl, %sil
movzbl %sil, %ecx
xorl $-0x41, %ecx
addl %eax, %ecx
movq %r15, %rdi
movl $0x1, %esi
jmp 0x48892
movslq -0x38(%rbp), %rax
leal -0x1(%rax), %ecx
movl %ecx, -0x38(%rbp)
cmpq $0xa, %rax
movl -0x40(%rbp), %r14d
jg 0x4889a
movslq -0x4(%rbx,%rax,4), %rcx
imulq $0x6bca1af3, %rcx, %rdx # imm = 0x6BCA1AF3
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x23, %rdx
addl %eax, %edx
movl %edx, -0x30(%rbp)
cmpq $0x168, %rcx            # imm = 0x168
jg 0x4889a
leal (%rdx,%rdx,8), %eax
leal (%rdx,%rax,2), %eax
subl %eax, %ecx
movq %rdi, %rbx
movq %r15, %rdi
movl $0x1, %esi
callq 0x46164
movq %rbx, %rdi
callq 0x3040
movq $-0x5a4, %rax           # imm = 0xFA5C
movss 0xc75a(%rip), %xmm2     # 0x55008
movss 0x5a4(%r15,%rax), %xmm0
movss 0xb48(%r15,%rax), %xmm1
movss %xmm1, 0x5a4(%r15,%rax)
movss %xmm0, 0xb48(%r15,%rax)
movaps %xmm2, %xmm0
subss 0x10ec(%r15,%rax), %xmm0
movss %xmm0, 0x10ec(%r15,%rax)
addq $0x4, %rax
jne 0x488ae
negl %r14d
movq -0x58(%rbp), %rsp
jmp 0x48618
cmpl $0x77, %eax
je 0x48912
cmpl $0x63, %eax
je 0x489a6
cmpl $0x62, %eax
jne 0x4889a
movq %rdi, %rbx
leaq 0x120ad(%rip), %rsi     # 0x5a9c9
leaq -0x31(%rbp), %rdx
leaq -0x29(%rbp), %rcx
leaq -0x30(%rbp), %r8
xorl %eax, %eax
callq 0x3320
movl -0x30(%rbp), %ecx
movl $0x13, %edx
subl %ecx, %edx
decl %ecx
cmpl $0x0, 0x239da(%rip)     # 0x6c31c
cmovnel %edx, %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x3, %eax
jne 0x48897
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %dl
cmpl $0x0, 0x239be(%rip)     # 0x6c320
setne %sil
andb %dl, %sil
movzbl %sil, %edx
xorl $-0x41, %edx
addl %eax, %edx
xorl %eax, %eax
cmpb $0x62, -0x31(%rbp)
sete %al
leal -0x1(,%rax,2), %eax
cmpl %r14d, %eax
leal (%rcx,%rcx,8), %eax
leal (%rcx,%rax,2), %esi
leal 0x169(%rcx,%rax,2), %eax
cmovel %esi, %eax
addl %edx, %eax
cltq
movl $0x3f800000, (%r15,%rax,4) # imm = 0x3F800000
jmp 0x48897
movq %rdi, %rbx
leaq 0x12019(%rip), %rsi     # 0x5a9c9
leaq -0x39(%rbp), %rdx
leaq -0x29(%rbp), %rcx
leaq -0x30(%rbp), %r8
xorl %eax, %eax
callq 0x3320
movl -0x30(%rbp), %ecx
movl $0x13, %edx
subl %ecx, %edx
decl %ecx
cmpl $0x0, 0x23946(%rip)     # 0x6c31c
cmovnel %edx, %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x3, %eax
jne 0x48897
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %dl
cmpl $0x0, 0x2392a(%rip)     # 0x6c320
setne %sil
andb %dl, %sil
movzbl %sil, %edx
xorl $-0x41, %edx
addl %eax, %edx
leal (%rcx,%rcx,8), %eax
leal (%rcx,%rax,2), %eax
leal (%rdx,%rax), %ecx
movslq %ecx, %rcx
xorl %esi, %esi
movl %esi, (%r15,%rcx,4)
addl %edx, %eax
addl $0x169, %eax            # imm = 0x169
cltq
movl %esi, (%r15,%rax,4)
jmp 0x48897