// File: /workspace/github_c_makefile_star2_O3/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 $0x228, %rsp            # imm = 0x228
movq %rdi, %rbx
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x316bc
movq %rax, 0xc0(%rsp)
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %rbx, %rdi
callq 0x36cb4
movq %rax, %rbx
leaq 0xccf7(%rip), %rsi      # 0x58a56
leaq 0xef5e(%rip), %rdx      # 0x5acc4
movq %rax, %rdi
callq 0x36e77
movq %rax, %r15
leaq 0xc2ec(%rip), %rsi      # 0x58064
leaq 0xeef1(%rip), %rdx      # 0x5ac70
movq %rbx, %rdi
callq 0x36e77
movq %rax, %r13
leaq 0xd50a(%rip), %rsi      # 0x5929b
movq %rbx, %rdi
movl $0x2, %edx
callq 0x36eed
movl %eax, 0xd0(%rsp)
leaq 0xf220(%rip), %rsi      # 0x5afcc
movl $0x1, %r12d
movq %rbx, %rdi
movl $0x1, %edx
callq 0x36eed
movl %eax, 0xac(%rsp)
movq %r15, %rdi
callq 0x2d26c
movq %rax, %rbx
movq %r13, %rdi
callq 0x2af38
movq %rax, %r13
movq %rax, %rdi
callq 0x11928
movq %rax, %r15
movslq (%r13), %rbp
movq %r13, %rdi
callq 0x118de
imulq $0x10624dd3, %rbp, %rcx # imm = 0x10624DD3
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x26, %rcx
addl %eax, %ecx
movl %ebp, %eax
cltd
movq %rcx, 0xb0(%rsp)
idivl %ecx
movl %eax, %r13d
leaq 0x180(%rsp), %r14
movl $0xa8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x31c0
movq 0xc0(%rsp), %rax
movq 0x90(%rax), %rax
movq %rax, 0x28(%r14)
movq %r15, 0xe8(%rsp)
movq %r15, 0x8(%r14)
movl 0xd0(%rsp), %eax
movl %eax, 0x50(%r14)
movl %r13d, 0x18(%r14)
movq %rbx, 0x20(%r14)
leaq 0x140(%rsp), %rax
movq %rax, 0x80(%r14)
movl $0x9, 0x98(%r14)
movl $0x15, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x2f8eb
movq %rax, 0xc8(%rsp)
movq %rbp, 0xb8(%rsp)
cmpq $0x3e8, %rbp            # imm = 0x3E8
jl 0x4c0ca
movq 0xb0(%rsp), %rbp
negl %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movq 0xb8(%rsp), %rax
movl %eax, %r14d
callq 0x3120
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
xorl %esi, %esi
callq 0x3470
movups 0x140(%rsp), %xmm0
movups 0x150(%rsp), %xmm1
movups 0x160(%rsp), %xmm2
movups 0x170(%rsp), %xmm3
movaps %xmm0, 0x100(%rsp)
movaps %xmm1, 0x110(%rsp)
movaps %xmm2, 0x120(%rsp)
movaps %xmm3, 0x130(%rsp)
movl %ebp, %eax
addl %r12d, %eax
je 0x4bf68
movl %r14d, %eax
xorl %edx, %edx
divl 0xb0(%rsp)
movq 0xe8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x188(%rsp)
movl $0x15, %ecx
movq %rsp, %rdi
leaq 0x180(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x2f8eb
movq %rax, 0xc8(%rsp)
leal 0x1(%r12), %r13d
movl 0x108(%rsp), %r15d
callq 0x3120
subq %rbx, %rax
movq %rax, %rdi
callq 0xf0bf
cvtss2sd %xmm0, %xmm0
leaq 0xed45(%rip), %rdi      # 0x5acd5
movl %r15d, %esi
movb $0x1, %al
callq 0x3160
callq 0x3120
movq %rax, %rbx
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movaps 0x120(%rsp), %xmm2
movaps 0x130(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq 0xc0(%rsp), %rdi
movl 0xac(%rsp), %r15d
movl %r15d, %esi
callq 0x33345
movsd (%rax), %xmm0
movaps 0xd0(%rsp), %xmm2
addps %xmm0, %xmm2
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
xorps %xmm1, %xmm1
cvtsi2ss %r12d, %xmm1
movaps %xmm2, 0xd0(%rsp)
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm2
movsd %xmm2, 0xf8(%rsp)
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0xf0(%rsp)
callq 0x3120
subq %rbx, %rax
movq %rax, %rdi
callq 0xf0bf
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
movl 0x108(%rsp), %ecx
leaq 0xec9d(%rip), %rdi      # 0x5acf7
movl %r12d, %esi
movsd 0xf8(%rsp), %xmm0
movl %r15d, %edx
movsd 0xf0(%rsp), %xmm1
movb $0x3, %al
callq 0x3160
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movaps 0x120(%rsp), %xmm2
movaps 0x130(%rsp), %xmm3
movups %xmm3, 0x30(%rsp)
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x2d296
leal (%rbp,%r13), %eax
addl 0xb8(%rsp), %r14d
movl %r13d, %r12d
cmpl $0x1, %eax
jne 0x4beca
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq