// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: try_classifier
void try_classifier(char *datacfg, char *cfgfile, char *weightfile, char *filename, int layer_num)
{
    network *net = load_network(cfgfile, weightfile, 0);
    set_batch_network(net, 1);
    srand(2222222);

    list *options = read_data_cfg(datacfg);

    char *name_list = option_find_str(options, "names", 0);
    if(!name_list) name_list = option_find_str(options, "labels", "data/labels.list");
    int top = option_find_int(options, "top", 1);

    int i = 0;
    char **names = get_labels(name_list);
    clock_t time;
    int *indexes = calloc(top, sizeof(int));
    char buff[256];
    char *input = buff;
    while(1){
        if(filename){
            strncpy(input, filename, 256);
        }else{
            printf("Enter Image Path: ");
            fflush(stdout);
            input = fgets(input, 256, stdin);
            if(!input) return;
            strtok(input, "\n");
        }
        image orig = load_image_color(input, 0, 0);
        image r = resize_min(orig, 256);
        image im = crop_image(r, (r.w - 224 - 1)/2 + 1, (r.h - 224 - 1)/2 + 1, 224, 224);
        float mean[] = {0.48263312050943, 0.45230225481413, 0.40099074308742};
        float std[] = {0.22590347483426, 0.22120921437787, 0.22103996251583};
        float var[3];
        var[0] = std[0]*std[0];
        var[1] = std[1]*std[1];
        var[2] = std[2]*std[2];

        normalize_cpu(im.data, mean, var, 1, 3, im.w*im.h);

        float *X = im.data;
        time=clock();
        float *predictions = network_predict(net, X);

        layer l = net->layers[layer_num];
        for(i = 0; i < l.c; ++i){
            if(l.rolling_mean) printf("%f %f %f\n", l.rolling_mean[i], l.rolling_variance[i], l.scales[i]);
        }
        for(i = 0; i < l.outputs; ++i){
            printf("%f\n", l.output[i]);
        }
        /*

           printf("\n\nWeights\n");
           for(i = 0; i < l.n*l.size*l.size*l.c; ++i){
           printf("%f\n", l.filters[i]);
           }

           printf("\n\nBiases\n");
           for(i = 0; i < l.n; ++i){
           printf("%f\n", l.biases[i]);
           }
         */

        top_predictions(net, top, indexes);
        printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        for(i = 0; i < top; ++i){
            int index = indexes[i];
            printf("%s: %f\n", names[index], predictions[index]);
        }
        free_image(im);
        if (filename) break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movl %r8d, %ebx
movq %rcx, %r12
movq %rdi, %r14
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x2f9e4
movq %rax, %r13
movq %rax, %rdi
movl $0x1, %esi
callq 0x302d4
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x3230
movq %r14, %rdi
callq 0x34b9c
movq %rax, %r14
leaq 0xc8c7(%rip), %rsi      # 0x576e9
movq %rax, %rdi
xorl %edx, %edx
callq 0x34d5b
movq %rax, %r15
testq %rax, %rax
jne 0x4ae4d
leaq 0xbb1b(%rip), %rsi      # 0x56956
leaq 0xdd11(%rip), %rdx      # 0x58b53
movq %r14, %rdi
callq 0x34d5b
movq %rax, %r15
leaq 0xe020(%rip), %rsi      # 0x58e74
movq %r14, %rdi
movl $0x1, %edx
callq 0x34d9f
movl %eax, %ebp
movq %r15, %rdi
callq 0x2b6d3
movq %rax, 0x60(%rsp)
movslq %ebp, %r14
movl $0x4, %esi
movq %r14, %rdi
callq 0x3260
movq %rax, 0x58(%rsp)
movslq %ebx, %rax
movl %r14d, %ecx
movq %rcx, 0x50(%rsp)
leaq 0xd0(%rsp), %rbx
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
movq %rax, 0x20(%rsp)
movq %r12, 0x68(%rsp)
movq %r12, %rsi
movq %r13, 0x28(%rsp)
testq %rsi, %rsi
je 0x4aec5
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
callq 0x3080
jmp 0x4af14
leaq 0xd13e(%rip), %rdi      # 0x5800a
xorl %eax, %eax
callq 0x3170
movq 0x1f0f6(%rip), %rax     # 0x69fd0
movq (%rax), %rdi
callq 0x3320
movq 0x1f0ef(%rip), %rax     # 0x69fd8
movq (%rax), %rdx
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x3240
testq %rax, %rax
je 0x4b1a6
movq %rax, %rbx
movq %rax, %rdi
leaq 0xd5fa(%rip), %rsi      # 0x58509
callq 0x33c0
leaq 0xb8(%rsp), %rdi
movq %rbx, 0x30(%rsp)
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x160b6
movq 0xc8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xb8(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0xa0(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x1920a
movl 0xa0(%rsp), %eax
movl 0xa4(%rsp), %ecx
movl %eax, %edx
movl $0xffffff1f, %edi       # imm = 0xFFFFFF1F
addl %edi, %edx
shrl $0x1f, %edx
leal (%rax,%rdx), %esi
addl $0xffffff1f, %esi       # imm = 0xFFFFFF1F
sarl %esi
incl %esi
movl %ecx, %eax
addl %edi, %eax
shrl $0x1f, %eax
leal (%rcx,%rax), %edx
addl $0xffffff1f, %edx       # imm = 0xFFFFFF1F
sarl %edx
incl %edx
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xa0(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x38(%rsp), %rdi
movl $0xe0, %ecx
movl $0xe0, %r8d
callq 0x181f7
movabsq $0x3ee794293ef71bb0, %rax # imm = 0x3EE794293EF71BB0
movq %rax, 0x88(%rsp)
movl $0x3ecd4ea9, 0x90(%rsp) # imm = 0x3ECD4EA9
movabsq $0x3d486e833d510755, %rax # imm = 0x3D486E833D510755
movq %rax, 0x94(%rsp)
movl $0x3d482006, 0x9c(%rsp) # imm = 0x3D482006
movq 0x48(%rsp), %rdi
movl 0x3c(%rsp), %r9d
imull 0x38(%rsp), %r9d
leaq 0x88(%rsp), %rsi
leaq 0x94(%rsp), %rdx
movl $0x1, %ecx
movl $0x3, %r8d
callq 0x28403
movq 0x48(%rsp), %rbx
callq 0x3130
movq %rax, 0x70(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x307ea
movq %rax, 0x78(%rsp)
movq 0x20(%r13), %rax
movq 0x20(%rsp), %rcx
movl 0x58(%rax,%rcx), %r14d
movslq 0x74(%rax,%rcx), %r15
movq 0x268(%rax,%rcx), %rbp
testq %r15, %r15
jle 0x4b0d1
movq 0x20(%rsp), %rcx
movq 0x240(%rax,%rcx), %rdx
movq %rdx, 0x80(%rsp)
movq 0x2b0(%rax,%rcx), %r13
movq 0x2b8(%rax,%rcx), %rbx
xorl %r12d, %r12d
testq %r13, %r13
je 0x4b0c9
xorps %xmm0, %xmm0
cvtss2sd (%r13,%r12,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd (%rbx,%r12,4), %xmm1
movq 0x80(%rsp), %rax
xorps %xmm2, %xmm2
cvtss2sd (%rax,%r12,4), %xmm2
leaq 0xc908(%rip), %rdi      # 0x579ca
movb $0x3, %al
callq 0x3170
incq %r12
cmpq %r12, %r15
jne 0x4b092
testl %r14d, %r14d
movq 0x60(%rsp), %r15
leaq 0xd7d8(%rip), %r12      # 0x588b8
jle 0x4b0ff
xorl %ebx, %ebx
xorps %xmm0, %xmm0
cvtss2sd (%rbp,%rbx,4), %xmm0
movq %r12, %rdi
movb $0x1, %al
callq 0x3170
incq %rbx
cmpq %rbx, %r14
jne 0x4b0e4
movq 0x28(%rsp), %rdi
movq 0x50(%rsp), %rbp
movl %ebp, %esi
movq 0x58(%rsp), %r14
movq %r14, %rdx
callq 0x307d3
callq 0x3130
subq 0x70(%rsp), %rax
movq %rax, %rdi
callq 0xe8d4
cvtss2sd %xmm0, %xmm0
leaq 0xceaf(%rip), %rdi      # 0x57fe4
movq 0x30(%rsp), %rsi
movb $0x1, %al
callq 0x3170
testl %ebp, %ebp
leaq 0xdaa3(%rip), %r13      # 0x58bed
movq 0x78(%rsp), %r12
jle 0x4b176
xorl %ebx, %ebx
movslq (%r14,%rbx,4), %rax
movq (%r15,%rax,8), %rsi
xorps %xmm0, %xmm0
cvtss2sd (%r12,%rax,4), %xmm0
movq %r13, %rdi
movb $0x1, %al
callq 0x3170
incq %rbx
cmpq %rbx, %rbp
jne 0x4b153
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq 0x68(%rsp), %rsi
testq %rsi, %rsi
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %r13
je 0x4aeb1
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq