// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/break.c
// Function: calc_moving_average
static void calc_moving_average(int64_t *arr, int32_t n, int32_t a)
{
    int i, pos, a1, a2;
    if (n < a) {
        a = n;
    }
    a1 = a >> 1;
    a2 = ~a & 1;

    int64_t *buff = (int64_t *) malloc(a * sizeof(int64_t));
    int64_t sum = 0;
    for (i = 0; i < a; ++i) {
        buff[i] = arr[i];
        sum += buff[i];
        if (i >= a1)
            arr[i - a1] = sum / (i + 1);
    }
    pos = 0;

    for (i = a1; i < n - a1 + a2; ++i) {
        arr[i] = sum / a;
        if (i < n - a + a1) {
            sum -= buff[pos];
            buff[pos] = arr[i + a - a1];
            sum += buff[pos];
            if (++pos == a)
                pos = 0;
        }
    }

    for (i = n - a1 + a2; i < n; ++i) {
        sum -= buff[pos];
        arr[i] = sum / (a1 + n - i);
        if (++pos == a)
            pos = 0;
    }

    free(buff);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5070
movl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
sarl %eax
movl %eax, -0x1c(%rbp)
movl -0x10(%rbp), %eax
xorl $-0x1, %eax
andl $0x1, %eax
movl %eax, -0x20(%rbp)
movslq -0x10(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2340
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x5113
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jl 0x5106
movq -0x30(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
subl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x5108
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x50a4
movl $0x0, -0x18(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
subl -0x1c(%rbp), %ecx
addl -0x20(%rbp), %ecx
cmpl %ecx, %eax
jge 0x51d2
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
cqto
idivq %rcx
movq %rax, %rdx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
movl -0xc(%rbp), %ecx
subl -0x10(%rbp), %ecx
addl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x51c2
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
addl -0x10(%rbp), %ecx
subl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl -0x10(%rbp), %eax
jne 0x51c0
movl $0x0, -0x18(%rbp)
jmp 0x51c2
jmp 0x51c4
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5120
movl -0xc(%rbp), %eax
subl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x5243
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl -0xc(%rbp), %ecx
subl -0x14(%rbp), %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rax, %rdx
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl -0x10(%rbp), %eax
jne 0x5236
movl $0x0, -0x18(%rbp)
jmp 0x5238
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x51de
movq -0x28(%rbp), %rdi
callq 0x2050
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)