#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int ch;
  int i;
  i = 0;
  while (1) {
    ch = getchar();
    if (ch == EOF) {
      printf("\n");
      return 0;
    }
    if (i % 16 == 0) {
      printf("%08X  ", i);
    }
    printf("%X%X", (ch & 0xF0) >> 4, ch & 0xF);
    if (i % 2 == 1) {
      printf(" ");
    }
    if (i % 16 == 15) {
      printf("\n");
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%eax
jne    116f <main+0x4f>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1194 <main+0x74>
mov    -0x18(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
and    $0xf0,%esi
sar    $0x4,%esi
mov    -0x14(%rbp),%edx
and    $0xf,%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11d6 <main+0xb6>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11f8 <main+0xd8>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9f(%rip),%r12
cmp    (%r12),%eax
jne    116a <main+0x3a>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
lea    0xe8d(%rip),%r14
lea    0xe8d(%rip),%r15
xor    %ebp,%ebp
jmp    1192 <main+0x62>
xchg   %ax,%ax
add    $0x1,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r12),%eax
je     114f <main+0x1f>
mov    %ebp,%r13d
and    $0xf,%r13d
jne    11a7 <main+0x77>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x4,%esi
and    $0xf,%esi
and    $0xf,%ebx
mov    %r15,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bpl
je     11ce <main+0x9e>
mov    $0x20,%edi
call   1030 <putchar@plt>
cmp    $0xf,%r13d
jne    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x50>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [2 x i8] c"\0A\00"
@.str.1 = [7 x i8] c"%08X \00"
@.str.2 = [5 x i8] c"%X%X\00"
@.str.3 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %2, %40
%9 = call i32 (...) @getchar()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
15: ; preds = %8
%16 = load i32, i32* %7
%17 = srem i32 %16, 16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %15
%23 = load i32, i32* %6
%24 = and i32 %23, 240
%25 = ashr i32 %24, 4
%26 = load i32, i32* %6
%27 = and i32 %26, 15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %27)
%29 = load i32, i32* %7
%30 = srem i32 %29, 2
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %34
32: ; preds = %22
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %22
%35 = load i32, i32* %7
%36 = srem i32 %35, 16
%37 = icmp eq i32 %36, 15
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %8
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [7 x i8] c"%08X \00"
@.str.2 = [5 x i8] c"%X%X\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %28, %2
%7 = tail call i32 @putchar(i32 10)
ret i32 0
8: ; preds = %2, %28
%9 = phi i32 [ %30, %28 ], [ %3, %2 ]
%10 = phi i32 [ %29, %28 ], [ 0, %2 ]
%11 = and i32 %10, 15
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %15
15: ; preds = %13, %8
%16 = lshr i32 %9, 4
%17 = and i32 %16, 15
%18 = and i32 %9, 15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18)
%20 = and i32 %10, 1
%21 = icmp eq i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = tail call i32 @putchar(i32 32)
br label %24
24: ; preds = %22, %15
%25 = icmp eq i32 %11, 15
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 @putchar(i32 10)
br label %28
28: ; preds = %26, %24
%29 = add nuw nsw i32 %10, 1
%30 = tail call i32 (...) @getchar()
%31 = load i32, i32* @EOF
%32 = icmp eq i32 %30, %31
br i1 %32, label %6, label %8
}