#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 */
float flt_add(float, float const);
scalar_t__ isrealf(float const);
float flt_sum(const float *restrict x, const size_t n) {
  float sum;
  size_t i;
  sum = 0.f;
  for (i = 0; i < n; i++) {
    if (isrealf(x[i])) {
      sum = flt_add(sum, x[i]);
    }
  }
  return sum;
}


x86 assembly (clang, -O0):
<flt_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119c <flt_sum+0x7c>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1040 <isrealf@plt>
cmp    $0x0,%rax
je     1186 <flt_sum+0x66>
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
call   1030 <flt_add@plt>
movss  %xmm0,-0x14(%rbp)
jmp    118b <flt_sum+0x6b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1140 <flt_sum+0x20>
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flt_sum>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rsi,%rsi
je     1188 <flt_sum+0x68>
mov    %rsi,%r15
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
jmp    1159 <flt_sum+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1191 <flt_sum+0x71>
movss  (%r14,%rbx,4),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <isrealf@plt>
test   %rax,%rax
je     1150 <flt_sum+0x30>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <flt_add@plt>
movss  %xmm0,0x8(%rsp)
jmp    1150 <flt_sum+0x30>
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @flt_sum(float* noalias %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca float
%6 = alloca i64
store float* %0, float** %3
store i64 %1, i64* %4
store float 0.000000e+00, float* %5
store i64 0, i64* %6
br label %7
7: ; preds = %26, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %4
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load float*, float** %3
%13 = load i64, i64* %6
%14 = getelementptr inbounds float, float* %12, i64 %13
%15 = load float, float* %14
%16 = call i64 @isrealf(float %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %11
%19 = load float, float* %5
%20 = load float*, float** %3
%21 = load i64, i64* %6
%22 = getelementptr inbounds float, float* %20, i64 %21
%23 = load float, float* %22
%24 = call float @flt_add(float %19, float %23)
store float %24, float* %5
br label %25
25: ; preds = %18, %11
br label %26
26: ; preds = %25
%27 = load i64, i64* %6
%28 = add i64 %27, 1
store i64 %28, i64* %6
br label %7
29: ; preds = %7
%30 = load float, float* %5
ret float %30
}

LLVM IR (-O2):
define float @flt_sum(float* noalias nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %17, label %4
4: ; preds = %2, %13
%5 = phi i64 [ %15, %13 ], [ 0, %2 ]
%6 = phi float [ %14, %13 ], [ 0.000000e+00, %2 ]
%7 = getelementptr inbounds float, float* %0, i64 %5
%8 = load float, float* %7
%9 = tail call i64 @isrealf(float %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call float @flt_add(float %6, float %8)
br label %13
13: ; preds = %4, %11
%14 = phi float [ %12, %11 ], [ %6, %4 ]
%15 = add nuw i64 %5, 1
%16 = icmp eq i64 %15, %1
br i1 %16, label %17, label %4
17: ; preds = %13, %2
%18 = phi float [ 0.000000e+00, %2 ], [ %14, %13 ]
ret float %18
}