int hpfilt(int datum, int init) {
  static long y = 0;
  static int data[25], ptr = 0;
  int z, halfPtr;
  if (init) {
    for (ptr = 0; ptr < 25; ++ptr)
      data[ptr] = 0;
    ptr = 0;
    y = 0;
  }
  y += datum - data[ptr];
  halfPtr = ptr - (25 / 2);
  if (halfPtr < 0)
    halfPtr += 25;
  z = data[halfPtr] - (y / 25);
  data[ptr] = datum;
  if (++ptr == 25)
    ptr = 0;
  return (z);
}


x86 assembly (clang, -O0):
<hpfilt>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1169 <hpfilt+0x69>
movl   $0x0,0x2f86(%rip)
cmpl   $0x19,0x2f7f(%rip)
jge    1154 <hpfilt+0x54>
movslq 0x2f72(%rip),%rcx
lea    0x2f07(%rip),%rax
movl   $0x0,(%rax,%rcx,4)
mov    0x2f5e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2f55(%rip)
jmp    111e <hpfilt+0x1e>
movl   $0x0,0x2f46(%rip)
movq   $0x0,0x2ec7(%rip)
mov    -0x4(%rbp),%eax
movslq 0x2f31(%rip),%rdx
lea    0x2ec6(%rip),%rcx
sub    (%rcx,%rdx,4),%eax
cltq
add    0x2eaa(%rip),%rax
mov    %rax,0x2ea3(%rip)
mov    0x2f11(%rip),%eax
sub    $0xc,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11ac <hpfilt+0xac>
mov    -0x10(%rbp),%eax
add    $0x19,%eax
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rcx
lea    0x2e89(%rip),%rax
movslq (%rax,%rcx,4),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e6a(%rip),%rax
mov    $0x19,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edx
movslq 0x2ebd(%rip),%rcx
lea    0x2e52(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    0x2ead(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea4(%rip)
cmp    $0x19,%eax
jne    1213 <hpfilt+0x113>
movl   $0x0,0x2e91(%rip)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpfilt>:
test   %esi,%esi
je     1143 <hpfilt+0x43>
xorps  %xmm0,%xmm0
movaps %xmm0,0x2f82(%rip)
movaps %xmm0,0x2f6b(%rip)
movaps %xmm0,0x2f54(%rip)
movaps %xmm0,0x2f3d(%rip)
movaps %xmm0,0x2f26(%rip)
movaps %xmm0,0x2f0f(%rip)
movl   $0x0,0x2f65(%rip)
xor    %eax,%eax
xor    %ecx,%ecx
xor    %edx,%edx
jmp    115b <hpfilt+0x5b>
movslq 0x2f5a(%rip),%rdx
lea    0x2eef(%rip),%rax
mov    (%rax,%rdx,4),%ecx
mov    0x2ed5(%rip),%rax
movslq %edx,%rsi
lea    0x2edb(%rip),%r8
mov    %edi,%edx
sub    %ecx,%edx
movslq %edx,%rcx
add    %rax,%rcx
lea    -0xc(%rsi),%eax
lea    0xd(%rsi),%edx
cmp    $0xc,%esi
cmovge %eax,%edx
movslq %edx,%r9
movabs $0x5c28f5c28f5c28f5,%rdx
f5 28 5c
mov    %rcx,%rax
imul   %rdx
sub    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x4,%rdx
add    %edx,%eax
add    (%r8,%r9,4),%eax
mov    %rcx,0x2e87(%rip)
mov    %edi,(%r8,%rsi,4)
lea    0x1(%rsi),%ecx
xor    %edx,%edx
cmp    $0x19,%ecx
cmovne %ecx,%edx
mov    %edx,0x2ee6(%rip)
ret

LLVM IR (-O0):
@hpfilt.y = internal global i64 0
@hpfilt.data = internal global [25 x i32] zeroinitializer
@hpfilt.ptr = internal global i32 0
define i32 @hpfilt(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %2
store i32 0, i32* @hpfilt.ptr
br label %10
10: ; preds = %17, %9
%11 = load i32, i32* @hpfilt.ptr
%12 = icmp slt i32 %11, 25
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* @hpfilt.ptr
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* @hpfilt.ptr
%19 = add nsw i32 %18, 1
store i32 %19, i32* @hpfilt.ptr
br label %10
20: ; preds = %10
store i32 0, i32* @hpfilt.ptr
store i64 0, i64* @hpfilt.y
br label %21
21: ; preds = %20, %2
%22 = load i32, i32* %3
%23 = load i32, i32* @hpfilt.ptr
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = sub nsw i32 %22, %26
%28 = sext i32 %27 to i64
%29 = load i64, i64* @hpfilt.y
%30 = add nsw i64 %29, %28
store i64 %30, i64* @hpfilt.y
%31 = load i32, i32* @hpfilt.ptr
%32 = sub nsw i32 %31, 12
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %21
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 25
store i32 %37, i32* %6
br label %38
38: ; preds = %35, %21
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = sext i32 %42 to i64
%44 = load i64, i64* @hpfilt.y
%45 = sdiv i64 %44, 25
%46 = sub nsw i64 %43, %45
%47 = trunc i64 %46 to i32
store i32 %47, i32* %5
%48 = load i32, i32* %3
%49 = load i32, i32* @hpfilt.ptr
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %50
store i32 %48, i32* %51
%52 = load i32, i32* @hpfilt.ptr
%53 = add nsw i32 %52, 1
store i32 %53, i32* @hpfilt.ptr
%54 = icmp eq i32 %53, 25
br i1 %54, label %55, label %56
55: ; preds = %38
store i32 0, i32* @hpfilt.ptr
br label %56
56: ; preds = %55, %38
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
@hpfilt.y = internal unnamed_addr global i64 0
@hpfilt.data = internal unnamed_addr global [25 x i32] zeroinitializer
@hpfilt.ptr = internal unnamed_addr global i32 0
define i32 @hpfilt(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @hpfilt.ptr
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = load i64, i64* @hpfilt.y
br label %11
10: ; preds = %2
br label %11
11: ; preds = %4, %10
%12 = phi i64 [ %9, %4 ], [ 0, %10 ]
%13 = phi i32 [ %8, %4 ], [ 0, %10 ]
%14 = phi i32 [ %5, %4 ], [ 0, %10 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %15
%17 = sub nsw i32 %0, %13
%18 = sext i32 %17 to i64
%19 = add nsw i64 %12, %18
store i64 %19, i64* @hpfilt.y
%20 = icmp slt i32 %14, 12
%21 = select i1 %20, i32 13, i32 -12
%22 = add nsw i32 %21, %14
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [25 x i32], [25 x i32]* @hpfilt.data, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = sdiv i64 %19, -25
%27 = trunc i64 %26 to i32
%28 = add i32 %25, %27
store i32 %0, i32* %16
%29 = add nsw i32 %14, 1
%30 = icmp eq i32 %29, 25
%31 = select i1 %30, i32 0, i32 %29
store i32 %31, i32* @hpfilt.ptr
ret i32 %28
}