#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
void 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");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     11df <main+0xaf>
mov    -0x4(%rbp),%eax
mov    %al,-0xd(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1182 <main+0x52>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1189 <main+0x59>
movl   $0x1,-0x8(%rbp)
cmpl   $0x8,-0xc(%rbp)
jne    11a8 <main+0x78>
movl   $0x0,-0xc(%rbp)
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c0 <main+0x90>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <main+0x16>
cmpl   $0x0,-0xc(%rbp)
je     11f7 <main+0xc7>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e93(%rip),%r14
cmp    (%r14),%eax
je     11f6 <main+0xb6>
mov    %eax,%ebx
mov    $0x9,%edi
call   1030 <putchar@plt>
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     11ec <main+0xac>
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe6c(%rip),%r15
jmp    11c9 <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     11e8 <main+0xa8>
mov    $0x2c,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
je     11a0 <main+0x60>
cmp    $0x8,%ebx
jne    11ac <main+0x6c>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x60>
test   %ebx,%ebx
je     11f6 <main+0xb6>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.3 = [7 x i8] c"0x%02X\00"
define void @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
%30 = tail call i32 @exit(i32 0)
unreachable
}