#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 */
uintptr_t NaClBundleSize();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  uintptr_t bundle_size = NaClBundleSize();
  printf("Bundle size is %d\n", bundle_size);
  if (0 != (bundle_size & (bundle_size - 1))) {
    printf("Not a power of 2\n");
    printf("FAILED\n");
    return 1;
  }
  printf("PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <NaClBundleSize@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
and    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     118e <main+0x6e>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a3 <main+0x83>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <NaClBundleSize@plt>
mov    %rax,%rbx
lea    0xeba(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%rbx),%rax
test   %rax,%rbx
jne    1162 <main+0x32>
lea    0xeb3(%rip),%rdi
jmp    117a <main+0x4a>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Bundle size is %d\0A\00"
@.str.1 = [18 x i8] c"Not a power of 2\0A\00"
@.str.2 = [8 x i8] c"FAILED\0A\00"
@.str.3 = [8 x i8] c"PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @NaClBundleSize()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %4)
%6 = load i64, i64* %2
%7 = load i64, i64* %2
%8 = sub i64 %7, 1
%9 = and i64 %6, %8
%10 = icmp ne i64 0, %9
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %16
16: ; preds = %14, %11
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [19 x i8] c"Bundle size is %d\0A\00"
@str = [7 x i8] c"PASSED\00"
@str.4 = [17 x i8] c"Not a power of 2\00"
@str.5 = [7 x i8] c"FAILED\00"
define i32 @main() {
%1 = tail call i64 (...) @NaClBundleSize()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %1)
%3 = tail call i64 @llvm.ctpop.i64(i64 %1)
%4 = icmp ult i64 %3, 2
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0))
br label %7
7: ; preds = %0, %5
%8 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), %0 ]
%9 = phi i32 [ 1, %5 ], [ 0, %0 ]
%10 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret i32 %9
}