// File: /workspace/github_c_makefile_star2_O1/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 0x2f9e4
movq %rax, -0x50(%rbp)
movq %rax, %rdi
movl $0x1, %esi
callq 0x302d4
xorl %edi, %edi
callq 0x32d0
movl %eax, %edi
callq 0x3230
movl $0x43b, %edi            # imm = 0x43B
movl $0x4, %esi
callq 0x3260
movq %rax, %r15
movss 0xcd49(%rip), %xmm2     # 0x53008
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 0x462bf
movl $0x16a, %edi            # imm = 0x16A
movl $0x4, %esi
callq 0x3260
movq %rax, %r12
movl $0x1, %r13d
movq -0x50(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movl -0x44(%rbp), %ecx
callq 0x43c90
addss 0xccd4(%rip), %xmm0     # 0x53008
mulss 0xcef8(%rip), %xmm0     # 0x53234
mulss 0xcf00(%rip), %xmm0     # 0x53244
cvtss2sd %xmm0, %xmm0
leaq 0x124c9(%rip), %rdi     # 0x58818
movb $0x1, %al
callq 0x3170
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 0xe8e2
movq 0x23c78(%rip), %rax     # 0x69ff8
movq (%rax), %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %rbx, %rcx
callq 0x43a5d
xorl %r14d, %r14d
movslq (%rbx,%r14,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 0x463e0
movss (%r12,%rax,4), %xmm0
mulss 0xce7c(%rip), %xmm0     # 0x53244
cvtss2sd %xmm0, %xmm0
leal 0x1(%r14), %esi
leaq 0x12454(%rip), %rdi     # 0x5882b
movb $0x1, %al
callq 0x3170
jmp 0x4643e
leal (%rcx,%rcx,8), %edx
leal (%rcx,%rdx,2), %edx
movl %eax, %esi
subl %edx, %esi
cmpl $0x8, %esi
setge %dl
cmpl $0x0, 0x23f39(%rip)     # 0x6a330
setne %dil
andb %dl, %dil
movzbl %dil, %edx
addl %esi, %edx
addl $0x41, %edx
movl $0x13, %esi
subl %ecx, %esi
incl %ecx
cmpl $0x0, 0x23f15(%rip)     # 0x6a32c
cmovnel %esi, %ecx
movss (%r12,%rax,4), %xmm0
mulss 0xce1c(%rip), %xmm0     # 0x53244
cvtss2sd %xmm0, %xmm0
leal 0x1(%r14), %esi
leaq 0x12406(%rip), %rdi     # 0x5883d
movb $0x1, %al
callq 0x3170
incq %r14
cmpq $0xa, %r14
jne 0x46394
movl %r13d, -0x40(%rbp)
cmpl $0x1, %r13d
leaq 0x12405(%rip), %rdi     # 0x5885f
leaq 0x123ef(%rip), %rax     # 0x58850
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x3170
movq 0x23b65(%rip), %rax     # 0x69fd8
movq (%rax), %rdi
callq 0xe165
movq %rax, %r13
movl $0x1, -0x38(%rbp)
movq %rax, %rdi
leaq 0x12783(%rip), %rsi     # 0x58c12
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x3330
movl %eax, %r14d
movq %r13, %rdi
leaq 0x123c7(%rip), %rsi     # 0x5886e
leaq -0x29(%rbp), %rdx
xorl %eax, %eax
callq 0x3330
testl %r14d, %r14d
jne 0x4653c
cmpb $0x0, (%r13)
je 0x4653c
testl %eax, %eax
je 0x46586
movzbl -0x29(%rbp), %eax
leal -0x41(%rax), %ecx
cmpb $0x13, %cl
ja 0x465f2
movq %r13, %rdi
leaq 0x12390(%rip), %rsi     # 0x58874
leaq -0x29(%rbp), %rdx
leaq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x3330
movl -0x30(%rbp), %edx
movl $0x13, %ecx
subl %edx, %ecx
decl %edx
cmpl $0x0, 0x23e26(%rip)     # 0x6a32c
cmovnel %ecx, %edx
movl %edx, -0x30(%rbp)
cmpl $0x2, %eax
jne 0x46586
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %cl
cmpl $0x0, 0x23e0e(%rip)     # 0x6a330
setne %sil
andb %cl, %sil
movzbl %sil, %ecx
xorl $-0x41, %ecx
addl %eax, %ecx
movq %r15, %rdi
movl $0x1, %esi
jmp 0x46581
movslq -0x38(%rbp), %rax
leal -0x1(%rax), %ecx
movl %ecx, -0x38(%rbp)
cmpq $0xa, %rax
jg 0x46586
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 0x46586
leal (%rdx,%rdx,8), %eax
leal (%rdx,%rax,2), %eax
subl %eax, %ecx
movq %r15, %rdi
movl $0x1, %esi
callq 0x43e98
movq %r13, %rdi
callq 0x3040
movq $-0x5a4, %rax           # imm = 0xFA5C
movss 0xca6b(%rip), %xmm2     # 0x53008
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 0x4659d
movl -0x40(%rbp), %r13d
negl %r13d
movq -0x58(%rbp), %rsp
jmp 0x4631a
cmpl $0x77, %eax
je 0x46605
cmpl $0x63, %eax
je 0x46699
cmpl $0x62, %eax
jne 0x46586
movq %r13, %rdi
leaq 0x12262(%rip), %rsi     # 0x58871
leaq -0x31(%rbp), %rdx
leaq -0x29(%rbp), %rcx
leaq -0x30(%rbp), %r8
xorl %eax, %eax
callq 0x3330
movl -0x30(%rbp), %ecx
movl $0x13, %edx
subl %ecx, %edx
decl %ecx
cmpl $0x0, 0x23cf7(%rip)     # 0x6a32c
cmovnel %edx, %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x3, %eax
jne 0x46586
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %dl
cmpl $0x0, 0x23cdb(%rip)     # 0x6a330
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 -0x40(%rbp), %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 0x46586
movq %r13, %rdi
leaq 0x121ce(%rip), %rsi     # 0x58871
leaq -0x39(%rbp), %rdx
leaq -0x29(%rbp), %rcx
leaq -0x30(%rbp), %r8
xorl %eax, %eax
callq 0x3330
movl -0x30(%rbp), %ecx
movl $0x13, %edx
subl %ecx, %edx
decl %ecx
cmpl $0x0, 0x23c63(%rip)     # 0x6a32c
cmovnel %edx, %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x3, %eax
jne 0x46586
movsbl -0x29(%rbp), %eax
cmpl $0x49, %eax
setge %dl
cmpl $0x0, 0x23c47(%rip)     # 0x6a330
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 0x46586