#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 */

/* Variables and functions */
int rand();
scalar_t__ test__popcountsi2(int);
int main() {
  if (test__popcountsi2(0))
    return 1;
  if (test__popcountsi2(1))
    return 1;
  if (test__popcountsi2(2))
    return 1;
  if (test__popcountsi2(0xFFFFFFFD))
    return 1;
  if (test__popcountsi2(0xFFFFFFFE))
    return 1;
  if (test__popcountsi2(0xFFFFFFFF))
    return 1;
  int i;
  for (i = 0; i < 10000; ++i)
    if (test__popcountsi2(rand()))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     114c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
mov    $0x1,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     116c <main+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
mov    $0x2,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     118c <main+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
mov    $0xfffffffd,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     11ac <main+0x8c>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
mov    $0xfffffffe,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     11cc <main+0xac>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
mov    $0xffffffff,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     11ec <main+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jge    1237 <main+0x117>
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,%edi
call   1040 <test__popcountsi2@plt>
cmp    $0x0,%rax
je     1224 <main+0x104>
movl   $0x1,-0x4(%rbp)
jmp    123e <main+0x11e>
jmp    1229 <main+0x109>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f3 <main+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1040 <test__popcountsi2@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1137 <main+0x17>
pop    %rbx
ret
mov    $0x1,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
jne    1182 <main+0x62>
mov    $0x2,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
jne    1182 <main+0x62>
mov    $0xfffffffd,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
jne    1182 <main+0x62>
mov    $0xfffffffe,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
jne    1182 <main+0x62>
mov    $0xffffffff,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
je     1189 <main+0x69>
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2710,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%edi
call   1040 <test__popcountsi2@plt>
test   %rax,%rax
jne    1182 <main+0x62>
xor    %eax,%eax
add    $0xffffffff,%ebx
jne    118e <main+0x6e>
jmp    1135 <main+0x15>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i64 @test__popcountsi2(i32 0)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 1, i32* %1
br label %40
6: ; preds = %0
%7 = call i64 @test__popcountsi2(i32 1)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %1
br label %40
10: ; preds = %6
%11 = call i64 @test__popcountsi2(i32 2)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 1, i32* %1
br label %40
14: ; preds = %10
%15 = call i64 @test__popcountsi2(i32 -3)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 1, i32* %1
br label %40
18: ; preds = %14
%19 = call i64 @test__popcountsi2(i32 -2)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %1
br label %40
22: ; preds = %18
%23 = call i64 @test__popcountsi2(i32 -1)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 1, i32* %1
br label %40
26: ; preds = %22
store i32 0, i32* %2
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 10000
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = call i32 (...) @rand()
%32 = call i64 @test__popcountsi2(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %1
br label %40
35: ; preds = %30
br label %36
36: ; preds = %35
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %27
39: ; preds = %27
store i32 0, i32* %1
br label %40
40: ; preds = %39, %34, %25, %21, %17, %13, %9, %5
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @test__popcountsi2(i32 0)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %26
3: ; preds = %0
%4 = tail call i64 @test__popcountsi2(i32 1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %26
6: ; preds = %3
%7 = tail call i64 @test__popcountsi2(i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = tail call i64 @test__popcountsi2(i32 -3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %9
%13 = tail call i64 @test__popcountsi2(i32 -2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = tail call i64 @test__popcountsi2(i32 -1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %26
18: ; preds = %21
%19 = add nuw nsw i32 %22, 1
%20 = icmp eq i32 %19, 10000
br i1 %20, label %26, label %21
21: ; preds = %15, %18
%22 = phi i32 [ %19, %18 ], [ 0, %15 ]
%23 = tail call i32 (...) @rand()
%24 = tail call i64 @test__popcountsi2(i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %18, label %26
26: ; preds = %21, %18, %15, %12, %9, %6, %3, %0
%27 = phi i32 [ 1, %0 ], [ 1, %3 ], [ 1, %6 ], [ 1, %9 ], [ 1, %12 ], [ 1, %15 ], [ 0, %18 ], [ 1, %21 ]
ret i32 %27
}