#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*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s identifier < filename.txt > filename.h\n",
            argv[0]);
    exit(1);
  }
  printf("static const char %s[] = {", argv[1]);
  for (;;) {
    unsigned char buffer[8];
    int count;
    int i;
    count = fread(buffer, 1, sizeof(buffer), stdin);
    if (count < 1)
      break;
    printf("   ");
    for (i = 0; i < count; i++) {
      printf(" 0x%02X", (int)buffer[i]);
      if (i != count - 1 || !feof(stdin))
        printf(",");
    }
    printf("\n");
  }
  printf("};\n");
  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)
cmpl   $0x2,-0x8(%rbp)
je     1196 <main+0x46>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
mov    0x2e31(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x8,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jge    11da <main+0x8a>
jmp    126e <main+0x11e>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125b <main+0x10b>
movslq -0x20(%rbp),%rax
movzbl -0x18(%rbp,%rax,1),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    123a <main+0xea>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    1248 <main+0xf8>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124d <main+0xfd>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ef <main+0x9f>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ac <main+0x5c>
lea    0xde6(%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   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1272 <main+0x102>
mov    0x8(%rsi),%rsi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e4b(%rip),%r13
mov    0x0(%r13),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1050 <fread@plt>
test   %eax,%eax
jle    1255 <main+0xe5>
mov    %eax,%r12d
lea    0xe8c(%rip),%r14
jmp    11f7 <main+0x87>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x0(%r13),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
call   1050 <fread@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    1255 <main+0xe5>
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    -0x1(%r12),%r15d
mov    %r12d,%ebx
xor    %ebp,%ebp
jmp    1233 <main+0xc3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2c,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11d0 <main+0x60>
movzbl (%rsp,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %rbp,%r15
jne    1220 <main+0xb0>
mov    0x0(%r13),%edi
call   1080 <feof@plt>
test   %eax,%eax
jne    122a <main+0xba>
jmp    1220 <main+0xb0>
lea    0xdfd(%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    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xd7b(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"Usage: %s identifier < filename.txt > filename.h\0A\00"
@.str.1 = [27 x i8] c"static const char %s[] = {\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c" \00"
@.str.3 = [8 x i8] c" 0x%02X\00"
@.str.4 = [2 x i8] c",\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %57, %18
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i32 @fread(i8* %24, i32 1, i32 8, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %23
br label %59
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %32
32: ; preds = %54, %30
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %57
36: ; preds = %32
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %8
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 1
%46 = icmp ne i32 %43, %45
br i1 %46, label %51, label %47
47: ; preds = %36
%48 = load i32, i32* @stdin
%49 = call i32 @feof(i32 %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %47, %36
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %32
57: ; preds = %32
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %23
59: ; preds = %29
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"Usage: %s identifier < filename.txt > filename.h\0A\00"
@.str.1 = [27 x i8] c"static const char %s[] = {\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c" \00"
@.str.3 = [8 x i8] c" 0x%02X\00"
@str = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i8* %14, i32 1, i32 8, i32 %15)
%17 = icmp slt i32 %16, 1
br i1 %17, label %45, label %18
18: ; preds = %10, %40
%19 = phi i32 [ %43, %40 ], [ %16, %10 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = add nsw i32 %19, -1
%22 = zext i32 %21 to i64
%23 = zext i32 %19 to i64
br label %24
24: ; preds = %18, %37
%25 = phi i64 [ 0, %18 ], [ %38, %37 ]
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %25, %22
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = load i32, i32* @stdin
%33 = call i32 @feof(i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31, %24
%36 = call i32 @putchar(i32 44)
br label %37
37: ; preds = %31, %35
%38 = add nuw nsw i64 %25, 1
%39 = icmp eq i64 %38, %23
br i1 %39, label %40, label %24
40: ; preds = %37
%41 = call i32 @putchar(i32 10)
%42 = load i32, i32* @stdin
%43 = call i32 @fread(i8* %14, i32 1, i32 8, i32 %42)
%44 = icmp slt i32 %43, 1
br i1 %44, label %45, label %18
45: ; preds = %40, %10
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 0
}