// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/rnn.c
// Function: test_char_rnn
void test_char_rnn(char *cfgfile, char *weightfile, int num, char *seed, float temp, int rseed, char *token_file)
{
    char **tokens = 0;
    if(token_file){
        size_t n;
        tokens = read_tokens(token_file, &n);
    }

    srand(rseed);
    char *base = basecfg(cfgfile);
    fprintf(stderr, "%s\n", base);

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

    int i, j;
    for(i = 0; i < net->n; ++i) net->layers[i].temperature = temp;
    int c = 0;
    int len = strlen(seed);
    float *input = calloc(inputs, sizeof(float));

    /*
       fill_cpu(inputs, 0, input, 1);
       for(i = 0; i < 10; ++i){
       network_predict(net, input);
       }
       fill_cpu(inputs, 0, input, 1);
     */

    for(i = 0; i < len-1; ++i){
        c = seed[i];
        input[c] = 1;
        network_predict(net, input);
        input[c] = 0;
        print_symbol(c, tokens);
    }
    if(len) c = seed[len-1];
    print_symbol(c, tokens);
    for(i = 0; i < num; ++i){
        input[c] = 1;
        float *out = network_predict(net, input);
        input[c] = 0;
        for(j = 32; j < 127; ++j){
            //printf("%d %c %f\n",j, j, out[j]);
        }
        for(j = 0; j < inputs; ++j){
            if (out[j] < .0001) out[j] = 0;
        }
        c = sample_array(out, inputs);
        print_symbol(c, tokens);
    }
    printf("\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, %ebp
movss %xmm0, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movl %edx, 0x24(%rsp)
movq %rsi, %r12
movq %rdi, %r15
xorl %ebx, %ebx
testq %r9, %r9
jne 0x3de22
xorl %r14d, %r14d
jmp 0x3de32
leaq 0x30(%rsp), %rsi
movq %r9, %rdi
callq 0x3d502
movq %rax, %r14
movl %ebp, %edi
callq 0x3220
movq %r15, %rdi
callq 0x41c8
movq 0x261b0(%rip), %rcx     # 0x63ff8
movq (%rcx), %rdi
leaq 0x11ba8(%rip), %rsi     # 0x4f9fa
movq %rax, %rdx
xorl %eax, %eax
callq 0x3270
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x22658
movq %rax, %r15
movslq 0x80(%rax), %rax
movq %rax, 0x18(%rsp)
movl (%r15), %eax
testl %eax, %eax
cmovlel %ebx, %eax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
movss 0x10(%rsp), %xmm0
cmpq %rbx, %rax
je 0x3dea8
movq 0x20(%r15), %rcx
movss %xmm0, 0x18c(%rcx,%rbx)
addq $0x4a0, %rbx            # imm = 0x4A0
jmp 0x3de8d
movq 0x8(%rsp), %rdi
callq 0x3140
movq %rax, %rbx
pushq $0x4
popq %rsi
movq 0x18(%rsp), %rdi
callq 0x3250
movq %rax, %rbp
movq %rbx, 0x10(%rsp)
movslq %ebx, %rcx
decq %rcx
xorl %r12d, %r12d
testl %ecx, %ecx
movl $0x0, %r13d
movq %rcx, 0x28(%rsp)
cmovgl %ecx, %r13d
xorl %ebx, %ebx
cmpq %r12, %r13
je 0x3df1c
movq 0x8(%rsp), %rax
movsbq (%rax,%r12), %rbx
movl $0x3f800000, (%rbp,%rbx,4) # imm = 0x3F800000
movq %r15, %rdi
movq %rbp, %rsi
callq 0x233e2
andl $0x0, (%rbp,%rbx,4)
movl %ebx, %edi
movq %r14, %rsi
callq 0x3ddd2
incq %r12
jmp 0x3dee6
cmpl $0x0, 0x10(%rsp)
je 0x3df31
movq 0x8(%rsp), %rax
movq 0x28(%rsp), %rcx
movsbl (%rax,%rcx), %ebx
movl %ebx, %edi
movq %r14, 0x8(%rsp)
movq %r14, %rsi
callq 0x3ddd2
xorl %r13d, %r13d
movq 0x18(%rsp), %rax
testl %eax, %eax
movl $0x0, %r12d
cmovgl %eax, %r12d
movl 0x24(%rsp), %r14d
testl %r14d, %r14d
cmovlel %r13d, %r14d
cmpl %r14d, %r13d
je 0x3dfc3
movslq %ebx, %rbx
movl $0x3f800000, (%rbp,%rbx,4) # imm = 0x3F800000
movq %r15, %rdi
movq %rbp, %rsi
callq 0x233e2
movsd 0x12a4d(%rip), %xmm1    # 0x509d0
andl $0x0, (%rbp,%rbx,4)
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x3dfa3
cvtss2sd (%rax,%rcx,4), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x3df9e
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0x3df8a
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x4b9e
movl %eax, %ebx
movl %eax, %edi
movq 0x8(%rsp), %rsi
callq 0x3ddd2
incl %r13d
jmp 0x3df60
pushq $0xa
popq %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3060