#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[]) {
  char *name;
  int c, i;
  unsigned length;
  if (argc >= 1)
    name = argv[1];
  else
    name = "__blob";
  printf("const unsigned char %s[] = {", name);
  i = 0;
  length = 0;
  while (EOF != (c = getchar())) {
    if (i == 0)
      printf("\n/* %04x */  ", length);
    printf("0x%02x, ", (unsigned char)c);
    if (++i == 8)
      i = 0;
    length++;
  }
  printf("\n};\n");
  printf("const unsigned %s_len = 0x%x;\n", name, length);
  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)
cmpl   $0x1,-0x8(%rbp)
jl     1151 <main+0x31>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    115c <main+0x3c>
lea    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
mov    %ecx,-0x1c(%rbp)
cmp    %ecx,%eax
je     11f5 <main+0xd5>
cmpl   $0x0,-0x20(%rbp)
jne    11ba <main+0x9a>
mov    -0x24(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
movzbl %al,%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x8,%eax
jne    11e7 <main+0xc7>
movl   $0x0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117c <main+0x5c>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe2f(%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
push   %rax
test   %edi,%edi
jle    1145 <main+0x15>
mov    0x8(%rsi),%rsi
jmp    114c <main+0x1c>
lea    0xeb4(%rip),%rsi
lea    0xeb4(%rip),%rdi
xor    %ebp,%ebp
mov    %rsi,(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%r14d
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %eax,%r14d
jne    11a7 <main+0x77>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
mov    (%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %r14d,%r14d
lea    0xe7f(%rip),%r12
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    11f4 <main+0xc4>
nopw   0x0(%rax,%rax,1)
movzbl %bl,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
cmp    $0x8,%r15d
cmove  %r14d,%r15d
add    $0x1,%ebp
mov    0x2e05(%rip),%rax
mov    (%rax),%r13d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    %eax,%r13d
je     1176 <main+0x46>
test   %r15d,%r15d
jne    11c0 <main+0x90>
lea    0xe24(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <main+0x90>

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

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