// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: validate_classifier_crop
void validate_classifier_crop(char *datacfg, char *filename, char *weightfile)
{
    int i = 0;
    network *net = load_network(filename, weightfile, 0);
    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);

    clock_t time;
    float avg_acc = 0;
    float avg_topk = 0;
    int splits = m/1000;
    int num = (i+1)*m/splits - i*m/splits;

    data val, buffer;

    load_args args = {0};
    args.w = net->w;
    args.h = net->h;

    args.paths = paths;
    args.classes = classes;
    args.n = num;
    args.m = 0;
    args.labels = labels;
    args.d = &buffer;
    args.type = OLD_CLASSIFICATION_DATA;

    pthread_t load_thread = load_data_in_thread(args);
    for(i = 1; i <= splits; ++i){
        time=clock();

        pthread_join(load_thread, 0);
        val = buffer;

        num = (i+1)*m/splits - i*m/splits;
        char **part = paths+(i*m/splits);
        if(i != splits){
            args.paths = part;
            load_thread = load_data_in_thread(args);
        }
        printf("Loaded: %d images in %lf seconds\n", val.X.rows, sec(clock()-time));

        time=clock();
        float *acc = network_accuracies(net, val, topk);
        avg_acc += acc[0];
        avg_topk += acc[1];
        printf("%d: top 1: %f, top %d: %f, %lf seconds, %d images\n", i, avg_acc/i, topk, avg_topk/i, sec(clock()-time), val.X.rows);
        free_data(val);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x22658
movq %rax, 0xb8(%rsp)
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %rbx, %rdi
callq 0x29598
movq %rax, %r14
leaq 0xf039(%rip), %rsi      # 0x4f9a6
leaq 0x11210(%rip), %rdx     # 0x51b84
movq %rax, %rdi
callq 0x29737
movq %rax, %r15
leaq 0xe5fe(%rip), %rsi      # 0x4ef84
leaq 0x111a3(%rip), %rdx     # 0x51b30
movq %r14, %rdi
callq 0x29737
movq %rax, %r12
leaq 0xf84c(%rip), %rsi      # 0x501eb
pushq $0x2
popq %rdx
movq %r14, %rdi
callq 0x2977d
movl %eax, 0xc0(%rsp)
leaq 0x114d4(%rip), %rsi     # 0x51e8c
pushq $0x1
popq %rbp
movq %r14, %rdi
movl %ebp, %edx
callq 0x2977d
movl %eax, 0xb4(%rsp)
movq %r15, %rdi
callq 0x1e673
movq %rax, 0xa8(%rsp)
movq %r12, %rdi
callq 0x1c8c8
movq %rax, %r12
movq %rax, %rdi
callq 0x72f5
movq %rax, %r14
movl (%r12), %r15d
movq %r12, %rdi
callq 0x72c6
movl $0x3e8, %ecx            # imm = 0x3E8
movl %r15d, %eax
cltd
idivl %ecx
movl %eax, %r13d
movl %r15d, %eax
cltd
idivl %r13d
movl %eax, %r12d
leaq 0x160(%rsp), %rbx
movl $0xa8, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31c0
movq 0xb8(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x28(%rbx)
movq %r14, 0xd0(%rsp)
movq %r14, 0x8(%rbx)
movl 0xc0(%rsp), %eax
movl %eax, 0x50(%rbx)
movl %r12d, 0x18(%rbx)
movq 0xa8(%rsp), %rax
movq %rax, 0x20(%rbx)
leaq 0x120(%rsp), %rax
movq %rax, 0x80(%rbx)
movl $0x9, 0x98(%rbx)
pushq $0x15
popq %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
callq 0x20b03
movq %rax, %rbx
movl %r15d, 0xb0(%rsp)
movl %r15d, %r12d
cmpl %r13d, %ebp
jg 0x40c8a
callq 0x3120
movq %rax, %r15
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3470
movups 0x120(%rsp), %xmm0
movups 0x130(%rsp), %xmm1
movups 0x140(%rsp), %xmm2
movups 0x150(%rsp), %xmm3
movaps %xmm0, 0xe0(%rsp)
movaps %xmm1, 0xf0(%rsp)
movaps %xmm2, 0x100(%rsp)
movaps %xmm3, 0x110(%rsp)
cmpl %ebp, %r13d
je 0x40b3f
movl %r12d, %eax
cltd
idivl %r13d
cltq
movq 0xd0(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x168(%rsp)
pushq $0x15
popq %rcx
movq %rsp, %rdi
leaq 0x160(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x20b03
movq %rax, %rbx
movl 0xe8(%rsp), %r14d
callq 0x3120
subq %r15, %rax
movq %rax, %rdi
callq 0x437c
cvtss2sd %xmm0, %xmm0
leaq 0x11033(%rip), %rdi     # 0x51b95
movl %r14d, %esi
movb $0x1, %al
callq 0x3160
callq 0x3120
movq %rax, %r15
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movaps 0x110(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0xb8(%rsp), %rdi
movl 0xb4(%rsp), %r14d
movl %r14d, %esi
callq 0x23f37
movsd (%rax), %xmm0
movaps 0xc0(%rsp), %xmm2
addps %xmm0, %xmm2
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
cvtsi2ss %ebp, %xmm1
movaps %xmm2, 0xc0(%rsp)
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0xa8(%rsp)
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xd8(%rsp)
callq 0x3120
subq %r15, %rax
movq %rax, %rdi
callq 0x437c
cvtss2sd %xmm0, %xmm2
movl 0xe8(%rsp), %ecx
leaq 0x10f92(%rip), %rdi     # 0x51bb7
movl %ebp, %esi
movsd 0xa8(%rsp), %xmm0
movl %r14d, %edx
movsd 0xd8(%rsp), %xmm1
movb $0x3, %al
callq 0x3160
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movaps 0x110(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1e69d
addl 0xb0(%rsp), %r12d
incl %ebp
jmp 0x40aa9
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq