#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int *__bits;
};
typedef TYPE_1__ cpu_set_t;
typedef int __cpu_mask;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int _cpu_count_s(size_t setsize, cpu_set_t *set) {
  int count = 0;
  size_t i;
  assert(setsize == sizeof(set->__bits));
  for (i = 0; i < sizeof(set->__bits) / sizeof(set->__bits[0]); i++) {
    __cpu_mask b;
    for (b = set->__bits[i]; b; b >>= 1) {
      if (b & 1) {
        count++;
      }
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<_cpu_count_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x8,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0x2,-0x20(%rbp)
jae    11a8 <_cpu_count_s+0x98>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1192 <_cpu_count_s+0x82>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     117f <_cpu_count_s+0x6f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <_cpu_count_s+0x74>
mov    -0x24(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <_cpu_count_s+0x4d>
jmp    1197 <_cpu_count_s+0x87>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1141 <_cpu_count_s+0x31>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_cpu_count_s>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x8,%rdi
sete   %al
mov    %eax,%edi
call   1030 <assert@plt>
mov    (%rbx),%rcx
mov    (%rcx),%edx
xor    %eax,%eax
test   %edx,%edx
je     1150 <_cpu_count_s+0x40>
mov    %edx,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,%edi
and    $0x1,%edi
add    %edi,%eax
sar    %esi
cmp    $0x1,%edx
mov    %esi,%edx
ja     1140 <_cpu_count_s+0x30>
mov    0x4(%rcx),%ecx
test   %ecx,%ecx
je     1170 <_cpu_count_s+0x60>
mov    %ecx,%edx
nopl   0x0(%rax)
mov    %ecx,%esi
and    $0x1,%esi
add    %esi,%eax
sar    %edx
cmp    $0x1,%ecx
mov    %edx,%ecx
ja     1160 <_cpu_count_s+0x50>
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32* }
define i32 @_cpu_count_s(i64 %0, %struct.TYPE_3__* %1) {
%3 = alloca i64
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
store i64 %0, i64* %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
store i32 0, i32* %5
%8 = load i64, i64* %3
%9 = icmp eq i64 %8, 8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i64 0, i64* %6
br label %12
12: ; preds = %37, %2
%13 = load i64, i64* %6
%14 = icmp ult i64 %13, 2
br i1 %14, label %15, label %40
15: ; preds = %12
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i32*, i32** %17
%19 = load i64, i64* %6
%20 = getelementptr inbounds i32, i32* %18, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %7
br label %22
22: ; preds = %33, %15
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load i32, i32* %7
%27 = and i32 %26, 1
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %25
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = ashr i32 %34, 1
store i32 %35, i32* %7
br label %22
36: ; preds = %22
br label %37
37: ; preds = %36
%38 = load i64, i64* %6
%39 = add i64 %38, 1
store i64 %39, i64* %6
br label %12
40: ; preds = %12
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32* }
define i32 @_cpu_count_s(i64 %0, %struct.TYPE_3__* nocapture %1) {
%3 = icmp eq i64 %0, 8
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2, %10
%11 = phi i32 [ %15, %10 ], [ %8, %2 ]
%12 = phi i32 [ %14, %10 ], [ 0, %2 ]
%13 = and i32 %11, 1
%14 = add nuw nsw i32 %13, %12
%15 = ashr i32 %11, 1
%16 = icmp ult i32 %11, 2
br i1 %16, label %17, label %10
17: ; preds = %10, %2
%18 = phi i32 [ 0, %2 ], [ %14, %10 ]
%19 = getelementptr inbounds i32, i32* %7, i64 1
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %17, %22
%23 = phi i32 [ %27, %22 ], [ %20, %17 ]
%24 = phi i32 [ %26, %22 ], [ %18, %17 ]
%25 = and i32 %23, 1
%26 = add nsw i32 %25, %24
%27 = ashr i32 %23, 1
%28 = icmp ult i32 %23, 2
br i1 %28, label %29, label %22
29: ; preds = %22, %17
%30 = phi i32 [ %18, %17 ], [ %26, %22 ]
ret i32 %30
}