// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/yolo.c
// Function: validate_yolo
void validate_yolo(char *cfg, char *weights)
{
    network *net = load_network(cfg, weights, 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));

    char *base = "results/comp4_det_test_";
    //list *plist = get_paths("data/voc.2007.test");
    list *plist = get_paths("/home/pjreddie/data/voc/2007_test.txt");
    //list *plist = get_paths("data/voc.2012.test");
    char **paths = (char **)list_to_array(plist);

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

    int j;
    FILE **fps = calloc(classes, sizeof(FILE *));
    for(j = 0; j < classes; ++j){
        char buff[1024];
        snprintf(buff, 1024, "%s%s.txt", base, voc_names[j]);
        fps[j] = fopen(buff, "w");
    }

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

    float thresh = .001;
    int nms = 1;
    float iou_thresh = .5;

    int nthreads = 8;
    image *val = calloc(nthreads, sizeof(image));
    image *val_resized = calloc(nthreads, sizeof(image));
    image *buf = calloc(nthreads, sizeof(image));
    image *buf_resized = calloc(nthreads, sizeof(image));
    pthread_t *thr = calloc(nthreads, sizeof(pthread_t));

    load_args args = {0};
    args.w = net->w;
    args.h = net->h;
    args.type = IMAGE_DATA;

    for(t = 0; t < nthreads; ++t){
        args.path = paths[i+t];
        args.im = &buf[t];
        args.resized = &buf_resized[t];
        thr[t] = load_data_in_thread(args);
    }
    time_t start = time(0);
    for(i = nthreads; i < m+nthreads; i += nthreads){
        fprintf(stderr, "%d\n", i);
        for(t = 0; t < nthreads && i+t-nthreads < m; ++t){
            pthread_join(thr[t], 0);
            val[t] = buf[t];
            val_resized[t] = buf_resized[t];
        }
        for(t = 0; t < nthreads && i+t < m; ++t){
            args.path = paths[i+t];
            args.im = &buf[t];
            args.resized = &buf_resized[t];
            thr[t] = load_data_in_thread(args);
        }
        for(t = 0; t < nthreads && i+t-nthreads < m; ++t){
            char *path = paths[i+t-nthreads];
            char *id = basecfg(path);
            float *X = val_resized[t].data;
            network_predict(net, X);
            int w = val[t].w;
            int h = val[t].h;
            int nboxes = 0;
            detection *dets = get_network_boxes(net, w, h, thresh, 0, 0, 0, &nboxes);
            if (nms) do_nms_sort(dets, l.side*l.side*l.n, classes, iou_thresh);
            print_yolo_detections(fps, id, l.side*l.side*l.n, classes, w, h, dets);
            free_detections(dets, nboxes);
            free(id);
            free_image(val[t]);
            free_image(val_resized[t]);
        }
    }
    fprintf(stderr, "Total Detection Time: %f Seconds\n", (double)(time(0) - start));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xac0, %rsp            # imm = 0xAC0
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 0x1b72d(%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 0xde6c(%rip), %rsi      # 0x75768
movb $0x3, %al
callq 0x3240
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
leaq 0xeef2(%rip), %rax      # 0x7680c
movq %rax, -0x20(%rbp)
leaq 0xf040(%rip), %rdi      # 0x76965
callq 0x31450
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9020
movq %rax, -0x30(%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 -0x4d0(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movl -0x3d4(%rbp), %eax
movl %eax, -0x4d4(%rbp)
movslq -0x4d4(%rbp), %rdi
movl $0x8, %esi
callq 0x3220
movq %rax, -0x4e0(%rbp)
movl $0x0, -0x4d8(%rbp)
movl -0x4d8(%rbp), %eax
cmpl -0x4d4(%rbp), %eax
jge 0x67a0e
leaq -0x8e0(%rbp), %rdi
movq -0x20(%rbp), %rcx
movslq -0x4d8(%rbp), %rdx
leaq 0x1c282(%rip), %rax     # 0x83c40
movq (%rax,%rdx,8), %r8
movl $0x400, %esi            # imm = 0x400
leaq 0xf07c(%rip), %rdx      # 0x76a4a
movb $0x0, %al
callq 0x3150
leaq -0x8e0(%rbp), %rdi
leaq 0xf088(%rip), %rsi      # 0x76a6b
callq 0x3360
movq %rax, %rdx
movq -0x4e0(%rbp), %rax
movslq -0x4d8(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d8(%rbp)
jmp 0x67997
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8e4(%rbp)
movl $0x0, -0x8e8(%rbp)
movss 0xc6b4(%rip), %xmm0     # 0x740e0
movss %xmm0, -0x8f0(%rbp)
movl $0x1, -0x8f4(%rbp)
movss 0x97a6(%rip), %xmm0     # 0x711ec
movss %xmm0, -0x8f8(%rbp)
movl $0x8, -0x8fc(%rbp)
movslq -0x8fc(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x908(%rbp)
movslq -0x8fc(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x910(%rbp)
movslq -0x8fc(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x918(%rbp)
movslq -0x8fc(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x920(%rbp)
movslq -0x8fc(%rbp), %rdi
movl $0x8, %esi
callq 0x3220
movq %rax, -0x928(%rbp)
leaq -0x9d0(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x3190
movq -0x18(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x9a4(%rbp)
movq -0x18(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x9a8(%rbp)
movl $0x4, -0x938(%rbp)
movl $0x0, -0x8ec(%rbp)
movl -0x8ec(%rbp), %eax
cmpl -0x8fc(%rbp), %eax
jge 0x67bbf
movq -0x30(%rbp), %rax
movl -0x8e8(%rbp), %ecx
addl -0x8ec(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9c0(%rbp)
movq -0x918(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x948(%rbp)
movq -0x920(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x940(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x9d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, %rdx
movq -0x928(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x67b17
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movq %rax, -0x9d8(%rbp)
movl -0x8fc(%rbp), %eax
movl %eax, -0x8e8(%rbp)
movl -0x8e8(%rbp), %eax
movl -0x8e4(%rbp), %ecx
addl -0x8fc(%rbp), %ecx
cmpl %ecx, %eax
jge 0x68051
movq 0x1b3fc(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movl -0x8e8(%rbp), %edx
leaq 0xb56a(%rip), %rsi      # 0x73176
movb $0x0, %al
callq 0x3240
movl $0x0, -0x8ec(%rbp)
movl -0x8ec(%rbp), %ecx
xorl %eax, %eax
cmpl -0x8fc(%rbp), %ecx
movb %al, -0xa09(%rbp)
jge 0x67c54
movl -0x8e8(%rbp), %eax
addl -0x8ec(%rbp), %eax
subl -0x8fc(%rbp), %eax
cmpl -0x8e4(%rbp), %eax
setl %al
movb %al, -0xa09(%rbp)
movb -0xa09(%rbp), %al
testb $0x1, %al
jne 0x67c63
jmp 0x67d12
movq -0x928(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
movq -0x908(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x918(%rbp), %rcx
movslq -0x8ec(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x910(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x920(%rbp), %rcx
movslq -0x8ec(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movl -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x67c1d
movl $0x0, -0x8ec(%rbp)
movl -0x8ec(%rbp), %ecx
xorl %eax, %eax
cmpl -0x8fc(%rbp), %ecx
movb %al, -0xa0a(%rbp)
jge 0x67d4d
movl -0x8e8(%rbp), %eax
addl -0x8ec(%rbp), %eax
cmpl -0x8e4(%rbp), %eax
setl %al
movb %al, -0xa0a(%rbp)
movb -0xa0a(%rbp), %al
testb $0x1, %al
jne 0x67d5c
jmp 0x67df2
movq -0x30(%rbp), %rax
movl -0x8e8(%rbp), %ecx
addl -0x8ec(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9c0(%rbp)
movq -0x918(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x948(%rbp)
movq -0x920(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x940(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x9d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, %rdx
movq -0x928(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x67d1c
movl $0x0, -0x8ec(%rbp)
movl -0x8ec(%rbp), %ecx
xorl %eax, %eax
cmpl -0x8fc(%rbp), %ecx
movb %al, -0xa0b(%rbp)
jge 0x67e33
movl -0x8e8(%rbp), %eax
addl -0x8ec(%rbp), %eax
subl -0x8fc(%rbp), %eax
cmpl -0x8e4(%rbp), %eax
setl %al
movb %al, -0xa0b(%rbp)
movb -0xa0b(%rbp), %al
testb $0x1, %al
jne 0x67e42
jmp 0x68038
movq -0x30(%rbp), %rax
movl -0x8e8(%rbp), %ecx
addl -0x8ec(%rbp), %ecx
subl -0x8fc(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9e0(%rbp)
movq -0x9e0(%rbp), %rdi
callq 0x4850
movq %rax, -0x9e8(%rbp)
movq -0x910(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x9f0(%rbp)
movq -0x18(%rbp), %rdi
movq -0x9f0(%rbp), %rsi
callq 0x3b160
movq -0x908(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x9f4(%rbp)
movq -0x908(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x9f8(%rbp)
movl $0x0, -0x9fc(%rbp)
movq -0x18(%rbp), %rdi
movl -0x9f4(%rbp), %esi
movl -0x9f8(%rbp), %edx
movss -0x8f0(%rbp), %xmm0
xorps %xmm1, %xmm1
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
leaq -0x9fc(%rbp), %r9
callq 0x3b640
movq %rax, -0xa08(%rbp)
cmpl $0x0, -0x8f4(%rbp)
je 0x67f5a
movq -0xa08(%rbp), %rdi
movl -0x43c(%rbp), %esi
imull -0x43c(%rbp), %esi
imull -0x44c(%rbp), %esi
movl -0x4d4(%rbp), %edx
movss -0x8f8(%rbp), %xmm0
callq 0x44d40
movq -0x4e0(%rbp), %rdi
movq -0x9e8(%rbp), %rsi
movl -0x43c(%rbp), %edx
imull -0x43c(%rbp), %edx
imull -0x44c(%rbp), %edx
movl -0x4d4(%rbp), %ecx
movl -0x9f4(%rbp), %r8d
movl -0x9f8(%rbp), %r9d
movq -0xa08(%rbp), %rax
movq %rax, (%rsp)
callq 0x67620
movq -0xa08(%rbp), %rdi
movl -0x9fc(%rbp), %esi
callq 0x3b6b0
movq -0x9e8(%rbp), %rdi
callq 0x3030
movq -0x908(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %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
movq -0x910(%rbp), %rax
movslq -0x8ec(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %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 -0x8ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8ec(%rbp)
jmp 0x67dfc
jmp 0x6803a
movl -0x8fc(%rbp), %eax
addl -0x8e8(%rbp), %eax
movl %eax, -0x8e8(%rbp)
jmp 0x67bdb
movq 0x1afa0(%rip), %rax     # 0x82ff8
movq (%rax), %rax
movq %rax, -0xa18(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movq -0xa18(%rbp), %rdi
subq -0x9d8(%rbp), %rax
cvtsi2sd %rax, %xmm0
leaq 0xe765(%rip), %rsi      # 0x767ea
movb $0x1, %al
callq 0x3240
addq $0xac0, %rsp            # imm = 0xAC0
popq %rbp
retq
nopw %cs:(%rax,%rax)