#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 NumberOfOnes(int);
int nextBig(int, int);
int nextSmall(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
main() {
  int x = 0x1037;
  int n1;
  int smallest, biggest;
  n1 = NumberOfOnes(x);
  printf("x=0x%x, 1s=%d\n", x, n1);
  smallest = nextSmall(x, n1);
  printf("small=0x%x\n", smallest);
  biggest = nextBig(x, n1);
  printf("next big=0x%x\n", biggest);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1037,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <NumberOfOnes@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <nextSmall@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <nextBig@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1037,%edi
call   1050 <NumberOfOnes@plt>
mov    %eax,%ebx
lea    0xeac(%rip),%rdi
mov    $0x1037,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1037,%edi
mov    %ebx,%esi
call   1060 <nextSmall@plt>
lea    0xe9a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1037,%edi
mov    %ebx,%esi
call   1040 <nextBig@plt>
lea    0xe8a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"x=0x%x, 1s=%d\0A\00"
@.str.1 = [12 x i8] c"small=0x%x\0A\00"
@.str.2 = [15 x i8] c"next big=0x%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 4151, i32* %1
%5 = load i32, i32* %1
%6 = call i32 @NumberOfOnes(i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = call i32 @nextSmall(i32 %10, i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = call i32 @nextBig(i32 %15, i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"x=0x%x, 1s=%d\0A\00"
@.str.1 = [12 x i8] c"small=0x%x\0A\00"
@.str.2 = [15 x i8] c"next big=0x%x\0A\00"
define i32 @main() {
%1 = tail call i32 @NumberOfOnes(i32 4151)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4151, i32 %1)
%3 = tail call i32 @nextSmall(i32 4151, i32 %1)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @nextBig(i32 4151, i32 %1)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %5)
ret i32 0
}