double AcceptationAverage(int item) {
  static int AcceptationVector[1000] = {0};
  static int front = -1, rear = -1;
  static int Sum = 0;
  if (front == (rear + 1) % 1000) {
    Sum -= AcceptationVector[front];
    if (front == rear)
      front = rear = -1;
    else
      front = (front + 1) % 1000;
  }
  if (front == -1)
    front = rear = 0;
  else
    rear = (rear + 1) % 1000;
  AcceptationVector[rear] = item;
  Sum += AcceptationVector[rear];
  return ((double)Sum / 1000);
}


x86 assembly (clang, -O0):
<AcceptationAverage>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    0x2f13(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0x2f0e(%rip),%eax
add    $0x1,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%eax
cmp    %edx,%eax
jne    1192 <AcceptationAverage+0x92>
movslq 0x2eed(%rip),%rcx
lea    0x2f06(%rip),%rax
mov    (%rax,%rcx,4),%ecx
mov    0x3e9d(%rip),%eax
sub    %ecx,%eax
mov    %eax,0x3e95(%rip)
mov    0x2ecf(%rip),%eax
cmp    0x2ecd(%rip),%eax
jne    1176 <AcceptationAverage+0x76>
movl   $0xffffffff,0x2ebd(%rip)
ff ff ff
movl   $0xffffffff,0x2eaf(%rip)
ff ff ff
jmp    118d <AcceptationAverage+0x8d>
mov    0x2ea4(%rip),%eax
add    $0x1,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,0x2e93(%rip)
jmp    1192 <AcceptationAverage+0x92>
cmpl   $0xffffffff,0x2e87(%rip)
jne    11b8 <AcceptationAverage+0xb8>
movl   $0x0,0x2e7b(%rip)
movl   $0x0,0x2e6d(%rip)
jmp    11cf <AcceptationAverage+0xcf>
mov    0x2e66(%rip),%eax
add    $0x1,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,0x2e55(%rip)
mov    -0x4(%rbp),%edx
movslq 0x2e4b(%rip),%rcx
lea    0x2e60(%rip),%rax
mov    %edx,(%rax,%rcx,4)
movslq 0x2e3a(%rip),%rcx
lea    0x2e4f(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    0x3de6(%rip),%eax
mov    %eax,0x3de0(%rip)
cvtsi2sdl 0x3dd8(%rip),%xmm0
movsd  0xdf0(%rip),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<AcceptationAverage>:
mov    0x2f1a(%rip),%eax
mov    0x2f18(%rip),%edx
lea    0x1(%rdx),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rcx
add    %esi,%ecx
imul   $0x3e8,%ecx,%ecx
neg    %ecx
add    %edx,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1176 <AcceptationAverage+0x76>
movslq %eax,%r8
lea    0x2eff(%rip),%rsi
mov    (%rsi,%r8,4),%esi
sub    %esi,0x3e95(%rip)
cmp    %edx,%eax
je     1186 <AcceptationAverage+0x86>
add    $0x1,%eax
cltq
imul   $0x10624dd3,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
add    %esi,%edx
imul   $0x3e8,%edx,%edx
sub    %edx,%eax
mov    %eax,0x2eaa(%rip)
cmp    $0xffffffff,%eax
je     1186 <AcceptationAverage+0x86>
mov    %ecx,0x2ea3(%rip)
movslq %ecx,%rax
jmp    119c <AcceptationAverage+0x9c>
movl   $0x0,0x2e94(%rip)
movl   $0x0,0x2e86(%rip)
xor    %eax,%eax
lea    0x2e9d(%rip),%rcx
mov    %edi,(%rcx,%rax,4)
add    0x3e34(%rip),%edi
mov    %edi,0x3e2e(%rip)
cvtsi2sd %edi,%xmm0
divsd  0xe42(%rip),%xmm0
ret

LLVM IR (-O0):
@AcceptationAverage.AcceptationVector = internal global [1000 x i32] zeroinitializer
@AcceptationAverage.front = internal global i32 -1
@AcceptationAverage.rear = internal global i32 -1
@AcceptationAverage.Sum = internal global i32 0
define double @AcceptationAverage(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @AcceptationAverage.front
%4 = load i32, i32* @AcceptationAverage.rear
%5 = add nsw i32 %4, 1
%6 = srem i32 %5, 1000
%7 = icmp eq i32 %3, %6
br i1 %7, label %8, label %24
8: ; preds = %1
%9 = load i32, i32* @AcceptationAverage.front
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1000 x i32], [1000 x i32]* @AcceptationAverage.AcceptationVector, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = load i32, i32* @AcceptationAverage.Sum
%14 = sub nsw i32 %13, %12
store i32 %14, i32* @AcceptationAverage.Sum
%15 = load i32, i32* @AcceptationAverage.front
%16 = load i32, i32* @AcceptationAverage.rear
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %8
store i32 -1, i32* @AcceptationAverage.rear
store i32 -1, i32* @AcceptationAverage.front
br label %23
19: ; preds = %8
%20 = load i32, i32* @AcceptationAverage.front
%21 = add nsw i32 %20, 1
%22 = srem i32 %21, 1000
store i32 %22, i32* @AcceptationAverage.front
br label %23
23: ; preds = %19, %18
br label %24
24: ; preds = %23, %1
%25 = load i32, i32* @AcceptationAverage.front
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* @AcceptationAverage.rear
store i32 0, i32* @AcceptationAverage.front
br label %32
28: ; preds = %24
%29 = load i32, i32* @AcceptationAverage.rear
%30 = add nsw i32 %29, 1
%31 = srem i32 %30, 1000
store i32 %31, i32* @AcceptationAverage.rear
br label %32
32: ; preds = %28, %27
%33 = load i32, i32* %2
%34 = load i32, i32* @AcceptationAverage.rear
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1000 x i32], [1000 x i32]* @AcceptationAverage.AcceptationVector, i64 0, i64 %35
store i32 %33, i32* %36
%37 = load i32, i32* @AcceptationAverage.rear
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1000 x i32], [1000 x i32]* @AcceptationAverage.AcceptationVector, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* @AcceptationAverage.Sum
%42 = add nsw i32 %41, %40
store i32 %42, i32* @AcceptationAverage.Sum
%43 = load i32, i32* @AcceptationAverage.Sum
%44 = sitofp i32 %43 to double
%45 = fdiv double %44, 1.000000e+03
ret double %45
}

LLVM IR (-O2):
@AcceptationAverage.AcceptationVector = internal unnamed_addr global [1000 x i32] zeroinitializer
@AcceptationAverage.front = internal unnamed_addr global i32 -1
@AcceptationAverage.rear = internal unnamed_addr global i32 -1
@AcceptationAverage.Sum = internal unnamed_addr global i32 0
define double @AcceptationAverage(i32 %0) {
%2 = load i32, i32* @AcceptationAverage.front
%3 = load i32, i32* @AcceptationAverage.rear
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 1000
%6 = icmp eq i32 %2, %5
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds [1000 x i32], [1000 x i32]* @AcceptationAverage.AcceptationVector, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = load i32, i32* @AcceptationAverage.Sum
%12 = sub nsw i32 %11, %10
store i32 %12, i32* @AcceptationAverage.Sum
%13 = icmp eq i32 %2, %3
br i1 %13, label %20, label %14
14: ; preds = %7
%15 = add nsw i32 %2, 1
%16 = srem i32 %15, 1000
store i32 %16, i32* @AcceptationAverage.front
br label %17
17: ; preds = %14, %1
%18 = phi i32 [ %16, %14 ], [ %2, %1 ]
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %7, %17
store i32 0, i32* @AcceptationAverage.rear
store i32 0, i32* @AcceptationAverage.front
br label %23
21: ; preds = %17
store i32 %5, i32* @AcceptationAverage.rear
%22 = sext i32 %5 to i64
br label %23
23: ; preds = %21, %20
%24 = phi i64 [ %22, %21 ], [ 0, %20 ]
%25 = getelementptr inbounds [1000 x i32], [1000 x i32]* @AcceptationAverage.AcceptationVector, i64 0, i64 %24
store i32 %0, i32* %25
%26 = load i32, i32* @AcceptationAverage.Sum
%27 = add nsw i32 %26, %0
store i32 %27, i32* @AcceptationAverage.Sum
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 1.000000e+03
ret double %29
}