#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 getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int b0 = 0, b1 = 0, bytes = 0;
  while ((b0 = getc(stdin)) != EOF) {
    if (bytes == 16) {
      printf("\n");
      bytes = 0;
    } else if (bytes == 8) {
      printf(" ");
    }
    bytes++;
    if (bytes % 2 == 1) {
      b1 = b0;
    } else {
      printf("%2.2x%2.2x ", (unsigned int)b0, (unsigned int)b1);
    }
  }
  if (bytes % 2 == 1) {
    printf("00%2.2x ", (unsigned int)b1);
  }
  printf("\n");
  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,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%eax
je     11ed <main+0xcd>
cmpl   $0x10,-0x1c(%rbp)
jne    118f <main+0x6f>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11ac <main+0x8c>
cmpl   $0x8,-0x1c(%rbp)
jne    11a7 <main+0x87>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ac <main+0x8c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11d4 <main+0xb4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e8 <main+0xc8>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114b <main+0x2b>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1212 <main+0xf2>
mov    -0x18(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2ea6(%rip),%r15
mov    (%r15),%edi
call   1050 <getc@plt>
mov    0x2e8f(%rip),%r12
cmp    (%r12),%eax
je     11fe <main+0xce>
mov    %eax,%ebp
lea    0xe9c(%rip),%r14
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    1192 <main+0x62>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x9,%ebx
mov    %ebp,%r13d
mov    (%r15),%edi
call   1050 <getc@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     11dc <main+0xac>
cmp    $0x8,%ebx
je     1170 <main+0x40>
cmp    $0x10,%ebx
jne    11b0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
jmp    117f <main+0x4f>
nopl   (%rax)
mov    %ebx,%eax
add    $0x1,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0x1,%eax
and    $0xfffffffe,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
cmp    $0x1,%ecx
je     117f <main+0x4f>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1182 <main+0x52>
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebx
cmp    $0x1,%ebx
jne    11fe <main+0xce>
lea    0xe18(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
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

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

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