// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/detector.c
// Function: validate_detector_recall
void validate_detector_recall(char *cfgfile, char *weightfile)
{
    network *net = load_network(cfgfile, weightfile, 0);
    set_batch_network(net, 1);
    fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
    srand(time(0));

    list *plist = get_paths("data/coco_val_5k.list");
    char **paths = (char **)list_to_array(plist);

    layer l = net->layers[net->n-1];

    int j, k;

    int m = plist->size;
    int i=0;

    float thresh = .001;
    float iou_thresh = .5;
    float nms = .4;

    int total = 0;
    int correct = 0;
    int proposals = 0;
    float avg_iou = 0;

    for(i = 0; i < m; ++i){
        char *path = paths[i];
        image orig = load_image_color(path, 0, 0);
        image sized = resize_image(orig, net->w, net->h);
        char *id = basecfg(path);
        network_predict(net, sized.data);
        int nboxes = 0;
        detection *dets = get_network_boxes(net, sized.w, sized.h, thresh, .5, 0, 1, &nboxes);
        if (nms) do_nms_obj(dets, nboxes, 1, nms);

        char labelpath[4096];
        find_replace(path, "images", "labels", labelpath);
        find_replace(labelpath, "JPEGImages", "labels", labelpath);
        find_replace(labelpath, ".jpg", ".txt", labelpath);
        find_replace(labelpath, ".JPEG", ".txt", labelpath);

        int num_labels = 0;
        box_label *truth = read_boxes(labelpath, &num_labels);
        for(k = 0; k < nboxes; ++k){
            if(dets[k].objectness > thresh){
                ++proposals;
            }
        }
        for (j = 0; j < num_labels; ++j) {
            ++total;
            box t = {truth[j].x, truth[j].y, truth[j].w, truth[j].h};
            float best_iou = 0;
            for(k = 0; k < l.w*l.h*l.n; ++k){
                float iou = box_iou(dets[k].bbox, t);
                if(dets[k].objectness > thresh && iou > best_iou){
                    best_iou = iou;
                }
            }
            avg_iou += best_iou;
            if(best_iou > iou_thresh){
                ++correct;
            }
        }

        fprintf(stderr, "%5d %5d %5d\tRPs/Img: %.2f\tIOU: %.2f%%\tRecall:%.2f%%\n", i, correct, total, (float)proposals/(i+1), avg_iou*100/total, 100.*correct/total);
        free(id);
        free_image(orig);
        free_image(sized);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1590, %rsp           # imm = 0x1590
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x3a9b0
movq 0x17c2d(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x18(%rbp), %rax
movss 0x38(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x18(%rbp), %rax
movss 0x3c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xa36c(%rip), %rsi      # 0x75768
movb $0x3, %al
callq 0x3240
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
leaq 0xb39e(%rip), %rdi      # 0x767b8
callq 0x31450
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x9020
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
cltq
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x4c8(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4d4(%rbp)
movl $0x0, -0x4d8(%rbp)
movss 0x8c64(%rip), %xmm0     # 0x740e0
movss %xmm0, -0x4dc(%rbp)
movss 0x5d60(%rip), %xmm0     # 0x711ec
movss %xmm0, -0x4e0(%rbp)
movss 0xb0bc(%rip), %xmm0     # 0x76558
movss %xmm0, -0x4e4(%rbp)
movl $0x0, -0x4e8(%rbp)
movl $0x0, -0x4ec(%rbp)
movl $0x0, -0x4f0(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x4f4(%rbp)
movl $0x0, -0x4d8(%rbp)
movl -0x4d8(%rbp), %eax
cmpl -0x4d4(%rbp), %eax
jge 0x6b9ba
movq -0x28(%rbp), %rax
movslq -0x4d8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x500(%rbp)
movq -0x500(%rbp), %rsi
leaq -0x518(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0xf510
movq -0x18(%rbp), %rax
movl 0x94(%rax), %esi
movq -0x18(%rbp), %rax
movl 0x90(%rax), %edx
leaq -0x530(%rbp), %rdi
leaq -0x518(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xfc00
movq -0x500(%rbp), %rdi
callq 0x4850
movq %rax, -0x538(%rbp)
movq -0x18(%rbp), %rdi
movq -0x520(%rbp), %rsi
callq 0x3b160
movl $0x0, -0x53c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x530(%rbp), %esi
movl -0x52c(%rbp), %edx
movss -0x4dc(%rbp), %xmm0
movss 0x5c49(%rip), %xmm1     # 0x711ec
xorl %eax, %eax
movl %eax, %ecx
movl $0x1, %r8d
leaq -0x53c(%rbp), %r9
callq 0x3b640
movq %rax, -0x548(%rbp)
movss -0x4e4(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x6b5d4
jp 0x6b5d4
jmp 0x6b5f3
movq -0x548(%rbp), %rdi
movl -0x53c(%rbp), %esi
movss -0x4e4(%rbp), %xmm0
movl $0x1, %edx
callq 0x44a60
movq -0x500(%rbp), %rdi
leaq -0x1550(%rbp), %rcx
leaq 0x8d37(%rip), %rsi      # 0x7433f
leaq 0x8d37(%rip), %rdx      # 0x74346
callq 0x4a50
leaq -0x1550(%rbp), %rdi
leaq -0x1550(%rbp), %rcx
leaq 0x8d24(%rip), %rsi      # 0x7434d
leaq 0x8d16(%rip), %rdx      # 0x74346
callq 0x4a50
leaq -0x1550(%rbp), %rdi
leaq -0x1550(%rbp), %rcx
leaq 0x7aef(%rip), %rsi      # 0x73139
leaq 0xaa15(%rip), %rdx      # 0x76066
callq 0x4a50
leaq -0x1550(%rbp), %rdi
leaq -0x1550(%rbp), %rcx
leaq 0x8cf2(%rip), %rsi      # 0x7435d
leaq 0xa9f4(%rip), %rdx      # 0x76066
callq 0x4a50
movl $0x0, -0x1554(%rbp)
leaq -0x1550(%rbp), %rdi
leaq -0x1554(%rbp), %rsi
callq 0x319a0
movq %rax, -0x1560(%rbp)
movl $0x0, -0x4d0(%rbp)
movl -0x4d0(%rbp), %eax
cmpl -0x53c(%rbp), %eax
jge 0x6b6f8
movq -0x548(%rbp), %rax
movslq -0x4d0(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movss 0x28(%rax), %xmm0
ucomiss -0x4dc(%rbp), %xmm0
jbe 0x6b6e5
movl -0x4f0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4f0(%rbp)
jmp 0x6b6e7
movl -0x4d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d0(%rbp)
jmp 0x6b6a5
movl $0x0, -0x4cc(%rbp)
movl -0x4cc(%rbp), %eax
cmpl -0x1554(%rbp), %eax
jge 0x6b8c8
movl -0x4e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4e8(%rbp)
movq -0x1560(%rbp), %rax
movslq -0x4cc(%rbp), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0x1570(%rbp)
movq -0x1560(%rbp), %rax
movslq -0x4cc(%rbp), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movss %xmm0, -0x156c(%rbp)
movq -0x1560(%rbp), %rax
movslq -0x4cc(%rbp), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movss 0xc(%rax), %xmm0
movss %xmm0, -0x1568(%rbp)
movq -0x1560(%rbp), %rax
movslq -0x4cc(%rbp), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movss 0x10(%rax), %xmm0
movss %xmm0, -0x1564(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1574(%rbp)
movl $0x0, -0x4d0(%rbp)
movl -0x4d0(%rbp), %eax
movl -0x458(%rbp), %ecx
imull -0x45c(%rbp), %ecx
imull -0x444(%rbp), %ecx
cmpl %ecx, %eax
jge 0x6b87a
movq -0x548(%rbp), %rax
movslq -0x4d0(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movsd (%rax,%rcx), %xmm0
movsd 0x8(%rax,%rcx), %xmm1
movsd -0x1570(%rbp), %xmm2
movsd -0x1568(%rbp), %xmm3
callq 0x44cd0
movss %xmm0, -0x1578(%rbp)
movq -0x548(%rbp), %rax
movslq -0x4d0(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movss 0x28(%rax), %xmm0
ucomiss -0x4dc(%rbp), %xmm0
jbe 0x6b864
movss -0x1578(%rbp), %xmm0
ucomiss -0x1574(%rbp), %xmm0
jbe 0x6b864
movss -0x1578(%rbp), %xmm0
movss %xmm0, -0x1574(%rbp)
jmp 0x6b866
movl -0x4d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d0(%rbp)
jmp 0x6b7c0
movss -0x1574(%rbp), %xmm0
addss -0x4f4(%rbp), %xmm0
movss %xmm0, -0x4f4(%rbp)
movss -0x1574(%rbp), %xmm0
ucomiss -0x4e0(%rbp), %xmm0
jbe 0x6b8b2
movl -0x4ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4ec(%rbp)
jmp 0x6b8b4
movl -0x4cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4cc(%rbp)
jmp 0x6b702
movq 0x17729(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movl -0x4d8(%rbp), %edx
movl -0x4ec(%rbp), %ecx
movl -0x4e8(%rbp), %r8d
cvtsi2ssl -0x4f0(%rbp), %xmm0
movl -0x4d8(%rbp), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x590a(%rip), %xmm1     # 0x71214
mulss -0x4f4(%rbp), %xmm1
cvtsi2ssl -0x4e8(%rbp), %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
cvtsi2sdl -0x4ec(%rbp), %xmm3
movsd 0xa15e(%rip), %xmm2     # 0x75a90
mulsd %xmm3, %xmm2
cvtsi2sdl -0x4e8(%rbp), %xmm3
divsd %xmm3, %xmm2
leaq 0xaf06(%rip), %rsi      # 0x7684f
movb $0x3, %al
callq 0x3240
movq -0x538(%rbp), %rdi
callq 0x3030
leaq -0x518(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
leaq -0x530(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xedb0
movl -0x4d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d8(%rbp)
jmp 0x6b4d7
addq $0x1590, %rsp           # imm = 0x1590
popq %rbp
retq
nopw %cs:(%rax,%rax)