#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 */
typedef int /*<<< orphan*/ cpu_set_t;

/* Variables and functions */
int CPU_COUNT(int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ CPU_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int);
int do_test(void) {
  cpu_set_t c;
  CPU_ZERO(&c);
  for (int cnt = 0; cnt < 130; ++cnt) {
    int n = CPU_COUNT(&c);
    if (n != cnt) {
      printf("expected %d, not %d\n", cnt, n);
      return 1;
    }
    CPU_SET(cnt, &c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1050 <CPU_ZERO@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x82,-0xc(%rbp)
jge    11b5 <do_test+0x75>
lea    -0x8(%rbp),%rdi
call   1040 <CPU_COUNT@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     119b <do_test+0x5b>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bc <do_test+0x7c>
mov    -0xc(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1060 <CPU_SET@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <do_test+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <CPU_ZERO@plt>
mov    %rbx,%rdi
call   1040 <CPU_COUNT@plt>
test   %eax,%eax
je     1167 <do_test+0x27>
xor    %ebp,%ebp
mov    $0x1,%bl
jmp    11b2 <do_test+0x72>
mov    $0xffffffff,%ebx
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   1060 <CPU_SET@plt>
cmp    $0x80,%ebx
je     11ce <do_test+0x8e>
mov    %r14,%rdi
call   1040 <CPU_COUNT@plt>
add    $0x2,%ebx
cmp    %eax,%ebx
mov    %ebp,%ebx
je     1180 <do_test+0x40>
cmp    $0x81,%ebp
setb   %bl
add    $0x1,%ebp
lea    0xe47(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
movzbl %bl,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
add    $0x1,%ebx
cmp    $0x81,%ebx
setb   %bl
jmp    11c2 <do_test+0x82>

LLVM IR (-O0):
@.str = [21 x i8] c"expected %d, not %d\0A\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 @CPU_ZERO(i32* %2)
store i32 0, i32* %3
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 130
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = call i32 @CPU_COUNT(i32* %2)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
store i32 1, i32* %1
br label %25
18: ; preds = %9
%19 = load i32, i32* %3
%20 = call i32 @CPU_SET(i32 %19, i32* %2)
br label %21
21: ; preds = %18
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %6
24: ; preds = %6
store i32 0, i32* %1
br label %25
25: ; preds = %24, %14
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [21 x i8] c"expected %d, not %d\0A\00"
define i32 @do_test() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @CPU_ZERO(i32* %1)
%4 = call i32 @CPU_COUNT(i32* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %11
6: ; preds = %16
%7 = call i32 @CPU_COUNT(i32* %1)
%8 = icmp eq i32 %7, %19
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = icmp ult i32 %17, 129
br label %11
11: ; preds = %9, %0
%12 = phi i1 [ true, %0 ], [ %10, %9 ]
%13 = phi i32 [ 0, %0 ], [ %19, %9 ]
%14 = phi i32 [ %4, %0 ], [ %7, %9 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
br label %23
16: ; preds = %0, %6
%17 = phi i32 [ %19, %6 ], [ 0, %0 ]
%18 = call i32 @CPU_SET(i32 %17, i32* %1)
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, 130
br i1 %20, label %21, label %6
21: ; preds = %16
%22 = icmp ult i32 %17, 129
br label %23
23: ; preds = %21, %11
%24 = phi i1 [ %12, %11 ], [ %22, %21 ]
%25 = zext i1 %24 to i32
ret i32 %25
}