#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 /*<<< orphan*/ finite(float);
long fvec_index_nonfinite(float *v, long n) {
  long i;
  for (i = 0; i < n; i++)
    if (!finite(v[i]))
      return i;
  return -1;
}


x86 assembly (clang, -O0):
<fvec_index_nonfinite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1174 <fvec_index_nonfinite+0x64>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <finite@plt>
cmp    $0x0,%eax
jne    115e <fvec_index_nonfinite+0x4e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <fvec_index_nonfinite+0x6c>
jmp    1163 <fvec_index_nonfinite+0x53>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <fvec_index_nonfinite+0x18>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fvec_index_nonfinite>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xffffffffffffffff,%r14
test   %rsi,%rsi
jle    114d <fvec_index_nonfinite+0x3d>
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movss  (%r15,%rbx,4),%xmm0
call   1030 <finite@plt>
test   %eax,%eax
je     114a <fvec_index_nonfinite+0x3a>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <fvec_index_nonfinite+0x20>
jmp    114d <fvec_index_nonfinite+0x3d>
mov    %rbx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @fvec_index_nonfinite(float* %0, i64 %1) {
%3 = alloca i64
%4 = alloca float*
%5 = alloca i64
%6 = alloca i64
store float* %0, float** %4
store i64 %1, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %21, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %5
%10 = icmp slt i64 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load float*, float** %4
%13 = load i64, i64* %6
%14 = getelementptr inbounds float, float* %12, i64 %13
%15 = load float, float* %14
%16 = call i32 @finite(float %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = load i64, i64* %6
store i64 %19, i64* %3
br label %25
20: ; preds = %11
br label %21
21: ; preds = %20
%22 = load i64, i64* %6
%23 = add nsw i64 %22, 1
store i64 %23, i64* %6
br label %7
24: ; preds = %7
store i64 -1, i64* %3
br label %25
25: ; preds = %24, %18
%26 = load i64, i64* %3
ret i64 %26
}

LLVM IR (-O2):
define i64 @fvec_index_nonfinite(float* nocapture %0, i64 %1) {
%3 = icmp sgt i64 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %2, %10
%5 = phi i64 [ %11, %10 ], [ 0, %2 ]
%6 = getelementptr inbounds float, float* %0, i64 %5
%7 = load float, float* %6
%8 = tail call i32 @finite(float %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %4
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, %1
br i1 %12, label %13, label %4
13: ; preds = %4, %10, %2
%14 = phi i64 [ -1, %2 ], [ -1, %10 ], [ %5, %4 ]
ret i64 %14
}