#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 fabs(float);
int /*<<< orphan*/ isinff(float);
int /*<<< orphan*/ isnanf(float);
void arr_float_sum_stages(float *pDest, float *pSrc, unsigned long int uStates,
                          unsigned long int uStages) {
  float fTol = 1E-3;
  unsigned long int i, j;
  for (i = 0; i < uStates; i++) {
    pDest[i] = 0;
    for (j = 0; j < uStages; j++) {
      float v = pSrc[j * uStates + i];
      if (!isnanf(v) && !isinff(v) && (fabs(v) > fTol)) {
        pDest[i] += v;
      }
    }
  }
}


x86 assembly (clang, -O0):
<arr_float_sum_stages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movss  0xeb0(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1229 <arr_float_sum_stages+0xf9>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1213 <arr_float_sum_stages+0xe3>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
imul   -0x18(%rbp),%rcx
add    -0x30(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
call   1030 <isnanf@plt>
cmp    $0x0,%eax
jne    11fd <arr_float_sum_stages+0xcd>
movss  -0x3c(%rbp),%xmm0
call   1050 <isinff@plt>
cmp    $0x0,%eax
jne    11fd <arr_float_sum_stages+0xcd>
movss  -0x3c(%rbp),%xmm0
call   1040 <fabs@plt>
ucomiss -0x24(%rbp),%xmm0
jbe    11fd <arr_float_sum_stages+0xcd>
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    1202 <arr_float_sum_stages+0xd2>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1183 <arr_float_sum_stages+0x53>
jmp    1218 <arr_float_sum_stages+0xe8>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    115d <arr_float_sum_stages+0x2d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arr_float_sum_stages>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%rax
mov    %rdx,(%rsp)
test   %rdx,%rdx
je     11e5 <arr_float_sum_stages+0xc5>
mov    %rsi,%r14
mov    %rdi,%r13
mov    (%rsp),%rax
lea    0x0(,%rax,4),%rbx
xor    %ebp,%ebp
jmp    116e <arr_float_sum_stages+0x4e>
nopl   0x0(%rax)
add    $0x1,%rbp
add    $0x4,%r14
cmp    (%rsp),%rbp
je     11e5 <arr_float_sum_stages+0xc5>
movl   $0x0,0x0(%r13,%rbp,4)
cmpq   $0x0,0x8(%rsp)
je     1160 <arr_float_sum_stages+0x40>
mov    %r14,%r12
mov    0x8(%rsp),%r15
jmp    1199 <arr_float_sum_stages+0x79>
nopl   0x0(%rax)
add    %rbx,%r12
add    $0xffffffffffffffff,%r15
je     1160 <arr_float_sum_stages+0x40>
movss  (%r12),%xmm0
movaps %xmm0,0x10(%rsp)
call   1030 <isnanf@plt>
test   %eax,%eax
jne    1190 <arr_float_sum_stages+0x70>
movaps 0x10(%rsp),%xmm0
call   1040 <isinff@plt>
test   %eax,%eax
jne    1190 <arr_float_sum_stages+0x70>
movaps 0x10(%rsp),%xmm0
andps  0xe39(%rip),%xmm0
ucomiss 0xe42(%rip),%xmm0
jbe    1190 <arr_float_sum_stages+0x70>
movaps 0x10(%rsp),%xmm0
addss  0x0(%r13,%rbp,4),%xmm0
movss  %xmm0,0x0(%r13,%rbp,4)
jmp    1190 <arr_float_sum_stages+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @arr_float_sum_stages(float* %0, float* %1, i64 %2, i64 %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca i64
%8 = alloca i64
%9 = alloca float
%10 = alloca i64
%11 = alloca i64
%12 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
store float 0x3F50624DE0000000, float* %9
store i64 0, i64* %10
br label %13
13: ; preds = %58, %4
%14 = load i64, i64* %10
%15 = load i64, i64* %7
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %61
17: ; preds = %13
%18 = load float*, float** %5
%19 = load i64, i64* %10
%20 = getelementptr inbounds float, float* %18, i64 %19
store float 0.000000e+00, float* %20
store i64 0, i64* %11
br label %21
21: ; preds = %54, %17
%22 = load i64, i64* %11
%23 = load i64, i64* %8
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %57
25: ; preds = %21
%26 = load float*, float** %6
%27 = load i64, i64* %11
%28 = load i64, i64* %7
%29 = mul i64 %27, %28
%30 = load i64, i64* %10
%31 = add i64 %29, %30
%32 = getelementptr inbounds float, float* %26, i64 %31
%33 = load float, float* %32
store float %33, float* %12
%34 = load float, float* %12
%35 = call i32 @isnanf(float %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %53, label %37
37: ; preds = %25
%38 = load float, float* %12
%39 = call i32 @isinff(float %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %53, label %41
41: ; preds = %37
%42 = load float, float* %12
%43 = call float @fabs(float %42)
%44 = load float, float* %9
%45 = fcmp ogt float %43, %44
br i1 %45, label %46, label %53
46: ; preds = %41
%47 = load float, float* %12
%48 = load float*, float** %5
%49 = load i64, i64* %10
%50 = getelementptr inbounds float, float* %48, i64 %49
%51 = load float, float* %50
%52 = fadd float %51, %47
store float %52, float* %50
br label %53
53: ; preds = %46, %41, %37, %25
br label %54
54: ; preds = %53
%55 = load i64, i64* %11
%56 = add i64 %55, 1
store i64 %56, i64* %11
br label %21
57: ; preds = %21
br label %58
58: ; preds = %57
%59 = load i64, i64* %10
%60 = add i64 %59, 1
store i64 %60, i64* %10
br label %13
61: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @arr_float_sum_stages(float* nocapture %0, float* nocapture %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %2, 0
br i1 %5, label %34, label %6
6: ; preds = %4
%7 = icmp eq i64 %3, 0
br label %8
8: ; preds = %6, %31
%9 = phi i64 [ 0, %6 ], [ %32, %31 ]
%10 = getelementptr inbounds float, float* %0, i64 %9
store float 0.000000e+00, float* %10
br i1 %7, label %31, label %11
11: ; preds = %8, %28
%12 = phi i64 [ %29, %28 ], [ 0, %8 ]
%13 = mul i64 %12, %2
%14 = add i64 %13, %9
%15 = getelementptr inbounds float, float* %1, i64 %14
%16 = load float, float* %15
%17 = tail call i32 @isnanf(float %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %11
%20 = tail call i32 @isinff(float %16)
%21 = icmp eq i32 %20, 0
%22 = tail call float @llvm.fabs.f32(float %16)
%23 = fcmp ogt float %22, 0x3F50624DE0000000
%24 = select i1 %21, i1 %23, i1 false
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load float, float* %10
%27 = fadd float %16, %26
store float %27, float* %10
br label %28
28: ; preds = %25, %19, %11
%29 = add nuw i64 %12, 1
%30 = icmp eq i64 %29, %3
br i1 %30, label %31, label %11
31: ; preds = %28, %8
%32 = add nuw i64 %9, 1
%33 = icmp eq i64 %32, %2
br i1 %33, label %34, label %8
34: ; preds = %31, %4
ret void
}