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

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  unsigned char buf[4096];
  size_t amt;
  size_t i;
  int col = 0;
  char *name;
  if (argc != 2) {
    fprintf(stderr, "usage: %s NAME < DAT_FILE > ASM_FILE\n", argv[0]);
    for (i = 0; i < argc; i++) {
      fprintf(stderr, " '%s'", argv[i]);
    }
    fprintf(stderr, "\n");
    return 1;
  }
  name = argv[1];
  printf("#ifdef __APPLE_CC__\n/*\n * The mid-2007 version of gcc that ships "
         "with Macs requires a\n * comma on the .section line, but the rest of "
         "the world thinks\n * that's a syntax error. It also wants globals to "
         "be explicitly\n * prefixed with \"_\" as opposed to modern gccs that "
         "do the\n * prefixing for you.\n */\n.globl _%s\n	.section "
         ".rodata,\n	.align 8\n_%s:\n#else\n.globl %s\n	.section "
         ".rodata\n	.align 8\n%s:\n#endif\n",
         name, name, name, name);
  while (!feof(stdin)) {
    amt = fread(buf, 1, sizeof(buf), stdin);
    for (i = 0; i < amt; i++) {
      if (col == 0) {
        printf(".byte ");
      }
      printf("0x%02x", buf[i]);
      col++;
      if (col == 16) {
        printf("\n");
        col = 0;
      } else if (col % 4 == 0) {
        printf(", ");
      } else {
        printf(",");
      }
    }
  }
  if (col != 0) {
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1024(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     120a <main+0xca>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movq   $0x0,-0x1020(%rbp)
mov    -0x1020(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11e7 <main+0xa7>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x1020(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
jmp    1196 <main+0x56>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    139c <main+0x25c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1030(%rbp)
mov    -0x1030(%rbp),%rsi
mov    -0x1030(%rbp),%rdx
mov    -0x1030(%rbp),%rcx
mov    -0x1030(%rbp),%r8
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1266 <main+0x126>
jmp    137a <main+0x23a>
lea    -0x1010(%rbp),%rdi
mov    0x2d74(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1018(%rbp)
movq   $0x0,-0x1020(%rbp)
mov    -0x1020(%rbp),%rax
cmp    -0x1018(%rbp),%rax
jae    1375 <main+0x235>
cmpl   $0x0,-0x1024(%rbp)
jne    12c6 <main+0x186>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1020(%rbp),%rax
movzbl -0x1010(%rbp,%rax,1),%esi
ff
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1024(%rbp)
cmpl   $0x10,-0x1024(%rbp)
jne    131c <main+0x1dc>
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1024(%rbp)
jmp    1359 <main+0x219>
mov    -0x1024(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1346 <main+0x206>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1354 <main+0x214>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1359 <main+0x219>
jmp    135e <main+0x21e>
mov    -0x1020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1020(%rbp)
jmp    1297 <main+0x157>
jmp    1243 <main+0x103>
cmpl   $0x0,-0x1024(%rbp)
je     1395 <main+0x255>
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r12
cmp    $0x2,%edi
jne    125c <main+0x10c>
mov    0x8(%r12),%rcx
lea    0xeb3(%rip),%rdi
xor    %ebx,%ebx
mov    %rcx,%rsi
mov    %rcx,%rdx
mov    %rcx,%r8
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e56(%rip),%rbp
mov    0x0(%rbp),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12d3 <main+0x183>
lea    0x1014(%rip),%r15
lea    0x1014(%rip),%r13
lea    0x1014(%rip),%r12
xor    %r14d,%r14d
jmp    11d7 <main+0x87>
nopl   0x0(%rax)
mov    0x2e21(%rip),%rbp
mov    0x0(%rbp),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    12c2 <main+0x172>
mov    0x0(%rbp),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    %rax,%rbx
xor    %ebp,%ebp
jmp    1216 <main+0xc6>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r14d,%r14d
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11c0 <main+0x70>
test   %r14d,%r14d
jne    1225 <main+0xd5>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl (%rsp,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14d
cmp    $0x10,%r14d
je     1200 <main+0xb0>
test   $0x3,%r14b
je     1250 <main+0x100>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    120d <main+0xbd>
nop
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    120d <main+0xbd>
mov    %edi,%ebp
mov    0x2d73(%rip),%r14
mov    (%r14),%edi
mov    (%r12),%rdx
lea    0xd8d(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %ebp,%ebp
je     12aa <main+0x15a>
movslq %ebp,%rbp
lea    0xd9e(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    (%r12,%rbx,8),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1290 <main+0x140>
mov    (%r14),%edi
lea    0xd70(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
jmp    12d3 <main+0x183>
xor    %ebx,%ebx
test   %r14d,%r14d
je     12d3 <main+0x183>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s NAME < DAT_FILE > ASM_FILE\0A\00"
@.str.1 = [6 x i8] c" '%s'\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [401 x i8] c"#ifdef __APPLE_CC__\0A/*\0A * The mid-2007 version of gcc that ships with Macs requires a\0A * comma on the .section line, but the rest of the world thinks\0A * that's a syntax error. It also wants globals to be explicitly\0A * prefixed with \22_\22 as opposed to modern gccs that do the\0A * prefixing for you.\0A */\0A.globl _%s\0A\09.section .rodata,\0A\09.align 8\0A_%s:\0A#else\0A.globl %s\0A\09.section .rodata\0A\09.align 8\0A%s:\0A#endif\0A\00"
@stdin = global i32 0
@.str.4 = [7 x i8] c".byte \00"
@.str.5 = [7 x i8] c"0x%02x\00"
@.str.6 = [3 x i8] c", \00"
@.str.7 = [2 x i8] c",\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %37
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %17)
store i64 0, i64* %8
br label %19
19: ; preds = %31, %13
%20 = load i64, i64* %8
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %20, %22
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = load i64, i64* %8
%28 = getelementptr inbounds i8*, i8** %26, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %24
%32 = load i64, i64* %8
%33 = add i64 %32, 1
store i64 %33, i64* %8
br label %19
34: ; preds = %19
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %96
37: ; preds = %2
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
store i8* %40, i8** %10
%41 = load i8*, i8** %10
%42 = load i8*, i8** %10
%43 = load i8*, i8** %10
%44 = load i8*, i8** %10
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([401 x i8], [401 x i8]* @.str.3, i64 0, i64 0), i8* %41, i8* %42, i8* %43, i8* %44)
br label %46
46: ; preds = %89, %37
%47 = load i32, i32* @stdin
%48 = call i32 @feof(i32 %47)
%49 = icmp ne i32 %48, 0
%50 = xor i1 %49, true
br i1 %50, label %51, label %90
51: ; preds = %46
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%53 = load i32, i32* @stdin
%54 = call i64 @fread(i8* %52, i32 1, i32 4096, i32 %53)
store i64 %54, i64* %7
store i64 0, i64* %8
br label %55
55: ; preds = %86, %51
%56 = load i64, i64* %8
%57 = load i64, i64* %7
%58 = icmp ult i64 %56, %57
br i1 %58, label %59, label %89
59: ; preds = %55
%60 = load i32, i32* %9
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %62, %59
%65 = load i64, i64* %8
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %68)
%70 = load i32, i32* %9
%71 = add nsw i32 %70, 1
store i32 %71, i32* %9
%72 = load i32, i32* %9
%73 = icmp eq i32 %72, 16
br i1 %73, label %74, label %76
74: ; preds = %64
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %9
br label %85
76: ; preds = %64
%77 = load i32, i32* %9
%78 = srem i32 %77, 4
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %84
82: ; preds = %76
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
br label %85
85: ; preds = %84, %74
br label %86
86: ; preds = %85
%87 = load i64, i64* %8
%88 = add i64 %87, 1
store i64 %88, i64* %8
br label %55
89: ; preds = %55
br label %46
90: ; preds = %46
%91 = load i32, i32* %9
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %95
95: ; preds = %93, %90
store i32 0, i32* %3
br label %96
96: ; preds = %95, %34
%97 = load i32, i32* %3
ret i32 %97
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s NAME < DAT_FILE > ASM_FILE\0A\00"
@.str.1 = [6 x i8] c" '%s'\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [401 x i8] c"#ifdef __APPLE_CC__\0A/*\0A * The mid-2007 version of gcc that ships with Macs requires a\0A * comma on the .section line, but the rest of the world thinks\0A * that's a syntax error. It also wants globals to be explicitly\0A * prefixed with \22_\22 as opposed to modern gccs that do the\0A * prefixing for you.\0A */\0A.globl _%s\0A\09.section .rodata,\0A\09.align 8\0A_%s:\0A#else\0A.globl %s\0A\09.section .rodata\0A\09.align 8\0A%s:\0A#endif\0A\00"
@stdin = global i32 0
@.str.4 = [7 x i8] c".byte \00"
@.str.5 = [7 x i8] c"0x%02x\00"
@.str.6 = [3 x i8] c", \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %24, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i32 %0, 0
br i1 %10, label %21, label %11
11: ; preds = %6
%12 = sext i32 %0 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ %19, %13 ], [ 0, %11 ]
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds i8*, i8** %1, i64 %14
%17 = load i8*, i8** %16
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = add nuw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %6
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %71
24: ; preds = %2
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([401 x i8], [401 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* %26, i8* %26, i8* %26)
%28 = load i32, i32* @stdin
%29 = call i32 @feof(i32 %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %36, label %71
31: ; preds = %63, %36
%32 = phi i32 [ %37, %36 ], [ %64, %63 ]
%33 = load i32, i32* @stdin
%34 = call i32 @feof(i32 %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %67
36: ; preds = %24, %31
%37 = phi i32 [ %32, %31 ], [ 0, %24 ]
%38 = load i32, i32* @stdin
%39 = call i64 @fread(i8* %4, i32 1, i32 4096, i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %31, label %41
41: ; preds = %36, %63
%42 = phi i32 [ %64, %63 ], [ %37, %36 ]
%43 = phi i64 [ %65, %63 ], [ 0, %36 ]
%44 = icmp eq i32 %42, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %43
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = add nsw i32 %42, 1
%53 = icmp eq i32 %52, 16
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @putchar(i32 10)
br label %63
56: ; preds = %47
%57 = and i32 %52, 3
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %63
61: ; preds = %56
%62 = call i32 @putchar(i32 44)
br label %63
63: ; preds = %54, %61, %59
%64 = phi i32 [ 0, %54 ], [ %52, %59 ], [ %52, %61 ]
%65 = add nuw i64 %43, 1
%66 = icmp eq i64 %65, %39
br i1 %66, label %31, label %41
67: ; preds = %31
%68 = icmp eq i32 %32, 0
br i1 %68, label %71, label %69
69: ; preds = %67
%70 = call i32 @putchar(i32 10)
br label %71
71: ; preds = %24, %67, %69, %21
%72 = phi i32 [ 1, %21 ], [ 0, %69 ], [ 0, %67 ], [ 0, %24 ]
ret i32 %72
}