// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x3a9b0
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movq -0x8(%rbp), %rdi
callq 0x426b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x10c66(%rip), %rsi     # 0x74346
leaq 0x12d09(%rip), %rdx     # 0x763f0
callq 0x42920
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x10278(%rip), %rsi     # 0x73973
leaq 0x12cb6(%rip), %rdx     # 0x763b8
callq 0x42920
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x11341(%rip), %rsi     # 0x74a57
movl $0x2, %edx
callq 0x42990
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x12fe2(%rip), %rsi     # 0x76710
movl $0x1, %edx
callq 0x42990
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x343c0
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rdi
callq 0x31450
movq %rax, -0x58(%rbp)
movq 0x12dd4(%rip), %rax     # 0x76530
movq %rax, -0x70(%rbp)
movq 0x12dd1(%rip), %rax     # 0x76538
movq %rax, -0x68(%rbp)
movl $0x4, -0x74(%rbp)
movq -0x58(%rbp), %rdi
callq 0x9020
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x58(%rbp), %rdi
callq 0x8fb0
xorps %xmm0, %xmm0
movss %xmm0, -0x88(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x8c(%rbp)
movslq -0x48(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x98(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x84(%rbp), %eax
jge 0x63af5
movl $0xffffffff, -0x9c(%rbp) # imm = 0xFFFFFFFF
movq -0x80(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa8(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x63837
movq -0xa8(%rbp), %rdi
movq -0x50(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3480
cmpq $0x0, %rax
je 0x6382a
movl -0x20(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x63837
jmp 0x6382c
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x637f9
movslq -0x44(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0xb0(%rbp)
movq -0x80(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0xc8(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xf510
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x639e2
movslq -0x20(%rbp), %rax
movl -0x70(%rbp,%rax,4), %esi
leaq -0xe0(%rbp), %rdi
leaq -0xc8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x12de0
movq -0x28(%rbp), %rdi
movl -0xe0(%rbp), %esi
movl -0xdc(%rbp), %edx
callq 0x3aa00
movq -0x28(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x3b160
movq %rax, -0xe8(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x63913
movq -0xe8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x84(%rax), %esi
movq -0x28(%rbp), %rax
movq 0xd0(%rax), %rdx
movl $0x1, %r8d
movl %r8d, %ecx
callq 0x4efb0
movl -0x44(%rbp), %edi
movq -0xe8(%rbp), %rsi
movq -0xb0(%rbp), %rcx
movss 0xd6e0(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
leaq -0xe0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x104c0
movq -0x28(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x3b160
movq %rax, -0xe8(%rbp)
movl -0x44(%rbp), %edi
movq -0xe8(%rbp), %rsi
movq -0xb0(%rbp), %rcx
movss 0xd67d(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
movq -0xd0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
je 0x639d2
leaq -0xe0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
jmp 0x639d4
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6386f
leaq -0xc8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
movq -0xb0(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movq -0x98(%rbp), %rcx
callq 0x4b70
movq -0xb0(%rbp), %rdi
callq 0x3030
movq -0x98(%rbp), %rax
movl (%rax), %eax
cmpl -0x9c(%rbp), %eax
jne 0x63a55
movss 0xd5c7(%rip), %xmm0     # 0x7100c
addss -0x88(%rbp), %xmm0
movss %xmm0, -0x88(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x63a9f
movq -0x98(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x9c(%rbp), %eax
jne 0x63a92
movss 0xd58a(%rip), %xmm0     # 0x7100c
addss -0x8c(%rbp), %xmm0
movss %xmm0, -0x8c(%rbp)
jmp 0x63a94
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x63a5c
movl -0x1c(%rbp), %esi
movss -0x88(%rbp), %xmm0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x48(%rbp), %edx
movss -0x8c(%rbp), %xmm1
movl -0x1c(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x12980(%rip), %rdi     # 0x76460
movb $0x2, %al
callq 0x3130
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x637c6
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop