#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 */
struct Flex {
  int dummy;
};

/* Variables and functions */
unsigned int count_bits(struct Flex *flex, unsigned int data) {
  if (flex == NULL)
    return 0;
  unsigned int n = (data >> 1) & 0x77777777;
  data = data - n;
  n = (n >> 1) & 0x77777777;
  data = data - n;
  n = (n >> 1) & 0x77777777;
  data = data - n;
  data = (data + (data >> 4)) & 0x0f0f0f0f;
  data = data * 0x01010101;
  return data >> 24;
}


x86 assembly (clang, -O0):
<count_bits>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1122 <count_bits+0x22>
movl   $0x0,-0x4(%rbp)
jmp    118d <count_bits+0x8d>
mov    -0x14(%rbp),%eax
shr    $0x1,%eax
and    $0x77777777,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
shr    $0x1,%eax
and    $0x77777777,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
shr    $0x1,%eax
and    $0x77777777,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
shr    $0x4,%ecx
add    %ecx,%eax
and    $0xf0f0f0f,%eax
mov    %eax,-0x14(%rbp)
imul   $0x1010101,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x18,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_bits>:
test   %rdi,%rdi
je     113f <count_bits+0x3f>
mov    %esi,%eax
shr    %eax
and    $0x77777777,%eax
mov    %esi,%ecx
shr    $0x2,%ecx
and    $0x33333333,%ecx
add    %eax,%ecx
mov    %esi,%eax
shr    $0x3,%eax
and    $0x11111111,%eax
add    %ecx,%eax
sub    %eax,%esi
mov    %esi,%eax
shr    $0x4,%eax
add    %esi,%eax
and    $0xf0f0f0f,%eax
imul   $0x1010101,%eax,%eax
shr    $0x18,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.Flex = type { i32 }
define i32 @count_bits(%struct.Flex* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.Flex*
%5 = alloca i32
%6 = alloca i32
store %struct.Flex* %0, %struct.Flex** %4
store i32 %1, i32* %5
%7 = load %struct.Flex*, %struct.Flex** %4
%8 = icmp eq %struct.Flex* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 0, i32* %3
br label %38
10: ; preds = %2
%11 = load i32, i32* %5
%12 = lshr i32 %11, 1
%13 = and i32 %12, 2004318071
store i32 %13, i32* %6
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = sub i32 %14, %15
store i32 %16, i32* %5
%17 = load i32, i32* %6
%18 = lshr i32 %17, 1
%19 = and i32 %18, 2004318071
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = sub i32 %20, %21
store i32 %22, i32* %5
%23 = load i32, i32* %6
%24 = lshr i32 %23, 1
%25 = and i32 %24, 2004318071
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = sub i32 %26, %27
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = load i32, i32* %5
%31 = lshr i32 %30, 4
%32 = add i32 %29, %31
%33 = and i32 %32, 252645135
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = mul i32 %34, 16843009
store i32 %35, i32* %5
%36 = load i32, i32* %5
%37 = lshr i32 %36, 24
store i32 %37, i32* %3
br label %38
38: ; preds = %10, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
%struct.Flex = type { i32 }
define i32 @count_bits(%struct.Flex* readnone %0, i32 %1) {
%3 = icmp eq %struct.Flex* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = lshr i32 %1, 1
%6 = and i32 %5, 2004318071
%7 = lshr i32 %1, 2
%8 = and i32 %7, 858993459
%9 = lshr i32 %1, 3
%10 = and i32 %9, 286331153
%11 = add nuw i32 %8, %6
%12 = add nuw i32 %11, %10
%13 = sub i32 %1, %12
%14 = lshr i32 %13, 4
%15 = add i32 %14, %13
%16 = and i32 %15, 252645135
%17 = mul i32 %16, 16843009
%18 = lshr i32 %17, 24
br label %19
19: ; preds = %2, %4
%20 = phi i32 [ %18, %4 ], [ 0, %2 ]
ret i32 %20
}