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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
unsigned char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned char c;
  FILE *fin, *fout;
  int idx = 0;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s input_text_file  output_rom_file\n", argv[0]);
    exit(-1);
  }
  fin = fopen(argv[1], "r");
  if (fin == NULL) {
    fprintf(stderr, "Error, cannot open input file %s.  Bye.\n", argv[1]);
    exit(-1);
  }
  fout = fopen(argv[2], "w");
  if (fin == NULL) {
    fprintf(stderr, "Error, cannot open output file %s.  Bye.\n", argv[2]);
    exit(-1);
  }
  fprintf(fout, "//////////////////////////////////////////////////////////////"
                "///////////////\n");
  fprintf(fout, "//\n");
  fprintf(fout, "// FILENAME: %s\n", argv[2]);
  fprintf(fout, "//\n");
  fprintf(fout, "// CREATED BY: %s\n", argv[0]);
  fprintf(fout, "//\n");
  fprintf(fout, "// DESCRIPTION: This is a distilation an ASCII text file "
                "converted to a\n");
  fprintf(fout, "//    Verilog ROM.  This program is not perfect.\n");
  fprintf(fout, "//\n");
  fprintf(fout, "//////////////////////////////////////////////////////////////"
                "///////////////\n");
  fprintf(fout, "module textrom ( input clk, input [11:0] addr, output reg "
                "[23:0] rom);\n");
  fprintf(fout, "   always@(posedge clk) begin \n");
  fprintf(fout, "     case (addr) \n");
  while (!feof(fin)) {
    c = getc(fin);
    if (feof(fin))
      break;
    fprintf(fout, "      9'd%03d:  rom = 8'h%02x;\n", idx++, c);
    if (idx > 512 - 1) {
      fprintf(
          stderr,
          "Warning: input text file greater than %d characters. Truncating.\n",
          512);
      break;
    }
  }
  fprintf(fout, "      default: rom = 8'h00;\n");
  fprintf(fout, "    endcase \n");
  fprintf(fout, "  end \n");
  fprintf(fout, "endmodule\n");
  fclose(fin);
  fclose(fout);
}


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)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11b0 <main+0x50>
mov    0x2e52(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11fd <main+0x9d>
mov    0x2e06(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    124a <main+0xea>
mov    0x2db9(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd7d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1362 <main+0x202>
jmp    13db <main+0x27b>
mov    -0x20(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x11(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     1386 <main+0x226>
jmp    13db <main+0x27b>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movzbl -0x11(%rbp),%ecx
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x1ff,-0x2c(%rbp)
jle    13d6 <main+0x276>
mov    0x2c25(%rip),%rax
movslq (%rax),%rdi
lea    0xe47(%rip),%rsi
mov    $0x200,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    13db <main+0x27b>
jmp    1343 <main+0x1e3>
mov    -0x28(%rbp),%rdi
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%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
mov    %rsi,%r12
cmp    $0x3,%edi
jne    13e8 <main+0x278>
mov    0x8(%r12),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     13ff <main+0x28f>
mov    %rax,%r13
mov    0x10(%r12),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe9a(%rip),%r15
mov    $0x4e,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xec9(%rip),%rbx
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    0x10(%r12),%rdx
lea    0xeac(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    (%r12),%rdx
lea    0xe93(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xe80(%rip),%rdi
mov    $0x48,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xeb0(%rip),%rdi
mov    $0x31,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    $0x4e,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xe9f(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xece(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xed5(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xecf(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    1363 <main+0x1f3>
mov    %r13,%rdi
call   1090 <getc@plt>
mov    %eax,%ebx
mov    %r13,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    1363 <main+0x1f3>
lea    0x1(%rbp),%r12d
movzbl %bl,%ecx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r12d,%ebp
cmp    $0x200,%r12d
jne    1300 <main+0x190>
mov    0x2c93(%rip),%rax
movslq (%rax),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x200,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xeba(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xebe(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xeb3(%rip),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
lea    0xea2(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bf1(%rip),%rax
movslq (%rax),%rdi
mov    (%r12),%rdx
lea    0xc03(%rip),%rsi
jmp    1415 <main+0x2a5>
mov    0x2bda(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%r12),%rdx
lea    0xc19(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s input_text_file output_rom_file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"Error, cannot open input file %s. Bye.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [42 x i8] c"Error, cannot open output file %s. Bye.\0A\00"
@.str.5 = [79 x i8] c"/////////////////////////////////////////////////////////////////////////////\0A\00"
@.str.6 = [4 x i8] c"//\0A\00"
@.str.7 = [17 x i8] c"// FILENAME: %s\0A\00"
@.str.8 = [19 x i8] c"// CREATED BY: %s\0A\00"
@.str.9 = [73 x i8] c"// DESCRIPTION: This is a distilation an ASCII text file converted to a\0A\00"
@.str.10 = [50 x i8] c"// Verilog ROM. This program is not perfect.\0A\00"
@.str.11 = [72 x i8] c"module textrom ( input clk, input [11:0] addr, output reg [23:0] rom);\0A\00"
@.str.12 = [32 x i8] c" always@(posedge clk) begin \0A\00"
@.str.13 = [19 x i8] c" case (addr) \0A\00"
@.str.14 = [32 x i8] c" 9'd%03d: rom = 8'h%02x;\0A\00"
@.str.15 = [66 x i8] c"Warning: input text file greater than %d characters. Truncating.\0A\00"
@.str.16 = [29 x i8] c" default: rom = 8'h00;\0A\00"
@.str.17 = [14 x i8] c" endcase \0A\00"
@.str.18 = [8 x i8] c" end \0A\00"
@.str.19 = [11 x i8] c"endmodule\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
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %37
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %21
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %8
%42 = load i32*, i32** %7
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %53
44: ; preds = %37
%45 = load i32, i32* @stderr
%46 = sext i32 %45 to i64
%47 = inttoptr i64 %46 to i32*
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %37
%54 = load i32*, i32** %8
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0))
%56 = load i32*, i32** %8
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32*, i32** %8
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = load i32*, i32** %8
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%65 = load i32*, i32** %8
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 0
%68 = load i8*, i8** %67
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %68)
%70 = load i32*, i32** %8
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%72 = load i32*, i32** %8
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %72, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.9, i64 0, i64 0))
%74 = load i32*, i32** %8
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %74, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
%76 = load i32*, i32** %8
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%78 = load i32*, i32** %8
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0))
%80 = load i32*, i32** %8
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.11, i64 0, i64 0))
%82 = load i32*, i32** %8
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%84 = load i32*, i32** %8
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %86
86: ; preds = %112, %53
%87 = load i32*, i32** %7
%88 = call i64 @feof(i32* %87)
%89 = icmp ne i64 %88, 0
%90 = xor i1 %89, true
br i1 %90, label %91, label %113
91: ; preds = %86
%92 = load i32*, i32** %7
%93 = call zeroext i8 @getc(i32* %92)
store i8 %93, i8* %6
%94 = load i32*, i32** %7
%95 = call i64 @feof(i32* %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %91
br label %113
98: ; preds = %91
%99 = load i32*, i32** %8
%100 = load i32, i32* %9
%101 = add nsw i32 %100, 1
store i32 %101, i32* %9
%102 = load i8, i8* %6
%103 = zext i8 %102 to i32
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0), i32 %100, i32 %103)
%105 = load i32, i32* %9
%106 = icmp sgt i32 %105, 511
br i1 %106, label %107, label %112
107: ; preds = %98
%108 = load i32, i32* @stderr
%109 = sext i32 %108 to i64
%110 = inttoptr i64 %109 to i32*
%111 = call i32 (i32*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.15, i64 0, i64 0), i32 512)
br label %113
112: ; preds = %98
br label %86
113: ; preds = %107, %97, %86
%114 = load i32*, i32** %8
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
%116 = load i32*, i32** %8
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0))
%118 = load i32*, i32** %8
%119 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0))
%120 = load i32*, i32** %8
%121 = call i32 (i32*, i8*, ...) @fprintf(i32* %120, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0))
%122 = load i32*, i32** %7
%123 = call i32 @fclose(i32* %122)
%124 = load i32*, i32** %8
%125 = call i32 @fclose(i32* %124)
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s input_text_file output_rom_file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"Error, cannot open input file %s. Bye.\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.5 = [79 x i8] c"/////////////////////////////////////////////////////////////////////////////\0A\00"
@.str.6 = [4 x i8] c"//\0A\00"
@.str.7 = [17 x i8] c"// FILENAME: %s\0A\00"
@.str.8 = [19 x i8] c"// CREATED BY: %s\0A\00"
@.str.9 = [73 x i8] c"// DESCRIPTION: This is a distilation an ASCII text file converted to a\0A\00"
@.str.10 = [50 x i8] c"// Verilog ROM. This program is not perfect.\0A\00"
@.str.11 = [72 x i8] c"module textrom ( input clk, input [11:0] addr, output reg [23:0] rom);\0A\00"
@.str.12 = [32 x i8] c" always@(posedge clk) begin \0A\00"
@.str.13 = [19 x i8] c" case (addr) \0A\00"
@.str.14 = [32 x i8] c" 9'd%03d: rom = 8'h%02x;\0A\00"
@.str.15 = [66 x i8] c"Warning: input text file greater than %d characters. Truncating.\0A\00"
@.str.16 = [29 x i8] c" default: rom = 8'h00;\0A\00"
@.str.17 = [14 x i8] c" endcase \0A\00"
@.str.18 = [8 x i8] c" end \0A\00"
@.str.19 = [11 x i8] c"endmodule\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load i8*, i8** %12
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %11
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0), i64 78, i64 1, i32* %26)
%28 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3, i64 1, i32* %26)
%29 = load i8*, i8** %24
%30 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %29)
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3, i64 1, i32* %26)
%32 = load i8*, i8** %1
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %32)
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3, i64 1, i32* %26)
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.9, i64 0, i64 0), i64 72, i64 1, i32* %26)
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i64 49, i64 1, i32* %26)
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i64 3, i64 1, i32* %26)
%38 = tail call i64 @fwrite(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.5, i64 0, i64 0), i64 78, i64 1, i32* %26)
%39 = tail call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.11, i64 0, i64 0), i64 71, i64 1, i32* %26)
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0), i64 31, i64 1, i32* %26)
%41 = tail call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i64 18, i64 1, i32* %26)
br label %42
42: ; preds = %50, %23
%43 = phi i32 [ 0, %23 ], [ %51, %50 ]
%44 = tail call i64 @feof(i32* %14)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %60
46: ; preds = %42
%47 = tail call zeroext i8 @getc(i32* %14)
%48 = tail call i64 @feof(i32* %14)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %46
%51 = add nuw nsw i32 %43, 1
%52 = zext i8 %47 to i32
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0), i32 %43, i32 %52)
%54 = icmp eq i32 %51, 512
br i1 %54, label %55, label %42
55: ; preds = %50
%56 = load i32, i32* @stderr
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i32*
%59 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.15, i64 0, i64 0), i32 512)
br label %60
60: ; preds = %46, %42, %55
%61 = tail call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0), i64 28, i64 1, i32* %26)
%62 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i64 13, i64 1, i32* %26)
%63 = tail call i64 @fwrite(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i64 7, i64 1, i32* %26)
%64 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.19, i64 0, i64 0), i64 10, i64 1, i32* %26)
%65 = tail call i32 @fclose(i32* %14)
%66 = tail call i32 @fclose(i32* %26)
ret i32 0
}