#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int abs(float);
float calc_average(float *arr) {
  int iter, avg_count = 0;
  float temp_sum = 0;
  for (iter = 0; iter < 1; ++iter) {
    if (abs(arr[iter]) < 2147483645) {
      temp_sum += arr[iter];
      ++avg_count;
    }
  }
  for (iter = 0; iter < 1; ++iter) {
    arr[iter] = 2147483645;
  }
  return !avg_count ? 2147483645 : (temp_sum / avg_count);
}


x86 assembly (clang, -O0):
<calc_average>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    118c <calc_average+0x7c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <abs@plt>
cmp    $0x7ffffffd,%eax
jge    1179 <calc_average+0x69>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117e <calc_average+0x6e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <calc_average+0x22>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    11c0 <calc_average+0xb0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  0xe53(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <calc_average+0x83>
cmpl   $0x0,-0x10(%rbp)
jne    11dc <calc_average+0xcc>
movss  0xe2e(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11ef <calc_average+0xdf>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_average>:
push   %rbx
mov    %rdi,%rbx
movss  (%rdi),%xmm0
call   1030 <abs@plt>
cmp    $0x7ffffffc,%eax
jg     112d <calc_average+0x1d>
xorps  %xmm0,%xmm0
addss  (%rbx),%xmm0
jmp    1135 <calc_average+0x25>
movss  0xecb(%rip),%xmm0
movl   $0x4f000000,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define float @calc_average(float* %0) {
%2 = alloca float*
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
store float* %0, float** %2
store i32 0, i32* %4
store float 0.000000e+00, float* %5
store i32 0, i32* %3
br label %6
6: ; preds = %28, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = load float*, float** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds float, float* %10, i64 %12
%14 = load float, float* %13
%15 = call i32 @abs(float %14)
%16 = icmp slt i32 %15, 2147483645
br i1 %16, label %17, label %27
17: ; preds = %9
%18 = load float*, float** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = load float, float* %5
%24 = fadd float %23, %22
store float %24, float* %5
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %27
27: ; preds = %17, %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %6
31: ; preds = %6
store i32 0, i32* %3
br label %32
32: ; preds = %40, %31
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = load float*, float** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float, float* %36, i64 %38
store float 0x41E0000000000000, float* %39
br label %40
40: ; preds = %35
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %32
43: ; preds = %32
%44 = load i32, i32* %4
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %43
br label %52
47: ; preds = %43
%48 = load float, float* %5
%49 = load i32, i32* %4
%50 = sitofp i32 %49 to float
%51 = fdiv float %48, %50
br label %52
52: ; preds = %47, %46
%53 = phi float [ 0x41E0000000000000, %46 ], [ %51, %47 ]
ret float %53
}

LLVM IR (-O2):
define float @calc_average(float* nocapture %0) {
%2 = load float, float* %0
%3 = tail call i32 @abs(float %2)
%4 = icmp slt i32 %3, 2147483645
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load float, float* %0
%7 = fadd float %6, 0.000000e+00
br label %8
8: ; preds = %1, %5
%9 = phi float [ %7, %5 ], [ 0x41E0000000000000, %1 ]
store float 0x41E0000000000000, float* %0
ret float %9
}