#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 */
char EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  FILE *fp = fopen("index1.js", "w+");
  FILE *fp2 = fopen("index2.js", "w+");
  fprintf(fp, "// Generated from generator.c \n\n\n");
  fprintf(fp, "var output = $('.output');\n");
  fprintf(fp, "var input = $('textarea.input');\n");
  fprintf(fp, "var toOutput;\n");
  fprintf(fp, "input.keypress(function(e) {\n\tif (e.which == 13) {\n");
  fprintf(fp, "\t\tvar inputVal = $.trim(input.val());\n");
  fprintf(fp, "\t\t");
  fprintf(fp2, "function separator() {\n");
  fprintf(fp2, "\tOutput('<span class=\"separator\">== == == == == == == == == "
               "== == == == == == == == ==</span></br>');");
  fprintf(fp2, "\n}\n\n");
  fprintf(fp2, "function Output(data) {\n");
  fprintf(fp2, "\t$(data).appendTo(output);");
  fprintf(fp2, "\n}\n\n");
  char command[10];
  char result[200];
  int lines = 0;
  int i = 0;
  char ch;
  printf("\nWelcome to the JS Code Generator for the Terminal Emulator!\n");
  printf("\nEnter X to exit.\n");
  while (1) {
    printf("\nPlease enter the command: ");
    scanf("%[^\n]s", command);
    getchar();
    if (command[0] == 'X')
      break;
    fprintf(fp, "if (inputVal.indexOf(\"%s\")>=0) {\n", command);
    fprintf(fp, "\t\t\t%s();\n\t\t\tinput.Val('');\n", command);
    fprintf(fp, "\t\t} else ");
    printf("How many lines do you have in your response?");
    scanf("%d", &lines);
    getchar();
    fprintf(fp2, "function %s() {\n\tseparator();\n\t", command);
    fprintf(fp2, "var outputArray = ['>%s',", command);
    for (i = 0; i < lines; i++) {
      printf("\nPlease enter line %d of the response:\n", i + 1);
      scanf("%[^\n]s", result);
      getchar();
      fprintf(fp2, "'%s',", result);
    }
    fseek(fp2, -1, SEEK_CUR);
    fprintf(fp2, "];\n\t");
    fprintf(fp2, "for (var  i = 0;  i < outputArray.length; i++) {\n\t\t");
    fprintf(fp2, "var out = '<span>' + outputArray[i] + '</span></br>';\n\t\t");
    fprintf(fp2, "Output(out);\n\t}\n\tseparator();\n}\n\n");
  }
  fprintf(fp, "{\n\t\t\tOutput('<span>Oops. <br>You outsmarted me. Try "
              "something else.</span></br>');");
  fprintf(fp, "\n\t\t\tinput.val('');\n\t\t}\n\t}\n});\n\n\n\n");
  rewind(fp);
  rewind(fp2);
  FILE *f = fopen("index3.js", "w+");
  while ((ch = fgetc(fp)) != EOF)
    fputc(ch, f);
  while ((ch = fgetc(fp2)) != EOF)
    fputc(ch, f);
  printf("Done!\n");
  fclose(fp);
  fclose(fp2);
  fclose(f);
  return 42;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe47(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe3d(%rip),%rdi
lea    0xe33(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0x10ff(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x10e9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x10b3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl -0x22(%rbp),%eax
cmp    $0x58,%eax
jne    1333 <main+0x193>
jmp    14a7 <main+0x307>
mov    -0x10(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xedb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0xf4(%rbp),%rsi
mov    $0x0,%al
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    -0x18(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    0xed5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x22(%rbp),%rdx
lea    0xedf(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x0,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
cmp    -0xf4(%rbp),%eax
jge    1443 <main+0x2a3>
mov    -0xf8(%rbp),%esi
add    $0x1,%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xf0(%rbp),%rsi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   10b0 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    -0x18(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xeb9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0xf8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf8(%rbp)
jmp    13d1 <main+0x231>
mov    -0x18(%rbp),%rdi
mov    0x2b9a(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    12fa <main+0x15a>
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xf0a(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1050 <rewind@plt>
lea    0xf0c(%rip),%rdi
lea    0xb1f(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x108(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0xf9(%rbp)
movsbl %al,%eax
mov    0x2ad0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1535 <main+0x395>
mov    -0xf9(%rbp),%al
mov    -0x108(%rbp),%rsi
movsbl %al,%edi
call   1070 <fputc@plt>
jmp    14f7 <main+0x357>
jmp    153a <main+0x39a>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0xf9(%rbp)
movsbl %al,%eax
mov    0x2a8d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1578 <main+0x3d8>
mov    -0xf9(%rbp),%al
mov    -0x108(%rbp),%rsi
movsbl %al,%edi
call   1070 <fputc@plt>
jmp    153a <main+0x39a>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x108(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x2a,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
lea    0xe28(%rip),%rdi
lea    0xe2b(%rip),%rbx
mov    %rbx,%rsi
call   10d0 <fopen@plt>
mov    %rax,%r12
lea    0xe1c(%rip),%rdi
mov    %rbx,%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbx
lea    0xe14(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe1d(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe20(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe29(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe1f(%rip),%rdi
mov    $0x33,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe3a(%rip),%rdi
mov    $0x26,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0x106c(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xe2f(%rip),%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xe2e(%rip),%rdi
mov    $0x65,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0x1041(%rip),%rbp
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xe5f(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xe5f(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
movl   $0x0,0x8(%rsp)
lea    0x105a(%rip),%rdi
call   1030 <puts@plt>
lea    0x108b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   10c0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
cmpb   $0x58,0xe(%rsp)
jne    1473 <main+0x2b3>
lea    0xf90(%rip),%rdi
mov    $0x52,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xfca(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    %r12,%rdi
call   1060 <rewind@plt>
mov    %rbx,%rdi
call   1060 <rewind@plt>
lea    0xfc3(%rip),%rdi
lea    0xc27(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   1070 <fgetc@plt>
mov    0x2be6(%rip),%r14
cmp    (%r14),%al
je     142b <main+0x26b>
nop
movsbl %al,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
cmp    (%r14),%al
jne    1400 <main+0x240>
jmp    142b <main+0x26b>
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    (%r14),%al
jne    1420 <main+0x260>
lea    0xfb9(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    $0x2a,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe(%rsp),%rbp
lea    0xd30(%rip),%r15
lea    0x20(%rsp),%r13
lea    0xe05(%rip),%r14
mov    %r12,0x18(%rsp)
jmp    1551 <main+0x391>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2b41(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   10b0 <fseek@plt>
mov    $0x4,%esi
mov    $0x1,%edx
lea    0xdcf(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    $0x33,%esi
mov    $0x1,%edx
lea    0xdbb(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    $0x38,%esi
mov    $0x1,%edx
lea    0xdd6(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
mov    $0x21,%esi
mov    $0x1,%edx
lea    0xdf6(%rip),%rdi
mov    %rbx,%rcx
call   10e0 <fwrite@plt>
lea    0xc72(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0xe(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   10c0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
cmpb   $0x58,0xe(%rsp)
mov    0x18(%rsp),%r12
je     1393 <main+0x1d3>
mov    %r12,%rdi
lea    0xc5b(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
lea    0xc69(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x9,%esi
mov    $0x1,%edx
lea    0xc6a(%rip),%rdi
mov    %r12,%rcx
call   10e0 <fwrite@plt>
lea    0xc65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc84(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10c0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %rbx,%rdi
lea    0xc6a(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %rbx,%rdi
lea    0xc76(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpl   $0x0,0x8(%rsp)
lea    0xc7a(%rip),%rbp
jle    14a0 <main+0x2e0>
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10c0 <scanf@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmp    0x8(%rsp),%r12d
jl     1600 <main+0x440>
jmp    14a0 <main+0x2e0>

LLVM IR (-O0):
@.str = [10 x i8] c"index1.js\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [10 x i8] c"index2.js\00"
@.str.3 = [34 x i8] c"// Generated from generator.c \0A\0A\0A\00"
@.str.4 = [28 x i8] c"var output = $('.output');\0A\00"
@.str.5 = [34 x i8] c"var input = $('textarea.input');\0A\00"
@.str.6 = [15 x i8] c"var toOutput;\0A\00"
@.str.7 = [52 x i8] c"input.keypress(function(e) {\0A\09if (e.which == 13) {\0A\00"
@.str.8 = [39 x i8] c"\09\09var inputVal = $.trim(input.val());\0A\00"
@.str.9 = [3 x i8] c"\09\09\00"
@.str.10 = [24 x i8] c"function separator() {\0A\00"
@.str.11 = [102 x i8] c"\09Output('<span class=\22separator\22>== == == == == == == == == == == == == == == == == ==</span></br>');\00"
@.str.12 = [5 x i8] c"\0A}\0A\0A\00"
@.str.13 = [25 x i8] c"function Output(data) {\0A\00"
@.str.14 = [27 x i8] c"\09$(data).appendTo(output);\00"
@.str.15 = [62 x i8] c"\0AWelcome to the JS Code Generator for the Terminal Emulator!\0A\00"
@.str.16 = [19 x i8] c"\0AEnter X to exit.\0A\00"
@.str.17 = [28 x i8] c"\0APlease enter the command: \00"
@.str.18 = [7 x i8] c"%[^\0A]s\00"
@.str.19 = [34 x i8] c"if (inputVal.indexOf(\22%s\22)>=0) {\0A\00"
@.str.20 = [28 x i8] c"\09\09\09%s();\0A\09\09\09input.Val('');\0A\00"
@.str.21 = [10 x i8] c"\09\09} else \00"
@.str.22 = [45 x i8] c"How many lines do you have in your response?\00"
@.str.23 = [3 x i8] c"%d\00"
@.str.24 = [32 x i8] c"function %s() {\0A\09separator();\0A\09\00"
@.str.25 = [26 x i8] c"var outputArray = ['>%s',\00"
@.str.26 = [40 x i8] c"\0APlease enter line %d of the response:\0A\00"
@.str.27 = [6 x i8] c"'%s',\00"
@SEEK_CUR = global i32 0
@.str.28 = [5 x i8] c"];\0A\09\00"
@.str.29 = [52 x i8] c"for (var i = 0; i < outputArray.length; i++) {\0A\09\09\00"
@.str.30 = [57 x i8] c"var out = '<span>' + outputArray[i] + '</span></br>';\0A\09\09\00"
@.str.31 = [34 x i8] c"Output(out);\0A\09}\0A\09separator();\0A}\0A\0A\00"
@.str.32 = [83 x i8] c"{\0A\09\09\09Output('<span>Oops. <br>You outsmarted me. Try something else.</span></br>');\00"
@.str.33 = [34 x i8] c"\0A\09\09\09input.val('');\0A\09\09}\0A\09}\0A});\0A\0A\0A\0A\00"
@.str.34 = [10 x i8] c"index3.js\00"
@EOF = global i8 0
@.str.35 = [7 x i8] c"Done!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [10 x i8]
%5 = alloca [200 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32*
store i32 0, i32* %1
%10 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %2
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %3
%12 = load i32*, i32** %2
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32*, i32** %2
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32*, i32** %2
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%18 = load i32*, i32** %2
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%20 = load i32*, i32** %2
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%22 = load i32*, i32** %2
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0))
%24 = load i32*, i32** %2
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%26 = load i32*, i32** %3
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%28 = load i32*, i32** %3
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.11, i64 0, i64 0))
%30 = load i32*, i32** %3
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%32 = load i32*, i32** %3
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0))
%36 = load i32*, i32** %3
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.15, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0))
br label %40
40: ; preds = %0, %85
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* %42)
%44 = call i32 (...) @getchar()
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 88
br i1 %48, label %49, label %50
49: ; preds = %40
br label %97
50: ; preds = %40
%51 = load i32*, i32** %2
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %52)
%54 = load i32*, i32** %2
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0), i8* %55)
%57 = load i32*, i32** %2
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i64 0, i64 0))
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.22, i64 0, i64 0))
%60 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0), i32* %6)
%61 = call i32 (...) @getchar()
%62 = load i32*, i32** %3
%63 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.24, i64 0, i64 0), i8* %63)
%65 = load i32*, i32** %3
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.25, i64 0, i64 0), i8* %66)
store i32 0, i32* %7
br label %68
68: ; preds = %82, %50
%69 = load i32, i32* %7
%70 = load i32, i32* %6
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %85
72: ; preds = %68
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.26, i64 0, i64 0), i32 %74)
%76 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%77 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* %76)
%78 = call i32 (...) @getchar()
%79 = load i32*, i32** %3
%80 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %72
%83 = load i32, i32* %7
%84 = add nsw i32 %83, 1
store i32 %84, i32* %7
br label %68
85: ; preds = %68
%86 = load i32*, i32** %3
%87 = load i32, i32* @SEEK_CUR
%88 = call i32 @fseek(i32* %86, i32 -1, i32 %87)
%89 = load i32*, i32** %3
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.28, i64 0, i64 0))
%91 = load i32*, i32** %3
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.29, i64 0, i64 0))
%93 = load i32*, i32** %3
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.30, i64 0, i64 0))
%95 = load i32*, i32** %3
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %95, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.31, i64 0, i64 0))
br label %40
97: ; preds = %49
%98 = load i32*, i32** %2
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.32, i64 0, i64 0))
%100 = load i32*, i32** %2
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.33, i64 0, i64 0))
%102 = load i32*, i32** %2
%103 = call i32 @rewind(i32* %102)
%104 = load i32*, i32** %3
%105 = call i32 @rewind(i32* %104)
%106 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.34, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %106, i32** %9
br label %107
107: ; preds = %114, %97
%108 = load i32*, i32** %2
%109 = call signext i8 @fgetc(i32* %108)
store i8 %109, i8* %8
%110 = sext i8 %109 to i32
%111 = load i8, i8* @EOF
%112 = sext i8 %111 to i32
%113 = icmp ne i32 %110, %112
br i1 %113, label %114, label %118
114: ; preds = %107
%115 = load i8, i8* %8
%116 = load i32*, i32** %9
%117 = call i32 @fputc(i8 signext %115, i32* %116)
br label %107
118: ; preds = %107
br label %119
119: ; preds = %126, %118
%120 = load i32*, i32** %3
%121 = call signext i8 @fgetc(i32* %120)
store i8 %121, i8* %8
%122 = sext i8 %121 to i32
%123 = load i8, i8* @EOF
%124 = sext i8 %123 to i32
%125 = icmp ne i32 %122, %124
br i1 %125, label %126, label %130
126: ; preds = %119
%127 = load i8, i8* %8
%128 = load i32*, i32** %9
%129 = call i32 @fputc(i8 signext %127, i32* %128)
br label %119
130: ; preds = %119
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.35, i64 0, i64 0))
%132 = load i32*, i32** %2
%133 = call i32 @fclose(i32* %132)
%134 = load i32*, i32** %3
%135 = call i32 @fclose(i32* %134)
%136 = load i32*, i32** %9
%137 = call i32 @fclose(i32* %136)
ret i32 42
}

LLVM IR (-O2):
@.str = [10 x i8] c"index1.js\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [10 x i8] c"index2.js\00"
@.str.3 = [34 x i8] c"// Generated from generator.c \0A\0A\0A\00"
@.str.4 = [28 x i8] c"var output = $('.output');\0A\00"
@.str.5 = [34 x i8] c"var input = $('textarea.input');\0A\00"
@.str.6 = [15 x i8] c"var toOutput;\0A\00"
@.str.7 = [52 x i8] c"input.keypress(function(e) {\0A\09if (e.which == 13) {\0A\00"
@.str.8 = [39 x i8] c"\09\09var inputVal = $.trim(input.val());\0A\00"
@.str.9 = [3 x i8] c"\09\09\00"
@.str.10 = [24 x i8] c"function separator() {\0A\00"
@.str.11 = [102 x i8] c"\09Output('<span class=\22separator\22>== == == == == == == == == == == == == == == == == ==</span></br>');\00"
@.str.12 = [5 x i8] c"\0A}\0A\0A\00"
@.str.13 = [25 x i8] c"function Output(data) {\0A\00"
@.str.14 = [27 x i8] c"\09$(data).appendTo(output);\00"
@.str.17 = [28 x i8] c"\0APlease enter the command: \00"
@.str.18 = [7 x i8] c"%[^\0A]s\00"
@.str.19 = [34 x i8] c"if (inputVal.indexOf(\22%s\22)>=0) {\0A\00"
@.str.20 = [28 x i8] c"\09\09\09%s();\0A\09\09\09input.Val('');\0A\00"
@.str.21 = [10 x i8] c"\09\09} else \00"
@.str.22 = [45 x i8] c"How many lines do you have in your response?\00"
@.str.23 = [3 x i8] c"%d\00"
@.str.24 = [32 x i8] c"function %s() {\0A\09separator();\0A\09\00"
@.str.25 = [26 x i8] c"var outputArray = ['>%s',\00"
@.str.26 = [40 x i8] c"\0APlease enter line %d of the response:\0A\00"
@.str.27 = [6 x i8] c"'%s',\00"
@SEEK_CUR = global i32 0
@.str.28 = [5 x i8] c"];\0A\09\00"
@.str.29 = [52 x i8] c"for (var i = 0; i < outputArray.length; i++) {\0A\09\09\00"
@.str.30 = [57 x i8] c"var out = '<span>' + outputArray[i] + '</span></br>';\0A\09\09\00"
@.str.31 = [34 x i8] c"Output(out);\0A\09}\0A\09separator();\0A}\0A\0A\00"
@.str.32 = [83 x i8] c"{\0A\09\09\09Output('<span>Oops. <br>You outsmarted me. Try something else.</span></br>');\00"
@.str.33 = [34 x i8] c"\0A\09\09\09input.val('');\0A\09\09}\0A\09}\0A});\0A\0A\0A\0A\00"
@.str.34 = [10 x i8] c"index3.js\00"
@EOF = global i8 0
@str = [61 x i8] c"\0AWelcome to the JS Code Generator for the Terminal Emulator!\00"
@str.36 = [18 x i8] c"\0AEnter X to exit.\00"
@str.37 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 33, i64 1, i32* %4)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 27, i64 1, i32* %4)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 33, i64 1, i32* %4)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 14, i64 1, i32* %4)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i64 51, i64 1, i32* %4)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i64 38, i64 1, i32* %4)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64 2, i64 1, i32* %4)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i64 23, i64 1, i32* %5)
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([102 x i8], [102 x i8]* @.str.11, i64 0, i64 0), i64 101, i64 1, i32* %5)
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i64 4, i64 1, i32* %5)
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i64 24, i64 1, i32* %5)
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), i64 26, i64 1, i32* %5)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i64 4, i64 1, i32* %5)
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%21 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.36, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* %19)
%26 = call i32 (...) @getchar()
%27 = load i8, i8* %19
%28 = icmp eq i8 %27, 88
br i1 %28, label %61, label %29
29: ; preds = %0, %49
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0), i8* %19)
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i64 0, i64 0), i8* %19)
%32 = call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.21, i64 0, i64 0), i64 9, i64 1, i32* %4)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.22, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0), i32* %3)
%35 = call i32 (...) @getchar()
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.24, i64 0, i64 0), i8* %19)
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.25, i64 0, i64 0), i8* %19)
%38 = load i32, i32* %3
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %29, %40
%41 = phi i32 [ %42, %40 ], [ 0, %29 ]
%42 = add nuw nsw i32 %41, 1
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.26, i64 0, i64 0), i32 %42)
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* %20)
%45 = call i32 (...) @getchar()
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i64 0, i64 0), i8* %20)
%47 = load i32, i32* %3
%48 = icmp slt i32 %42, %47
br i1 %48, label %40, label %49
49: ; preds = %40, %29
%50 = load i32, i32* @SEEK_CUR
%51 = call i32 @fseek(i32* %5, i32 -1, i32 %50)
%52 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.28, i64 0, i64 0), i64 4, i64 1, i32* %5)
%53 = call i64 @fwrite(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.29, i64 0, i64 0), i64 51, i64 1, i32* %5)
%54 = call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.30, i64 0, i64 0), i64 56, i64 1, i32* %5)
%55 = call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.31, i64 0, i64 0), i64 33, i64 1, i32* %5)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%57 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.18, i64 0, i64 0), i8* %19)
%58 = call i32 (...) @getchar()
%59 = load i8, i8* %19
%60 = icmp eq i8 %59, 88
br i1 %60, label %61, label %29
61: ; preds = %49, %0
%62 = call i64 @fwrite(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.32, i64 0, i64 0), i64 82, i64 1, i32* %4)
%63 = call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.33, i64 0, i64 0), i64 33, i64 1, i32* %4)
%64 = call i32 @rewind(i32* %4)
%65 = call i32 @rewind(i32* %5)
%66 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.34, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%67 = call signext i8 @fgetc(i32* %4)
%68 = load i8, i8* @EOF
%69 = icmp eq i8 %67, %68
br i1 %69, label %70, label %74
70: ; preds = %74, %61
%71 = call signext i8 @fgetc(i32* %5)
%72 = load i8, i8* @EOF
%73 = icmp eq i8 %71, %72
br i1 %73, label %86, label %80
74: ; preds = %61, %74
%75 = phi i8 [ %77, %74 ], [ %67, %61 ]
%76 = call i32 @fputc(i8 signext %75, i32* %66)
%77 = call signext i8 @fgetc(i32* %4)
%78 = load i8, i8* @EOF
%79 = icmp eq i8 %77, %78
br i1 %79, label %70, label %74
80: ; preds = %70, %80
%81 = phi i8 [ %83, %80 ], [ %71, %70 ]
%82 = call i32 @fputc(i8 signext %81, i32* %66)
%83 = call signext i8 @fgetc(i32* %5)
%84 = load i8, i8* @EOF
%85 = icmp eq i8 %83, %84
br i1 %85, label %86, label %80
86: ; preds = %80, %70
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.37, i64 0, i64 0))
%88 = call i32 @fclose(i32* %4)
%89 = call i32 @fclose(i32* %5)
%90 = call i32 @fclose(i32* %66)
ret i32 42
}