#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 /*<<< orphan*/ print_binary(unsigned int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, unsigned int *);
unsigned int swap_pairs(unsigned int);
int main(void) {
  printf("Enter a number for the Flip Bit to Win game\n");
  printf("> ");
  unsigned n;
  while (scanf("%u", &n) == 1) {
    printf("Input:\t");
    print_binary(n);
    printf("Output:\t");
    print_binary(swap_pairs(n));
    printf("> ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    11c0 <main+0x80>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1050 <print_binary@plt>
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <swap_pairs@plt>
mov    %eax,%edi
call   1050 <print_binary@plt>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
jmp    1167 <main+0x27>
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    0xeb3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
call   1050 <printf@plt>
lea    0xe87(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11f1 <main+0xa1>
lea    0xe74(%rip),%r14
lea    0xe75(%rip),%r15
lea    0xe60(%rip),%r12
lea    0xe5c(%rip),%r13
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
call   1060 <print_binary@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
call   1040 <swap_pairs@plt>
mov    %eax,%edi
call   1060 <print_binary@plt>
mov    %r12,%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     11b0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Enter a number for the Flip Bit to Win game\0A\00"
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [8 x i8] c"Input:\09\00"
@.str.4 = [9 x i8] c"Output:\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %8, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = call i32 @print_binary(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32, i32* %2
%14 = call i32 @swap_pairs(i32 %13)
%15 = call i32 @print_binary(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %5
17: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"> \00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [8 x i8] c"Input:\09\00"
@.str.4 = [9 x i8] c"Output:\09\00"
@str = [44 x i8] c"Enter a number for the Flip Bit to Win game\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %18
7: ; preds = %0, %7
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = call i32 @print_binary(i32 %9)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @swap_pairs(i32 %12)
%14 = call i32 @print_binary(i32 %13)
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%17 = icmp eq i32 %16, 1
br i1 %17, label %7, label %18
18: ; preds = %7, %0
ret i32 0
}