#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);
int /*<<< orphan*/ putchar(char);
int main() {
  int value = getchar();
  int count = 0;
  while (value != EOF) {
    printf("%02x", value);
    value = getchar();
    if (++count == 64) {
      putchar('\n');
    }
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%eax
je     119c <main+0x6c>
mov    -0x8(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x40,%eax
jne    1197 <main+0x67>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%eax
jne    1161 <main+0x31>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x3f,%ebx
lea    0xe91(%rip),%r15
jmp    1185 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    (%r14),%ebp
je     114a <main+0x1a>
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
sub    $0x1,%ebx
jae    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x50>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %18, %0
%6 = load i32, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 (...) @getchar()
store i32 %12, i32* %2
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
%15 = icmp eq i32 %14, 64
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 @putchar(i8 signext 10)
br label %18
18: ; preds = %16, %9
br label %5
19: ; preds = %5
%20 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %16, label %4
4: ; preds = %0, %13
%5 = phi i32 [ %9, %13 ], [ 0, %0 ]
%6 = phi i32 [ %8, %13 ], [ %1, %0 ]
%7 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 (...) @getchar()
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 64
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @putchar(i8 signext 10)
br label %13
13: ; preds = %11, %4
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %8, %14
br i1 %15, label %16, label %4
16: ; preds = %13, %0
%17 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}