// File: /workspace/github_c_makefile_star2_O3/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, 0x4a0(%rsp)
movl %edx, 0x4b8(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movq 0x6574c(%rip), %rax     # 0x6bff8
movq (%rax), %rdi
leaq 0x52f11(%rip), %rsi     # 0x597c7
movq %r13, %rdx
xorl %eax, %eax
callq 0x3270
movq 0x65709(%rip), %rax     # 0x6bfd0
movq (%rax), %rdi
callq 0x3310
leaq 0x4e802(%rip), %rsi     # 0x550d8
movq %r13, %rdi
callq 0x3390
movq %rax, 0x4a8(%rsp)
testq %rax, %rax
jne 0x68f3
movq %r13, %rdi
callq 0xe925
leaq 0x4f4(%rsp), %r13
pushq $0x4
popq %rbp
pushq $0x1
popq %r15
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq 0x4a8(%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 0x6987
cmpl $0x3e7, %r14d           # imm = 0x3E7
jg 0x6987
imull $0xa, %r14d, %eax
addl %ebp, %eax
cmpl $0x2, %eax
jl 0x6987
movq 0x8(%rbx), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq 0x4a8(%rsp), %rcx
callq 0x30d0
jmp 0x69b3
leaq 0x4e8(%rsp), %r15
andl $0x0, (%r15)
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
movq 0x4a8(%rsp), %rcx
callq 0x30d0
movslq (%r15), %rax
movq 0x8(%rbx), %rcx
movq %rax, (%rcx)
movl $0x3e9, %ecx            # imm = 0x3E9
cmpl %ecx, %r14d
setge %al
cmpl %ecx, %ebp
setge %cl
movl 0x4a0(%rsp), %edx
movl 0x4b8(%rsp), %esi
cmpl %edx, %esi
jge 0x6eb1
cmpl %esi, (%rbx)
jle 0x6eb1
orb %cl, %al
movzbl %al, %eax
movl %eax, 0x4b4(%rsp)
movslq %esi, %r14
movslq %edx, %rbp
imulq $0x4a0, %r14, %r12      # imm = 0x4A0
incq %r14
movq 0x20(%rbx), %rax
cmpl $0x0, 0x17c(%rax,%r12)
jne 0x6e3c
leaq (%rax,%r12), %rsi
movl (%rax,%r12), %ecx
cmpl $0x1, %ecx
ja 0x6a3a
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %rdi
callq 0x36ba9
jmp 0x6e3c
leal -0xc(%rcx), %edx
cmpl $0x7, %edx
ja 0x6adc
movslq 0x74(%rax,%r12), %r15
movq 0x390(%rax,%r12), %rsi
movq 0x398(%rax,%r12), %r13
movq 0x3a0(%rax,%r12), %r8
leaq 0x525b2(%rip), %rdi     # 0x5901c
movslq (%rdi,%rdx,4), %rcx
addq %rdi, %rcx
jmpq *%rcx
movslq 0x58(%rax,%r12), %rdx
movl 0x7c(%rax,%r12), %ecx
movl 0x90(%rax,%r12), %esi
movq 0x230(%rax,%r12), %rdi
movq 0x250(%rax,%r12), %r8
movq %r8, 0x4a0(%rsp)
imull 0x78(%rax,%r12), %ecx
imull %esi, %esi
imull %ecx, %esi
imull 0x84(%rax,%r12), %r15d
imull %esi, %r15d
pushq $0x4
popq %rsi
movq 0x4a8(%rsp), %r13
movq %r13, %rcx
callq 0x30d0
movslq %r15d, %rdx
movq 0x4a0(%rsp), %rdi
pushq $0x4
popq %rsi
jmp 0x6c7a
cmpl $0x2, %ecx
jne 0x6e3c
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %rdi
movl 0x4b4(%rsp), %esi
jmp 0x6e37
movq 0x420(%rax,%r12), %rsi
movq 0x428(%rax,%r12), %rcx
movq %rcx, 0x4d0(%rsp)
movq 0x430(%rax,%r12), %rcx
movq %rcx, 0x4c0(%rsp)
movq 0x438(%rax,%r12), %rcx
movq %rcx, 0x4b8(%rsp)
movq 0x440(%rax,%r12), %rcx
movq %rcx, 0x4c8(%rsp)
movq 0x448(%rax,%r12), %rax
movq %rax, 0x4a0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %r13
movq %r13, %rdi
movl 0x4b4(%rsp), %r15d
movl %r15d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movl %r15d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movl %r15d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movl %r15d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movl %r15d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4a0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movl %r15d, %esi
jmp 0x6e37
movq 0x240(%rax,%r12), %rdi
movq 0x2b0(%rax,%r12), %rcx
movq %rcx, 0x4b8(%rsp)
movq 0x2b8(%rax,%r12), %rax
movq %rax, 0x4a0(%rsp)
pushq $0x4
popq %rsi
movq %r15, %rdx
movq 0x4a8(%rsp), %r13
movq %r13, %rcx
callq 0x30d0
movq 0x4b8(%rsp), %rdi
pushq $0x4
popq %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x30d0
movq 0x4a0(%rsp), %rdi
pushq $0x4
popq %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x30d0
jmp 0x6e3c
movq 0x450(%rax,%r12), %rcx
movq %rcx, 0x4b8(%rsp)
movq 0x458(%rax,%r12), %rcx
movq %rcx, 0x4e0(%rsp)
movq 0x460(%rax,%r12), %rcx
movq %rcx, 0x4d0(%rsp)
movq 0x468(%rax,%r12), %rcx
movq %rcx, 0x4d8(%rsp)
movq 0x470(%rax,%r12), %rcx
movq %rcx, 0x4c8(%rsp)
movq 0x478(%rax,%r12), %rsi
movq 0x480(%rax,%r12), %rcx
movq %rcx, 0x4a0(%rsp)
movq 0x488(%rax,%r12), %rax
movq %rax, 0x4c0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %r15
movq %r15, %rdi
movl 0x4b4(%rsp), %r13d
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4e0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4c8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4d0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4b8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
jmp 0x6e16
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %r15
movq %r15, %rdi
movl 0x4b4(%rsp), %esi
movq %r8, 0x4a0(%rsp)
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl 0x4b4(%rsp), %r13d
movl %r13d, %esi
callq 0x3672a
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4a0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
movl %r13d, %esi
callq 0x3672a
cmpq %rbp, %r14
jge 0x6eb1
movslq (%rbx), %rax
addq $0x4a0, %r12            # imm = 0x4A0
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jl 0x69fd
jmp 0x6eb1
movl $0x94, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x4a8(%rsp), %r15
movq %r15, %rdi
movq %r8, 0x4a0(%rsp)
callq 0x36ba9
movl $0x94, %ecx
movq %rsp, %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
callq 0x36ba9
movl $0x94, %ecx
movq %rsp, %rdi
movq 0x4a0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, %rdi
jmp 0x6a30
movq 0x65140(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x52920(%rip), %rdi     # 0x597e2
pushq $0x6
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movq 0x4a8(%rsp), %rdi
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130