#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 c;
  int comma = 0;
  int count = 0;
  while ((c = getchar()) != EOF) {
    unsigned char x = c;
    if (comma)
      printf(",");
    else
      comma = 1;
    if (count == 8) {
      count = 0;
      printf("\n");
    }
    if (count == 0)
      printf("\t");
    printf("0x%02X", c);
    count++;
  }
  if (count)
    printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11d6 <main+0xb6>
mov    -0x8(%rbp),%eax
mov    %al,-0x11(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1179 <main+0x59>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x60>
movl   $0x1,-0xc(%rbp)
cmpl   $0x8,-0x10(%rbp)
jne    119f <main+0x7f>
movl   $0x0,-0x10(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11b7 <main+0x97>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <main+0x1d>
cmpl   $0x0,-0x10(%rbp)
je     11ee <main+0xce>
lea    0xe1b(%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   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%eax
je     11e6 <main+0xb6>
mov    %eax,%ebx
mov    $0x9,%edi
call   1030 <putchar@plt>
lea    0xe9f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     11dc <main+0xac>
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe7c(%rip),%r15
jmp    11b9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
je     11d8 <main+0xa8>
mov    $0x2c,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
je     1190 <main+0x60>
cmp    $0x8,%ebx
jne    119c <main+0x6c>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x60>
test   %ebx,%ebx
je     11e6 <main+0xb6>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.3 = [7 x i8] c"0x%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 %29, label %4
4: ; preds = %0
%5 = tail call i32 @putchar(i32 9)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %1)
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %27, label %10
10: ; preds = %4, %18
%11 = phi i32 [ %22, %18 ], [ %7, %4 ]
%12 = phi i32 [ %21, %18 ], [ 1, %4 ]
%13 = tail call i32 @putchar(i32 44)
switch i32 %12, label %18 [
i32 8, label %14
i32 0, label %16
]
14: ; preds = %10
%15 = tail call i32 @putchar(i32 10)
br label %16
16: ; preds = %10, %14
%17 = tail call i32 @putchar(i32 9)
br label %18
18: ; preds = %10, %16
%19 = phi i32 [ 0, %16 ], [ %12, %10 ]
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%21 = add nsw i32 %19, 1
%22 = tail call i32 (...) @getchar()
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %10
25: ; preds = %18
%26 = icmp eq i32 %21, 0
br i1 %26, label %29, label %27
27: ; preds = %4, %25
%28 = tail call i32 @putchar(i32 10)
br label %29
29: ; preds = %0, %27, %25
ret i32 0
}