#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 main(int argc, char **argv) {
  int c;
  int i;
  const char *name = argv[1];
  printf("#include <stddef.h>\n");
  printf("const unsigned char %s[] = {\n", name);
  i = 0;
  while ((c = getchar()) != EOF) {
    if ((i % 16) != 0) {
      putchar(' ');
    }
    printf("0x%02x,", c);
    i++;
    if ((i % 16) == 0) {
      putchar('\n');
    }
  }
  putchar('\n');
  printf("};\n");
  printf("size_t %s_size = sizeof(%s);\n", name, name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%eax
je     11ed <main+0xbd>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11b0 <main+0x80>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e8 <main+0xb8>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1179 <main+0x49>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x8(%rsi),%r14
lea    0xef1(%rip),%rdi
call   1040 <puts@plt>
lea    0xea1(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e71(%rip),%r15
cmp    (%r15),%eax
jne    11b1 <main+0x71>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8d(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe5f(%rip),%r12
jmp    11e1 <main+0xa1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
add    $0x1,%ebx
cmp    (%r15),%eax
je     117c <main+0x3c>
lea    -0x1(%rbx),%eax
test   $0xf,%al
je     11f2 <main+0xb2>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0xf,%bl
jne    11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11d0 <main+0x90>

LLVM IR (-O0):
@.str = [21 x i8] c"#include <stddef.h>\0A\00"
@.str.1 = [30 x i8] c"const unsigned char %s[] = {\0A\00"
@EOF = global i32 0
@.str.2 = [8 x i8] c"0x%02x,\00"
@.str.3 = [4 x i8] c"};\0A\00"
@.str.4 = [30 x i8] c"size_t %s_size = sizeof(%s);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
store i8* %11, i8** %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i32 0, i32* %7
br label %15
15: ; preds = %35, %2
%16 = call i32 (...) @getchar()
store i32 %16, i32* %6
%17 = load i32, i32* @EOF
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %36
19: ; preds = %15
%20 = load i32, i32* %7
%21 = srem i32 %20, 16
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @putchar(i8 signext 32)
br label %25
25: ; preds = %23, %19
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = srem i32 %30, 16
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %25
%34 = call i32 @putchar(i8 signext 10)
br label %35
35: ; preds = %33, %25
br label %15
36: ; preds = %15
%37 = call i32 @putchar(i8 signext 10)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%39 = load i8*, i8** %8
%40 = load i8*, i8** %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %39, i8* %40)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"const unsigned char %s[] = {\0A\00"
@EOF = global i32 0
@.str.2 = [8 x i8] c"0x%02x,\00"
@.str.4 = [30 x i8] c"size_t %s_size = sizeof(%s);\0A\00"
@str = [20 x i8] c"#include <stddef.h>\00"
@str.5 = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %28, label %10
10: ; preds = %2, %24
%11 = phi i32 [ %25, %24 ], [ %7, %2 ]
%12 = phi i32 [ %19, %24 ], [ 0, %2 ]
%13 = and i32 %12, 15
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = tail call i32 @putchar(i8 signext 32)
br label %17
17: ; preds = %15, %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%19 = add nuw nsw i32 %12, 1
%20 = and i32 %19, 15
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 @putchar(i8 signext 10)
br label %24
24: ; preds = %22, %17
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %10
28: ; preds = %24, %2
%29 = tail call i32 @putchar(i8 signext 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0))
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* %4)
ret i32 0
}