int findOpenIndex(double *arr) {
  int i;
  for (i = 0; i < 30; i++) {
    if (arr[i] == -1) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<findOpenIndex>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
jge    115c <findOpenIndex+0x5c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xed2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1149 <findOpenIndex+0x49>
jp     1149 <findOpenIndex+0x49>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1163 <findOpenIndex+0x63>
jmp    114e <findOpenIndex+0x4e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <findOpenIndex+0xf>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<findOpenIndex>:
movsd  (%rdi),%xmm0
xor    %eax,%eax
ucomisd 0xef2(%rip),%xmm0
jne    1113 <findOpenIndex+0x13>
jp     1113 <findOpenIndex+0x13>
ret
movsd  0x8(%rdi),%xmm0
mov    $0x1,%eax
ucomisd 0xedb(%rip),%xmm0
jne    1129 <findOpenIndex+0x29>
jnp    1112 <findOpenIndex+0x12>
movsd  0x10(%rdi),%xmm0
mov    $0x2,%eax
ucomisd 0xec5(%rip),%xmm0
jne    113f <findOpenIndex+0x3f>
jnp    1112 <findOpenIndex+0x12>
movsd  0x18(%rdi),%xmm0
mov    $0x3,%eax
ucomisd 0xeaf(%rip),%xmm0
jne    1155 <findOpenIndex+0x55>
jnp    1112 <findOpenIndex+0x12>
movsd  0x20(%rdi),%xmm0
mov    $0x4,%eax
ucomisd 0xe99(%rip),%xmm0
jne    116b <findOpenIndex+0x6b>
jnp    1112 <findOpenIndex+0x12>
movsd  0x28(%rdi),%xmm0
mov    $0x5,%eax
ucomisd 0xe83(%rip),%xmm0
jne    1181 <findOpenIndex+0x81>
jnp    1112 <findOpenIndex+0x12>
movsd  0x30(%rdi),%xmm0
mov    $0x6,%eax
ucomisd 0xe6d(%rip),%xmm0
jne    119b <findOpenIndex+0x9b>
jnp    1112 <findOpenIndex+0x12>
movsd  0x38(%rdi),%xmm0
mov    $0x7,%eax
ucomisd 0xe53(%rip),%xmm0
jne    11b5 <findOpenIndex+0xb5>
jnp    1112 <findOpenIndex+0x12>
movsd  0x40(%rdi),%xmm0
mov    $0x8,%eax
ucomisd 0xe39(%rip),%xmm0
jne    11cf <findOpenIndex+0xcf>
jnp    1112 <findOpenIndex+0x12>
movsd  0x48(%rdi),%xmm0
mov    $0x9,%eax
ucomisd 0xe1f(%rip),%xmm0
jne    11e9 <findOpenIndex+0xe9>
jnp    1112 <findOpenIndex+0x12>
movsd  0x50(%rdi),%xmm0
mov    $0xa,%eax
ucomisd 0xe05(%rip),%xmm0
jne    1203 <findOpenIndex+0x103>
jnp    1112 <findOpenIndex+0x12>
movsd  0x58(%rdi),%xmm0
mov    $0xb,%eax
ucomisd 0xdeb(%rip),%xmm0
jne    121d <findOpenIndex+0x11d>
jnp    1112 <findOpenIndex+0x12>
movsd  0x60(%rdi),%xmm0
mov    $0xc,%eax
ucomisd 0xdd1(%rip),%xmm0
jne    1237 <findOpenIndex+0x137>
jnp    1112 <findOpenIndex+0x12>
movsd  0x68(%rdi),%xmm0
mov    $0xd,%eax
ucomisd 0xdb7(%rip),%xmm0
jne    1251 <findOpenIndex+0x151>
jnp    1112 <findOpenIndex+0x12>
movsd  0x70(%rdi),%xmm0
mov    $0xe,%eax
ucomisd 0xd9d(%rip),%xmm0
jne    126b <findOpenIndex+0x16b>
jnp    1112 <findOpenIndex+0x12>
movsd  0x78(%rdi),%xmm0
mov    $0xf,%eax
ucomisd 0xd83(%rip),%xmm0
jne    1285 <findOpenIndex+0x185>
jnp    1112 <findOpenIndex+0x12>
movsd  0x80(%rdi),%xmm0
mov    $0x10,%eax
ucomisd 0xd66(%rip),%xmm0
jne    12a2 <findOpenIndex+0x1a2>
jnp    1112 <findOpenIndex+0x12>
movsd  0x88(%rdi),%xmm0
mov    $0x11,%eax
ucomisd 0xd49(%rip),%xmm0
jne    12bf <findOpenIndex+0x1bf>
jnp    1112 <findOpenIndex+0x12>
movsd  0x90(%rdi),%xmm0
mov    $0x12,%eax
ucomisd 0xd2c(%rip),%xmm0
jne    12dc <findOpenIndex+0x1dc>
jnp    1112 <findOpenIndex+0x12>
movsd  0x98(%rdi),%xmm0
mov    $0x13,%eax
ucomisd 0xd0f(%rip),%xmm0
jne    12f9 <findOpenIndex+0x1f9>
jnp    1112 <findOpenIndex+0x12>
movsd  0xa0(%rdi),%xmm0
mov    $0x14,%eax
ucomisd 0xcf2(%rip),%xmm0
jne    1316 <findOpenIndex+0x216>
jnp    1112 <findOpenIndex+0x12>
movsd  0xa8(%rdi),%xmm0
mov    $0x15,%eax
ucomisd 0xcd5(%rip),%xmm0
jne    1333 <findOpenIndex+0x233>
jnp    1112 <findOpenIndex+0x12>
movsd  0xb0(%rdi),%xmm0
mov    $0x16,%eax
ucomisd 0xcb8(%rip),%xmm0
jne    1350 <findOpenIndex+0x250>
jnp    1112 <findOpenIndex+0x12>
movsd  0xb8(%rdi),%xmm0
mov    $0x17,%eax
ucomisd 0xc9b(%rip),%xmm0
jne    136d <findOpenIndex+0x26d>
jnp    1112 <findOpenIndex+0x12>
movsd  0xc0(%rdi),%xmm0
mov    $0x18,%eax
ucomisd 0xc7e(%rip),%xmm0
jne    138a <findOpenIndex+0x28a>
jnp    1112 <findOpenIndex+0x12>
movsd  0xc8(%rdi),%xmm0
mov    $0x19,%eax
ucomisd 0xc61(%rip),%xmm0
jne    13a7 <findOpenIndex+0x2a7>
jnp    1112 <findOpenIndex+0x12>
movsd  0xd0(%rdi),%xmm0
mov    $0x1a,%eax
ucomisd 0xc44(%rip),%xmm0
jne    13c4 <findOpenIndex+0x2c4>
jnp    1112 <findOpenIndex+0x12>
movsd  0xd8(%rdi),%xmm0
mov    $0x1b,%eax
ucomisd 0xc27(%rip),%xmm0
jne    13e1 <findOpenIndex+0x2e1>
jnp    1112 <findOpenIndex+0x12>
movsd  0xe0(%rdi),%xmm0
mov    $0x1c,%eax
ucomisd 0xc0a(%rip),%xmm0
jne    13fe <findOpenIndex+0x2fe>
jnp    1112 <findOpenIndex+0x12>
movsd  0xe8(%rdi),%xmm0
mov    $0x1d,%eax
ucomisd 0xbed(%rip),%xmm0
jne    141b <findOpenIndex+0x31b>
jnp    1112 <findOpenIndex+0x12>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @findOpenIndex(double* %0) {
%2 = alloca i32
%3 = alloca double*
%4 = alloca i32
store double* %0, double** %3
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 30
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load double*, double** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %9, i64 %11
%13 = load double, double* %12
%14 = fcmp oeq double %13, -1.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = load i32, i32* %4
store i32 %16, i32* %2
br label %22
17: ; preds = %8
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
store i32 -1, i32* %2
br label %22
22: ; preds = %21, %15
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @findOpenIndex(double* nocapture %0) {
%2 = load double, double* %0
%3 = fcmp oeq double %2, -1.000000e+00
br i1 %3, label %121, label %4
4: ; preds = %1
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = load double, double* %5
%7 = fcmp oeq double %6, -1.000000e+00
br i1 %7, label %121, label %8
8: ; preds = %4
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = fcmp oeq double %10, -1.000000e+00
br i1 %11, label %121, label %12
12: ; preds = %8
%13 = getelementptr inbounds double, double* %0, i64 3
%14 = load double, double* %13
%15 = fcmp oeq double %14, -1.000000e+00
br i1 %15, label %121, label %16
16: ; preds = %12
%17 = getelementptr inbounds double, double* %0, i64 4
%18 = load double, double* %17
%19 = fcmp oeq double %18, -1.000000e+00
br i1 %19, label %121, label %20
20: ; preds = %16
%21 = getelementptr inbounds double, double* %0, i64 5
%22 = load double, double* %21
%23 = fcmp oeq double %22, -1.000000e+00
br i1 %23, label %121, label %24
24: ; preds = %20
%25 = getelementptr inbounds double, double* %0, i64 6
%26 = load double, double* %25
%27 = fcmp oeq double %26, -1.000000e+00
br i1 %27, label %121, label %28
28: ; preds = %24
%29 = getelementptr inbounds double, double* %0, i64 7
%30 = load double, double* %29
%31 = fcmp oeq double %30, -1.000000e+00
br i1 %31, label %121, label %32
32: ; preds = %28
%33 = getelementptr inbounds double, double* %0, i64 8
%34 = load double, double* %33
%35 = fcmp oeq double %34, -1.000000e+00
br i1 %35, label %121, label %36
36: ; preds = %32
%37 = getelementptr inbounds double, double* %0, i64 9
%38 = load double, double* %37
%39 = fcmp oeq double %38, -1.000000e+00
br i1 %39, label %121, label %40
40: ; preds = %36
%41 = getelementptr inbounds double, double* %0, i64 10
%42 = load double, double* %41
%43 = fcmp oeq double %42, -1.000000e+00
br i1 %43, label %121, label %44
44: ; preds = %40
%45 = getelementptr inbounds double, double* %0, i64 11
%46 = load double, double* %45
%47 = fcmp oeq double %46, -1.000000e+00
br i1 %47, label %121, label %48
48: ; preds = %44
%49 = getelementptr inbounds double, double* %0, i64 12
%50 = load double, double* %49
%51 = fcmp oeq double %50, -1.000000e+00
br i1 %51, label %121, label %52
52: ; preds = %48
%53 = getelementptr inbounds double, double* %0, i64 13
%54 = load double, double* %53
%55 = fcmp oeq double %54, -1.000000e+00
br i1 %55, label %121, label %56
56: ; preds = %52
%57 = getelementptr inbounds double, double* %0, i64 14
%58 = load double, double* %57
%59 = fcmp oeq double %58, -1.000000e+00
br i1 %59, label %121, label %60
60: ; preds = %56
%61 = getelementptr inbounds double, double* %0, i64 15
%62 = load double, double* %61
%63 = fcmp oeq double %62, -1.000000e+00
br i1 %63, label %121, label %64
64: ; preds = %60
%65 = getelementptr inbounds double, double* %0, i64 16
%66 = load double, double* %65
%67 = fcmp oeq double %66, -1.000000e+00
br i1 %67, label %121, label %68
68: ; preds = %64
%69 = getelementptr inbounds double, double* %0, i64 17
%70 = load double, double* %69
%71 = fcmp oeq double %70, -1.000000e+00
br i1 %71, label %121, label %72
72: ; preds = %68
%73 = getelementptr inbounds double, double* %0, i64 18
%74 = load double, double* %73
%75 = fcmp oeq double %74, -1.000000e+00
br i1 %75, label %121, label %76
76: ; preds = %72
%77 = getelementptr inbounds double, double* %0, i64 19
%78 = load double, double* %77
%79 = fcmp oeq double %78, -1.000000e+00
br i1 %79, label %121, label %80
80: ; preds = %76
%81 = getelementptr inbounds double, double* %0, i64 20
%82 = load double, double* %81
%83 = fcmp oeq double %82, -1.000000e+00
br i1 %83, label %121, label %84
84: ; preds = %80
%85 = getelementptr inbounds double, double* %0, i64 21
%86 = load double, double* %85
%87 = fcmp oeq double %86, -1.000000e+00
br i1 %87, label %121, label %88
88: ; preds = %84
%89 = getelementptr inbounds double, double* %0, i64 22
%90 = load double, double* %89
%91 = fcmp oeq double %90, -1.000000e+00
br i1 %91, label %121, label %92
92: ; preds = %88
%93 = getelementptr inbounds double, double* %0, i64 23
%94 = load double, double* %93
%95 = fcmp oeq double %94, -1.000000e+00
br i1 %95, label %121, label %96
96: ; preds = %92
%97 = getelementptr inbounds double, double* %0, i64 24
%98 = load double, double* %97
%99 = fcmp oeq double %98, -1.000000e+00
br i1 %99, label %121, label %100
100: ; preds = %96
%101 = getelementptr inbounds double, double* %0, i64 25
%102 = load double, double* %101
%103 = fcmp oeq double %102, -1.000000e+00
br i1 %103, label %121, label %104
104: ; preds = %100
%105 = getelementptr inbounds double, double* %0, i64 26
%106 = load double, double* %105
%107 = fcmp oeq double %106, -1.000000e+00
br i1 %107, label %121, label %108
108: ; preds = %104
%109 = getelementptr inbounds double, double* %0, i64 27
%110 = load double, double* %109
%111 = fcmp oeq double %110, -1.000000e+00
br i1 %111, label %121, label %112
112: ; preds = %108
%113 = getelementptr inbounds double, double* %0, i64 28
%114 = load double, double* %113
%115 = fcmp oeq double %114, -1.000000e+00
br i1 %115, label %121, label %116
116: ; preds = %112
%117 = getelementptr inbounds double, double* %0, i64 29
%118 = load double, double* %117
%119 = fcmp oeq double %118, -1.000000e+00
br i1 %119, label %121, label %120
120: ; preds = %116
br label %121
121: ; preds = %120, %116, %112, %108, %104, %100, %96, %92, %88, %84, %80, %76, %72, %68, %64, %60, %56, %52, %48, %44, %40, %36, %32, %28, %24, %20, %16, %12, %8, %4, %1
%122 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %8 ], [ 3, %12 ], [ 4, %16 ], [ 5, %20 ], [ 6, %24 ], [ 7, %28 ], [ 8, %32 ], [ 9, %36 ], [ 10, %40 ], [ 11, %44 ], [ 12, %48 ], [ 13, %52 ], [ 14, %56 ], [ 15, %60 ], [ 16, %64 ], [ 17, %68 ], [ 18, %72 ], [ 19, %76 ], [ 20, %80 ], [ 21, %84 ], [ 22, %88 ], [ 23, %92 ], [ 24, %96 ], [ 25, %100 ], [ 26, %104 ], [ 27, %108 ], [ 28, %112 ], [ 29, %116 ], [ -1, %120 ]
ret i32 %122
}