#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*/ printf(char *, char const *const, ...);
int /*<<< orphan*/ putchar(char);
int scanf(char *, unsigned long *);
char *writeUTF8(char *, unsigned long);
int main(void) {
  static const char *const nibbles[16] = {
      "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111",
      "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
  unsigned long value;
  char buffer[20], *end, *ch;
  unsigned shift;
  while (scanf("%lu", &value) == 1) {
    end = writeUTF8(buffer, value);
    shift = 32;
    do {
      shift -= 4;
      printf("  %s" + !(shift & 4), nibbles[(value >> shift) & 15]);
    } while (shift);
    putchar('\n');
    for (ch = buffer; ch != end; ++ch) {
      printf("  %s %s", nibbles[(unsigned char)*ch >> 4], nibbles[*ch & 15]);
    }
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xefa(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1253 <main+0x113>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <writeUTF8@plt>
mov    %rax,-0x38(%rbp)
movl   $0x20,-0x44(%rbp)
mov    -0x44(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cltq
lea    0xeaf(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
shr    %cl,%rax
mov    %rax,%rcx
and    $0xf,%rcx
lea    0x2be0(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     1244 <main+0x104>
mov    -0x40(%rbp),%rax
movzbl (%rax),%eax
sar    $0x4,%eax
movslq %eax,%rcx
lea    0x2b97(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0x2b7f(%rip),%rax
mov    (%rax,%rcx,8),%rdx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11e7 <main+0xa7>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xefb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    12e0 <main+0x1a0>
lea    0x2c31(%rip),%r13
lea    0xedf(%rip),%r15
lea    0xedc(%rip),%rbp
jmp    11a4 <main+0x64>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xebf(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    12e0 <main+0x1a0>
mov    0x8(%rsp),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1050 <writeUTF8@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rax
shr    $0x19,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
lea    0xe84(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    $0x15,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    $0x11,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    $0xd,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    $0x9,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    $0x5,%rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
shr    %rax
and    $0x78,%eax
mov    (%rax,%r13,1),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rax
and    $0xf,%eax
mov    0x0(%r13,%rax,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r12,%r14
je     1180 <main+0x40>
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14),%eax
mov    %rax,%rcx
shr    $0x4,%rcx
mov    0x0(%r13,%rcx,8),%rsi
and    $0xf,%eax
mov    0x0(%r13,%rax,8),%rdx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r12,%r14
jne    12b0 <main+0x170>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.nibbles = internal constant [16 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0)]
@.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 = [4 x i8] c"%lu\00"
@.str.17 = [5 x i8] c" %s\00"
@.str.18 = [8 x i8] c" %s %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [20 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
br label %7
7: ; preds = %61, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i64* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %63
10: ; preds = %7
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = load i64, i64* %2
%13 = call i8* @writeUTF8(i8* %11, i64 %12)
store i8* %13, i8** %4
store i32 32, i32* %6
br label %14
14: ; preds = %32, %10
%15 = load i32, i32* %6
%16 = sub i32 %15, 4
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = and i32 %17, 4
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i64 %22
%24 = load i64, i64* %2
%25 = load i32, i32* %6
%26 = zext i32 %25 to i64
%27 = lshr i64 %24, %26
%28 = and i64 %27, 15
%29 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, ...) @printf(i8* %23, i8* %30)
br label %32
32: ; preds = %14
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %14, label %35
35: ; preds = %32
%36 = call i32 @putchar(i8 signext 10)
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
store i8* %37, i8** %5
br label %38
38: ; preds = %58, %35
%39 = load i8*, i8** %5
%40 = load i8*, i8** %4
%41 = icmp ne i8* %39, %40
br i1 %41, label %42, label %61
42: ; preds = %38
%43 = load i8*, i8** %5
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = ashr i32 %45, 4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = load i8*, i8** %5
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = and i32 %52, 15
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* %49, i8* %56)
br label %58
58: ; preds = %42
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %5
br label %38
61: ; preds = %38
%62 = call i32 @putchar(i8 signext 10)
br label %7
63: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@main.nibbles = internal unnamed_addr constant [16 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0)]
@.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 = [4 x i8] c"%lu\00"
@.str.17 = [5 x i8] c" %s\00"
@.str.18 = [8 x i8] c" %s %s\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [20 x i8]
%3 = bitcast i64* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i64* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %77
7: ; preds = %0, %73
%8 = load i64, i64* %1
%9 = call i8* @writeUTF8(i8* %4, i64 %8)
%10 = load i64, i64* %1
%11 = lshr i64 %10, 28
%12 = and i64 %11, 15
%13 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %14)
%16 = load i64, i64* %1
%17 = lshr i64 %16, 24
%18 = and i64 %17, 15
%19 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 1), i8* %20)
%22 = load i64, i64* %1
%23 = lshr i64 %22, 20
%24 = and i64 %23, 15
%25 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %26)
%28 = load i64, i64* %1
%29 = lshr i64 %28, 16
%30 = and i64 %29, 15
%31 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 1), i8* %32)
%34 = load i64, i64* %1
%35 = lshr i64 %34, 12
%36 = and i64 %35, 15
%37 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %38)
%40 = load i64, i64* %1
%41 = lshr i64 %40, 8
%42 = and i64 %41, 15
%43 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 1), i8* %44)
%46 = load i64, i64* %1
%47 = lshr i64 %46, 4
%48 = and i64 %47, 15
%49 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i8* %50)
%52 = load i64, i64* %1
%53 = and i64 %52, 15
%54 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 1), i8* %55)
%57 = call i32 @putchar(i8 signext 10)
%58 = icmp eq i8* %4, %9
br i1 %58, label %73, label %59
59: ; preds = %7, %59
%60 = phi i8* [ %71, %59 ], [ %4, %7 ]
%61 = load i8, i8* %60
%62 = lshr i8 %61, 4
%63 = zext i8 %62 to i64
%64 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %63
%65 = load i8*, i8** %64
%66 = and i8 %61, 15
%67 = zext i8 %66 to i64
%68 = getelementptr inbounds [16 x i8*], [16 x i8*]* @main.nibbles, i64 0, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8* %65, i8* %69)
%71 = getelementptr inbounds i8, i8* %60, i64 1
%72 = icmp eq i8* %71, %9
br i1 %72, label %73, label %59
73: ; preds = %59, %7
%74 = call i32 @putchar(i8 signext 10)
%75 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.16, i64 0, i64 0), i64* %1)
%76 = icmp eq i32 %75, 1
br i1 %76, label %7, label %77
77: ; preds = %73, %0
ret i32 0
}