// File: /workspace/github_c_makefile_star2_O3/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 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 0xc929(%rip), %rsi      # 0x58a56
leaq 0xeb90(%rip), %rdx      # 0x5acc4
movq %rax, %rdi
callq 0x36e77
movq %rax, %r15
leaq 0xbf1e(%rip), %rsi      # 0x58064
leaq 0xeb23(%rip), %rdx      # 0x5ac70
movq %r14, %rdi
callq 0x36e77
movq %rax, %r12
leaq 0xd13c(%rip), %rsi      # 0x5929b
movq %r14, %rdi
movl $0x2, %edx
callq 0x36eed
movl %eax, %ebp
leaq 0xee57(%rip), %rsi      # 0x5afcc
movq %r14, %rdi
movl $0x1, %edx
callq 0x36eed
movl %eax, %r13d
movq %r15, %rdi
callq 0x2d26c
movq %rax, 0x68(%rsp)
movq %r12, %rdi
callq 0x2af38
movq %rax, %r14
movq %rax, %rdi
callq 0x11928
movq %rax, 0x90(%rsp)
movslq (%r14), %r15
movq %r14, %rdi
callq 0x118de
movslq %r13d, %rdi
movl $0x4, %esi
callq 0x3250
movq %r15, 0x88(%rsp)
testq %r15, %r15
jle 0x4c6bf
movq %rax, %r12
movslq %ebp, %rax
movq %rax, 0x78(%rsp)
movl %eax, %eax
movl %r13d, %ecx
movq %rcx, 0x70(%rsp)
xorps %xmm1, %xmm1
xorl %ecx, %ecx
xorps %xmm0, %xmm0
movl %r13d, 0x58(%rsp)
movq %rax, %r13
movq %rax, 0x60(%rsp)
movq %r12, 0x80(%rsp)
movss %xmm1, 0x5c(%rsp)
movss %xmm0, 0x3c(%rsp)
movq 0x90(%rsp), %rax
movq %rcx, 0x98(%rsp)
movq (%rax,%rcx,8), %r15
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
testl %ebp, %ebp
jle 0x4c25c
xorl %r14d, %r14d
movq 0x68(%rsp), %r12
movq (%r12,%r14,8), %rsi
movq %r15, %rdi
callq 0x34b0
testq %rax, %rax
jne 0x4c257
incq %r14
cmpq %r14, %r13
jne 0x4c23c
jmp 0x4c25c
movl %r14d, 0x1c(%rsp)
movl 0x90(%rbx), %r12d
movl 0x94(%rbx), %r14d
leal 0x20(%r14), %edx
leal 0x20(%r12), %ecx
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x16ac9
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 0x18a89
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 0x18a89
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 0x18a89
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 0x18a89
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 0x18a89
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 0x1786a
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 0x18a89
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 0x18a89
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 0x18a89
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 0x18a89
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 0x18a89
movq 0x50(%rsp), %rax
movq %rax, 0xd0(%r15)
movups 0x40(%rsp), %xmm0
movups %xmm0, 0xc0(%r15)
movl $0x4, %esi
movq 0x78(%rsp), %rdi
callq 0x3250
movq %rax, %r14
xorl %r12d, %r12d
movq 0xb0(%rsp,%r12), %rsi
movq %rbx, %rdi
callq 0x32690
movq %rax, %r15
movq 0xd0(%rbx), %rdx
testq %rdx, %rdx
je 0x4c56d
movl 0x84(%rbx), %esi
movq %r15, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x3eeda
leaq (%rsp,%r12), %r13
addq $0xa0, %r13
movl %ebp, %edi
movss 0x8a86(%rip), %xmm0     # 0x55008
movq %r15, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x29d31
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
addq $0x18, %r12
cmpq $0xf0, %r12
jne 0x4c535
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq %r14, %rdi
movl %ebp, %esi
movl 0x58(%rsp), %r15d
movl %r15d, %edx
movq 0x80(%rsp), %r12
movq %r12, %rcx
callq 0xf0cd
movq %r14, %rdi
callq 0x3040
movss 0x5c(%rsp), %xmm0
movaps %xmm0, %xmm2
addss 0x89fa(%rip), %xmm2     # 0x55008
movl 0x1c(%rsp), %edx
cmpl %edx, (%r12)
je 0x4c61b
movaps %xmm0, %xmm2
testl %r15d, %r15d
movq 0x70(%rsp), %rcx
movq 0x98(%rsp), %rsi
movss 0x3c(%rsp), %xmm0
jle 0x4c65b
xorl %eax, %eax
movaps %xmm0, %xmm3
movq 0x60(%rsp), %r13
addss 0x89c3(%rip), %xmm3     # 0x55008
cmpl %edx, (%r12,%rax,4)
je 0x4c64e
movaps %xmm0, %xmm3
incq %rax
movaps %xmm3, %xmm0
cmpq %rax, %rcx
jne 0x4c63d
jmp 0x4c663
movaps %xmm0, %xmm3
movq 0x60(%rsp), %r13
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 0xe692(%rip), %rdi      # 0x5ad2a
movl %r15d, %edx
movb $0x2, %al
callq 0x3160
movq %r14, %rcx
movss 0x1c(%rsp), %xmm1
movss 0x3c(%rsp), %xmm0
cmpq 0x88(%rsp), %r14
jne 0x4c208
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq