// File: /workspace/github_c_makefile_star2_O1/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 $0x198, %rsp            # imm = 0x198
movq %rdi, %r14
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x2f9e4
movq %rax, %rbx
movq %rax, %rdi
movl $0x1, %esi
callq 0x302d4
xorl %edi, %edi
callq 0x32d0
movl %eax, %edi
callq 0x3230
movq %r14, %rdi
callq 0x34b9c
movq %rax, %r14
leaq 0xcb3a(%rip), %rsi      # 0x56956
leaq 0xed30(%rip), %rdx      # 0x58b53
movq %rax, %rdi
callq 0x34d5b
movq %rax, %r15
leaq 0xc157(%rip), %rsi      # 0x55f8c
leaq 0xece4(%rip), %rdx      # 0x58b20
movq %r14, %rdi
callq 0x34d5b
movq %rax, %r12
leaq 0xd34d(%rip), %rsi      # 0x5719b
movq %r14, %rdi
movl $0x2, %edx
callq 0x34d9f
movl %eax, %ebp
leaq 0xf010(%rip), %rsi      # 0x58e74
movq %r14, %rdi
movl $0x1, %edx
callq 0x34d9f
movl %eax, %r13d
movq %r15, %rdi
callq 0x2b6d3
movq %rax, 0x70(%rsp)
movq %r12, %rdi
callq 0x296f8
movq %rax, %r14
movq %rax, %rdi
callq 0x10fa0
movq %rax, 0x68(%rsp)
movslq (%r14), %r15
movq %r14, %rdi
callq 0x10f56
movslq %r13d, %rdi
movl $0x4, %esi
callq 0x3260
movq %r15, 0x98(%rsp)
testq %r15, %r15
jle 0x4a3b3
movq %rax, %r12
movslq %ebp, %rax
movq %rax, 0x88(%rsp)
movl %eax, %eax
movl %r13d, %ecx
movq %rcx, 0x78(%rsp)
xorps %xmm1, %xmm1
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movl %r13d, 0x60(%rsp)
movq %rax, %r13
movq %rax, 0x80(%rsp)
movq %r12, 0x90(%rsp)
movss %xmm1, 0x64(%rsp)
movss %xmm0, 0x3c(%rsp)
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
testl %ebp, %ebp
movq %rcx, 0x58(%rsp)
jle 0x49f4d
movq 0x68(%rsp), %rax
movq (%rax,%rcx,8), %r14
xorl %r12d, %r12d
movq 0x70(%rsp), %r15
movq (%r15,%r12,8), %rsi
movq %r14, %rdi
callq 0x34c0
testq %rax, %rax
jne 0x49f43
incq %r12
cmpq %r12, %r13
jne 0x49f28
jmp 0x49f48
movl %r12d, 0x1c(%rsp)
movq 0x58(%rsp), %rcx
movl 0x90(%rbx), %r12d
movl 0x94(%rbx), %r14d
movq 0x68(%rsp), %rax
movq (%rax,%rcx,8), %rsi
leal 0x20(%r14), %edx
leal 0x20(%r12), %ecx
leaq 0x20(%rsp), %rdi
callq 0x160b6
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x40(%rsp), %r13
movq %r13, %rdi
movl $0xffffffe0, %esi       # imm = 0xFFFFFFE0
movl $0xffffffe0, %edx       # imm = 0xFFFFFFE0
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0xb0(%rsp)
movups 0x40(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0x20, %esi
movl $0xffffffe0, %edx       # imm = 0xFFFFFFE0
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
leaq 0xb8(%rsp), %r15
movq %rax, 0x10(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0x28(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x18(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0xffffffe0, %esi       # imm = 0xFFFFFFE0
movl $0x20, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0x40(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x30(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0x58(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x48(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x16f91
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0xffffffe0, %esi       # imm = 0xFFFFFFE0
movl $0xffffffe0, %edx       # imm = 0xFFFFFFE0
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0x70(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x60(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0x20, %esi
movl $0xffffffe0, %edx       # imm = 0xFFFFFFE0
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0x88(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x78(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0xa0(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0x90(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0xffffffe0, %esi       # imm = 0xFFFFFFE0
movl $0x20, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0xb8(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0xa8(%r15)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x181f7
movq 0x50(%rsp), %rax
movq %rax, 0xd0(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0xc0(%r15)
movl $0x4, %esi
movq 0x88(%rsp), %rdi
callq 0x3260
movq %rax, %r14
xorl %r13d, %r13d
movq 0xb0(%rsp,%r13), %rsi
movq %rbx, %rdi
callq 0x307ea
movq %rax, %r12
movq 0xd0(%rbx), %rdx
testq %rdx, %rdx
je 0x4a267
movl 0x84(%rbx), %esi
movq %r12, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x3cc56
leaq (%rsp,%r13), %r15
addq $0xa0, %r15
movl %ebp, %edi
movss 0x8d8c(%rip), %xmm0     # 0x53008
movq %r12, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x285e9
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
addq $0x18, %r13
cmpq $0xf0, %r13
jne 0x4a22f
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq %r14, %rdi
movl %ebp, %esi
movl 0x60(%rsp), %r15d
movl %r15d, %edx
movq 0x90(%rsp), %r12
movq %r12, %rcx
callq 0xe8e2
movq %r14, %rdi
callq 0x3040
movss 0x64(%rsp), %xmm0
movaps %xmm0, %xmm2
addss 0x8d01(%rip), %xmm2     # 0x53008
movl 0x1c(%rsp), %edx
cmpl %edx, (%r12)
je 0x4a314
movaps %xmm0, %xmm2
testl %r15d, %r15d
movq 0x80(%rsp), %r13
movq 0x78(%rsp), %rcx
movq 0x58(%rsp), %rsi
movss 0x3c(%rsp), %xmm0
jle 0x4a354
xorl %eax, %eax
movaps %xmm0, %xmm3
addss 0x8cca(%rip), %xmm3     # 0x53008
cmpl %edx, (%r12,%rax,4)
je 0x4a347
movaps %xmm0, %xmm3
incq %rax
movaps %xmm3, %xmm0
cmpq %rax, %rcx
jne 0x4a336
jmp 0x4a357
movaps %xmm0, %xmm3
movss %xmm3, 0x3c(%rsp)
leaq 0x1(%rsi), %r14
cvtsi2ss %r14d, %xmm1
movaps %xmm2, %xmm0
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movss %xmm2, 0x1c(%rsp)
movaps %xmm3, %xmm2
divss %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
leaq 0xe82d(%rip), %rdi      # 0x58bb9
movl %r15d, %edx
movb $0x2, %al
callq 0x3170
movq %r14, %rcx
movss 0x1c(%rsp), %xmm1
movss 0x3c(%rsp), %xmm0
cmpq 0x98(%rsp), %r14
jne 0x49efa
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq