// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movl %r8d, %ebp
movq %rcx, %r12
movl %edx, 0x4(%rsp)
movq %rsi, %rbx
movq %rdi, %r15
testq %r9, %r9
movd %xmm0, 0x8(%rsp)
jne 0xa900
xorl %r14d, %r14d
jmp 0xa910
leaq 0x20(%rsp), %rsi
movq %r9, %rdi
callq 0x49493
movq %rax, %r14
movl %ebp, %edi
callq 0x3220
movq %r15, %rdi
callq 0xef02
movq 0x616d2(%rip), %rcx     # 0x6bff8
movq (%rcx), %rdi
leaq 0x4e17a(%rip), %rsi     # 0x58aaa
xorl %ebp, %ebp
movq %rax, %rdx
xorl %eax, %eax
callq 0x3270
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x316bc
movslq 0x80(%rax), %rcx
movq %rcx, 0x10(%rsp)
movslq (%rax), %rcx
testq %rcx, %rcx
movss 0x8(%rsp), %xmm9
jle 0xaa77
movq 0x20(%rax), %rdi
leal 0x3(%rcx), %edx
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %edx
imulq $0x1280, %rdx, %rcx     # imm = 0x1280
movdqa 0x4a7e2(%rip), %xmm1    # 0x55170
movdqa 0x4a6ea(%rip), %xmm2    # 0x55080
xorl %edx, %edx
movdqa 0x4a6f0(%rip), %xmm3    # 0x55090
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x4a7d0(%rip), %xmm5    # 0x55180
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0xa9ef
movss %xmm9, 0x18c(%rdi,%rdx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xaa08
movss %xmm9, 0x62c(%rdi,%rdx)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %esi
testb $0x1, %sil
je 0xaa4a
movss %xmm9, 0xacc(%rdi,%rdx)
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xaa5f
movss %xmm9, 0xf6c(%rdi,%rdx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x1280, %rdx           # imm = 0x1280
cmpq %rdx, %rcx
jne 0xa9b0
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x3140
movq %rax, %r15
pushq $0x4
popq %rsi
movq 0x10(%rsp), %rdi
callq 0x3250
movq %rax, %rbx
leal -0x1(%r15), %eax
movl %eax, (%rsp)
movq %r15, 0x18(%rsp)
cmpl $0x2, %r15d
movq %r14, %r15
jl 0xaae2
movl (%rsp), %r14d
xorl %r13d, %r13d
movsbq (%r12,%r13), %rbp
movl $0x3f800000, (%rbx,%rbp,4) # imm = 0x3F800000
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x32690
andl $0x0, (%rbx,%rbp,4)
movl %ebp, %edi
movq %r15, %rsi
callq 0x49925
incq %r13
cmpq %r13, %r14
jne 0xaab3
cmpl $0x0, 0x18(%rsp)
je 0xaaf2
movslq (%rsp), %rax
movsbl (%r12,%rax), %ebp
movl %ebp, %edi
movq %r15, %rsi
callq 0x49925
cmpl $0x0, 0x4(%rsp)
movq 0x10(%rsp), %r12
jle 0xab70
movl %r12d, %r13d
xorl %r14d, %r14d
movslq %ebp, %rbp
movl $0x3f800000, (%rbx,%rbp,4) # imm = 0x3F800000
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x32690
andl $0x0, (%rbx,%rbp,4)
testl %r12d, %r12d
movsd 0x4ef54(%rip), %xmm1    # 0x59a88
jle 0xab4f
xorl %ecx, %ecx
cvtss2sd (%rax,%rcx,4), %xmm0
ucomisd %xmm0, %xmm1
jbe 0xab47
andl $0x0, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0xab38
movq %rax, %rdi
movl %r12d, %esi
callq 0xf97d
movl %eax, %ebp
movl %eax, %edi
movq %r15, %rsi
callq 0x49925
incl %r14d
cmpl 0x4(%rsp), %r14d
jne 0xab0e
pushq $0xa
popq %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3060