// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/parser.c
// Function: load_weights_upto
void load_weights_upto(network *net, char *filename, int start, int cutoff)
{
    fprintf(stderr, "Loading weights from %s...", filename);
    fflush(stdout);
    FILE *fp = fopen(filename, "rb");
    if(!fp) file_error(filename);

    int major;
    int minor;
    int revision;
    fread(&major, sizeof(int), 1, fp);
    fread(&minor, sizeof(int), 1, fp);
    fread(&revision, sizeof(int), 1, fp);
    if ((major*10 + minor) >= 2 && major < 1000 && minor < 1000){
        fread(net->seen, sizeof(size_t), 1, fp);
    } else {
        int iseen = 0;
        fread(&iseen, sizeof(int), 1, fp);
        *net->seen = iseen;
    }
    int transpose = (major > 1000) || (minor > 1000);

    int i;
    for(i = start; i < net->n && i < cutoff; ++i){
        layer l = net->layers[i];
        if (l.dontload) continue;
        if(l.type == CONVOLUTIONAL || l.type == DECONVOLUTIONAL){
            load_convolutional_weights(l, fp);
        }
        if(l.type == CONNECTED){
            load_connected_weights(l, fp, transpose);
        }
        if(l.type == BATCHNORM){
            load_batchnorm_weights(l, fp);
        }
        if(l.type == CRNN){
            load_convolutional_weights(*(l.input_layer), fp);
            load_convolutional_weights(*(l.self_layer), fp);
            load_convolutional_weights(*(l.output_layer), fp);
        }
        if(l.type == RNN){
            load_connected_weights(*(l.input_layer), fp, transpose);
            load_connected_weights(*(l.self_layer), fp, transpose);
            load_connected_weights(*(l.output_layer), fp, transpose);
        }
        if (l.type == LSTM) {
            load_connected_weights(*(l.wi), fp, transpose);
            load_connected_weights(*(l.wf), fp, transpose);
            load_connected_weights(*(l.wo), fp, transpose);
            load_connected_weights(*(l.wg), fp, transpose);
            load_connected_weights(*(l.ui), fp, transpose);
            load_connected_weights(*(l.uf), fp, transpose);
            load_connected_weights(*(l.uo), fp, transpose);
            load_connected_weights(*(l.ug), fp, transpose);
        }
        if (l.type == GRU) {
            if(1){
                load_connected_weights(*(l.wz), fp, transpose);
                load_connected_weights(*(l.wr), fp, transpose);
                load_connected_weights(*(l.wh), fp, transpose);
                load_connected_weights(*(l.uz), fp, transpose);
                load_connected_weights(*(l.ur), fp, transpose);
                load_connected_weights(*(l.uh), fp, transpose);
            }else{
                load_connected_weights(*(l.reset_layer), fp, transpose);
                load_connected_weights(*(l.update_layer), fp, transpose);
                load_connected_weights(*(l.state_layer), fp, transpose);
            }
        }
        if(l.type == LOCAL){
            int locations = l.out_w*l.out_h;
            int size = l.size*l.size*l.c*l.n*locations;
            fread(l.biases, sizeof(float), l.outputs, fp);
            fread(l.weights, sizeof(float), size, fp);
        }
    }
    fprintf(stderr, "Done!\n");
    fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4f8, %rsp            # imm = 0x4F8
movl %ecx, 0x4b0(%rsp)
movl %edx, 0x4b8(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movq 0x3b05a(%rip), %rax     # 0x63ff8
movq (%rax), %rdi
leaq 0x2776f(%rip), %rsi     # 0x50717
movq %r13, %rdx
xorl %eax, %eax
callq 0x3270
movq 0x3b017(%rip), %rax     # 0x63fd0
movq (%rax), %rdi
callq 0x3310
leaq 0x230e8(%rip), %rsi     # 0x4c0b0
movq %r13, %rdi
callq 0x3390
movq %rax, 0x4a0(%rsp)
testq %rax, %rax
jne 0x28fe5
movq %r13, %rdi
callq 0x3d0f
leaq 0x4f4(%rsp), %r13
pushq $0x4
popq %rbp
pushq $0x1
popq %r15
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq 0x4a0(%rsp), %r14
movq %r14, %rcx
callq 0x30d0
leaq 0x4f0(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30d0
leaq 0x4ec(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x30d0
movl (%r13), %r14d
movl (%r12), %ebp
cmpl $0x3e7, %ebp            # imm = 0x3E7
jg 0x29079
cmpl $0x3e7, %r14d           # imm = 0x3E7
jg 0x29079
imull $0xa, %r14d, %eax
addl %ebp, %eax
cmpl $0x2, %eax
jl 0x29079
movq 0x8(%rbx), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq 0x4a0(%rsp), %rcx
callq 0x30d0
jmp 0x290a5
leaq 0x4e8(%rsp), %r15
andl $0x0, (%r15)
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq 0x4a0(%rsp), %rcx
callq 0x30d0
movslq (%r15), %rax
movq 0x8(%rbx), %rcx
movq %rax, (%rcx)
movl $0x3e9, %eax            # imm = 0x3E9
cmpl %eax, %r14d
setge %cl
cmpl %eax, %ebp
setge %al
orb %cl, %al
movzbl %al, %eax
movl %eax, 0x4ac(%rsp)
movslq 0x4b8(%rsp), %r13
movslq 0x4b0(%rsp), %rbp
imulq $0x4a0, %r13, %r14      # imm = 0x4A0
cmpq %rbp, %r13
jge 0x29555
movslq (%rbx), %rax
cmpq %rax, %r13
jge 0x29555
movq 0x20(%rbx), %rcx
cmpl $0x0, 0x17c(%rcx,%r14)
jne 0x294f7
leaq (%rcx,%r14), %rsi
movl (%rcx,%r14), %eax
cmpl $0x1, %eax
ja 0x2912a
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %rdi
callq 0x28e72
jmp 0x294f7
leal -0xc(%rax), %edx
cmpl $0x7, %edx
ja 0x291d4
movq 0x390(%rcx,%r14), %rax
movq 0x398(%rcx,%r14), %r12
movq 0x3a0(%rcx,%r14), %r15
leaq 0x26e17(%rip), %rdi     # 0x4ff6c
movslq (%rdi,%rdx,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movslq 0x58(%rcx,%r14), %rdx
movl 0x7c(%rcx,%r14), %eax
movl 0x84(%rcx,%r14), %r12d
movl 0x90(%rcx,%r14), %esi
movq 0x230(%rcx,%r14), %rdi
movq 0x250(%rcx,%r14), %r8
movq %r8, 0x4b0(%rsp)
imull 0x78(%rcx,%r14), %eax
imull %esi, %esi
imull %eax, %esi
imull 0x74(%rcx,%r14), %r12d
imull %esi, %r12d
pushq $0x4
popq %rsi
movq 0x4a0(%rsp), %r15
movq %r15, %rcx
callq 0x30d0
movslq %r12d, %rdx
movq 0x4b0(%rsp), %rdi
pushq $0x4
popq %rsi
movq %r15, %rcx
callq 0x30d0
jmp 0x294f7
cmpl $0x2, %eax
jne 0x294f7
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %rdi
jmp 0x294eb
movq 0x420(%rcx,%r14), %rsi
movq 0x428(%rcx,%r14), %rax
movq %rax, 0x4d0(%rsp)
movq 0x430(%rcx,%r14), %rax
movq %rax, 0x4c0(%rsp)
movq 0x438(%rcx,%r14), %rax
movq %rax, 0x4b8(%rsp)
movq 0x440(%rcx,%r14), %rax
movq %rax, 0x4c8(%rsp)
movq 0x448(%rcx,%r14), %rax
movq %rax, 0x4b0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %r12
movq %r12, %rdi
movl 0x4ac(%rsp), %r15d
movl %r15d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl %r15d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl %r15d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl %r15d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl %r15d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl %r15d, %esi
jmp 0x294f2
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %rdi
callq 0x28c66
jmp 0x294f7
movq 0x450(%rcx,%r14), %rax
movq %rax, 0x4b8(%rsp)
movq 0x458(%rcx,%r14), %rax
movq %rax, 0x4e0(%rsp)
movq 0x460(%rcx,%r14), %rax
movq %rax, 0x4d0(%rsp)
movq 0x468(%rcx,%r14), %rax
movq %rax, 0x4d8(%rsp)
movq 0x470(%rcx,%r14), %rax
movq %rax, 0x4c8(%rsp)
movq 0x478(%rcx,%r14), %rsi
movq 0x480(%rcx,%r14), %rax
movq %rax, 0x4b0(%rsp)
movq 0x488(%rcx,%r14), %rax
movq %rax, 0x4c0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %r15
movq %r15, %rdi
movl 0x4ac(%rsp), %r12d
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4e0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r12d, %esi
jmp 0x294f2
movl $0x94, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %rdi
movl 0x4ac(%rsp), %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %r12
movq %r12, %rdi
movl 0x4ac(%rsp), %esi
callq 0x28b95
movl $0x94, %ecx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movl 0x4ac(%rsp), %esi
callq 0x28b95
incq %r13
addq $0x4a0, %r14            # imm = 0x4A0
jmp 0x290d8
movl $0x94, %ecx
movq %rsp, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %rdi
callq 0x28e72
movl $0x94, %ecx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a0(%rsp), %r12
movq %r12, %rdi
callq 0x28e72
movl $0x94, %ecx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
jmp 0x29120
movq 0x3aa9c(%rip), %rax     # 0x63ff8
movq (%rax), %rcx
leaq 0x271cc(%rip), %rdi     # 0x50732
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movq 0x4a0(%rsp), %rdi
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130