// File: /workspace/github_c_makefile_star2_O2/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 0x22658
movq %rax, %rbx
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x3220
movq %r14, %rdi
callq 0x29598
movq %rax, %r14
leaq 0xfa0a(%rip), %rsi      # 0x52115
leaq 0xf521(%rip), %rdx      # 0x51c33
movq %rax, %rdi
callq 0x29737
movq %rax, %r15
leaq 0xdac7(%rip), %rsi      # 0x501eb
pushq $0x2
popq %rdx
movq %r14, %rdi
callq 0x2977d
movl %eax, %ebp
movq %r15, %rdi
callq 0x1c8c8
movq %rax, %r15
movq %rax, %rdi
callq 0x72f5
movq %rax, %r14
movl (%r15), %r12d
movq %r15, %rdi
callq 0x72c6
leaq 0x160(%rsp), %r15
movl $0xa8, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x31c0
movq 0x90(%rbx), %rax
movq %rax, 0x28(%r15)
movq %r14, 0xc0(%rsp)
movq %r14, 0x8(%r15)
movl %ebp, 0x50(%r15)
movl 0x4(%rbx), %eax
movl %eax, 0x18(%r15)
andq $0x0, 0x20(%r15)
leaq 0x120(%rsp), %rax
movq %rax, 0x80(%r15)
movl $0x9, 0x98(%r15)
pushq $0x15
popq %rcx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x20b03
movq %rax, %rbp
movq %rbx, 0xa8(%rsp)
movl 0x4(%rbx), %r13d
movq 0x21827(%rip), %r14     # 0x63ff8
leaq 0xf490(%rip), %r15      # 0x51c68
movl %r12d, 0xbc(%rsp)
movl %r12d, %ebx
subl %r13d, %ebx
jle 0x42a5c
callq 0x3120
movq %rax, 0xb0(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3470
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 %r13d, %rax
movq 0xc0(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rax, 0x168(%rsp)
movq 0xa8(%rsp), %rax
movl 0x4(%rax), %eax
addl %r13d, %eax
cmpl %r12d, %eax
jle 0x42874
movl %ebx, 0x178(%rsp)
pushq $0x15
popq %rcx
movq %rsp, %rdi
leaq 0x160(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x20b03
movq %rax, 0xd8(%rsp)
movq (%r14), %rbp
movl 0xe8(%rsp), %ebx
callq 0x3120
subq 0xb0(%rsp), %rax
movq %rax, %rdi
callq 0x437c
cvtss2sd %xmm0, %xmm0
movq %rbp, %rdi
leaq 0xf2d6(%rip), %rsi      # 0x51b95
movl %ebx, %edx
movb $0x1, %al
callq 0x3270
callq 0x3120
movq %rax, 0xd0(%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 0xa8(%rsp), %rdi
callq 0x23a7d
movq %rax, %rcx
movq %rdx, %rbp
movq %rax, %r12
shrq $0x20, %r12
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
testl %ecx, %ecx
movl $0x0, %eax
movq %rcx, 0xc8(%rsp)
cmovgl %ecx, %eax
movq %rax, 0xb0(%rsp)
xorl %r14d, %r14d
cmpq 0xb0(%rsp), %r14
je 0x429b5
movq %r13, %rbx
leal (%r14,%r13), %eax
movq 0xa8(%rsp), %rcx
subl 0x4(%rcx), %eax
cltq
movq 0xc0(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0xd04f(%rip), %rdi      # 0x4f9cb
xorl %eax, %eax
callq 0x3160
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x429a5
movq (%rbp,%r14,8), %rax
cvtss2sd (%rax,%r13,4), %xmm0
movq %r15, %rdi
movb $0x1, %al
callq 0x3160
incq %r13
jmp 0x42986
pushq $0xa
popq %rdi
callq 0x3060
incq %r14
movq %rbx, %r13
jmp 0x4294b
movq 0xc8(%rsp), %rdi
movq %rbp, %rsi
callq 0x21edc
movq 0x2162c(%rip), %r14     # 0x63ff8
movq (%r14), %rbp
callq 0x3120
subq 0xd0(%rsp), %rax
movq %rax, %rdi
callq 0x437c
cvtss2sd %xmm0, %xmm0
movl 0xe8(%rsp), %edx
movq %rbp, %rdi
leaq 0xf24d(%rip), %rsi      # 0x51c46
movl %r13d, %ecx
movb $0x1, %al
callq 0x3270
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
movq 0xa8(%rsp), %rax
addl 0x4(%rax), %r13d
movl 0xbc(%rsp), %r12d
movq 0xd8(%rsp), %rbp
jmp 0x427e0
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq