// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: validate_classifier_full
void validate_classifier_full(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 *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));

    int size = net->w;
    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 resized = resize_min(im, size);
        resize_network(net, resized.w, resized.h);
        //show_image(im, "orig");
        //show_image(crop, "cropped");
        //cvWaitKey(0);
        float *pred = network_predict(net, resized.data);
        if(net->hierarchy) hierarchy_predictions(pred, net->outputs, net->hierarchy, 1, 1);

        free_image(im);
        free_image(resized);
        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("%d: top 1: %f, top %d: %f\n", i, avg_acc/(i+1), topk, avg_topk/(i+1));
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r15
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x22658
movq %rax, %r14
pushq $0x1
popq %r13
movq %rax, %rdi
movl %r13d, %esi
callq 0x22f00
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %r15, %rdi
callq 0x29598
movq %rax, %r15
leaq 0xe6c6(%rip), %rsi      # 0x4f9a6
leaq 0x1089d(%rip), %rdx     # 0x51b84
movq %rax, %rdi
callq 0x29737
movq %rax, %r12
leaq 0xdc8b(%rip), %rsi      # 0x4ef84
leaq 0x10830(%rip), %rdx     # 0x51b30
movq %r15, %rdi
callq 0x29737
movq %rax, 0x20(%rsp)
leaq 0xeed7(%rip), %rsi      # 0x501eb
pushq $0x2
popq %rdx
movq %r15, %rdi
callq 0x2977d
movl %eax, %ebx
leaq 0x10b64(%rip), %rsi     # 0x51e8c
movq %r15, %rdi
movl %r13d, %edx
callq 0x2977d
movl %eax, %ebp
movq %r12, %rdi
xorl %r12d, %r12d
callq 0x1e673
movq %rax, %r13
movq 0x20(%rsp), %rdi
callq 0x1c8c8
movq %rax, %r15
movq %rax, %rdi
callq 0x72f5
movq %rax, 0x40(%rsp)
movl (%r15), %eax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
callq 0x72c6
movl %ebp, 0x2c(%rsp)
movslq %ebp, %r15
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x3250
testl %ebx, %ebx
movl %ebx, 0x3c(%rsp)
cmovlel %r12d, %ebx
testl %r15d, %r15d
cmovlel %r12d, %r15d
movq %rax, %rbp
movq 0x30(%rsp), %rax
testl %eax, %eax
cmovlel %r12d, %eax
movq %rax, 0x30(%rsp)
movl 0x94(%r14), %eax
movl %eax, 0x38(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x28(%rsp)
movss %xmm0, 0x1c(%rsp)
movq %r14, 0x48(%rsp)
cmpq 0x30(%rsp), %r12
je 0x41562
movq %r12, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq (%rax,%r12,8), %r12
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x413fa
movq (%r13,%r14,8), %rsi
movq %r12, %rdi
callq 0x34b0
testq %rax, %rax
jne 0x41400
incq %r14
jmp 0x413de
pushq $-0x1
popq %rax
movl %eax, %r14d
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %rdi
movl 0x38(%rsp), %esi
callq 0xe96d
movl 0x58(%rsp), %esi
movl 0x5c(%rsp), %edx
movq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x22f25
movq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0x233e2
movq %rax, 0x20(%rsp)
movq 0xd0(%r12), %rdx
testq %rdx, %rdx
je 0x41481
movl 0x84(%r12), %esi
movq 0x20(%rsp), %rdi
pushq $0x1
popq %rcx
movl %ecx, %r8d
callq 0x324ad
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %esi
movl 0x2c(%rsp), %edx
movq %rbp, %rcx
callq 0x438a
movl (%rbp), %eax
movss 0x1c(%rsp), %xmm3
addss 0xab2e(%rip), %xmm3     # 0x4c008
xorl %ecx, %ecx
movq 0x50(%rsp), %rsi
movss 0x28(%rsp), %xmm2
cmpq %rcx, %r15
je 0x41509
movaps %xmm2, %xmm0
addss 0xab11(%rip), %xmm0     # 0x4c008
cmpl %r14d, (%rbp,%rcx,4)
je 0x41501
movaps %xmm2, %xmm0
incq %rcx
movaps %xmm0, %xmm2
jmp 0x414e7
cmpl %r14d, %eax
je 0x41514
movss 0x1c(%rsp), %xmm3
movss %xmm3, 0x20(%rsp)
leaq 0x1(%rsi), %r14
cvtsi2ss %r14d, %xmm1
movaps %xmm3, %xmm0
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movss %xmm2, 0x28(%rsp)
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm1
leaq 0x106a7(%rip), %rdi     # 0x51bea
movl 0x2c(%rsp), %edx
movb $0x2, %al
callq 0x3160
movq %r14, %r12
movss 0x20(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
jmp 0x413c2
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq