// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: validate_classifier_multi
void validate_classifier_multi(char *datacfg, char *cfg, char *weights)
{
    int i, j;
    network *net = load_network(cfg, weights, 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);
    //int scales[] = {224, 288, 320, 352, 384};
    int scales[] = {224, 256, 288, 320};
    int nscales = sizeof(scales)/sizeof(scales[0]);

    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;
            }
        }
        float *pred = calloc(classes, sizeof(float));
        image im = load_image_color(paths[i], 0, 0);
        for(j = 0; j < nscales; ++j){
            image r = resize_max(im, scales[j]);
            resize_network(net, r.w, r.h);
            float *p = network_predict(net, r.data);
            if(net->hierarchy) hierarchy_predictions(p, net->outputs, net->hierarchy, 1 , 1);
            axpy_cpu(classes, 1, p, 1, pred, 1);
            flip_image(r);
            p = network_predict(net, r.data);
            axpy_cpu(classes, 1, p, 1, pred, 1);
            if(r.data != im.data) free_image(r);
        }
        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 $0x98, %rsp
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 0xbee4(%rip), %rsi      # 0x56956
leaq 0xe0da(%rip), %rdx      # 0x58b53
movq %rax, %rdi
callq 0x34d5b
movq %rax, %r15
leaq 0xb501(%rip), %rsi      # 0x55f8c
leaq 0xe08e(%rip), %rdx      # 0x58b20
movq %r14, %rdi
callq 0x34d5b
movq %rax, %r12
leaq 0xc6f7(%rip), %rsi      # 0x5719b
movq %r14, %rdi
movl $0x2, %edx
callq 0x34d9f
movl %eax, %ebp
leaq 0xe3ba(%rip), %rsi      # 0x58e74
movq %r14, %rdi
movl $0x1, %edx
callq 0x34d9f
movl %eax, %r13d
movq %r15, %rdi
callq 0x2b6d3
movq %rax, 0x50(%rsp)
movq %r12, %rdi
callq 0x296f8
movq %rax, %r14
movq %rax, %rdi
callq 0x10fa0
movq %rax, 0x48(%rsp)
movslq (%r14), %r15
movq %r14, %rdi
callq 0x10f56
movslq %r13d, %rdi
movl $0x4, %esi
callq 0x3260
movq %rax, 0x68(%rsp)
movq %r15, 0x70(%rsp)
testq %r15, %r15
jle 0x4adbd
movslq %ebp, %rax
movq %rax, 0x60(%rsp)
movl %eax, %eax
movq %rax, 0x78(%rsp)
movl %r13d, %eax
movq %rax, 0x58(%rsp)
xorps %xmm1, %xmm1
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movl %r13d, 0x2c(%rsp)
movss %xmm1, 0x18(%rsp)
movss %xmm0, 0x1c(%rsp)
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %ebp, %ebp
movq %r15, 0x20(%rsp)
jle 0x4ab91
movq 0x48(%rsp), %rax
movq (%rax,%r15,8), %r14
xorl %r15d, %r15d
movq 0x50(%rsp), %r13
movq (%r13,%r15,8), %rsi
movq %r14, %rdi
callq 0x34c0
testq %rax, %rax
jne 0x4ab89
incq %r15
cmpq %r15, 0x78(%rsp)
jne 0x4ab6b
jmp 0x4ab8c
movl %r15d, %r12d
movq 0x20(%rsp), %r15
movl $0x4, %esi
movq 0x60(%rsp), %rdi
callq 0x3260
movq %rax, %r14
movq 0x48(%rsp), %rax
movq (%rax,%r15,8), %rsi
leaq 0x80(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x160b6
xorl %r13d, %r13d
leaq 0xe0d9(%rip), %rax      # 0x58ca0
movl (%r13,%rax), %esi
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x30(%rsp), %rdi
callq 0x19196
movl 0x30(%rsp), %esi
movl 0x34(%rsp), %edx
movq %rbx, %rdi
callq 0x302fd
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x307ea
movq %rax, %r15
movq 0xd0(%rbx), %rdx
testq %rdx, %rdx
je 0x4ac34
movl 0x84(%rbx), %esi
movq %r15, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x3cc56
movl %ebp, %edi
movss 0x83ca(%rip), %xmm0     # 0x53008
movq %r15, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x285e9
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x16f91
movq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x307ea
movl %ebp, %edi
movss 0x8385(%rip), %xmm0     # 0x53008
movq %rax, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x285e9
movq 0x40(%rsp), %rax
cmpq 0x90(%rsp), %rax
je 0x4acc0
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
addq $0x4, %r13
cmpq $0x10, %r13
jne 0x4abc0
movq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x80(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq %r14, %rdi
movl %ebp, %esi
movl 0x2c(%rsp), %r15d
movl %r15d, %edx
movq 0x68(%rsp), %r13
movq %r13, %rcx
callq 0xe8e2
movq %r14, %rdi
callq 0x3040
movss 0x18(%rsp), %xmm0
movaps %xmm0, %xmm2
addss 0x82e9(%rip), %xmm2     # 0x53008
cmpl %r12d, (%r13)
je 0x4ad28
movaps %xmm0, %xmm2
testl %r15d, %r15d
movq 0x58(%rsp), %rcx
movss 0x1c(%rsp), %xmm0
jle 0x4ad5c
xorl %eax, %eax
movaps %xmm0, %xmm3
addss 0x82c3(%rip), %xmm3     # 0x53008
cmpl %r12d, (%r13,%rax,4)
je 0x4ad4f
movaps %xmm0, %xmm3
incq %rax
movaps %xmm3, %xmm0
cmpq %rax, %rcx
jne 0x4ad3d
jmp 0x4ad5f
movaps %xmm0, %xmm3
movss %xmm3, 0x18(%rsp)
movq 0x20(%rsp), %rsi
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 0xde20(%rip), %rdi      # 0x58bb9
movl %r15d, %edx
movb $0x2, %al
callq 0x3170
movq %r14, %r15
movss 0x1c(%rsp), %xmm1
movss 0x18(%rsp), %xmm0
cmpq 0x70(%rsp), %r14
jne 0x4ab3f
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq