#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*/ coco_error(char *, int, char const *);
size_t coco_numbers_count(const size_t *numbers, const char *name) {
  size_t count = 0;
  while ((count < 1000) && (numbers[count] != 0)) {
    count++;
  }
  if (count == 1000) {
    coco_error("coco_numbers_count(): over %lu numbers in %s", 1000, name);
    return 0;
  }
  return count;
}


x86 assembly (clang, -O0):
<coco_numbers_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x3e8,-0x20(%rbp)
mov    %al,-0x21(%rbp)
jae    114e <coco_numbers_count+0x3e>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    115e <coco_numbers_count+0x4e>
jmp    116f <coco_numbers_count+0x5f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <coco_numbers_count+0x18>
cmpq   $0x3e8,-0x20(%rbp)
jne    119f <coco_numbers_count+0x8f>
mov    -0x18(%rbp),%rdx
lea    0xe78(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <coco_error@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a7 <coco_numbers_count+0x97>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<coco_numbers_count>:
push   %rax
mov    %rsi,%rdx
mov    $0x4,%eax
nopl   0x0(%rax)
cmpq   $0x0,-0x20(%rdi,%rax,8)
je     1168 <coco_numbers_count+0x58>
cmpq   $0x0,-0x18(%rdi,%rax,8)
je     116e <coco_numbers_count+0x5e>
cmpq   $0x0,-0x10(%rdi,%rax,8)
je     1174 <coco_numbers_count+0x64>
cmpq   $0x0,-0x8(%rdi,%rax,8)
je     117a <coco_numbers_count+0x6a>
cmpq   $0x0,(%rdi,%rax,8)
je     116c <coco_numbers_count+0x5c>
add    $0x5,%rax
cmp    $0x3ec,%rax
jne    1120 <coco_numbers_count+0x10>
lea    0xea6(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <coco_error@plt>
xor    %eax,%eax
pop    %rcx
ret
add    $0xfffffffffffffffc,%rax
pop    %rcx
ret
add    $0xfffffffffffffffd,%rax
pop    %rcx
ret
add    $0xfffffffffffffffe,%rax
pop    %rcx
ret
add    $0xffffffffffffffff,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [45 x i8] c"coco_numbers_count(): over %lu numbers in %s\00"
define i64 @coco_numbers_count(i64* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i64
store i64* %0, i64** %4
store i8* %1, i8** %5
store i64 0, i64* %6
br label %7
7: ; preds = %18, %2
%8 = load i64, i64* %6
%9 = icmp ult i64 %8, 1000
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i64*, i64** %4
%12 = load i64, i64* %6
%13 = getelementptr inbounds i64, i64* %11, i64 %12
%14 = load i64, i64* %13
%15 = icmp ne i64 %14, 0
br label %16
16: ; preds = %10, %7
%17 = phi i1 [ false, %7 ], [ %15, %10 ]
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i64, i64* %6
%20 = add i64 %19, 1
store i64 %20, i64* %6
br label %7
21: ; preds = %16
%22 = load i64, i64* %6
%23 = icmp eq i64 %22, 1000
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %5
%26 = call i32 @coco_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 1000, i8* %25)
store i64 0, i64* %3
br label %29
27: ; preds = %21
%28 = load i64, i64* %6
store i64 %28, i64* %3
br label %29
29: ; preds = %27, %24
%30 = load i64, i64* %3
ret i64 %30
}

LLVM IR (-O2):
@.str = [45 x i8] c"coco_numbers_count(): over %lu numbers in %s\00"
define i64 @coco_numbers_count(i64* nocapture %0, i8* %1) {
br label %3
3: ; preds = %28, %2
%4 = phi i64 [ 0, %2 ], [ %29, %28 ]
%5 = getelementptr inbounds i64, i64* %0, i64 %4
%6 = load i64, i64* %5
%7 = icmp eq i64 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %3
%9 = add nuw nsw i64 %4, 1
%10 = getelementptr inbounds i64, i64* %0, i64 %9
%11 = load i64, i64* %10
%12 = icmp eq i64 %11, 0
br i1 %12, label %33, label %13
13: ; preds = %8
%14 = add nuw nsw i64 %4, 2
%15 = getelementptr inbounds i64, i64* %0, i64 %14
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %13
%19 = add nuw nsw i64 %4, 3
%20 = getelementptr inbounds i64, i64* %0, i64 %19
%21 = load i64, i64* %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %18
%24 = add nuw nsw i64 %4, 4
%25 = getelementptr inbounds i64, i64* %0, i64 %24
%26 = load i64, i64* %25
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = add nuw nsw i64 %4, 5
%30 = icmp eq i64 %29, 1000
br i1 %30, label %31, label %3
31: ; preds = %28
%32 = tail call i32 @coco_error(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 1000, i8* %1)
br label %33
33: ; preds = %3, %8, %13, %18, %23, %31
%34 = phi i64 [ 0, %31 ], [ %4, %3 ], [ %9, %8 ], [ %14, %13 ], [ %19, %18 ], [ %24, %23 ]
ret i64 %34
}