#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 */
unsigned int next_largest(unsigned int);
unsigned int next_smallest(unsigned int);
int /*<<< orphan*/ print_binary(unsigned int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, unsigned int *);
int main(void) {
  printf("Enter a number\n");
  unsigned n;
  while (scanf("%u", &n) == 1) {
    printf("Received:\t");
    print_binary(n);
    printf("\nNext smallest:\t");
    print_binary(next_smallest(n));
    printf("\nNext largest:\t");
    print_binary(next_largest(n));
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11df <main+0x8f>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <print_binary@plt>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <next_smallest@plt>
mov    %eax,%edi
call   1060 <print_binary@plt>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <next_largest@plt>
mov    %eax,%edi
call   1060 <print_binary@plt>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
jmp    116b <main+0x1b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeab(%rip),%rdi
call   1050 <puts@plt>
lea    0xe70(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    121b <main+0xab>
lea    0xe5d(%rip),%r14
lea    0xe61(%rip),%r15
lea    0xe6b(%rip),%r12
lea    0xe45(%rip),%r13
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
call   1080 <print_binary@plt>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
call   1040 <next_smallest@plt>
mov    %eax,%edi
call   1080 <print_binary@plt>
mov    %r12,%rdi
call   1060 <printf@plt>
mov    0xc(%rsp),%edi
call   1070 <next_largest@plt>
mov    %eax,%edi
call   1080 <print_binary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
cmp    $0x1,%eax
je     11c0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a number\0A\00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [11 x i8] c"Received:\09\00"
@.str.3 = [17 x i8] c"\0ANext smallest:\09\00"
@.str.4 = [16 x i8] c"\0ANext largest:\09\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %7, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = call i32 @print_binary(i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @next_smallest(i32 %12)
%14 = call i32 @print_binary(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = call i32 @next_largest(i32 %16)
%18 = call i32 @print_binary(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %4
20: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [11 x i8] c"Received:\09\00"
@.str.3 = [17 x i8] c"\0ANext smallest:\09\00"
@.str.4 = [16 x i8] c"\0ANext largest:\09\00"
@str = [15 x i8] c"Enter a number\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %21
6: ; preds = %0, %6
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = call i32 @print_binary(i32 %8)
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = call i32 @next_smallest(i32 %11)
%13 = call i32 @print_binary(i32 %12)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = call i32 @next_largest(i32 %15)
%17 = call i32 @print_binary(i32 %16)
%18 = call i32 @putchar(i32 10)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%20 = icmp eq i32 %19, 1
br i1 %20, label %6, label %21
21: ; preds = %6, %0
ret i32 0
}