// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: predict_classifier
void predict_classifier(char *datacfg, char *cfgfile, char *weightfile, char *filename, int top)
{
    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");
    if(top == 0) 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 im = load_image_color(input, 0, 0);
        image r = letterbox_image(im, net->w, net->h);
        //image r = resize_min(im, 320);
        //printf("%d %d\n", r.w, r.h);
        //resize_network(net, r.w, r.h);
        //printf("%d %d\n", r.w, r.h);

        float *X = r.data;
        time=clock();
        float *predictions = network_predict(net, X);
        if(net->hierarchy) hierarchy_predictions(predictions, net->outputs, net->hierarchy, 1, 1);
        top_k(predictions, net->outputs, top, indexes);
        fprintf(stderr, "%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        for(i = 0; i < top; ++i){
            int index = indexes[i];
            //if(net->hierarchy) printf("%d, %s: %f, parent: %s \n",index, names[index], predictions[index], (net->hierarchy->parent[index] >= 0) ? names[net->hierarchy->parent[index]] : "Root");
            //else printf("%s: %f\n",names[index], predictions[index]);
            printf("%5.2f%%: %s\n", predictions[index]*100, names[index]);
        }
        if(r.data != im.data) free_image(r);
        free_image(im);
        if (filename) break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x3a9b0
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x31e0
movq -0x8(%rbp), %rdi
callq 0x426b0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
leaq 0x10f93(%rip), %rsi     # 0x74fa5
xorl %eax, %eax
movl %eax, %edx
callq 0x42920
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x64041
movq -0x38(%rbp), %rdi
leaq 0x10315(%rip), %rsi     # 0x74346
leaq 0x123b8(%rip), %rdx     # 0x763f0
callq 0x42920
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x6405f
movq -0x38(%rbp), %rdi
leaq 0x126be(%rip), %rsi     # 0x76710
movl $0x1, %edx
callq 0x42990
movl %eax, -0x24(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x40(%rbp), %rdi
callq 0x343c0
movq %rax, -0x50(%rbp)
movslq -0x24(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x60(%rbp)
leaq -0x160(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x640b1
movq -0x168(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x3060
jmp 0x64112
leaq 0x1183a(%rip), %rdi     # 0x758f2
movb $0x0, %al
callq 0x3130
movq 0x1ef0a(%rip), %rax     # 0x82fd0
movq (%rax), %rdi
callq 0x32e0
movq -0x168(%rbp), %rdi
movq 0x1eefc(%rip), %rax     # 0x82fd8
movq (%rax), %rdx
movl $0x100, %esi            # imm = 0x100
callq 0x3200
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x168(%rbp)
jne 0x640ff
jmp 0x6430b
movq -0x168(%rbp), %rdi
leaq 0x11ca1(%rip), %rsi     # 0x75dae
callq 0x3380
movq -0x168(%rbp), %rsi
leaq -0x180(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xf510
movq -0x30(%rbp), %rax
movl 0x94(%rax), %esi
movq -0x30(%rbp), %rax
movl 0x90(%rax), %edx
leaq -0x198(%rbp), %rdi
leaq -0x180(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x12c60
movq -0x188(%rbp), %rax
movq %rax, -0x1a0(%rbp)
callq 0x30f0
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0x3b160
movq %rax, -0x1a8(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x641cf
movq -0x1a8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x84(%rax), %esi
movq -0x30(%rbp), %rax
movq 0xd0(%rax), %rdx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x4efb0
movq -0x1a8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x84(%rax), %esi
movl -0x24(%rbp), %edx
movq -0x60(%rbp), %rcx
callq 0x4b70
movq 0x1ee05(%rip), %rax     # 0x82ff8
movq (%rax), %rax
movq %rax, -0x1c0(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x1b8(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x58(%rbp), %rdi
callq 0x4b50
movq -0x1c0(%rbp), %rdi
movq -0x1b8(%rbp), %rdx
cvtss2sd %xmm0, %xmm0
leaq 0x11697(%rip), %rsi     # 0x758cc
movb $0x1, %al
callq 0x3240
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x642a3
movq -0x60(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1ac(%rbp)
movq -0x1a8(%rbp), %rax
movslq -0x1ac(%rbp), %rcx
movss 0xcfa2(%rip), %xmm0     # 0x71214
mulss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x50(%rbp), %rax
movslq -0x1ac(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1220b(%rip), %rdi     # 0x7649c
movb $0x1, %al
callq 0x3130
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x64243
movq -0x188(%rbp), %rax
cmpq -0x170(%rbp), %rax
je 0x642d8
leaq -0x198(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
leaq -0x180(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
cmpq $0x0, -0x20(%rbp)
je 0x64306
jmp 0x6430b
jmp 0x64093
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopw %cs:(%rax,%rax)