#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 argc, char *argv[]) {
  int ch, total = 0;
  if (argc > 1)
    printf("const char *%s %s=\n", argv[1], argc > 2 ? argv[2] : "");
  do {
    printf("\t\"");
    while ((ch = getchar()) != EOF) {
      total++;
      printf("\\x%02x", ch);
      if (total % 16 == 0)
        break;
    }
    printf("\"\n");
  } while (ch != EOF);
  if (argc > 1)
    printf("\t;\n\nconst int %s_size = %d;\n", argv[1], total);
  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)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1194 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    116e <main+0x4e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    117e <main+0x5e>
lea    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    117e <main+0x5e>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <main+0x79>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e30(%rip),%rcx
cmp    (%rcx),%eax
je     11f8 <main+0xd8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f3 <main+0xd3>
jmp    11f8 <main+0xd8>
jmp    11a7 <main+0x87>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%eax
jne    1199 <main+0x79>
cmpl   $0x1,-0x8(%rbp)
jle    123b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
cmp    $0x2,%edi
jl     116b <main+0x3b>
mov    0x8(%rbx),%rsi
jne    1159 <main+0x29>
lea    0xee3(%rip),%rdx
jmp    115d <main+0x2d>
mov    0x10(%rbx),%rdx
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,0x10(%rsp)
lea    0xe9d(%rip),%r12
mov    0x2e6a(%rip),%r15
lea    0xe90(%rip),%r13
lea    0xe8b(%rip),%rbp
xor    %ebx,%ebx
jmp    119d <main+0x6d>
mov    %r13,%rdi
call   1030 <puts@plt>
cmp    (%r15),%r14d
je     11d6 <main+0xa6>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%r14d
cmp    (%r15),%eax
je     1190 <main+0x60>
add    $0x1,%ebx
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0xf,%bl
jne    11b0 <main+0x80>
jmp    1190 <main+0x60>
cmpl   $0x2,0xc(%rsp)
jl     11f6 <main+0xc6>
mov    0x10(%rsp),%rax
mov    0x8(%rax),%rsi
lea    0xe31(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"const char *%s %s=\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"\09\22\00"
@EOF = global i32 0
@.str.3 = [7 x i8] c"\\x%02x\00"
@.str.4 = [3 x i8] c"\22\0A\00"
@.str.5 = [29 x i8] c"\09;\0A\0Aconst int %s_size = %d;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %24
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
br label %21
20: ; preds = %10
br label %21
21: ; preds = %20, %16
%22 = phi i8* [ %19, %16 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %20 ]
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %22)
br label %24
24: ; preds = %21, %2
br label %25
25: ; preds = %43, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %40, %25
%28 = call i32 (...) @getchar()
store i32 %28, i32* %6
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %7
%37 = srem i32 %36, 16
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %31
br label %41
40: ; preds = %31
br label %27
41: ; preds = %39, %27
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %43
43: ; preds = %41
%44 = load i32, i32* %6
%45 = load i32, i32* @EOF
%46 = icmp ne i32 %44, %45
br i1 %46, label %25, label %47
47: ; preds = %43
%48 = load i32, i32* %4
%49 = icmp sgt i32 %48, 1
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
%54 = load i32, i32* %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %53, i32 %54)
br label %56
56: ; preds = %50, %47
ret i32 0
}

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