#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;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int __popcountdi2(int64_t a) {
  uint64_t x2 = (uint64_t)a;
  x2 = x2 - ((x2 >> 1) & 0x5555555555555555uLL);
  x2 = ((x2 >> 2) & 0x3333333333333333uLL) + (x2 & 0x3333333333333333uLL);
  x2 = (x2 + (x2 >> 4)) & 0x0F0F0F0F0F0F0F0FuLL;
  unsigned int x = (unsigned int)(x2 + (x2 >> 32));
  x = x + (x >> 16);
  return (x + (x >> 8)) & 0x0000007F;
}


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

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

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

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