// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/classifier.c
// Function: test_classifier
void test_classifier(char *datacfg, char *cfgfile, char *weightfile, int target_layer)
{
    int curr = 0;
    network *net = load_network(cfgfile, weightfile, 0);
    srand(time(0));

    list *options = read_data_cfg(datacfg);

    char *test_list = option_find_str(options, "test", "data/test.list");
    int classes = option_find_int(options, "classes", 2);

    list *plist = get_paths(test_list);

    char **paths = (char **)list_to_array(plist);
    int m = plist->size;
    free_list(plist);

    clock_t time;

    data val, buffer;

    load_args args = {0};
    args.w = net->w;
    args.h = net->h;
    args.paths = paths;
    args.classes = classes;
    args.n = net->batch;
    args.m = 0;
    args.labels = 0;
    args.d = &buffer;
    args.type = OLD_CLASSIFICATION_DATA;

    pthread_t load_thread = load_data_in_thread(args);
    for(curr = net->batch; curr < m; curr += net->batch){
        time=clock();

        pthread_join(load_thread, 0);
        val = buffer;

        if(curr < m){
            args.paths = paths + curr;
            if (curr + net->batch > m) args.n = m - curr;
            load_thread = load_data_in_thread(args);
        }
        fprintf(stderr, "Loaded: %d images in %lf seconds\n", val.X.rows, sec(clock()-time));

        time=clock();
        matrix pred = network_predict_data(net, val);

        int i, j;
        if (target_layer >= 0){
            //layer l = net->layers[target_layer];
        }

        for(i = 0; i < pred.rows; ++i){
            printf("%s", paths[curr-net->batch+i]);
            for(j = 0; j < pred.cols; ++j){
                printf("\t%g", pred.vals[i][j]);
            }
            printf("\n");
        }

        free_matrix(pred);

        fprintf(stderr, "%lf seconds, %d images, %d total\n", sec(clock()-time), val.X.rows, curr);
        free_data(val);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %r14
movq %rsi, %rdi
movq %rdx, %rsi
xorl %edx, %edx
callq 0x2f9e4
movq %rax, %rbx
xorl %edi, %edi
callq 0x32d0
movl %eax, %edi
callq 0x3230
movq %r14, %rdi
callq 0x34b9c
movq %rax, %r14
leaq 0xd858(%rip), %rsi      # 0x590fd
leaq 0xd356(%rip), %rdx      # 0x58c02
movq %rax, %rdi
callq 0x34d5b
movq %rax, %r15
leaq 0xb8dd(%rip), %rsi      # 0x5719b
movq %r14, %rdi
movl $0x2, %edx
callq 0x34d9f
movl %eax, %ebp
movq %r15, %rdi
callq 0x296f8
movq %rax, %r15
movq %rax, %rdi
callq 0x10fa0
movq %rax, %r14
movl (%r15), %r13d
movq %r15, %rdi
callq 0x10f56
leaq 0x160(%rsp), %r15
movl $0xa8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x31d0
movl 0x94(%rbx), %eax
movl %eax, 0x2c(%r15)
movl 0x90(%rbx), %eax
movl %eax, 0x28(%r15)
movq %r14, 0xc0(%rsp)
movq %r14, 0x8(%r15)
movl %ebp, 0x50(%r15)
movl 0x4(%rbx), %eax
movl %eax, 0x18(%r15)
movl $0x0, 0x1c(%r15)
movq $0x0, 0x20(%r15)
leaq 0x120(%rsp), %rax
movq %rax, 0x80(%r15)
movl $0x9, 0x98(%r15)
movl $0x15, %ecx
movq %rsp, %rdi
movq %r15, %rsi
movq %rbx, %r15
rep  movsq (%rsi), %es:(%rdi)
callq 0x2dc84
movl 0x4(%rbx), %ebx
cmpl %r13d, %ebx
jge 0x4bc02
movq %rax, %rbp
movq 0x1e672(%rip), %r14     # 0x69ff8
leaq 0xd2aa(%rip), %r12      # 0x58c37
movl %r13d, 0xb4(%rsp)
callq 0x3130
movq %rax, 0xa8(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3480
movups 0x120(%rsp), %xmm0
movups 0x130(%rsp), %xmm1
movups 0x140(%rsp), %xmm2
movups 0x150(%rsp), %xmm3
movaps %xmm3, 0x110(%rsp)
movaps %xmm2, 0x100(%rsp)
movaps %xmm1, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movslq %ebx, %rax
movq 0xc0(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, 0x168(%rsp)
addl 0x4(%r15), %eax
cmpl %r13d, %eax
jle 0x4ba18
movl %r13d, %eax
subl %ebx, %eax
movl %eax, 0x178(%rsp)
movl $0x15, %ecx
movq %rsp, %rdi
leaq 0x160(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x2dc84
movq %rax, 0xd0(%rsp)
movq (%r14), %r13
movl 0xe8(%rsp), %ebp
callq 0x3130
subq 0xa8(%rsp), %rax
movq %rax, %rdi
callq 0xe8d4
cvtss2sd %xmm0, %xmm0
movq %r13, %rdi
leaq 0xd0ff(%rip), %rsi      # 0x58b64
movl %ebp, %edx
movb $0x1, %al
callq 0x3280
callq 0x3130
movq %rax, 0xc8(%rsp)
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 %r15, %rdi
callq 0x30f61
movq %rdx, %r13
movq %rax, 0xb8(%rsp)
testl %eax, %eax
jle 0x4bb60
movq 0xb8(%rsp), %rax
movq %rax, %rbp
shrq $0x20, %rbp
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0xa8(%rsp)
xorl %r14d, %r14d
movq %rbx, 0xd8(%rsp)
leal (%rbx,%r14), %eax
movq %r15, %rbx
subl 0x4(%r15), %eax
cltq
movq 0xc0(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xae6b(%rip), %rdi      # 0x5697b
xorl %eax, %eax
callq 0x3170
testl %ebp, %ebp
jle 0x4bb3e
xorl %r15d, %r15d
movq (%r13,%r14,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%r15,4), %xmm0
movq %r12, %rdi
movb $0x1, %al
callq 0x3170
incq %r15
cmpq %r15, %rbp
jne 0x4bb1e
movl $0xa, %edi
callq 0x3060
incq %r14
cmpq 0xa8(%rsp), %r14
movq %rbx, %r15
movq 0xd8(%rsp), %rbx
jne 0x4baf0
movq 0xb8(%rsp), %rdi
movq %r13, %rsi
callq 0x2f214
movq 0x1e481(%rip), %r14     # 0x69ff8
movq (%r14), %r13
callq 0x3130
subq 0xc8(%rsp), %rax
movq %rax, %rdi
callq 0xe8d4
cvtss2sd %xmm0, %xmm0
movl 0xe8(%rsp), %edx
movq %r13, %rdi
leaq 0xd071(%rip), %rsi      # 0x58c15
movl %ebx, %ecx
movb $0x1, %al
callq 0x3280
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 0x2b6fd
addl 0x4(%r15), %ebx
movl 0xb4(%rsp), %r13d
cmpl %r13d, %ebx
movq 0xd0(%rsp), %rbp
jl 0x4b995
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq