// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/tag.c
// Function: train_tag
void train_tag(char *cfgfile, char *weightfile, int clear)
{
    srand(time(0));
    float avg_loss = -1;
    char *base = basecfg(cfgfile);
    char *backup_directory = "/home/pjreddie/backup/";
    printf("%s\n", base);
    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 = 1024;
    list *plist = get_paths("/home/pjreddie/tag/train.list");
    char **paths = (char **)list_to_array(plist);
    printf("%d\n", plist->size);
    int N = plist->size;
    clock_t time;
    pthread_t load_thread;
    data train;
    data buffer;

    load_args args = {0};
    args.w = net->w;
    args.h = net->h;

    args.min = net->w;
    args.max = net->max_crop;
    args.size = net->w;

    args.paths = paths;
    args.classes = net->outputs;
    args.n = imgs;
    args.m = N;
    args.d = &buffer;
    args.type = TAG_DATA;

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

    fprintf(stderr, "%d classes\n", net->outputs);

    load_thread = load_data_in_thread(args);
    int epoch = (*net->seen)/N;
    while(get_current_batch(net) < net->max_batches || net->max_batches == 0){
        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 == -1) avg_loss = loss;
        avg_loss = avg_loss*.9 + loss*.1;
        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);
        free_data(train);
        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);

    pthread_join(load_thread, 0);
    free_data(buffer);
    free_network(net);
    free_ptrs((void**)paths, plist->size);
    free_list(plist);
    free(base);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x570, %rsp            # imm = 0x570
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3290
movl %eax, %edi
callq 0x31e0
movss 0x1d81e(%rip), %xmm0    # 0x740dc
movss %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4850
movq %rax, -0x20(%rbp)
leaq 0x1f09e(%rip), %rax     # 0x75975
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rsi
leaq 0x1dab7(%rip), %rdi     # 0x7439d
movb $0x0, %al
callq 0x3130
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x39a70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x30(%rbp), %rax
movss 0x38(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x30(%rbp), %rax
movss 0x3c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
leaq 0x1ee39(%rip), %rdi     # 0x75768
movb $0x3, %al
callq 0x3130
movl $0x400, -0x34(%rbp)     # imm = 0x400
leaq 0x1f0ae(%rip), %rdi     # 0x759f2
callq 0x31450
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x9020
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movl (%rax), %esi
leaq 0x1c80f(%rip), %rdi     # 0x73176
movb $0x0, %al
callq 0x3130
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
leaq -0x188(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x3190
movq -0x30(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x15c(%rbp)
movq -0x30(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x160(%rbp)
movq -0x30(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x144(%rbp)
movq -0x30(%rbp), %rax
movl 0x9c(%rax), %eax
movl %eax, -0x140(%rbp)
movq -0x30(%rbp), %rax
movl 0x94(%rax), %eax
movl %eax, -0x13c(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x30(%rbp), %rax
movl 0x84(%rax), %eax
movl %eax, -0x138(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x170(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x16c(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0x108(%rbp)
movl $0x8, -0xf0(%rbp)
movq -0x30(%rbp), %rax
movss 0xb0(%rax), %xmm0
movss %xmm0, -0x120(%rbp)
movq -0x30(%rbp), %rax
movss 0xb8(%rax), %xmm0
movss %xmm0, -0x114(%rbp)
movq -0x30(%rbp), %rax
movss 0xbc(%rax), %xmm0
movss %xmm0, -0x118(%rbp)
movq -0x30(%rbp), %rax
movss 0xc0(%rax), %xmm0
movss %xmm0, -0x110(%rbp)
movq 0x2c582(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x84(%rax), %edx
leaq 0x1ef86(%rip), %rsi     # 0x75a10
movb $0x0, %al
callq 0x3240
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x188(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x4c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x18c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x39ad0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movslq 0x54(%rax), %rdx
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x491(%rbp)
jb 0x56af8
movq -0x30(%rbp), %rax
cmpl $0x0, 0x54(%rax)
sete %al
movb %al, -0x491(%rbp)
movb -0x491(%rbp), %al
testb $0x1, %al
jne 0x56b07
jmp 0x56e01
callq 0x30f0
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
leaq -0xa0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
movl $0x40, %edx
callq 0x3280
movq %rsp, %rdi
movl $0x15, %ecx
leaq -0x188(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x37500
movq %rax, -0x60(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x58(%rbp), %rdi
callq 0x4b50
cvtss2sd %xmm0, %xmm0
leaq 0x1ec88(%rip), %rdi     # 0x757f4
movb $0x1, %al
callq 0x3130
callq 0x30f0
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movups -0xa0(%rbp), %xmm0
movups -0x90(%rbp), %xmm1
movups -0x80(%rbp), %xmm2
movups -0x70(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x3a860
movss %xmm0, -0x190(%rbp)
movss -0x18(%rbp), %xmm0
movss 0x1d51a(%rip), %xmm1    # 0x740dc
ucomiss %xmm1, %xmm0
jne 0x56bd6
jp 0x56bd6
movss -0x190(%rbp), %xmm0
movss %xmm0, -0x18(%rbp)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x190(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movsd 0x1d4c5(%rip), %xmm2    # 0x740b8
mulsd %xmm2, %xmm1
movsd 0x1eb61(%rip), %xmm2    # 0x75760
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
movq -0x30(%rbp), %rdi
callq 0x39ad0
movq %rax, -0x4a8(%rbp)
movq -0x30(%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, -0x49c(%rbp)
testq %rax, %rax
movss %xmm0, -0x498(%rbp)
js 0x56c6c
movss -0x49c(%rbp), %xmm0
movss %xmm0, -0x498(%rbp)
movss -0x498(%rbp), %xmm0
cvtsi2ssl -0x4c(%rbp), %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4b0(%rbp)
movss -0x190(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4c8(%rbp)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4c0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x39b60
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x4b8(%rbp)
callq 0x30f0
movq %rax, %rdi
subq -0x58(%rbp), %rdi
callq 0x4b50
movq -0x4a8(%rbp), %rsi
movsd -0x4c8(%rbp), %xmm1
movsd -0x4c0(%rbp), %xmm2
movsd -0x4b8(%rbp), %xmm3
movaps %xmm0, %xmm4
movsd -0x4b0(%rbp), %xmm0
cvtss2sd %xmm4, %xmm4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdx
leaq 0x1ed08(%rip), %rdi     # 0x75a1c
movb $0x5, %al
callq 0x3130
movups -0xa0(%rbp), %xmm0
movups -0x90(%rbp), %xmm1
movups -0x80(%rbp), %xmm2
movups -0x70(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x34400
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x4c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movslq -0x18c(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x56db6
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movslq -0x4c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x18c(%rbp)
leaq -0x290(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl -0x18c(%rbp), %r8d
leaq 0x1ec1e(%rip), %rsi     # 0x759bd
movb $0x0, %al
callq 0x33f0
movq -0x30(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x41980
movq -0x30(%rbp), %rdi
callq 0x39ad0
movl $0x64, %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x56dfc
leaq -0x390(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1ebe9(%rip), %rsi     # 0x759ce
movb $0x0, %al
callq 0x33f0
movq -0x30(%rbp), %rdi
leaq -0x390(%rbp), %rsi
callq 0x41980
jmp 0x56ac6
leaq -0x490(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x1ec3e(%rip), %rsi     # 0x75a55
movb $0x0, %al
callq 0x33f0
movq -0x30(%rbp), %rdi
leaq -0x490(%rbp), %rsi
callq 0x41980
movq -0x60(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3440
movups -0xe0(%rbp), %xmm0
movups -0xd0(%rbp), %xmm1
movups -0xc0(%rbp), %xmm2
movups -0xb0(%rbp), %xmm3
movq %rsp, %rax
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x34400
movq -0x30(%rbp), %rdi
callq 0x3c0b0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
movl (%rax), %esi
callq 0x4f40
movq -0x40(%rbp), %rdi
callq 0x8fb0
movq -0x20(%rbp), %rdi
callq 0x3030
addq $0x570, %rsp            # imm = 0x570
popq %rbp
retq
nopw %cs:(%rax,%rax)