// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/rnn.c
// Function: valid_tactic_rnn
void valid_tactic_rnn(char *cfgfile, char *weightfile, char *seed)
{
    char *base = basecfg(cfgfile);
    fprintf(stderr, "%s\n", base);

    network *net = load_network(cfgfile, weightfile, 0);
    int inputs = net->inputs;

    int count = 0;
    int words = 1;
    int c;
    int len = strlen(seed);
    float *input = calloc(inputs, sizeof(float));
    int i;
    for(i = 0; i < len; ++i){
        c = seed[i];
        input[(int)c] = 1;
        network_predict(net, input);
        input[(int)c] = 0;
    }
    float sum = 0;
    c = getc(stdin);
    float log2 = log(2);
    int in = 0;
    while(c != EOF){
        int next = getc(stdin);
        if(next == EOF) break;
        if(next < 0 || next >= 255) error("Out of range character");

        input[c] = 1;
        float *out = network_predict(net, input);
        input[c] = 0;

        if(c == '.' && next == '\n') in = 0;
        if(!in) {
            if(c == '>' && next == '>'){
                in = 1;
                ++words;
            }
            c = next;
            continue;
        }
        ++count;
        sum += log(out[next])/log2;
        c = next;
        printf("%d %d Perplexity: %4.4f    Word Perplexity: %4.4f\n", count, words, pow(2, -sum/count), pow(2, -sum/words));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x20(%rbp)
movq 0x23cdd(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x15074(%rip), %rsi     # 0x7439d
movb $0x0, %al
callq 0x3240
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x80(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3110
movl %eax, -0x3c(%rbp)
movslq -0x2c(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x5f3d7
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
movss 0x11c62(%rip), %xmm0    # 0x7100c
movss %xmm0, (%rax,%rcx,4)
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3b160
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x5f383
xorps %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movq 0x23bf2(%rip), %rax     # 0x82fd8
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x38(%rbp)
movsd 0x11c5f(%rip), %xmm0    # 0x71058
callq 0x31a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
cmpl $-0x1, -0x38(%rbp)
je 0x5f59b
movq 0x23bb9(%rip), %rax     # 0x82fd8
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x5c(%rbp)
cmpl $-0x1, -0x5c(%rbp)
jne 0x5f435
jmp 0x5f59b
cmpl $0x0, -0x5c(%rbp)
jl 0x5f444
cmpl $0xff, -0x5c(%rbp)
jl 0x5f450
leaq 0x16e0f(%rip), %rdi     # 0x7625a
callq 0x4c50
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
movss 0x11bac(%rip), %xmm0    # 0x7100c
movss %xmm0, (%rax,%rcx,4)
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3b160
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
cmpl $0x2e, -0x38(%rbp)
jne 0x5f499
cmpl $0xa, -0x5c(%rbp)
jne 0x5f499
movl $0x0, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jne 0x5f4c6
cmpl $0x3e, -0x38(%rbp)
jne 0x5f4bb
cmpl $0x3e, -0x5c(%rbp)
jne 0x5f4bb
movl $0x1, -0x58(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x5f40e
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x31a0
movaps %xmm0, %xmm1
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
divsd %xmm0, %xmm1
movss -0x50(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x74(%rbp)
movss -0x50(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtsi2ssl -0x30(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x11b14(%rip), %xmm0    # 0x71058
callq 0x30e0
movsd %xmm0, -0x70(%rbp)
movss -0x50(%rbp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtsi2ssl -0x34(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x11ae3(%rip), %xmm0    # 0x71058
callq 0x30e0
movl -0x78(%rbp), %esi
movl -0x74(%rbp), %edx
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
leaq 0x16ce2(%rip), %rdi     # 0x76271
movb $0x2, %al
callq 0x3130
jmp 0x5f40e
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)