#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 uint8_t;
typedef int uint64_t;

/* Variables and functions */
uint8_t popcnt64(uint64_t r1) {
  uint64_t temp = r1;
  temp = (temp & 0x5555555555555555) + ((temp >> 1) & 0x5555555555555555);
  temp = (temp & 0x3333333333333333) + ((temp >> 2) & 0x3333333333333333);
  temp = (temp & 0x0f0f0f0f0f0f0f0f) + ((temp >> 4) & 0x0f0f0f0f0f0f0f0f);
  temp = (temp & 0x00ff00ff00ff00ff) + ((temp >> 8) & 0x00ff00ff00ff00ff);
  temp = (temp & 0x0000ffff0000ffff) + ((temp >> 16) & 0x0000ffff0000ffff);
  temp = (temp & 0x00000000ffffffff) + ((temp >> 32) & 0x00000000ffffffff);
  return temp;
}


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

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

LLVM IR (-O0):
define i32 @popcnt64(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = and i64 %6, 6148914691236517205
%8 = load i32, i32* %3
%9 = ashr i32 %8, 1
%10 = sext i32 %9 to i64
%11 = and i64 %10, 6148914691236517205
%12 = add nsw i64 %7, %11
%13 = trunc i64 %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = and i64 %15, 3689348814741910323
%17 = load i32, i32* %3
%18 = ashr i32 %17, 2
%19 = sext i32 %18 to i64
%20 = and i64 %19, 3689348814741910323
%21 = add nsw i64 %16, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = and i64 %24, 1085102592571150095
%26 = load i32, i32* %3
%27 = ashr i32 %26, 4
%28 = sext i32 %27 to i64
%29 = and i64 %28, 1085102592571150095
%30 = add nsw i64 %25, %29
%31 = trunc i64 %30 to i32
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = and i64 %33, 71777214294589695
%35 = load i32, i32* %3
%36 = ashr i32 %35, 8
%37 = sext i32 %36 to i64
%38 = and i64 %37, 71777214294589695
%39 = add nsw i64 %34, %38
%40 = trunc i64 %39 to i32
store i32 %40, i32* %3
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = and i64 %42, 281470681808895
%44 = load i32, i32* %3
%45 = ashr i32 %44, 16
%46 = sext i32 %45 to i64
%47 = and i64 %46, 281470681808895
%48 = add nsw i64 %43, %47
%49 = trunc i64 %48 to i32
store i32 %49, i32* %3
%50 = load i32, i32* %3
%51 = and i32 %50, -1
%52 = load i32, i32* %3
%53 = ashr i32 %52, 32
%54 = and i32 %53, -1
%55 = add i32 %51, %54
store i32 %55, i32* %3
%56 = load i32, i32* %3
ret i32 %56
}

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