#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 uint64_t;

/* Variables and functions */
int UINT64_C(int);
unsigned int count_1bits(uint64_t x) {
  const uint64_t h55 = UINT64_C(0x5555555555555555);
  const uint64_t h33 = UINT64_C(0x3333333333333333);
  const uint64_t h0F = UINT64_C(0x0F0F0F0F0F0F0F0F);
  const uint64_t h01 = UINT64_C(0x0101010101010101);
  x -= (x >> 1) & h55;
  x = (x & h33) + ((x >> 2) & h33);
  x = (x + (x >> 4)) & h0F;
  return (x * h01) >> 56;
}


x86 assembly (clang, -O0):
<count_1bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x55555555,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0x8(%rbp)
mov    $0x33333333,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0xc(%rbp)
mov    $0xf0f0f0f,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0x10(%rbp)
mov    $0x1010101,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
and    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x2,%ecx
and    -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x4,%ecx
add    %ecx,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_1bits>:
push   %rax
mov    $0x55555555,%edi
call   1030 <UINT64_C@plt>
mov    $0x33333333,%edi
call   1030 <UINT64_C@plt>
mov    $0xf0f0f0f,%edi
call   1030 <UINT64_C@plt>
mov    $0x1010101,%edi
pop    %rax
jmp    1030 <UINT64_C@plt>

LLVM IR (-O0):
define i32 @count_1bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i32 @UINT64_C(i32 1431655765)
store i32 %7, i32* %3
%8 = call i32 @UINT64_C(i32 858993459)
store i32 %8, i32* %4
%9 = call i32 @UINT64_C(i32 252645135)
store i32 %9, i32* %5
%10 = call i32 @UINT64_C(i32 16843009)
store i32 %10, i32* %6
%11 = load i32, i32* %2
%12 = ashr i32 %11, 1
%13 = load i32, i32* %3
%14 = and i32 %12, %13
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, %14
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = load i32, i32* %4
%19 = and i32 %17, %18
%20 = load i32, i32* %2
%21 = ashr i32 %20, 2
%22 = load i32, i32* %4
%23 = and i32 %21, %22
%24 = add nsw i32 %19, %23
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = load i32, i32* %2
%27 = ashr i32 %26, 4
%28 = add nsw i32 %25, %27
%29 = load i32, i32* %5
%30 = and i32 %28, %29
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = load i32, i32* %6
%33 = mul nsw i32 %31, %32
%34 = ashr i32 %33, 56
ret i32 %34
}

LLVM IR (-O2):
define i32 @count_1bits(i32 %0) {
%2 = tail call i32 @UINT64_C(i32 1431655765)
%3 = tail call i32 @UINT64_C(i32 858993459)
%4 = tail call i32 @UINT64_C(i32 252645135)
%5 = tail call i32 @UINT64_C(i32 16843009)
ret i32 poison
}