#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 fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int ch, i;
  if (argc != 2) {
    fprintf(stderr, "usage: %s tag < input > output\n", argv[0]);
    return -1;
  }
  printf("/* Automatically generated by BIN2C, G.Vanem 1995 */\n");
  printf("const char %s[] = {\n", argv[1]);
  for (i = 0, ch = fgetc(stdin); ch != EOF; i++, ch = fgetc(stdin)) {
    if (i == 0)
      printf("    ");
    else if (i % 12 == 0)
      printf("\n    ");
    printf("0x%02X,", ch);
  }
  printf("\n};\n");
  printf("const int %s_len = %d;\n", argv[1], i);
  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     1178 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1268 <main+0x138>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%eax
je     123a <main+0x10a>
cmpl   $0x0,-0x18(%rbp)
jne    11e3 <main+0xb3>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <main+0xda>
mov    -0x18(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1205 <main+0xd5>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120a <main+0xda>
mov    -0x14(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x84>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%edx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11f3 <main+0xb3>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,(%rsp)
mov    0x8(%rbx),%rsi
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e68(%rip),%r14
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    0x2e51(%rip),%r15
mov    $0x0,%ebp
cmp    (%r15),%eax
je     11cb <main+0x8b>
mov    %eax,%ebx
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    $0x1,%ebp
cmp    (%r15),%eax
jne    121f <main+0xdf>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
mov    0x8(%rax),%rsi
lea    0xe5d(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1210 <main+0xd0>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdfa(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    $0x1,%ebp
mov    $0xaaaaaaab,%r12d
lea    0xe08(%rip),%r13
jmp    1262 <main+0x122>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    (%r14),%edi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r15),%eax
je     11cb <main+0x8b>
mov    %ebp,%eax
imul   %r12,%rax
shr    $0x23,%rax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
cmp    %eax,%ebp
jne    1240 <main+0x100>
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1240 <main+0x100>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"usage: %s tag < input > output\0A\00"
@.str.1 = [54 x i8] c"/* Automatically generated by BIN2C, G.Vanem 1995 */\0A\00"
@.str.2 = [21 x i8] c"const char %s[] = {\0A\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.3 = [5 x i8] c" \00"
@.str.4 = [6 x i8] c"\0A \00"
@.str.5 = [8 x i8] c"0x%02X,\00"
@.str.6 = [5 x i8] c"\0A};\0A\00"
@.str.7 = [24 x i8] c"const int %s_len = %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
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %55
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 0, i32* %7
%22 = load i32, i32* @stdin
%23 = call i32 @fgetc(i32 %22)
store i32 %23, i32* %6
br label %24
24: ; preds = %43, %16
%25 = load i32, i32* %6
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %48
28: ; preds = %24
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %40
33: ; preds = %28
%34 = load i32, i32* %7
%35 = srem i32 %34, 12
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
br label %40
40: ; preds = %39, %31
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
%46 = load i32, i32* @stdin
%47 = call i32 @fgetc(i32 %46)
store i32 %47, i32* %6
br label %24
48: ; preds = %24
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = load i32, i32* %7
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %52, i32 %53)
store i32 0, i32* %3
br label %55
55: ; preds = %48, %10
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"usage: %s tag < input > output\0A\00"
@.str.2 = [21 x i8] c"const char %s[] = {\0A\00"
@stdin = global i32 0
@EOF = global i32 0
@.str.3 = [5 x i8] c" \00"
@.str.4 = [6 x i8] c"\0A \00"
@.str.5 = [8 x i8] c"0x%02X,\00"
@.str.7 = [24 x i8] c"const int %s_len = %d;\0A\00"
@str = [53 x i8] c"/* Automatically generated by BIN2C, G.Vanem 1995 */\00"
@str.8 = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %43
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stdin
%14 = tail call i32 @fgetc(i32 %13)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %38, label %17
17: ; preds = %8
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%20 = load i32, i32* @stdin
%21 = tail call i32 @fgetc(i32 %20)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %38, label %24
24: ; preds = %17, %31
%25 = phi i32 [ %33, %31 ], [ 1, %17 ]
%26 = phi i32 [ %35, %31 ], [ %21, %17 ]
%27 = urem i32 %25, 12
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %24, %29
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%33 = add nuw nsw i32 %25, 1
%34 = load i32, i32* @stdin
%35 = tail call i32 @fgetc(i32 %34)
%36 = load i32, i32* @EOF
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %24
38: ; preds = %31, %17, %8
%39 = phi i32 [ 0, %8 ], [ 1, %17 ], [ %33, %31 ]
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0))
%41 = load i8*, i8** %10
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i8* %41, i32 %39)
br label %43
43: ; preds = %38, %4
%44 = phi i32 [ -1, %4 ], [ 0, %38 ]
ret i32 %44
}