#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 */
typedef int /*<<< orphan*/ data;

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int /*<<< orphan*/, unsigned char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char **argv) {
  const char *name = "binary";
  unsigned char data[16];
  int i, r;
  if (argc > 1)
    name = argv[1];
  printf("/* auto generated file */\n\n");
  printf("unsigned char %s_data[] = {\n", name);
  for (;;) {
    r = read(0, data, sizeof(data));
    if (r == 0)
      break;
    if (r < 0) {
      if (errno == EINTR)
        continue;
      fprintf(stderr, "error: %s\n", strerror(errno));
      return -1;
    }
    for (i = 0; i < r; i++)
      printf("0x%02x,", data[i]);
    printf("\n");
  }
  printf("};\n");
  printf("unsigned %s_size = sizeof(%s_data);\n", name, name);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
xor    %edi,%edi
mov    $0x10,%edx
call   1040 <read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    11b9 <main+0x79>
jmp    1266 <main+0x126>
cmpl   $0x0,-0x38(%rbp)
jge    121b <main+0xdb>
mov    0x2e0e(%rip),%rax
mov    (%rax),%rax
mov    0x2dfc(%rip),%rcx
cmp    (%rcx),%rax
jne    11e2 <main+0xa2>
jmp    1197 <main+0x57>
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xe36(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1291 <main+0x151>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1253 <main+0x113>
movslq -0x34(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1222 <main+0xe2>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <main+0x57>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jl     1179 <main+0x19>
mov    0x8(%rsi),%rbx
jmp    1180 <main+0x20>
lea    0xe80(%rip),%rbx
lea    0xed5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,0x8(%rsp)
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    $0x10,%edx
call   1060 <read@plt>
test   %eax,%eax
je     1235 <main+0xd5>
mov    0x2e1a(%rip),%r12
mov    0x2e0b(%rip),%r13
lea    0x10(%rsp),%rbp
lea    0xe5e(%rip),%rbx
jmp    11fd <main+0x9d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12),%rdi
cmp    0x0(%r13),%rdi
jne    1268 <main+0x108>
xor    %edi,%edi
mov    %rbp,%rsi
mov    $0x10,%edx
call   1060 <read@plt>
test   %eax,%eax
je     1235 <main+0xd5>
test   %eax,%eax
js     11e0 <main+0x80>
mov    %eax,%r14d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
movzbl 0x10(%rsp,%r15,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1210 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11ea <main+0x8a>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
lea    0xdef(%rip),%rdi
mov    0x8(%rsp),%rdx
mov    %rdx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d71(%rip),%rax
mov    (%rax),%ebx
call   1080 <strerror@plt>
lea    0xda7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1259 <main+0xf9>

LLVM IR (-O0):
@.str = [7 x i8] c"binary\00"
@.str.1 = [28 x i8] c"/* auto generated file */\0A\0A\00"
@.str.2 = [29 x i8] c"unsigned char %s_data[] = {\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.3 = [11 x i8] c"error: %s\0A\00"
@.str.4 = [8 x i8] c"0x%02x,\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [4 x i8] c"};\0A\00"
@.str.7 = [37 x i8] c"unsigned %s_size = sizeof(%s_data);\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [16 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i32, i32* %4
%11 = icmp sgt 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 %16
16: ; preds = %12, %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %54, %33, %16
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%22 = call i32 @read(i32 0, i8* %21, i32 16)
store i32 %22, i32* %9
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %56
26: ; preds = %20
%27 = load i32, i32* %9
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %26
%30 = load i64, i64* @errno
%31 = load i64, i64* @EINTR
%32 = icmp eq i64 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %20
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = load i64, i64* @errno
%37 = call i8* @strerror(i64 %36)
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %37)
store i32 -1, i32* %3
br label %61
39: ; preds = %26
store i32 0, i32* %8
br label %40
40: ; preds = %51, %39
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %40
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %20
56: ; preds = %25
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%58 = load i8*, i8** %6
%59 = load i8*, i8** %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %58, i8* %59)
store i32 0, i32* %3
br label %61
61: ; preds = %56, %34
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [7 x i8] c"binary\00"
@.str.2 = [29 x i8] c"unsigned char %s_data[] = {\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.3 = [11 x i8] c"error: %s\0A\00"
@.str.4 = [8 x i8] c"0x%02x,\00"
@.str.7 = [37 x i8] c"unsigned %s_size = sizeof(%s_data);\0A\00"
@str = [27 x i8] c"/* auto generated file */\0A\00"
@str.8 = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
br label %9
9: ; preds = %6, %2
%10 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%13 = call i32 @read(i32 0, i8* %4, i32 16)
%14 = icmp eq i32 %13, 0
br i1 %14, label %41, label %15
15: ; preds = %9, %38
%16 = phi i32 [ %39, %38 ], [ %13, %9 ]
%17 = icmp slt i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = zext i32 %16 to i64
br label %28
20: ; preds = %15
%21 = load i64, i64* @errno
%22 = load i64, i64* @EINTR
%23 = icmp eq i64 %21, %22
br i1 %23, label %38, label %24
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = tail call i8* @strerror(i64 %21)
%27 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %26)
br label %44
28: ; preds = %18, %28
%29 = phi i64 [ 0, %18 ], [ %34, %28 ]
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %29, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %36, label %28
36: ; preds = %28
%37 = tail call i32 @putchar(i32 10)
br label %38
38: ; preds = %36, %20
%39 = call i32 @read(i32 0, i8* %4, i32 16)
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %15
41: ; preds = %38, %9
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.8, i64 0, i64 0))
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %10, i8* %10)
br label %44
44: ; preds = %41, %24
%45 = phi i32 [ 0, %41 ], [ -1, %24 ]
ret i32 %45
}