// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x316bc
movq %rax, %rbx
movq %rax, %rdi
movl $0x1, %esi
callq 0x320a7
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %r14, %rdi
callq 0x36cb4
movq %rax, %r14
leaq 0xc334(%rip), %rsi      # 0x58a56
leaq 0xe59b(%rip), %rdx      # 0x5acc4
movq %rax, %rdi
callq 0x36e77
movq %rax, %r15
leaq 0xb929(%rip), %rsi      # 0x58064
leaq 0xe52e(%rip), %rdx      # 0x5ac70
movq %r14, %rdi
callq 0x36e77
movq %rax, %r12
leaq 0xcb47(%rip), %rsi      # 0x5929b
movq %r14, %rdi
movl $0x2, %edx
callq 0x36eed
movl %eax, 0x24(%rsp)
leaq 0xe860(%rip), %rsi      # 0x5afcc
movq %r14, %rdi
movl $0x1, %edx
callq 0x36eed
movl %eax, %ebp
movq %r15, %rdi
movq %rbx, %r15
callq 0x2d26c
movq %rax, 0x50(%rsp)
movq %r12, %rdi
callq 0x2af38
movq %rax, %r12
movq %rax, %rdi
callq 0x11928
movq %rax, 0x40(%rsp)
movslq (%r12), %rbx
movq %r12, %rdi
callq 0x118de
movslq %ebp, %rdi
movl $0x4, %esi
callq 0x3250
movq %rbx, 0x38(%rsp)
testq %rbx, %rbx
jle 0x4c9b5
movq %rax, %r13
movl 0x94(%r15), %eax
movl %eax, 0x30(%rsp)
movl 0x24(%rsp), %ebx
movl %ebp, %r14d
xorps %xmm1, %xmm1
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movq %r15, 0x28(%rsp)
movl %ebp, 0x34(%rsp)
movss %xmm1, 0x1c(%rsp)
movss %xmm0, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq %rcx, 0x48(%rsp)
movq (%rax,%rcx,8), %rbp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $0x0, 0x24(%rsp)
jle 0x4c842
xorl %r15d, %r15d
movq 0x50(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %rbp, %rdi
callq 0x34b0
testq %rax, %rax
jne 0x4c83a
incq %r15
cmpq %r15, %rbx
jne 0x4c81a
jmp 0x4c83d
movl %r15d, %r12d
movq 0x28(%rsp), %r15
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ac9
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x19bb8
movl 0x58(%rsp), %esi
movl 0x5c(%rsp), %edx
movq %r15, %rdi
callq 0x321b7
movq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x32690
movq %rax, %rbp
movq 0xd0(%r15), %rdx
testq %rdx, %rdx
je 0x4c8bd
movl 0x84(%r15), %esi
movq %rbp, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x3eeda
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq %rbp, %rdi
movl 0x24(%rsp), %esi
movl 0x34(%rsp), %ebp
movl %ebp, %edx
movq %r13, %rcx
callq 0xf0cd
movss 0x1c(%rsp), %xmm1
movaps %xmm1, %xmm2
movss 0x86f2(%rip), %xmm0     # 0x55008
addss %xmm0, %xmm2
cmpl %r12d, (%r13)
je 0x4c923
movaps %xmm1, %xmm2
testl %ebp, %ebp
movq 0x48(%rsp), %rsi
movss 0x20(%rsp), %xmm1
jle 0x4c952
xorl %eax, %eax
movaps %xmm1, %xmm3
addss %xmm0, %xmm3
cmpl %r12d, (%r13,%rax,4)
je 0x4c945
movaps %xmm1, %xmm3
incq %rax
movaps %xmm3, %xmm1
cmpq %rax, %r14
jne 0x4c937
jmp 0x4c955
movaps %xmm1, %xmm3
movss %xmm3, 0x1c(%rsp)
leaq 0x1(%rsi), %r15
xorps %xmm1, %xmm1
cvtsi2ss %r15d, %xmm1
movaps %xmm2, %xmm0
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movss %xmm2, 0x20(%rsp)
movaps %xmm3, %xmm2
divss %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
leaq 0xe39d(%rip), %rdi      # 0x5ad2a
movl %ebp, %edx
movb $0x2, %al
callq 0x3160
movq %r15, %rcx
movss 0x20(%rsp), %xmm1
movss 0x1c(%rsp), %xmm0
cmpq 0x38(%rsp), %r15
movq 0x28(%rsp), %r15
jne 0x4c7f0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq