// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/detector.c
// Function: test_detector
void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh, char *outfile, int fullscreen)
{
    list *options = read_data_cfg(datacfg);
    char *name_list = option_find_str(options, "names", "data/names.list");
    char **names = get_labels(name_list);

    image **alphabet = load_alphabet();
    network *net = load_network(cfgfile, weightfile, 0);
    set_batch_network(net, 1);
    srand(2222222);
    double time;
    char buff[256];
    char *input = buff;
    float nms=.45;
    while(1){
        if(filename){
            strncpy(input, filename, 256);
        } else {
            printf("Enter Image Path: ");
            fflush(stdout);
            input = fgets(input, 256, stdin);
            if(!input) return;
            strtok(input, "\n");
        }
        image im = load_image_color(input,0,0);
        image sized = letterbox_image(im, net->w, net->h);
        //image sized = resize_image(im, net->w, net->h);
        //image sized2 = resize_max(im, net->w);
        //image sized = crop_image(sized2, -((net->w - sized2.w)/2), -((net->h - sized2.h)/2), net->w, net->h);
        //resize_network(net, sized.w, sized.h);
        layer l = net->layers[net->n-1];


        float *X = sized.data;
        time=what_time_is_it_now();
        network_predict(net, X);
        printf("%s: Predicted in %f seconds.\n", input, what_time_is_it_now()-time);
        int nboxes = 0;
        detection *dets = get_network_boxes(net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes);
        //printf("%d\n", nboxes);
        //if (nms) do_nms_obj(boxes, probs, l.w*l.h*l.n, l.classes, nms);
        if (nms) do_nms_sort(dets, nboxes, l.classes, nms);
        draw_detections(im, dets, nboxes, thresh, names, alphabet, l.classes);
        free_detections(dets, nboxes);
        if(outfile){
            save_image(im, outfile);
        }
        else{
            save_image(im, "predictions");
        }

        free_image(im);
        free_image(sized);
        if (filename) break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %r8, %r14
movss %xmm1, 0x24(%rsp)
movss %xmm0, 0x20(%rsp)
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
callq 0x29598
leaq 0x8e19(%rip), %rsi      # 0x50739
leaq 0xa845(%rip), %rdx      # 0x5216c
movq %rax, %rdi
callq 0x29737
movq %rax, %rdi
callq 0x1e673
movq %rax, 0x48(%rsp)
xorl %eax, %eax
callq 0xbe7c
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x22658
movq %rax, %r12
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x22f00
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x3220
testq %r14, %r14
leaq 0xa694(%rip), %r13      # 0x5200b
cmovneq %r14, %r13
leaq 0x70(%rsp), %rbp
testq %rbx, %rbx
je 0x47997
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3080
jmp 0x479e6
leaq 0x96a4(%rip), %rdi      # 0x51042
xorl %eax, %eax
callq 0x3160
movq 0x1c624(%rip), %rax     # 0x63fd0
movq (%rax), %rdi
callq 0x3310
movq 0x1c61d(%rip), %rax     # 0x63fd8
movq (%rax), %rdx
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x3230
testq %rax, %rax
je 0x47b51
movq %rax, %rbp
movq %rax, %rdi
leaq 0x9b38(%rip), %rsi      # 0x51519
callq 0x33b0
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
movl 0x90(%r12), %edx
movl 0x94(%r12), %esi
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movupd 0x28(%rsp), %xmm0
movupd %xmm0, (%rsp)
leaq 0x58(%rsp), %rdi
callq 0xe7d0
movq 0x20(%r12), %rax
movslq (%r12), %rcx
imulq $0x4a0, %rcx, %rcx      # imm = 0x4A0
movl -0x3a4(%rax,%rcx), %r14d
movq 0x68(%rsp), %r15
xorl %eax, %eax
callq 0x3bc0
movsd %xmm0, 0x50(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x233e2
xorl %eax, %eax
callq 0x3bc0
subsd 0x50(%rsp), %xmm0
leaq 0x95ad(%rip), %rdi      # 0x5101c
movq %rbp, %rsi
movb $0x1, %al
callq 0x3160
andl $0x0, 0x1c(%rsp)
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movq %r12, %rdi
movss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm1
xorl %ecx, %ecx
pushq $0x1
popq %r8
leaq 0x1c(%rsp), %r9
callq 0x2379c
movq %rax, %r15
movl 0x1c(%rsp), %esi
movq %rax, %rdi
movl %r14d, %edx
movss 0xa666(%rip), %xmm0     # 0x52120
callq 0x2b219
movl 0x1c(%rsp), %esi
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movss 0x20(%rsp), %xmm0
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rcx
movl %r14d, %r8d
callq 0xbf48
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x237fe
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
callq 0xd514
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
testq %rbx, %rbx
je 0x47980
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq