// File: /workspace/github_c_makefile_star2_O3/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 0x36cb4
leaq 0x93c4(%rip), %rsi      # 0x597e9
leaq 0xae80(%rip), %rdx      # 0x5b2ac
movq %rax, %rdi
callq 0x36e77
movq %rax, %rdi
callq 0x2d26c
movq %rax, 0x48(%rsp)
xorl %eax, %eax
callq 0x16a0a
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x316bc
movq %rax, %r12
movq %rax, %rdi
movl $0x1, %esi
callq 0x320a7
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x3220
testq %r14, %r14
leaq 0xaccd(%rip), %r13      # 0x5b14b
cmovneq %r14, %r13
leaq 0x70(%rsp), %rbp
testq %rbx, %rbx
je 0x5049e
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3080
jmp 0x504ed
leaq 0x9c9d(%rip), %rdi      # 0x5a142
xorl %eax, %eax
callq 0x3160
movq 0x1bb1d(%rip), %rax     # 0x6bfd0
movq (%rax), %rdi
callq 0x3310
movq 0x1bb16(%rip), %rax     # 0x6bfd8
movq (%rax), %rdx
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x3230
testq %rax, %rax
je 0x5065d
movq %rax, %rbp
movq %rax, %rdi
leaq 0xa179(%rip), %rsi      # 0x5a661
callq 0x33b0
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16ac9
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 0x19916
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 0xe79c
movsd %xmm0, 0x50(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x32690
xorl %eax, %eax
callq 0xe79c
subsd 0x50(%rsp), %xmm0
leaq 0x9ba6(%rip), %rdi      # 0x5a11c
movq %rbp, %rsi
movb $0x1, %al
callq 0x3160
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 0x32a67
movq %rax, %r15
movl 0x1c(%rsp), %esi
movq %rax, %rdi
movl %r14d, %edx
movss 0xac9a(%rip), %xmm0     # 0x5b260
callq 0x38a2a
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 0x16add
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0x32ac9
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
callq 0x18301
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x28(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x1657b
testq %rbx, %rbx
je 0x50487
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq