// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: validate_classifier_single
void validate_classifier_single(char *datacfg, char *filename, char *weightfile)
{
    int i, j;
    network *net = load_network(filename, weightfile, 0);
    set_batch_network(net, 1);
    srand(time(0));

    list *options = read_data_cfg(datacfg);

    char *label_list = option_find_str(options, "labels", "data/labels.list");
    char *leaf_list = option_find_str(options, "leaves", 0);
    if(leaf_list) change_leaves(net->hierarchy, leaf_list);
    char *valid_list = option_find_str(options, "valid", "data/train.list");
    int classes = option_find_int(options, "classes", 2);
    int topk = option_find_int(options, "top", 1);

    char **labels = get_labels(label_list);
    list *plist = get_paths(valid_list);

    char **paths = (char **)list_to_array(plist);
    int m = plist->size;
    free_list(plist);

    float avg_acc = 0;
    float avg_topk = 0;
    int *indexes = calloc(topk, sizeof(int));

    for(i = 0; i < m; ++i){
        int class = -1;
        char *path = paths[i];
        for(j = 0; j < classes; ++j){
            if(strstr(path, labels[j])){
                class = j;
                break;
            }
        }
        image im = load_image_color(paths[i], 0, 0);
        image crop = center_crop_image(im, net->w, net->h);
        //grayscale_image_3c(crop);
        //show_image(im, "orig");
        //show_image(crop, "cropped");
        //cvWaitKey(0);
        float *pred = network_predict(net, crop.data);
        if(net->hierarchy) hierarchy_predictions(pred, net->outputs, net->hierarchy, 1, 1);

        free_image(im);
        free_image(crop);
        top_k(pred, classes, topk, indexes);

        if(indexes[0] == class) avg_acc += 1;
        for(j = 0; j < topk; ++j){
            if(indexes[j] == class) avg_topk += 1;
        }

        printf("%s, %d, %f, %f, \n", paths[i], class, pred[0], pred[1]);
        printf("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x3a9b0
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movq -0x8(%rbp), %rdi
callq 0x426b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x11036(%rip), %rsi     # 0x74346
leaq 0x130d9(%rip), %rdx     # 0x763f0
callq 0x42920
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x13150(%rip), %rsi     # 0x7647b
xorl %eax, %eax
movl %eax, %edx
callq 0x42920
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x63353
movq -0x28(%rbp), %rax
movq 0xd0(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x4ee50
movq -0x30(%rbp), %rdi
leaq 0x10615(%rip), %rsi     # 0x73973
leaq 0x13053(%rip), %rdx     # 0x763b8
callq 0x42920
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x116de(%rip), %rsi     # 0x74a57
movl $0x2, %edx
callq 0x42990
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x1337f(%rip), %rsi     # 0x76710
movl $0x1, %edx
callq 0x42990
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0x343c0
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rdi
callq 0x31450
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x9020
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x6c(%rbp)
movq -0x60(%rbp), %rdi
callq 0x8fb0
xorps %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x74(%rbp)
movslq -0x50(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x80(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jge 0x63669
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
movq -0x68(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x90(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x6346e
movq -0x90(%rbp), %rdi
movq -0x58(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3480
cmpq $0x0, %rax
je 0x63461
movl -0x20(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x6346e
jmp 0x63463
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x63430
movq -0x68(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0xa8(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xf510
movq -0x28(%rbp), %rax
movl 0x94(%rax), %esi
movq -0x28(%rbp), %rax
movl 0x90(%rax), %edx
leaq -0xc0(%rbp), %rdi
leaq -0xa8(%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 0x11bb0
movq -0x28(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x3b160
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x63519
movq -0xc8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x84(%rax), %esi
movq -0x28(%rbp), %rax
movq 0xd0(%rax), %rdx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x4efb0
leaq -0xa8(%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 -0xc0(%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
movq -0xc8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl -0x50(%rbp), %edx
movq -0x80(%rbp), %rcx
callq 0x4b70
movq -0x80(%rbp), %rax
movl (%rax), %eax
cmpl -0x84(%rbp), %eax
jne 0x63599
movss 0xda7d(%rip), %xmm0     # 0x7100c
addss -0x70(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x635da
movq -0x80(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x84(%rbp), %eax
jne 0x635cd
movss 0xda49(%rip), %xmm0     # 0x7100c
addss -0x74(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
jmp 0x635cf
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x635a0
movq -0x68(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl -0x84(%rbp), %edx
movq -0xc8(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0xc8(%rbp), %rax
movss 0x4(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x12e70(%rip), %rdi     # 0x76482
movb $0x2, %al
callq 0x3130
movl -0x1c(%rbp), %esi
movss -0x70(%rbp), %xmm0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x50(%rbp), %edx
movss -0x74(%rbp), %xmm1
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x12e0c(%rip), %rdi     # 0x76460
movb $0x2, %al
callq 0x3130
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x63400
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)