// File: /workspace/github_c_makefile_star2_O1/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 0x34b9c
leaq 0x9544(%rip), %rsi      # 0x576e9
leaq 0xafa8(%rip), %rdx      # 0x59154
movq %rax, %rdi
callq 0x34d5b
movq %rax, %rdi
callq 0x2b6d3
movq %rax, 0x48(%rsp)
xorl %eax, %eax
callq 0x15ff7
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2f9e4
movq %rax, %r12
movq %rax, %rdi
movl $0x1, %esi
callq 0x302d4
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x3230
testq %r14, %r14
leaq 0xadf5(%rip), %r13      # 0x58ff3
cmovneq %r14, %r13
leaq 0x70(%rsp), %rbp
testq %rbx, %rbx
je 0x4e21e
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3080
jmp 0x4e26d
leaq 0x9de5(%rip), %rdi      # 0x5800a
xorl %eax, %eax
callq 0x3170
movq 0x1bd9d(%rip), %rax     # 0x69fd0
movq (%rax), %rdi
callq 0x3320
movq 0x1bd96(%rip), %rax     # 0x69fd8
movq (%rax), %rdx
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x3240
testq %rax, %rax
je 0x4e3dd
movq %rax, %rbp
movq %rax, %rdi
leaq 0xa2a1(%rip), %rsi      # 0x58509
callq 0x33c0
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x160b6
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 0x1905c
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 0xdfdc
movsd %xmm0, 0x50(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x307ea
xorl %eax, %eax
callq 0xdfdc
subsd 0x50(%rsp), %xmm0
leaq 0x9cee(%rip), %rdi      # 0x57fe4
movq %rbp, %rsi
movb $0x1, %al
callq 0x3170
movl $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
movl $0x1, %r8d
leaq 0x1c(%rsp), %r9
callq 0x30bbb
movq %rax, %r15
movl 0x1c(%rsp), %esi
movq %rax, %rdi
movl %r14d, %edx
movss 0xadc2(%rip), %xmm0     # 0x59108
callq 0x36827
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 0x160ca
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x30c1d
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
callq 0x17a72
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x15b37
testq %rbx, %rbx
je 0x4e207
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq