int alphasVectorCount(float *alphas) {
  int i;
  for (i = 0; i < 8; i++) {
    if (alphas[i] == -1) {
      break;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<alphasVectorCount>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1155 <alphasVectorCount+0x55>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  0xed2(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1142 <alphasVectorCount+0x42>
jp     1142 <alphasVectorCount+0x42>
jmp    1155 <alphasVectorCount+0x55>
jmp    1147 <alphasVectorCount+0x47>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <alphasVectorCount+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<alphasVectorCount>:
movss  (%rdi),%xmm0
xor    %eax,%eax
ucomiss 0xef3(%rip),%xmm0
jne    1112 <alphasVectorCount+0x12>
jp     1112 <alphasVectorCount+0x12>
ret
movss  0x4(%rdi),%xmm0
mov    $0x1,%eax
ucomiss 0xedd(%rip),%xmm0
jne    1127 <alphasVectorCount+0x27>
jnp    1111 <alphasVectorCount+0x11>
movss  0x8(%rdi),%xmm0
mov    $0x2,%eax
ucomiss 0xec8(%rip),%xmm0
jne    113c <alphasVectorCount+0x3c>
jnp    1111 <alphasVectorCount+0x11>
movss  0xc(%rdi),%xmm0
mov    $0x3,%eax
ucomiss 0xeb3(%rip),%xmm0
jne    1151 <alphasVectorCount+0x51>
jnp    1111 <alphasVectorCount+0x11>
movss  0x10(%rdi),%xmm0
mov    $0x4,%eax
ucomiss 0xe9e(%rip),%xmm0
jne    1166 <alphasVectorCount+0x66>
jnp    1111 <alphasVectorCount+0x11>
movss  0x14(%rdi),%xmm0
mov    $0x5,%eax
ucomiss 0xe89(%rip),%xmm0
jne    117b <alphasVectorCount+0x7b>
jnp    1111 <alphasVectorCount+0x11>
movss  0x18(%rdi),%xmm0
mov    $0x6,%eax
ucomiss 0xe74(%rip),%xmm0
jne    1190 <alphasVectorCount+0x90>
jnp    1111 <alphasVectorCount+0x11>
movss  0x1c(%rdi),%xmm0
mov    $0x7,%eax
ucomiss 0xe5f(%rip),%xmm0
jne    11a9 <alphasVectorCount+0xa9>
jnp    1111 <alphasVectorCount+0x11>
mov    $0x8,%eax
ret

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

LLVM IR (-O2):
define i32 @alphasVectorCount(float* nocapture %0) {
%2 = load float, float* %0
%3 = fcmp oeq float %2, -1.000000e+00
br i1 %3, label %33, label %4
4: ; preds = %1
%5 = getelementptr inbounds float, float* %0, i64 1
%6 = load float, float* %5
%7 = fcmp oeq float %6, -1.000000e+00
br i1 %7, label %33, label %8
8: ; preds = %4
%9 = getelementptr inbounds float, float* %0, i64 2
%10 = load float, float* %9
%11 = fcmp oeq float %10, -1.000000e+00
br i1 %11, label %33, label %12
12: ; preds = %8
%13 = getelementptr inbounds float, float* %0, i64 3
%14 = load float, float* %13
%15 = fcmp oeq float %14, -1.000000e+00
br i1 %15, label %33, label %16
16: ; preds = %12
%17 = getelementptr inbounds float, float* %0, i64 4
%18 = load float, float* %17
%19 = fcmp oeq float %18, -1.000000e+00
br i1 %19, label %33, label %20
20: ; preds = %16
%21 = getelementptr inbounds float, float* %0, i64 5
%22 = load float, float* %21
%23 = fcmp oeq float %22, -1.000000e+00
br i1 %23, label %33, label %24
24: ; preds = %20
%25 = getelementptr inbounds float, float* %0, i64 6
%26 = load float, float* %25
%27 = fcmp oeq float %26, -1.000000e+00
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = getelementptr inbounds float, float* %0, i64 7
%30 = load float, float* %29
%31 = fcmp oeq float %30, -1.000000e+00
br i1 %31, label %33, label %32
32: ; preds = %28
br label %33
33: ; preds = %32, %28, %24, %20, %16, %12, %8, %4, %1
%34 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %8 ], [ 3, %12 ], [ 4, %16 ], [ 5, %20 ], [ 6, %24 ], [ 7, %28 ], [ 8, %32 ]
ret i32 %34
}