#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 nibble_swap(int);
int /*<<< orphan*/ printf(char *);
void print_number_as_binary(int number) {
  unsigned int i;
  unsigned int nibble;
  unsigned int mask = 0x0000000F;
  unsigned int remainder;
  remainder = nibble_swap(number);
  for (i = 0; i < (sizeof(unsigned int) * 2); i++) {
    nibble = (remainder & mask) >> (i * 4);
    remainder = (remainder & (~mask));
    mask = mask << 4;
    switch (nibble) {
    case 0:
      printf("0000");
      break;
    case 1:
      printf("0001");
      break;
    case 2:
      printf("0010");
      break;
    case 3:
      printf("0011");
      break;
    case 4:
      printf("0100");
      break;
    case 5:
      printf("0101");
      break;
    case 6:
      printf("0110");
      break;
    case 7:
      printf("0111");
      break;
    case 8:
      printf("1000");
      break;
    case 9:
      printf("1001");
      break;
    case 0xA:
      printf("1010");
      break;
    case 0xB:
      printf("1011");
      break;
    case 0xC:
      printf("1100");
      break;
    case 0xD:
      printf("1101");
      break;
    case 0xE:
      printf("1110");
      break;
    case 0xF:
      printf("1111");
      break;
    default:
      printf("oops.\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<print_number_as_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xf,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <nibble_swap@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    $0x8,%rax
jae    12ce <print_number_as_binary+0x1ae>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
and    %ecx,%eax
mov    -0x8(%rbp),%cl
shl    $0x2,%cl
shr    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
not    %ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0xf,%rax
ja     12af <print_number_as_binary+0x18f>
mov    -0x20(%rbp),%rax
lea    0xe6a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xde6(%rip),%rdi
call   1030 <printf@plt>
jmp    12bb <print_number_as_binary+0x19b>
lea    0xdda(%rip),%rdi
call   1030 <printf@plt>
jmp    12c0 <print_number_as_binary+0x1a0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <print_number_as_binary+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_number_as_binary>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1050 <nibble_swap@plt>
mov    %eax,%ebx
mov    $0xf,%r15d
xor    %ebp,%ebp
lea    0xeaf(%rip),%r12
lea    0xf2e(%rip),%r13
lea    0xf2c(%rip),%r14
jmp    1187 <print_number_as_binary+0x57>
lea    0xf28(%rip),%rdi
call   1030 <puts@plt>
nopl   (%rax)
mov    %r15d,%eax
not    %eax
and    %eax,%ebx
shl    $0x4,%r15d
add    $0x4,%ebp
cmp    $0x20,%ebp
je     1297 <print_number_as_binary+0x167>
mov    %ebx,%eax
and    %r15d,%eax
mov    %ebp,%ecx
shr    %cl,%eax
cmp    $0xf,%eax
ja     1161 <print_number_as_binary+0x31>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
mov    %r13,%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    1170 <print_number_as_binary+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@.str.16 = [7 x i8] c"oops.\0A\00"
define void @print_number_as_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 15, i32* %5
%7 = load i32, i32* %2
%8 = call i32 @nibble_swap(i32 %7)
store i32 %8, i32* %6
store i32 0, i32* %3
br label %9
9: ; preds = %62, %1
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = icmp ult i64 %11, 8
br i1 %12, label %13, label %65
13: ; preds = %9
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = and i32 %14, %15
%17 = load i32, i32* %3
%18 = mul i32 %17, 4
%19 = lshr i32 %16, %18
store i32 %19, i32* %4
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = xor i32 %21, -1
%23 = and i32 %20, %22
store i32 %23, i32* %6
%24 = load i32, i32* %5
%25 = shl i32 %24, 4
store i32 %25, i32* %5
%26 = load i32, i32* %4
switch i32 %26, label %59 [
i32 0, label %27
i32 1, label %29
i32 2, label %31
i32 3, label %33
i32 4, label %35
i32 5, label %37
i32 6, label %39
i32 7, label %41
i32 8, label %43
i32 9, label %45
i32 10, label %47
i32 11, label %49
i32 12, label %51
i32 13, label %53
i32 14, label %55
i32 15, label %57
]
27: ; preds = %13
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %61
29: ; preds = %13
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %61
31: ; preds = %13
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %61
33: ; preds = %13
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %61
35: ; preds = %13
%36 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %61
37: ; preds = %13
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %61
39: ; preds = %13
%40 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %61
41: ; preds = %13
%42 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %61
43: ; preds = %13
%44 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %61
45: ; preds = %13
%46 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %61
47: ; preds = %13
%48 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %61
49: ; preds = %13
%50 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %61
51: ; preds = %13
%52 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %61
53: ; preds = %13
%54 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %61
55: ; preds = %13
%56 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %61
57: ; preds = %13
%58 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
br label %61
59: ; preds = %13
%60 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0))
br label %61
61: ; preds = %59, %57, %55, %53, %51, %49, %47, %45, %43, %41, %39, %37, %35, %33, %31, %29, %27
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = add i32 %63, 1
store i32 %64, i32* %3
br label %9
65: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"0000\00"
@.str.1 = [5 x i8] c"0001\00"
@.str.2 = [5 x i8] c"0010\00"
@.str.3 = [5 x i8] c"0011\00"
@.str.4 = [5 x i8] c"0100\00"
@.str.5 = [5 x i8] c"0101\00"
@.str.6 = [5 x i8] c"0110\00"
@.str.7 = [5 x i8] c"0111\00"
@.str.8 = [5 x i8] c"1000\00"
@.str.9 = [5 x i8] c"1001\00"
@.str.10 = [5 x i8] c"1010\00"
@.str.11 = [5 x i8] c"1011\00"
@.str.12 = [5 x i8] c"1100\00"
@.str.13 = [5 x i8] c"1101\00"
@.str.14 = [5 x i8] c"1110\00"
@.str.15 = [5 x i8] c"1111\00"
@str = [6 x i8] c"oops.\00"
define void @print_number_as_binary(i32 %0) {
%2 = tail call i32 @nibble_swap(i32 %0)
br label %3
3: ; preds = %1, %47
%4 = phi i32 [ %2, %1 ], [ %11, %47 ]
%5 = phi i32 [ 15, %1 ], [ %12, %47 ]
%6 = phi i32 [ 0, %1 ], [ %48, %47 ]
%7 = and i32 %4, %5
%8 = shl nuw nsw i32 %6, 2
%9 = lshr i32 %7, %8
%10 = xor i32 %5, -1
%11 = and i32 %4, %10
%12 = shl i32 %5, 4
switch i32 %9, label %45 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
i32 5, label %23
i32 6, label %25
i32 7, label %27
i32 8, label %29
i32 9, label %31
i32 10, label %33
i32 11, label %35
i32 12, label %37
i32 13, label %39
i32 14, label %41
i32 15, label %43
]
13: ; preds = %3
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %47
15: ; preds = %3
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %47
17: ; preds = %3
%18 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %47
19: ; preds = %3
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %47
21: ; preds = %3
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %47
23: ; preds = %3
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %47
25: ; preds = %3
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %47
27: ; preds = %3
%28 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %47
29: ; preds = %3
%30 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %47
31: ; preds = %3
%32 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %47
33: ; preds = %3
%34 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %47
35: ; preds = %3
%36 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %47
37: ; preds = %3
%38 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %47
39: ; preds = %3
%40 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0))
br label %47
41: ; preds = %3
%42 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %47
43: ; preds = %3
%44 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0))
br label %47
45: ; preds = %3
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %47
47: ; preds = %13, %15, %17, %19, %21, %23, %25, %27, %29, %31, %33, %35, %37, %39, %41, %43, %45
%48 = add nuw nsw i32 %6, 1
%49 = icmp eq i32 %48, 8
br i1 %49, label %50, label %3
50: ; preds = %47
ret void
}