// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/yolo.c
// Function: train_yolo
void train_yolo(char *cfgfile, char *weightfile)
{
    char *train_images = "/data/voc/train.txt";
    char *backup_directory = "/home/pjreddie/backup/";
    srand(time(0));
    char *base = basecfg(cfgfile);
    printf("%s\n", base);
    float avg_loss = -1;
    network *net = load_network(cfgfile, weightfile, 0);
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);
    int imgs = net->batch*net->subdivisions;
    int i = *net->seen/imgs;
    data train, buffer;


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

    int side = l.side;
    int classes = l.classes;
    float jitter = l.jitter;

    list *plist = get_paths(train_images);
    //int N = plist->size;
    char **paths = (char **)list_to_array(plist);

    load_args args = {0};
    args.w = net->w;
    args.h = net->h;
    args.paths = paths;
    args.n = imgs;
    args.m = plist->size;
    args.classes = classes;
    args.jitter = jitter;
    args.num_boxes = side;
    args.d = &buffer;
    args.type = REGION_DATA;

    args.angle = net->angle;
    args.exposure = net->exposure;
    args.saturation = net->saturation;
    args.hue = net->hue;

    pthread_t load_thread = load_data_in_thread(args);
    clock_t time;
    //while(i*imgs < N*120){
    while(get_current_batch(net) < net->max_batches){
        i += 1;
        time=clock();
        pthread_join(load_thread, 0);
        train = buffer;
        load_thread = load_data_in_thread(args);

        printf("Loaded: %lf seconds\n", sec(clock()-time));

        time=clock();
        float loss = train_network(net, train);
        if (avg_loss < 0) avg_loss = loss;
        avg_loss = avg_loss*.9 + loss*.1;

        printf("%d: %f, %f avg, %f rate, %lf seconds, %d images\n", i, loss, avg_loss, get_current_rate(net), sec(clock()-time), i*imgs);
        if(i%1000==0 || (i < 1000 && i%100 == 0)){
            char buff[256];
            sprintf(buff, "%s/%s_%d.weights", backup_directory, base, i);
            save_weights(net, buff);
        }
        free_data(train);
    }
    char buff[256];
    sprintf(buff, "%s/%s_final.weights", backup_directory, base);
    save_weights(net, buff);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x910, %rsp            # imm = 0x910
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0xf7d4(%rip), %rax      # 0x7693e
movq %rax, -0x18(%rbp)
leaq 0xe800(%rip), %rax      # 0x75975
movq %rax, -0x20(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
leaq 0xd1fc(%rip), %rdi      # 0x7439d
movb $0x0, %al
callq 0x3130
movss 0xcf2c(%rip), %xmm0     # 0x740dc
movss %xmm0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x38(%rbp), %rax
movss 0x38(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x38(%rbp), %rax
movss 0x3c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0xe572(%rip), %rdi      # 0x75768
movb $0x3, %al
callq 0x3130
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
imull 0x1c(%rcx), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x38(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
cltq
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x560(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movl -0x4cc(%rbp), %eax
movl %eax, -0x564(%rbp)
movl -0x464(%rbp), %eax
movl %eax, -0x568(%rbp)
movss -0x488(%rbp), %xmm0
movss %xmm0, -0x56c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31450
movq %rax, -0x578(%rbp)
movq -0x578(%rbp), %rdi
callq 0x9020
movq %rax, -0x580(%rbp)
leaq -0x628(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x3190
movq -0x38(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x5fc(%rbp)
movq -0x38(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x600(%rbp)
movq -0x580(%rbp), %rax
movq %rax, -0x620(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x610(%rbp)
movq -0x578(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x60c(%rbp)
movl -0x568(%rbp), %eax
movl %eax, -0x5d8(%rbp)
movss -0x56c(%rbp), %xmm0
movss %xmm0, -0x5c4(%rbp)
movl -0x564(%rbp), %eax
movl %eax, -0x5e8(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0x5a8(%rbp)
movl $0x3, -0x590(%rbp)
movq -0x38(%rbp), %rax
movss 0xb0(%rax), %xmm0
movss %xmm0, -0x5c0(%rbp)
movq -0x38(%rbp), %rax
movss 0xb8(%rax), %xmm0
movss %xmm0, -0x5b4(%rbp)
movq -0x38(%rbp), %rax
movss 0xbc(%rax), %xmm0
movss %xmm0, -0x5b8(%rbp)
movq -0x38(%rbp), %rax
movss 0xc0(%rax), %xmm0
movss %xmm0, -0x5b0(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x628(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x630(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39ad0
movq -0x38(%rbp), %rcx
movslq 0x54(%rcx), %rcx
cmpq %rcx, %rax
jae 0x675e4
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
callq 0x30f0
movq %rax, -0x638(%rbp)
movq -0x630(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
leaq -0x80(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movl $0x40, %edx
callq 0x3280
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x628(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x630(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x638(%rbp), %rdi
callq 0x4b50
cvtss2sd %xmm0, %xmm0
leaq 0xe3bd(%rip), %rdi      # 0x757f4
movb $0x1, %al
callq 0x3130
callq 0x30f0
movq %rax, -0x638(%rbp)
movq -0x38(%rbp), %rdi
movups -0x80(%rbp), %xmm0
movups -0x70(%rbp), %xmm1
movups -0x60(%rbp), %xmm2
movups -0x50(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3a860
movss %xmm0, -0x63c(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x2c(%rbp), %xmm0
jbe 0x67493
movss -0x63c(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x63c(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0xcc08(%rip), %xmm2     # 0x740b8
mulsd %xmm2, %xmm1
movsd 0xe2a4(%rip), %xmm2     # 0x75760
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x85c(%rbp)
movss -0x63c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x848(%rbp)
movss -0x2c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x858(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39b60
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x850(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x638(%rbp), %rdi
callq 0x4b50
movl -0x85c(%rbp), %esi
movsd -0x858(%rbp), %xmm1
movsd -0x850(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x848(%rbp), %xmm0
cvtss2sd %xmm3, %xmm3
movl -0x40(%rbp), %edx
imull -0x3c(%rbp), %edx
leaq 0xe435(%rip), %rdi      # 0x7598c
movb $0x4, %al
callq 0x3130
movl -0x40(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x67587
cmpl $0x3e8, -0x40(%rbp)     # imm = 0x3E8
jge 0x675b8
movl -0x40(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x675b8
leaq -0x740(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl -0x40(%rbp), %r8d
leaq 0xe41c(%rip), %rsi      # 0x759bd
movb $0x0, %al
callq 0x33f0
movq -0x38(%rbp), %rdi
leaq -0x740(%rbp), %rsi
callq 0x41980
movups -0x80(%rbp), %xmm0
movups -0x70(%rbp), %xmm1
movups -0x60(%rbp), %xmm2
movups -0x50(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x34400
jmp 0x673a6
leaq -0x840(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq 0xe3e1(%rip), %rsi      # 0x759db
movb $0x0, %al
callq 0x33f0
movq -0x38(%rbp), %rdi
leaq -0x840(%rbp), %rsi
callq 0x41980
addq $0x910, %rsp            # imm = 0x910
popq %rbp
retq
nopw (%rax,%rax)