int find_number_of_zeros_in_array_of_ones_and_zeros_v1(int *array, int len) {
  int i, num;
  if (!array || (len <= 0)) {
    return (0);
  }
  num = 0;
  for (i = len - 1; ((i >= 0) && (array[i] != 1)); --i) {
    if (array[i] == 0)
      ++num;
  }
  return (num);
}


x86 assembly (clang, -O0):
<find_number_of_zeros_in_array_of_ones_and_zeros_v1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1120 <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x20>
cmpl   $0x0,-0x14(%rbp)
jg     112c <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    11a1 <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0xa1>
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
jl     115d <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x5d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    116d <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x6d>
jmp    119b <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1188 <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x88>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118d <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x8d>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x3c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_number_of_zeros_in_array_of_ones_and_zeros_v1>:
xor    %eax,%eax
test   %rdi,%rdi
je     113c <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x3c>
test   %esi,%esi
jle    113c <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x3c>
mov    %esi,%ecx
add    $0x1,%rcx
xor    %eax,%eax
jmp    112d <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x2d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
add    $0xffffffffffffffff,%rcx
cmp    $0x1,%rcx
jbe    113c <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x3c>
lea    -0x2(%rcx),%edx
mov    (%rdi,%rdx,4),%edx
test   %edx,%edx
je     1120 <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x20>
cmp    $0x1,%edx
jne    1123 <find_number_of_zeros_in_array_of_ones_and_zeros_v1+0x23>
ret

LLVM IR (-O0):
define i32 @find_number_of_zeros_in_array_of_ones_and_zeros_v1(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store i32 0, i32* %3
br label %45
14: ; preds = %10
store i32 0, i32* %7
%15 = load i32, i32* %5
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %6
br label %17
17: ; preds = %40, %14
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32*, i32** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = icmp ne i32 %25, 1
br label %27
27: ; preds = %20, %17
%28 = phi i1 [ false, %17 ], [ %26, %20 ]
br i1 %28, label %29, label %43
29: ; preds = %27
%30 = load i32*, i32** %4
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %29
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %39
39: ; preds = %36, %29
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, -1
store i32 %42, i32* %6
br label %17
43: ; preds = %27
%44 = load i32, i32* %7
store i32 %44, i32* %3
br label %45
45: ; preds = %43, %13
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @find_number_of_zeros_in_array_of_ones_and_zeros_v1(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %20, label %6
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %17
%9 = phi i64 [ %7, %6 ], [ %11, %17 ]
%10 = phi i32 [ 0, %6 ], [ %18, %17 ]
%11 = add nsw i64 %9, -1
%12 = and i64 %11, 4294967295
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
switch i32 %14, label %17 [
i32 1, label %20
i32 0, label %15
]
15: ; preds = %8
%16 = add nsw i32 %10, 1
br label %17
17: ; preds = %8, %15
%18 = phi i32 [ %16, %15 ], [ %10, %8 ]
%19 = icmp ugt i64 %9, 1
br i1 %19, label %8, label %20
20: ; preds = %8, %17, %2
%21 = phi i32 [ 0, %2 ], [ %10, %8 ], [ %18, %17 ]
ret i32 %21
}