// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/cifar.c
// Function: train_cifar
void train_cifar(char *cfgfile, char *weightfile)
{
    srand(time(0));
    float avg_loss = -1;
    char *base = basecfg(cfgfile);
    printf("%s\n", base);
    network *net = load_network(cfgfile, weightfile, 0);
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net->learning_rate, net->momentum, net->decay);

    char *backup_directory = "/home/pjreddie/backup/";
    int classes = 10;
    int N = 50000;

    char **labels = get_labels("data/cifar/labels.txt");
    int epoch = (*net->seen)/N;
    data train = load_all_cifar10();
    while(get_current_batch(net) < net->max_batches || net->max_batches == 0){
        clock_t time=clock();

        float loss = train_network_sgd(net, train, 1);
        if(avg_loss == -1) avg_loss = loss;
        avg_loss = avg_loss*.95 + loss*.05;
        printf("%ld, %.3f: %f, %f avg, %f rate, %lf seconds, %ld images\n", get_current_batch(net), (float)(*net->seen)/N, loss, avg_loss, get_current_rate(net), sec(clock()-time), *net->seen);
        if(*net->seen/N > epoch){
            epoch = *net->seen/N;
            char buff[256];
            sprintf(buff, "%s/%s_%d.weights",backup_directory,base, epoch);
            save_weights(net, buff);
        }
        if(get_current_batch(net)%100 == 0){
            char buff[256];
            sprintf(buff, "%s/%s.backup",backup_directory,base);
            save_weights(net, buff);
        }
    }
    char buff[256];
    sprintf(buff, "%s/%s.weights", backup_directory, base);
    save_weights(net, buff);

    free_network(net);
    free_ptrs((void**)labels, classes);
    free(base);
    free_data(train);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movss 0x1ce31(%rip), %xmm0    # 0x740dc
movss %xmm0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x1d0d5(%rip), %rdi     # 0x7439d
movb $0x0, %al
callq 0x3130
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x39a70
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x28(%rbp), %rax
movss 0x38(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x28(%rbp), %rax
movss 0x3c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x1e458(%rip), %rdi     # 0x75768
movb $0x3, %al
callq 0x3130
leaq 0x1e657(%rip), %rax     # 0x75975
movq %rax, -0x30(%rbp)
movl $0xa, -0x34(%rbp)
movl $0xc350, -0x38(%rbp)    # imm = 0xC350
leaq 0x1e761(%rip), %rdi     # 0x75a98
callq 0x343c0
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x44(%rbp)
leaq -0x88(%rbp), %rdi
movb $0x0, %al
callq 0x38500
movq -0x28(%rbp), %rdi
callq 0x39ad0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movslq 0x54(%rax), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x3a1(%rbp)
jb 0x57397
movq -0x28(%rbp), %rax
cmpl $0x0, 0x54(%rax)
sete %al
movb %al, -0x3a1(%rbp)
movb -0x3a1(%rbp), %al
testb $0x1, %al
jne 0x573a6
jmp 0x57606
callq 0x30f0
movq %rax, -0x90(%rbp)
movq -0x28(%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)
movl $0x1, %esi
callq 0x3a7a0
movss %xmm0, -0x94(%rbp)
movss -0x14(%rbp), %xmm0
movss 0x1cce2(%rip), %xmm1    # 0x740dc
ucomiss %xmm1, %xmm0
jne 0x5740e
jp 0x5740e
movss -0x94(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x94(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x1e655(%rip), %xmm2    # 0x75a80
mulsd %xmm2, %xmm1
movsd 0x1e651(%rip), %xmm2    # 0x75a88
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x14(%rbp)
movq -0x28(%rbp), %rdi
callq 0x39ad0
movq %rax, -0x3b8(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x3ac(%rbp)
testq %rax, %rax
movss %xmm0, -0x3a8(%rbp)
js 0x574a4
movss -0x3ac(%rbp), %xmm0
movss %xmm0, -0x3a8(%rbp)
movss -0x3a8(%rbp), %xmm0
cvtsi2ssl -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3c0(%rbp)
movss -0x94(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3d8(%rbp)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3d0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x39b60
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3c8(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x90(%rbp), %rdi
callq 0x4b50
movq -0x3b8(%rbp), %rsi
movsd -0x3d8(%rbp), %xmm1
movsd -0x3d0(%rbp), %xmm2
movsd -0x3c8(%rbp), %xmm3
movaps %xmm0, %xmm4
movsd -0x3c0(%rbp), %xmm0
cvtss2sd %xmm4, %xmm4
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdx
leaq 0x1e4cd(%rip), %rdi     # 0x75a1c
movb $0x5, %al
callq 0x3130
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movslq -0x44(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x575bb
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x44(%rbp)
leaq -0x1a0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl -0x44(%rbp), %r8d
leaq 0x1e419(%rip), %rsi     # 0x759bd
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x41980
movq -0x28(%rbp), %rdi
callq 0x39ad0
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x57601
leaq -0x2a0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1e3e4(%rip), %rsi     # 0x759ce
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x41980
jmp 0x57365
leaq -0x3a0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1e439(%rip), %rsi     # 0x75a55
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x41980
movq -0x28(%rbp), %rdi
callq 0x3c0b0
movq -0x40(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x4f40
movq -0x20(%rbp), %rdi
callq 0x3030
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
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
nopw %cs:(%rax,%rax)