#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*/ printbuf(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(int argc, char **argv) {
  int c;
  int len = 0;
  char buf[8];
  while ((c = getchar()) != EOF) {
    buf[len] = c;
    printf("%02x ", c);
    len++;
    if (len == 8) {
      printf("    ");
      len = 0;
      printbuf(buf, 8);
      putchar('\n');
    }
  }
  if (len > 0)
    printbuf(buf, len);
}


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   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%eax
je     11d9 <main+0x99>
mov    -0x14(%rbp),%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x14(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jne    11d4 <main+0x94>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x8,%esi
call   1060 <printbuf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    115d <main+0x1d>
cmpl   $0x0,-0x18(%rbp)
jle    11ef <main+0xaf>
lea    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <printbuf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e8d(%rip),%r13
cmp    0x0(%r13),%eax
je     11dd <main+0x9d>
lea    0xe98(%rip),%r14
lea    0xe97(%rip),%r15
lea    0x8(%rsp),%r12
xor    %ebx,%ebx
jmp    118d <main+0x4d>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    0x0(%r13),%eax
je     11cd <main+0x8d>
movslq %ebx,%rbx
mov    %al,0x8(%rsp,%rbx,1)
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x8,%ebx
jne    1180 <main+0x40>
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x8,%esi
call   1060 <printbuf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x40>
test   %ebx,%ebx
jle    11dd <main+0x9d>
lea    0x8(%rsp),%rdi
mov    %ebx,%esi
call   1060 <printbuf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [6 x i8] c"%02x \00"
@.str.1 = [5 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
%8 = alloca [8 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %9
9: ; preds = %30, %2
%10 = call i32 (...) @getchar()
store i32 %10, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i32, i32* %6
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 %17
store i8 %15, i8* %18
%19 = load i32, i32* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp eq i32 %23, 8
br i1 %24, label %25, label %30
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%28 = call i32 @printbuf(i8* %27, i32 8)
%29 = call i32 @putchar(i8 signext 10)
br label %30
30: ; preds = %25, %13
br label %9
31: ; preds = %9
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%36 = load i32, i32* %7
%37 = call i32 @printbuf(i8* %35, i32 %36)
br label %38
38: ; preds = %34, %31
%39 = load i32, i32* %3
ret i32 %39
}

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