// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/rnn.c
// Function: valid_char_rnn
void valid_char_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);
    while(c != EOF){
        int next = getc(stdin);
        if(next == EOF) break;
        if(next < 0 || next >= 255) error("Out of range character");
        ++count;
        if(next == ' ' || next == '\n' || next == '\t') ++words;
        input[c] = 1;
        float *out = network_predict(net, input);
        input[c] = 0;
        sum += log(out[next])/log2;
        c = next;
        printf("%d BPC: %4.4f   Perplexity: %4.4f    Word Perplexity: %4.4f\n", count, -sum/count, 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 0x23a1d(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x14db4(%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 0x5f697
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 0x119a2(%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 0x5f643
xorps %xmm0, %xmm0
movss %xmm0, -0x50(%rbp)
movq 0x23932(%rip), %rax     # 0x82fd8
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x38(%rbp)
movsd 0x1199f(%rip), %xmm0    # 0x71058
callq 0x31a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
cmpl $-0x1, -0x38(%rbp)
je 0x5f84f
movq 0x23900(%rip), %rax     # 0x82fd8
movq (%rax), %rdi
callq 0x3470
movl %eax, -0x58(%rbp)
cmpl $-0x1, -0x58(%rbp)
jne 0x5f6ee
jmp 0x5f84f
cmpl $0x0, -0x58(%rbp)
jl 0x5f6fd
cmpl $0xff, -0x58(%rbp)
jl 0x5f709
leaq 0x16b56(%rip), %rdi     # 0x7625a
callq 0x4c50
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x20, -0x58(%rbp)
je 0x5f724
cmpl $0xa, -0x58(%rbp)
je 0x5f724
cmpl $0x9, -0x58(%rbp)
jne 0x5f72d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
movss 0x118cf(%rip), %xmm0    # 0x7100c
movss %xmm0, (%rax,%rcx,4)
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3b160
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movslq -0x58(%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 -0x58(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x30(%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, %xmm0
movsd %xmm0, -0x68(%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 0x11862(%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 0x11831(%rip), %xmm0    # 0x71058
callq 0x30e0
movl -0x74(%rbp), %esi
movsd -0x70(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x68(%rbp), %xmm0
leaq 0x16a61(%rip), %rdi     # 0x762a4
movb $0x3, %al
callq 0x3130
jmp 0x5f6c7
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)