#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 hweight64(uint64_t a) {
  a = (a & 0x5555555555555555ULL) + ((a >> 1) & 0x5555555555555555ULL);
  a = (a & 0x3333333333333333ULL) + ((a >> 2) & 0x3333333333333333ULL);
  a = (a + (a >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
  a = (a + (a >> 8));
  a = (a + (a >> 16));
  a = (a + (a >> 32));
  return a & 0xFF;
}


x86 assembly (clang, -O0):
<hweight64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0x5555555555555555,%rcx
55 55 55
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x1,%ecx
movslq %ecx,%rcx
movabs $0x5555555555555555,%rdx
55 55 55
and    %rdx,%rcx
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0x3333333333333333,%rcx
33 33 33
and    %rcx,%rax
mov    -0x4(%rbp),%ecx
sar    $0x2,%ecx
movslq %ecx,%rcx
movabs $0x3333333333333333,%rdx
33 33 33
and    %rdx,%rcx
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x4,%ecx
add    %ecx,%eax
cltq
movabs $0xf0f0f0f0f0f0f0f,%rcx
0f 0f 0f
and    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hweight64>:
ret

LLVM IR (-O0):
define i32 @hweight64(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sext i32 %3 to i64
%5 = and i64 %4, 6148914691236517205
%6 = load i32, i32* %2
%7 = ashr i32 %6, 1
%8 = sext i32 %7 to i64
%9 = and i64 %8, 6148914691236517205
%10 = add i64 %5, %9
%11 = trunc i64 %10 to i32
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = and i64 %13, 3689348814741910323
%15 = load i32, i32* %2
%16 = ashr i32 %15, 2
%17 = sext i32 %16 to i64
%18 = and i64 %17, 3689348814741910323
%19 = add i64 %14, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = ashr i32 %22, 4
%24 = add nsw i32 %21, %23
%25 = sext i32 %24 to i64
%26 = and i64 %25, 1085102592571150095
%27 = trunc i64 %26 to i32
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = load i32, i32* %2
%30 = ashr i32 %29, 8
%31 = add nsw i32 %28, %30
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = load i32, i32* %2
%34 = ashr i32 %33, 16
%35 = add nsw i32 %32, %34
store i32 %35, i32* %2
%36 = load i32, i32* %2
%37 = load i32, i32* %2
%38 = ashr i32 %37, 32
%39 = add nsw i32 %36, %38
store i32 %39, i32* %2
%40 = load i32, i32* %2
%41 = and i32 %40, 255
ret i32 %41
}

LLVM IR (-O2):
define i32 @hweight64(i32 %0) {
ret i32 poison
}