// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/darknet.c
// Function: average
void average(int argc, char *argv[])
{
    char *cfgfile = argv[2];
    char *outfile = argv[3];
    gpu_index = -1;
    network *net = parse_network_cfg(cfgfile);
    network *sum = parse_network_cfg(cfgfile);

    char *weightfile = argv[4];   
    load_weights(sum, weightfile);

    int i, j;
    int n = argc - 5;
    for(i = 0; i < n; ++i){
        weightfile = argv[i+5];   
        load_weights(net, weightfile);
        for(j = 0; j < net->n; ++j){
            layer l = net->layers[j];
            layer out = sum->layers[j];
            if(l.type == CONVOLUTIONAL){
                int num = l.n*l.c*l.size*l.size;
                axpy_cpu(l.n, 1, l.biases, 1, out.biases, 1);
                axpy_cpu(num, 1, l.weights, 1, out.weights, 1);
                if(l.batch_normalize){
                    axpy_cpu(l.n, 1, l.scales, 1, out.scales, 1);
                    axpy_cpu(l.n, 1, l.rolling_mean, 1, out.rolling_mean, 1);
                    axpy_cpu(l.n, 1, l.rolling_variance, 1, out.rolling_variance, 1);
                }
            }
            if(l.type == CONNECTED){
                axpy_cpu(l.outputs, 1, l.biases, 1, out.biases, 1);
                axpy_cpu(l.outputs*l.inputs, 1, l.weights, 1, out.weights, 1);
            }
        }
    }
    n = n+1;
    for(j = 0; j < net->n; ++j){
        layer l = sum->layers[j];
        if(l.type == CONVOLUTIONAL){
            int num = l.n*l.c*l.size*l.size;
            scal_cpu(l.n, 1./n, l.biases, 1);
            scal_cpu(num, 1./n, l.weights, 1);
                if(l.batch_normalize){
                    scal_cpu(l.n, 1./n, l.scales, 1);
                    scal_cpu(l.n, 1./n, l.rolling_mean, 1);
                    scal_cpu(l.n, 1./n, l.rolling_variance, 1);
                }
        }
        if(l.type == CONNECTED){
            scal_cpu(l.outputs, 1./n, l.biases, 1);
            scal_cpu(l.outputs*l.inputs, 1./n, l.weights, 1);
        }
    }
    save_weights(sum, outfile);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe40, %rsp            # imm = 0xE40
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
leaq 0x1581f(%rip), %rax     # 0x83e40
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rdi
callq 0x400e0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x400e0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x42680
movl -0x4(%rbp), %eax
subl $0x5, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x6e88b
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x42680
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x6e87b
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x40(%rbp), %rax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x4e8(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x40(%rbp), %rax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x988(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
cmpl $0x0, -0x4e8(%rbp)
jne 0x6e807
movl -0x464(%rbp), %eax
imull -0x474(%rbp), %eax
imull -0x458(%rbp), %eax
imull -0x458(%rbp), %eax
movl %eax, -0x98c(%rbp)
movl -0x464(%rbp), %edi
movq -0x2b8(%rbp), %rsi
movq -0x758(%rbp), %rcx
movss 0x28c6(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
movl -0x98c(%rbp), %edi
movq -0x298(%rbp), %rsi
movq -0x738(%rbp), %rcx
movss 0x289c(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
cmpl $0x0, -0x4a8(%rbp)
je 0x6e805
movl -0x464(%rbp), %edi
movq -0x2a8(%rbp), %rsi
movq -0x748(%rbp), %rcx
movss 0x2869(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
movl -0x464(%rbp), %edi
movq -0x238(%rbp), %rsi
movq -0x6d8(%rbp), %rcx
movss 0x283f(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
movl -0x464(%rbp), %edi
movq -0x230(%rbp), %rsi
movq -0x6d0(%rbp), %rcx
movss 0x2815(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
jmp 0x6e807
cmpl $0x2, -0x4e8(%rbp)
jne 0x6e86b
movl -0x490(%rbp), %edi
movq -0x2b8(%rbp), %rsi
movq -0x758(%rbp), %rcx
movss 0x27e0(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
movl -0x490(%rbp), %edi
imull -0x494(%rbp), %edi
movq -0x298(%rbp), %rsi
movq -0x738(%rbp), %rcx
movss 0x27af(%rip), %xmm0     # 0x7100c
movl $0x1, %r8d
movl %r8d, %edx
callq 0x2f680
jmp 0x6e86d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x6e69f
jmp 0x6e87d
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6e66a
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x6ea62
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x40(%rbp), %rax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0xe30(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
cmpl $0x0, -0xe30(%rbp)
jne 0x6e9ea
movl -0xdac(%rbp), %eax
imull -0xdbc(%rbp), %eax
imull -0xda0(%rbp), %eax
imull -0xda0(%rbp), %eax
movl %eax, -0xe34(%rbp)
movl -0xdac(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x274e(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xc00(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
movl -0xe34(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x2722(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xbe0(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
cmpl $0x0, -0xdf0(%rbp)
je 0x6e9e8
movl -0xdac(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x26e9(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xbf0(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
movl -0xdac(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x26bd(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xb80(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
movl -0xdac(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x2691(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xb78(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
jmp 0x6e9ea
cmpl $0x2, -0xe30(%rbp)
jne 0x6ea52
movl -0xdd8(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x265a(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xc00(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
movl -0xdd8(%rbp), %edi
imull -0xddc(%rbp), %edi
cvtsi2sdl -0x44(%rbp), %xmm1
movsd 0x2627(%rip), %xmm0     # 0x71060
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0xbe0(%rbp), %rsi
movl $0x1, %edx
callq 0x2f6f0
jmp 0x6ea54
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x6e89b
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x41980
addq $0xe40, %rsp            # imm = 0xE40
popq %rbp
retq
nopl (%rax,%rax)