#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 /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  int c;
  unsigned long n = 0;
  printf("\nchar %s[] = {\n", argc > 1 ? argv[1] : "chararray");
  while ((c = getchar()) != EOF) {
    printf("%c 0x%.02X", n++ ? ',' : ' ', c);
    if ((n % 9) == 0)
      putchar('\n');
  }
  puts("\n, 0x00\n};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1179 <main+0x39>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <main+0x49>
lea    0xe90(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1189 <main+0x49>
mov    -0x28(%rbp),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%eax
je     120c <main+0xcc>
mov    -0x20(%rbp),%rcx
mov    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    $0x20,%esi
mov    $0x2c,%eax
cmp    $0x0,%rcx
cmovne %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
mov    $0x9,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    1207 <main+0xc7>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    119b <main+0x5b>
lea    0xe12(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1156 <main+0x16>
mov    0x8(%rsi),%rsi
jmp    115d <main+0x1d>
lea    0xeb3(%rip),%rsi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ecx
mov    0x2e6d(%rip),%rax
cmp    (%rax),%ecx
jne    119c <main+0x5c>
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffffffffffff,%r12
mov    $0x1,%ebx
mov    $0x20,%ebp
lea    0xe66(%rip),%r14
xor    %r15d,%r15d
jmp    11dc <main+0x9c>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ecx
add    $0xffffffffffffffff,%r12
add    $0x1,%rbx
mov    0x2e10(%rip),%rax
cmp    (%rax),%ecx
je     117f <main+0x3f>
mov    %rbx,%rax
movabs $0xe38e38e38e38e38f,%rdx
38 8e e3
mul    %rdx
shr    $0x3,%rdx
lea    (%rdx,%rdx,8),%r13
sub    $0x1,%r15
mov    $0x2c,%esi
cmovb  %ebp,%esi
mov    %r14,%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    %r12,%r13
jne    11c0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c0 <main+0x80>

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

LLVM IR (-O2):
@.str = [16 x i8] c"\0Achar %s[] = {\0A\00"
@.str.1 = [10 x i8] c"chararray\00"
@EOF = global i32 0
@.str.2 = [11 x i8] c"%c 0x%.02X\00"
@.str.3 = [12 x i8] c"\0A, 0x00\0A};\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %2 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 (...) @getchar()
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %28, label %13
13: ; preds = %7, %24
%14 = phi i32 [ %25, %24 ], [ %10, %7 ]
%15 = phi i64 [ %16, %24 ], [ 0, %7 ]
%16 = add i64 %15, 1
%17 = icmp eq i64 %15, 0
%18 = select i1 %17, i32 32, i32 44
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %14)
%20 = urem i64 %16, 9
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = tail call i32 @putchar(i8 signext 10)
br label %24
24: ; preds = %22, %13
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %13
28: ; preds = %24, %7
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}