// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/cifar.c
// Function: train_cifar_distill
void train_cifar_distill(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();
    matrix soft = csv_to_matrix("results/ensemble.csv");

    float weight = .9;
    scale_matrix(soft, weight);
    scale_matrix(train.y, 1. - weight);
    matrix_add_matrix(soft, train.y);

    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 $0x430, %rsp            # imm = 0x430
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movss 0x1ca21(%rip), %xmm0    # 0x740dc
movss %xmm0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x1ccc5(%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 0x1e048(%rip), %rdi     # 0x75768
movb $0x3, %al
callq 0x3130
leaq 0x1e247(%rip), %rax     # 0x75975
movq %rax, -0x30(%rbp)
movl $0xa, -0x34(%rbp)
movl $0xc350, -0x38(%rbp)    # imm = 0xC350
leaq 0x1e351(%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
leaq 0x1e332(%rip), %rdi     # 0x75aae
callq 0x39660
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movss 0x1d055(%rip), %xmm0    # 0x747ec
movss %xmm0, -0x9c(%rbp)
movss -0x9c(%rbp), %xmm0
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x39170
movss -0x9c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x19892(%rip), %xmm0    # 0x71060
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x39170
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
callq 0x392e0
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, -0x3b1(%rbp)
jb 0x57830
movq -0x28(%rbp), %rax
cmpl $0x0, 0x54(%rax)
sete %al
movb %al, -0x3b1(%rbp)
movb -0x3b1(%rbp), %al
testb $0x1, %al
jne 0x5783f
jmp 0x57a9f
callq 0x30f0
movq %rax, -0xa8(%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, -0xac(%rbp)
movss -0x14(%rbp), %xmm0
movss 0x1c849(%rip), %xmm1    # 0x740dc
ucomiss %xmm1, %xmm0
jne 0x578a7
jp 0x578a7
movss -0xac(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0xac(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x1e1bc(%rip), %xmm2    # 0x75a80
mulsd %xmm2, %xmm1
movsd 0x1e1b8(%rip), %xmm2    # 0x75a88
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x14(%rbp)
movq -0x28(%rbp), %rdi
callq 0x39ad0
movq %rax, -0x3c8(%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, -0x3bc(%rbp)
testq %rax, %rax
movss %xmm0, -0x3b8(%rbp)
js 0x5793d
movss -0x3bc(%rbp), %xmm0
movss %xmm0, -0x3b8(%rbp)
movss -0x3b8(%rbp), %xmm0
cvtsi2ssl -0x38(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3d0(%rbp)
movss -0xac(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3e8(%rbp)
movss -0x14(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3e0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x39b60
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x3d8(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0xa8(%rbp), %rdi
callq 0x4b50
movq -0x3c8(%rbp), %rsi
movsd -0x3e8(%rbp), %xmm1
movsd -0x3e0(%rbp), %xmm2
movsd -0x3d8(%rbp), %xmm3
movaps %xmm0, %xmm4
movsd -0x3d0(%rbp), %xmm0
cvtss2sd %xmm4, %xmm4
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdx
leaq 0x1e034(%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 0x57a54
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 -0x1b0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl -0x44(%rbp), %r8d
leaq 0x1df80(%rip), %rsi     # 0x759bd
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x41980
movq -0x28(%rbp), %rdi
callq 0x39ad0
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x57a9a
leaq -0x2b0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1df4b(%rip), %rsi     # 0x759ce
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x41980
jmp 0x577fe
leaq -0x3b0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1dfa0(%rip), %rsi     # 0x75a55
movb $0x0, %al
callq 0x33f0
movq -0x28(%rbp), %rdi
leaq -0x3b0(%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 $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nopl (%rax)