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

    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;
            }
        }
        int w = net->w;
        int h = net->h;
        int shift = 32;
        image im = load_image_color(paths[i], w+shift, h+shift);
        image images[10];
        images[0] = crop_image(im, -shift, -shift, w, h);
        images[1] = crop_image(im, shift, -shift, w, h);
        images[2] = crop_image(im, 0, 0, w, h);
        images[3] = crop_image(im, -shift, shift, w, h);
        images[4] = crop_image(im, shift, shift, w, h);
        flip_image(im);
        images[5] = crop_image(im, -shift, -shift, w, h);
        images[6] = crop_image(im, shift, -shift, w, h);
        images[7] = crop_image(im, 0, 0, w, h);
        images[8] = crop_image(im, -shift, shift, w, h);
        images[9] = crop_image(im, shift, shift, w, h);
        float *pred = calloc(classes, sizeof(float));
        for(j = 0; j < 10; ++j){
            float *p = network_predict(net, images[j].data);
            if(net->hierarchy) hierarchy_predictions(p, net->outputs, net->hierarchy, 1, 1);
            axpy_cpu(classes, 1, p, 1, pred, 1);
            free_image(images[j]);
        }
        free_image(im);
        top_k(pred, classes, topk, indexes);
        free(pred);
        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 $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %r14
xorl %r13d, %r13d
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x22658
movq %rax, %rbp
pushq $0x1
popq %r15
movq %rax, %rdi
movl %r15d, %esi
callq 0x22f00
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %r14, %rdi
callq 0x29598
movq %rax, %r14
leaq 0xecb4(%rip), %rsi      # 0x4f9a6
leaq 0x10e8b(%rip), %rdx     # 0x51b84
movq %rax, %rdi
callq 0x29737
movq %rax, 0x58(%rsp)
leaq 0xe277(%rip), %rsi      # 0x4ef84
leaq 0x10e1c(%rip), %rdx     # 0x51b30
movq %r14, %rdi
callq 0x29737
movq %rax, %r12
leaq 0xf4c5(%rip), %rsi      # 0x501eb
pushq $0x2
popq %rdx
movq %r14, %rdi
callq 0x2977d
movl %eax, %ebx
leaq 0x11152(%rip), %rsi     # 0x51e8c
movq %r14, %rdi
movl %r15d, %edx
callq 0x2977d
movl %eax, %r15d
movq 0x58(%rsp), %rdi
callq 0x1e673
movq %rax, 0x88(%rsp)
movq %r12, %rdi
callq 0x1c8c8
movq %rax, %r14
movq %rax, %rdi
callq 0x72f5
movq %rax, 0x80(%rsp)
movl (%r14), %r12d
movq %r14, %rdi
callq 0x72c6
movl %r15d, 0x54(%rsp)
movslq %r15d, %r14
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x3250
movq %rax, 0x70(%rsp)
movslq %ebx, %rax
movq %rax, 0x68(%rsp)
testl %eax, %eax
movl $0x0, %eax
movl %ebx, 0x58(%rsp)
cmovgl %ebx, %eax
movq %rax, 0xa8(%rsp)
movq %r14, %rbx
testl %ebx, %ebx
cmovlel %r13d, %ebx
testl %r12d, %r12d
cmovlel %r13d, %r12d
movq %r12, 0x90(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x50(%rsp)
movss %xmm0, 0x4c(%rsp)
movq %rbx, 0x78(%rsp)
cmpq 0x90(%rsp), %r13
je 0x4127b
movq %r13, 0xa0(%rsp)
movq 0x80(%rsp), %rax
movq (%rax,%r13,8), %r13
xorl %r15d, %r15d
pushq $0x1
popq %rbx
movq 0x88(%rsp), %r14
cmpq %r15, 0xa8(%rsp)
je 0x40e32
movq (%r14,%r15,8), %rsi
movq %r13, %rdi
callq 0x34b0
testq %rax, %rax
jne 0x40e3c
incq %r15
jmp 0x40e12
pushq $-0x1
popq %rax
movq %rax, 0x60(%rsp)
jmp 0x40e41
movq %r15, 0x60(%rsp)
movl 0x90(%rbp), %eax
movq %rax, 0x98(%rsp)
movl 0x94(%rbp), %r14d
leal 0x20(%r14), %edx
leal 0x20(%rax), %ecx
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xbf36
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %r13
movq %r13, %rdi
pushq $-0x20
popq %r15
movl %r15d, %esi
movl %r15d, %edx
movl %r14d, %ecx
movq %r14, %r12
movq 0x98(%rsp), %r14
movl %r14d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0xc0(%rsp)
movups 0x18(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
pushq $0x20
popq %rsi
movl %r15d, %edx
movl %r12d, %ecx
movl %r14d, %r8d
movq %r14, %r13
callq 0xdba7
movq 0x28(%rsp), %rax
leaq 0xc8(%rsp), %r14
movq %rax, 0x10(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0x28(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x18(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
pushq $-0x20
popq %rsi
pushq $0x20
popq %r15
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0x40(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x30(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
movl %r15d, %esi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0x58(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x48(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xcb93
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
pushq $-0x20
popq %rdx
movl %edx, %esi
movl %edx, %r15d
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0x70(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x60(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
pushq $0x20
popq %rsi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0x88(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x78(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
movq %rdi, %r15
xorl %esi, %esi
xorl %edx, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0xa0(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x90(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
pushq $-0x20
popq %rsi
pushq $0x20
popq %rdx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0xb8(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0xa8(%r14)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
pushq $0x20
popq %rdx
movl %edx, %esi
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xdba7
movq 0x28(%rsp), %rax
movq %rax, 0xd0(%r14)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0xc0(%r14)
movq 0x68(%rsp), %rdi
pushq $0x4
popq %rsi
callq 0x3250
movq %rax, %r13
xorl %r14d, %r14d
cmpq $0xf0, %r14
je 0x411ab
movq 0xc0(%rsp,%r14), %rsi
movq %rbp, %rdi
callq 0x233e2
movq %rax, %r15
movq 0xd0(%rbp), %rdx
testq %rdx, %rdx
je 0x4115f
movl 0x84(%rbp), %esi
movq %r15, %rdi
movl %ebx, %ecx
movl %ebx, %r8d
callq 0x324ad
movq %rbp, %r12
leaq (%rsp,%r14), %rbp
addq $0xb0, %rbp
movl 0x58(%rsp), %edi
movss 0xae8f(%rip), %xmm0     # 0x4c008
movq %r15, %rsi
movl %ebx, %edx
movq %r13, %rcx
movl %ebx, %r8d
callq 0x1b3ed
movq 0x10(%rbp), %rax
movq %rax, 0x10(%rsp)
movups (%rbp), %xmm0
movq %r12, %rbp
movups %xmm0, (%rsp)
callq 0xba88
addq $0x18, %r14
jmp 0x41124
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq %r13, %rdi
movl 0x58(%rsp), %esi
movl 0x54(%rsp), %edx
movq 0x70(%rsp), %r14
movq %r14, %rcx
callq 0x438a
movq %r13, %rdi
callq 0x3040
movl (%r14), %eax
movss 0x4c(%rsp), %xmm3
addss 0xae14(%rip), %xmm3     # 0x4c008
xorl %ecx, %ecx
movq 0xa0(%rsp), %rsi
movq 0x78(%rsp), %rbx
movss 0x50(%rsp), %xmm2
movq 0x60(%rsp), %rdx
cmpq %rcx, %rbx
je 0x4122f
movaps %xmm2, %xmm0
addss 0xadea(%rip), %xmm0     # 0x4c008
cmpl %edx, (%r14,%rcx,4)
je 0x41227
movaps %xmm2, %xmm0
incq %rcx
movaps %xmm0, %xmm2
jmp 0x4120e
cmpl %edx, %eax
je 0x41239
movss 0x4c(%rsp), %xmm3
movss %xmm3, 0x4c(%rsp)
leaq 0x1(%rsi), %r14
cvtsi2ss %r14d, %xmm1
movaps %xmm3, %xmm0
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movss %xmm2, 0x50(%rsp)
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm1
leaq 0x10982(%rip), %rdi     # 0x51bea
movl 0x54(%rsp), %edx
movb $0x2, %al
callq 0x3160
movq %r14, %r13
jmp 0x40de2
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq