// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/super.c
// Function: train_super
void train_super(char *cfgfile, char *weightfile, int clear)
{
    char *train_images = "/data/imagenet/imagenet1k.train.list";
    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, clear);
    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;


    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.scale = 4;
    args.paths = paths;
    args.n = imgs;
    args.m = plist->size;
    args.d = &buffer;
    args.type = SUPER_DATA;

    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){
            char buff[256];
            sprintf(buff, "%s/%s_%d.weights", backup_directory, base, i);
            save_weights(net, buff);
        }
        if(i%100==0){
            char buff[256];
            sprintf(buff, "%s/%s.backup", backup_directory, base);
            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 $0x570, %rsp            # imm = 0x570
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq 0x1f86f(%rip), %rax     # 0x7592c
movq %rax, -0x20(%rbp)
leaq 0x1f8ad(%rip), %rax     # 0x75975
movq %rax, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
leaq 0x1e2a9(%rip), %rdi     # 0x7439d
movb $0x0, %al
callq 0x3130
movss 0x1dfd9(%rip), %xmm0    # 0x740dc
movss %xmm0, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x39a70
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x40(%rbp), %rax
movss 0x38(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x40(%rbp), %rax
movss 0x3c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x1f61e(%rip), %rdi     # 0x75768
movb $0x3, %al
callq 0x3130
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x40(%rbp), %rcx
imull 0x1c(%rcx), %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x44(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x31450
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x9020
movq %rax, -0xd8(%rbp)
leaq -0x180(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x3190
movq -0x40(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x154(%rbp)
movq -0x40(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x158(%rbp)
movl $0x4, -0x128(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x178(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x168(%rbp)
movq -0xd0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x164(%rbp)
leaq -0xc8(%rbp), %rax
movq %rax, -0x100(%rbp)
movl $0xc, -0xe8(%rbp)
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x180(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x188(%rbp)
movq -0x40(%rbp), %rdi
callq 0x39ad0
movq -0x40(%rbp), %rcx
movslq 0x54(%rcx), %rcx
cmpq %rcx, %rax
jae 0x564a1
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
callq 0x30f0
movq %rax, -0x190(%rbp)
movq -0x188(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
leaq -0x88(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
movl $0x40, %edx
callq 0x3280
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x180(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x188(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x190(%rbp), %rdi
callq 0x4b50
cvtss2sd %xmm0, %xmm0
leaq 0x1f52a(%rip), %rdi     # 0x757f4
movb $0x1, %al
callq 0x3130
callq 0x30f0
movq %rax, -0x190(%rbp)
movq -0x40(%rbp), %rdi
movups -0x88(%rbp), %xmm0
movups -0x78(%rbp), %xmm1
movups -0x68(%rbp), %xmm2
movups -0x58(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3a860
movss %xmm0, -0x194(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x56329
movss -0x194(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x194(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x1dd72(%rip), %xmm2    # 0x740b8
mulsd %xmm2, %xmm1
movsd 0x1f40e(%rip), %xmm2    # 0x75760
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x4bc(%rbp)
movss -0x194(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4a8(%rbp)
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4b8(%rbp)
movq -0x40(%rbp), %rdi
callq 0x39b60
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4b0(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x190(%rbp), %rdi
callq 0x4b50
movl -0x4bc(%rbp), %esi
movsd -0x4b8(%rbp), %xmm1
movsd -0x4b0(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x4a8(%rbp), %xmm0
cvtss2sd %xmm3, %xmm3
movl -0x48(%rbp), %edx
imull -0x44(%rbp), %edx
leaq 0x1f59f(%rip), %rdi     # 0x7598c
movb $0x4, %al
callq 0x3130
movl -0x48(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x56435
leaq -0x2a0(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x48(%rbp), %r8d
leaq 0x1f59f(%rip), %rsi     # 0x759bd
movb $0x0, %al
callq 0x33f0
movq -0x40(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x41980
movl -0x48(%rbp), %eax
movl $0x64, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x56472
leaq -0x3a0(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x1f573(%rip), %rsi     # 0x759ce
movb $0x0, %al
callq 0x33f0
movq -0x40(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x41980
movups -0x88(%rbp), %xmm0
movups -0x78(%rbp), %xmm1
movups -0x68(%rbp), %xmm2
movups -0x58(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x34400
jmp 0x56236
leaq -0x4a0(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x1f524(%rip), %rsi     # 0x759db
movb $0x0, %al
callq 0x33f0
movq -0x40(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x41980
addq $0x570, %rsp            # imm = 0x570
popq %rbp
retq
nopw (%rax,%rax)