// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/parser.c
// Function: save_weights_upto
void save_weights_upto(network *net, char *filename, int cutoff)
{
    fprintf(stderr, "Saving weights to %s\n", filename);
    FILE *fp = fopen(filename, "wb");
    if(!fp) file_error(filename);

    int major = 0;
    int minor = 2;
    int revision = 0;
    fwrite(&major, sizeof(int), 1, fp);
    fwrite(&minor, sizeof(int), 1, fp);
    fwrite(&revision, sizeof(int), 1, fp);
    fwrite(net->seen, sizeof(size_t), 1, fp);

    int i;
    for(i = 0; i < net->n && i < cutoff; ++i){
        layer l = net->layers[i];
        if (l.dontsave) continue;
        if(l.type == CONVOLUTIONAL || l.type == DECONVOLUTIONAL){
            save_convolutional_weights(l, fp);
        } if(l.type == CONNECTED){
            save_connected_weights(l, fp);
        } if(l.type == BATCHNORM){
            save_batchnorm_weights(l, fp);
        } if(l.type == RNN){
            save_connected_weights(*(l.input_layer), fp);
            save_connected_weights(*(l.self_layer), fp);
            save_connected_weights(*(l.output_layer), fp);
        } if (l.type == LSTM) {
            save_connected_weights(*(l.wi), fp);
            save_connected_weights(*(l.wf), fp);
            save_connected_weights(*(l.wo), fp);
            save_connected_weights(*(l.wg), fp);
            save_connected_weights(*(l.ui), fp);
            save_connected_weights(*(l.uf), fp);
            save_connected_weights(*(l.uo), fp);
            save_connected_weights(*(l.ug), fp);
        } if (l.type == GRU) {
            if(1){
                save_connected_weights(*(l.wz), fp);
                save_connected_weights(*(l.wr), fp);
                save_connected_weights(*(l.wh), fp);
                save_connected_weights(*(l.uz), fp);
                save_connected_weights(*(l.ur), fp);
                save_connected_weights(*(l.uh), fp);
            }else{
                save_connected_weights(*(l.reset_layer), fp);
                save_connected_weights(*(l.update_layer), fp);
                save_connected_weights(*(l.state_layer), fp);
            }
        }  if(l.type == CRNN){
            save_convolutional_weights(*(l.input_layer), fp);
            save_convolutional_weights(*(l.self_layer), fp);
            save_convolutional_weights(*(l.output_layer), fp);
        } if(l.type == LOCAL){
            int locations = l.out_w*l.out_h;
            int size = l.size*l.size*l.c*l.n*locations;
            fwrite(l.biases, sizeof(float), l.outputs, fp);
            fwrite(l.weights, sizeof(float), size, fp);
        }
    }
    fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x968, %rsp            # imm = 0x968
movl %edx, 0x4a0(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x63d95(%rip), %rax     # 0x69ff8
movq (%rax), %rdi
leaq 0x51444(%rip), %rsi     # 0x576b1
movq %r15, %rdx
xorl %eax, %eax
callq 0x3280
leaq 0x4f414(%rip), %rsi     # 0x55692
movq %r15, %rdi
callq 0x33a0
movq %rax, %r14
testq %rax, %rax
jne 0x6296
movq %r15, %rdi
callq 0xe142
leaq 0x4c4(%rsp), %rdi
andl $0x0, (%rdi)
leaq 0x4c0(%rsp), %r12
movl $0x2, (%r12)
leaq 0x4bc(%rsp), %r13
andl $0x0, (%r13)
pushq $0x4
popq %rbp
pushq $0x1
popq %r15
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3450
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3450
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3450
movq 0x8(%rbx), %rdi
pushq $0x8
popq %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x3450
movl 0x4a0(%rsp), %eax
testl %eax, %eax
jle 0x66b4
cmpl $0x0, (%rbx)
jle 0x66b4
movl %eax, %r12d
xorl %r13d, %r13d
movq %rbx, 0x4a8(%rsp)
movq 0x20(%rbx), %rbp
addq %r13, %rbp
movl $0x4a0, %edx            # imm = 0x4A0
leaq 0x4c8(%rsp), %rdi
movq %rbp, %rsi
callq 0x32c0
cmpl $0x0, 0x648(%rsp)
jne 0x6695
movq %r12, %rbx
movl 0x4c8(%rsp), %r12d
cmpl $0x1, %r12d
ja 0x637e
movl $0x94, %ecx
movq %rsp, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34532
leal -0xc(%r12), %eax
cmpl $0x7, %eax
ja 0x63fd
leaq 0x50b6d(%rip), %rcx     # 0x56efc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rbx, %r12
movq 0x4a8(%rsp), %rbx
jmpq *%rax
movl 0x540(%rsp), %eax
movl 0x558(%rsp), %ebp
imull 0x544(%rsp), %eax
imull %ebp, %ebp
imull %eax, %ebp
imull 0x53c(%rsp), %ebp
imull 0x54c(%rsp), %ebp
movq 0x6f8(%rsp), %rdi
movslq 0x520(%rsp), %rdx
pushq $0x4
popq %rsi
movq %r14, %rcx
callq 0x3450
movq 0x718(%rsp), %rdi
movslq %ebp, %rdx
pushq $0x4
popq %rsi
jmp 0x651d
cmpl $0x2, %r12d
movq %rbx, %r12
movq 0x4a8(%rsp), %rbx
jne 0x6695
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x4c8(%rsp), %rsi
jmp 0x6637
movq 0x8e8(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x8f8(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x908(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x8f0(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x900(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x910(%rsp), %rsi
jmp 0x662f
movslq 0x53c(%rsp), %rbp
movq 0x708(%rsp), %rdi
movq 0x778(%rsp), %rax
movq %rax, 0x4b0(%rsp)
movq 0x780(%rsp), %rax
movq %rax, 0x4a0(%rsp)
pushq $0x4
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x3450
movq 0x4b0(%rsp), %rdi
pushq $0x4
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x3450
movq 0x4a0(%rsp), %rdi
pushq $0x4
popq %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x3450
jmp 0x6695
movq 0x940(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x930(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x920(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x950(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x938(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x928(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x918(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x948(%rsp), %rsi
jmp 0x662f
movq 0x858(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x860(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
movq 0x868(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34638
jmp 0x6695
movq 0x858(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34532
movq 0x860(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34532
movq 0x868(%rsp), %rsi
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x34532
cmpq %r12, %r15
jae 0x66b4
movslq (%rbx), %rax
addq $0x4a0, %r13            # imm = 0x4A0
leaq 0x1(%r15), %rcx
cmpq %rax, %r15
movq %rcx, %r15
jl 0x632d
movq %r14, %rdi
addq $0x968, %rsp            # imm = 0x968
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3140