// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/coco.c
// Function: validate_coco
void validate_coco(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/";
    list *plist = get_paths("data/coco_val_5k.list");
    //list *plist = get_paths("/home/pjreddie/data/people-art/test.txt");
    //list *plist = get_paths("/home/pjreddie/data/voc/test/2007_test.txt");
    char **paths = (char **)list_to_array(plist);

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

    char buff[1024];
    snprintf(buff, 1024, "%s/coco_results.json", base);
    FILE *fp = fopen(buff, "w");
    fprintf(fp, "[\n");

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

    float thresh = .01;
    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];
            int image_id = get_coco_image_id(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_cocos(fp, image_id, dets, l.side*l.side*l.n, classes, w, h);
            free_detections(dets, nboxes);
            free_image(val[t]);
            free_image(val_resized[t]);
        }
    }
    fseek(fp, -2, SEEK_CUR); 
    fprintf(fp, "\n]\n");
    fclose(fp);

    fprintf(stderr, "Total Detection Time: %f Seconds\n", (double)(time(0) - start));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xad0, %rsp            # imm = 0xAD0
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 0x1d61d(%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 0xfd5c(%rip), %rsi      # 0x75768
movb $0x3, %al
callq 0x3240
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
leaq 0x10d85(%rip), %rax     # 0x767af
movq %rax, -0x20(%rbp)
leaq 0x10d83(%rip), %rdi     # 0x767b8
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)
leaq -0x8e0(%rbp), %rdi
movq -0x20(%rbp), %rcx
movl $0x400, %esi            # imm = 0x400
leaq 0x10d32(%rip), %rdx     # 0x767ce
movb $0x0, %al
callq 0x3150
leaq -0x8e0(%rbp), %rdi
leaq 0x10fba(%rip), %rsi     # 0x76a6b
callq 0x3360
movq %rax, -0x8e8(%rbp)
movq -0x8e8(%rbp), %rdi
leaq 0x10d18(%rip), %rsi     # 0x767e3
movb $0x0, %al
callq 0x3240
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8ec(%rbp)
movl $0x0, -0x8f0(%rbp)
movss 0xfa3c(%rip), %xmm0     # 0x7552c
movss %xmm0, -0x8f8(%rbp)
movl $0x1, -0x8fc(%rbp)
movss 0xb6e2(%rip), %xmm0     # 0x711ec
movss %xmm0, -0x900(%rbp)
movl $0x8, -0x904(%rbp)
movslq -0x904(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x910(%rbp)
movslq -0x904(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x918(%rbp)
movslq -0x904(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x920(%rbp)
movslq -0x904(%rbp), %rdi
movl $0x18, %esi
callq 0x3220
movq %rax, -0x928(%rbp)
movslq -0x904(%rbp), %rdi
movl $0x8, %esi
callq 0x3220
movq %rax, -0x930(%rbp)
leaq -0x9d8(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x3190
movq -0x18(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x9ac(%rbp)
movq -0x18(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x9b0(%rbp)
movl $0x4, -0x940(%rbp)
movl $0x0, -0x8f4(%rbp)
movl -0x8f4(%rbp), %eax
cmpl -0x904(%rbp), %eax
jge 0x65c83
movq -0x30(%rbp), %rax
movl -0x8f0(%rbp), %ecx
addl -0x8f4(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9c8(%rbp)
movq -0x920(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x950(%rbp)
movq -0x928(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x948(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x9d8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, %rdx
movq -0x930(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
jmp 0x65bdb
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movq %rax, -0x9e0(%rbp)
movl -0x904(%rbp), %eax
movl %eax, -0x8f0(%rbp)
movl -0x8f0(%rbp), %eax
movl -0x8ec(%rbp), %ecx
addl -0x904(%rbp), %ecx
cmpl %ecx, %eax
jge 0x66106
movq 0x1d338(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movl -0x8f0(%rbp), %edx
leaq 0xd4a6(%rip), %rsi      # 0x73176
movb $0x0, %al
callq 0x3240
movl $0x0, -0x8f4(%rbp)
movl -0x8f4(%rbp), %ecx
xorl %eax, %eax
cmpl -0x904(%rbp), %ecx
movb %al, -0xa11(%rbp)
jge 0x65d18
movl -0x8f0(%rbp), %eax
addl -0x8f4(%rbp), %eax
subl -0x904(%rbp), %eax
cmpl -0x8ec(%rbp), %eax
setl %al
movb %al, -0xa11(%rbp)
movb -0xa11(%rbp), %al
testb $0x1, %al
jne 0x65d27
jmp 0x65dd6
movq -0x930(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
movq -0x910(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x920(%rbp), %rcx
movslq -0x8f4(%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 -0x918(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x928(%rbp), %rcx
movslq -0x8f4(%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 -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
jmp 0x65ce1
movl $0x0, -0x8f4(%rbp)
movl -0x8f4(%rbp), %ecx
xorl %eax, %eax
cmpl -0x904(%rbp), %ecx
movb %al, -0xa12(%rbp)
jge 0x65e11
movl -0x8f0(%rbp), %eax
addl -0x8f4(%rbp), %eax
cmpl -0x8ec(%rbp), %eax
setl %al
movb %al, -0xa12(%rbp)
movb -0xa12(%rbp), %al
testb $0x1, %al
jne 0x65e20
jmp 0x65eb6
movq -0x30(%rbp), %rax
movl -0x8f0(%rbp), %ecx
addl -0x8f4(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9c8(%rbp)
movq -0x920(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x950(%rbp)
movq -0x928(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x948(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x9d8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, %rdx
movq -0x930(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
jmp 0x65de0
movl $0x0, -0x8f4(%rbp)
movl -0x8f4(%rbp), %ecx
xorl %eax, %eax
cmpl -0x904(%rbp), %ecx
movb %al, -0xa13(%rbp)
jge 0x65ef7
movl -0x8f0(%rbp), %eax
addl -0x8f4(%rbp), %eax
subl -0x904(%rbp), %eax
cmpl -0x8ec(%rbp), %eax
setl %al
movb %al, -0xa13(%rbp)
movb -0xa13(%rbp), %al
testb $0x1, %al
jne 0x65f06
jmp 0x660ed
movq -0x30(%rbp), %rax
movl -0x8f0(%rbp), %ecx
addl -0x8f4(%rbp), %ecx
subl -0x904(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x9e8(%rbp)
movq -0x9e8(%rbp), %rdi
callq 0x65960
movl %eax, -0x9ec(%rbp)
movq -0x918(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movq %rax, -0x9f8(%rbp)
movq -0x18(%rbp), %rdi
movq -0x9f8(%rbp), %rsi
callq 0x3b160
movq -0x910(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x9fc(%rbp)
movq -0x910(%rbp), %rax
movslq -0x8f4(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0xa00(%rbp)
movl $0x0, -0xa04(%rbp)
movq -0x18(%rbp), %rdi
movl -0x9fc(%rbp), %esi
movl -0xa00(%rbp), %edx
movss -0x8f8(%rbp), %xmm0
xorps %xmm1, %xmm1
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
leaq -0xa04(%rbp), %r9
callq 0x3b640
movq %rax, -0xa10(%rbp)
cmpl $0x0, -0x8fc(%rbp)
je 0x6601d
movq -0xa10(%rbp), %rdi
movl -0x43c(%rbp), %esi
imull -0x43c(%rbp), %esi
imull -0x44c(%rbp), %esi
movl -0x4d4(%rbp), %edx
movss -0x900(%rbp), %xmm0
callq 0x44d40
movq -0x8e8(%rbp), %rdi
movl -0x9ec(%rbp), %esi
movq -0xa10(%rbp), %rdx
movl -0x43c(%rbp), %ecx
imull -0x43c(%rbp), %ecx
imull -0x44c(%rbp), %ecx
movl -0x4d4(%rbp), %r8d
movl -0x9fc(%rbp), %r9d
movl -0xa00(%rbp), %eax
movl %eax, (%rsp)
callq 0x66190
movq -0xa10(%rbp), %rdi
movl -0xa04(%rbp), %esi
callq 0x3b6b0
movq -0x910(%rbp), %rax
movslq -0x8f4(%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 -0x918(%rbp), %rax
movslq -0x8f4(%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 -0x8f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8f4(%rbp)
jmp 0x65ec0
jmp 0x660ef
movl -0x904(%rbp), %eax
addl -0x8f0(%rbp), %eax
movl %eax, -0x8f0(%rbp)
jmp 0x65c9f
movq -0x8e8(%rbp), %rdi
movq $-0x2, %rsi
movl $0x1, %edx
callq 0x3300
movq -0x8e8(%rbp), %rdi
leaq 0x106ba(%rip), %rsi     # 0x767e6
movb $0x0, %al
callq 0x3240
movq -0x8e8(%rbp), %rdi
callq 0x3100
movq 0x1ceb2(%rip), %rax     # 0x82ff8
movq (%rax), %rax
movq %rax, -0xa20(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movq -0xa20(%rbp), %rdi
subq -0x9e0(%rbp), %rax
cvtsi2sd %rax, %xmm0
leaq 0x10677(%rip), %rsi     # 0x767ea
movb $0x1, %al
callq 0x3240
addq $0xad0, %rsp            # imm = 0xAD0
popq %rbp
retq
nopw %cs:(%rax,%rax)