#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*/ badargdie();
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ nofiledie(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
char *strcat(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ *strstr(char *, char *);
int main(int argc, char **argv) {
  FILE *foutput;
  int i, nstates, naccp, intbuf, nrules;
  char strbuf[10001];
  char charbuf;
  char *filename = malloc(10000);
  if (argc != 2)
    badargdie();
  strcpy(filename, argv[1]);
  if (strstr(filename, ".rule") == NULL ||
      strcmp(strstr(filename, ".rule"), ".rule"))
    filename = strcat(filename, ".rule");
  foutput = fopen(filename, "w");
  if (foutput == NULL)
    nofiledie(filename);
  while (1) {
    printf("How many states are in the Turing machine? ");
    scanf("%d", &nstates);
    if (nstates > 0)
      break;
    printf("Number of states has to be at least 1.\n");
  }
  while (1) {
    printf("How many accepting states are in the Turing machine? ");
    scanf("%d", &naccp);
    if (naccp >= 0)
      break;
    printf("Number of states has to be at least 0.\n");
  }
  fprintf(foutput, "%d %d", nstates, naccp);
  for (i = 1; i <= naccp; ++i) {
    printf("Accepting state #%d: ", i);
    scanf("%d", &intbuf);
    if (intbuf < 0 || intbuf > nstates - 1) {
      printf("State has to be between 0 and %d.\n", nstates - 1);
      i--;
      continue;
    }
    fprintf(foutput, " %d", intbuf);
  }
  printf("How many rules are there? ");
  scanf("%d", &nrules);
  fprintf(foutput, "\n%d\n", nrules);
  for (i = 1; i <= nrules; ++i) {
    printf("\nRule #%d:\n", i);
    while (1) {
      printf("\tFor state: ");
      scanf("%d", &intbuf);
      if (intbuf < 0 || intbuf > nstates - 1) {
        printf("\tState has to be between 0 and %d.\n", nstates - 1);
        continue;
      }
      break;
    }
    fprintf(foutput, "%d", intbuf);
    printf("\tFor input symbol: ");
    scanf("%s", &strbuf);
    charbuf = strbuf[0];
    fprintf(foutput, " %c", charbuf);
    while (1) {
      printf("\tChange to state: ");
      scanf("%d", &intbuf);
      if (intbuf < 0 || intbuf > nstates - 1) {
        printf("\tState has to be between 0 and %d.\n", nstates - 1);
        continue;
      }
      break;
    }
    fprintf(foutput, " %d", intbuf);
    printf("\tChange the tape square to: ");
    scanf("%s", &strbuf);
    charbuf = strbuf[0];
    fprintf(foutput, " %c", charbuf);
    while (1) {
      printf("\tMove (L)eft or (R)ight: ");
      scanf("%s", &strbuf);
      charbuf = strbuf[0];
      if (charbuf == 'L' || charbuf == 'R') {
        fprintf(foutput, " %c", charbuf);
        break;
      }
      printf("\tPlease type L or R.\n");
    }
    fprintf(foutput, "\n");
  }
  printf("Successfully generated rulefile: %s\n", filename);
  free(filename);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2750,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2710,%edi
call   1080 <malloc@plt>
mov    %rax,-0x2750(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11fb <main+0x3b>
mov    $0x0,%al
call   1090 <badargdie@plt>
mov    -0x2750(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x2750(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
je     1258 <main+0x98>
mov    -0x2750(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,%rdi
lea    0xdb7(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1272 <main+0xb2>
mov    -0x2750(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   10c0 <strcat@plt>
mov    %rax,-0x2750(%rbp)
mov    -0x2750(%rbp),%rdi
lea    0xd86(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a0 <main+0xe0>
mov    -0x2750(%rbp),%rdi
call   10d0 <nofiledie@plt>
jmp    12a5 <main+0xe5>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x20(%rbp)
jle    12d4 <main+0x114>
jmp    12e7 <main+0x127>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12a5 <main+0xe5>
jmp    12ec <main+0x12c>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdbc(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
jl     131b <main+0x15b>
jmp    132e <main+0x16e>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ec <main+0x12c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     13dc <main+0x21c>
mov    -0x1c(%rbp),%esi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd4c(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jl     1397 <main+0x1d7>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    13b9 <main+0x1f9>
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    13ce <main+0x20e>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xcf5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    134d <main+0x18d>
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xccc(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xce7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jg     1641 <main+0x481>
mov    -0x1c(%rbp),%esi
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc73(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jl     1470 <main+0x2b0>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1489 <main+0x2c9>
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1435 <main+0x275>
jmp    148e <main+0x2ce>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc8f(%rip),%rdi
lea    -0x2740(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x2740(%rbp),%al
mov    %al,-0x2741(%rbp)
mov    -0x18(%rbp),%rdi
movsbl -0x2741(%rbp),%edx
lea    0xc66(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbbd(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x28(%rbp)
jl     1526 <main+0x366>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    153f <main+0x37f>
mov    -0x20(%rbp),%esi
sub    $0x1,%esi
lea    0xbdc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14eb <main+0x32b>
jmp    1544 <main+0x384>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%edx
lea    0xb6a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xc01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbd9(%rip),%rdi
lea    -0x2740(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x2740(%rbp),%al
mov    %al,-0x2741(%rbp)
mov    -0x18(%rbp),%rdi
movsbl -0x2741(%rbp),%edx
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    0xbd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xb91(%rip),%rdi
lea    -0x2740(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
mov    -0x2740(%rbp),%al
mov    %al,-0x2741(%rbp)
movsbl -0x2741(%rbp),%eax
cmp    $0x4c,%eax
je     15f0 <main+0x430>
movsbl -0x2741(%rbp),%eax
cmp    $0x52,%eax
jne    160e <main+0x44e>
mov    -0x18(%rbp),%rdi
movsbl -0x2741(%rbp),%edx
lea    0xb48(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1621 <main+0x461>
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15a1 <main+0x3e1>
mov    -0x18(%rbp),%rdi
lea    0xa8c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1418 <main+0x258>
mov    -0x2750(%rbp),%rsi
lea    0xb5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2750(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x2750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2748,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x2710,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
je     120f <main+0x2f>
xor    %eax,%eax
call   10c0 <badargdie@plt>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   1100 <strstr@plt>
test   %rax,%rax
je     1243 <main+0x63>
lea    0xdca(%rip),%rsi
mov    %rax,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1259 <main+0x79>
mov    %rbx,%rdi
call   1060 <strlen@plt>
movl   $0x6c75722e,(%rbx,%rax,1)
movw   $0x65,0x4(%rbx,%rax,1)
lea    0xda6(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
jne    127a <main+0x9a>
mov    %rbx,%rdi
call   10f0 <nofiledie@plt>
mov    %rbx,0x20(%rsp)
lea    0xd82(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd9(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jg     12f6 <main+0x116>
lea    0xebf(%rip),%r14
lea    0xd53(%rip),%r15
lea    0xdb1(%rip),%rbx
lea    0x8(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    12d0 <main+0xf0>
lea    0xd37(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd62(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x10(%rsp),%ecx
test   %ecx,%ecx
jns    1367 <main+0x187>
lea    0xe6e(%rip),%r14
lea    0xd07(%rip),%r15
lea    0xd39(%rip),%rbx
lea    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x10(%rsp),%ecx
test   %ecx,%ecx
js     1340 <main+0x160>
mov    0x8(%rsp),%edx
lea    0xcf8(%rip),%rsi
mov    0x18(%rsp),%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1415 <main+0x235>
mov    $0x1,%ebp
lea    0xcdb(%rip),%r14
lea    0xcd1(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xcc4(%rip),%r12
lea    0xd11(%rip),%r13
jmp    13db <main+0x1fb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0xffffffff,%ebp
lea    0x1(%rbp),%eax
cmp    0x10(%rsp),%ebp
mov    %eax,%ebp
jge    1415 <main+0x235>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
test   %edx,%edx
js     13c0 <main+0x1e0>
cmp    %esi,%edx
jge    13c0 <main+0x1e0>
mov    0x18(%rsp),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13d0 <main+0x1f0>
lea    0xc6a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc43(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x14(%rsp),%edx
lea    0xc60(%rip),%rsi
mov    0x18(%rsp),%rdi
xor    %eax,%eax
call   10a0 <fprintf@plt>
cmpl   $0x0,0x14(%rsp)
jle    1638 <main+0x458>
mov    $0x1,%esi
lea    0xc4e(%rip),%r15
lea    0xc02(%rip),%r12
lea    0xc(%rsp),%rbp
lea    0xc87(%rip),%r14
lea    0xc41(%rip),%rbx
jmp    14d1 <main+0x2f1>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
lea    0xc6b(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1080 <fputc@plt>
mov    0x28(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    0x14(%rsp),%ecx
mov    %eax,%esi
lea    0xbfa(%rip),%r15
lea    0xc3f(%rip),%r14
lea    0xc(%rsp),%rbp
lea    0xbf4(%rip),%rbx
jge    1638 <main+0x458>
lea    0xbce(%rip),%rdi
mov    %rsi,0x28(%rsp)
jmp    14e6 <main+0x306>
nop
add    $0xffffffff,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
test   %edx,%edx
js     14e0 <main+0x300>
cmp    %esi,%edx
jge    14e0 <main+0x300>
mov    0x18(%rsp),%r13
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xbb6(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbbc(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
movsbl 0x30(%rsp),%edx
mov    %r13,%rdi
lea    0xba4(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    156d <main+0x38d>
nop
add    $0xffffffff,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
test   %edx,%edx
js     1560 <main+0x380>
cmp    %esi,%edx
jge    1560 <main+0x380>
mov    0x18(%rsp),%r13
mov    %r13,%rdi
lea    0xac9(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xb60(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xb38(%rip),%r15
mov    %r15,%rdi
lea    0x30(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
movsbl 0x30(%rsp),%edx
mov    %r13,%rdi
lea    0xb1a(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    0xb40(%rip),%rbp
lea    0xbc6(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
movzbl 0x30(%rsp),%edx
cmp    $0x52,%edx
je     1480 <main+0x2a0>
cmp    $0x4c,%dl
je     1480 <main+0x2a0>
mov    %rbx,%rdi
call   1050 <puts@plt>
jmp    1600 <main+0x420>
lea    0xb09(%rip),%rdi
mov    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x2748,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c".rule\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [44 x i8] c"How many states are in the Turing machine? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [40 x i8] c"Number of states has to be at least 1.\0A\00"
@.str.5 = [54 x i8] c"How many accepting states are in the Turing machine? \00"
@.str.6 = [40 x i8] c"Number of states has to be at least 0.\0A\00"
@.str.7 = [6 x i8] c"%d %d\00"
@.str.8 = [22 x i8] c"Accepting state #%d: \00"
@.str.9 = [35 x i8] c"State has to be between 0 and %d.\0A\00"
@.str.10 = [4 x i8] c" %d\00"
@.str.11 = [27 x i8] c"How many rules are there? \00"
@.str.12 = [5 x i8] c"\0A%d\0A\00"
@.str.13 = [12 x i8] c"\0ARule #%d:\0A\00"
@.str.14 = [13 x i8] c"\09For state: \00"
@.str.15 = [36 x i8] c"\09State has to be between 0 and %d.\0A\00"
@.str.16 = [20 x i8] c"\09For input symbol: \00"
@.str.17 = [3 x i8] c"%s\00"
@.str.18 = [4 x i8] c" %c\00"
@.str.19 = [19 x i8] c"\09Change to state: \00"
@.str.20 = [29 x i8] c"\09Change the tape square to: \00"
@.str.21 = [26 x i8] c"\09Move (L)eft or (R)ight: \00"
@.str.22 = [22 x i8] c"\09Please type L or R.\0A\00"
@.str.23 = [2 x i8] c"\0A\00"
@.str.24 = [37 x i8] c"Successfully generated rulefile: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [10001 x i8]
%13 = alloca i8
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i8* @malloc(i32 10000)
store i8* %15, i8** %14
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @badargdie()
br label %20
20: ; preds = %18, %2
%21 = load i8*, i8** %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %21, i8* %24)
%26 = load i8*, i8** %14
%27 = call i32* @strstr(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %34, label %29
29: ; preds = %20
%30 = load i8*, i8** %14
%31 = call i32* @strstr(i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%32 = call i64 @strcmp(i32* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29, %20
%35 = load i8*, i8** %14
%36 = call i8* @strcat(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %36, i8** %14
br label %37
37: ; preds = %34, %29
%38 = load i8*, i8** %14
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %6
%40 = load i32*, i32** %6
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i8*, i8** %14
%44 = call i32 @nofiledie(i8* %43)
br label %45
45: ; preds = %42, %37
br label %46
46: ; preds = %45, %52
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%49 = load i32, i32* %8
%50 = icmp sgt i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %46
br label %54
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %46
54: ; preds = %51
br label %55
55: ; preds = %54, %61
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%57 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%58 = load i32, i32* %9
%59 = icmp sge i32 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %55
br label %63
61: ; preds = %55
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
br label %55
63: ; preds = %60
%64 = load i32*, i32** %6
%65 = load i32, i32* %8
%66 = load i32, i32* %9
%67 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %65, i32 %66)
store i32 1, i32* %7
br label %68
68: ; preds = %93, %63
%69 = load i32, i32* %7
%70 = load i32, i32* %9
%71 = icmp sle i32 %69, %70
br i1 %71, label %72, label %96
72: ; preds = %68
%73 = load i32, i32* %7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %73)
%75 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%76 = load i32, i32* %10
%77 = icmp slt i32 %76, 0
br i1 %77, label %83, label %78
78: ; preds = %72
%79 = load i32, i32* %10
%80 = load i32, i32* %8
%81 = sub nsw i32 %80, 1
%82 = icmp sgt i32 %79, %81
br i1 %82, label %83, label %89
83: ; preds = %78, %72
%84 = load i32, i32* %8
%85 = sub nsw i32 %84, 1
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %7
%88 = add nsw i32 %87, -1
store i32 %88, i32* %7
br label %93
89: ; preds = %78
%90 = load i32*, i32** %6
%91 = load i32, i32* %10
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %89, %83
%94 = load i32, i32* %7
%95 = add nsw i32 %94, 1
store i32 %95, i32* %7
br label %68
96: ; preds = %68
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%98 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %11)
%99 = load i32*, i32** %6
%100 = load i32, i32* %11
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %100)
store i32 1, i32* %7
br label %102
102: ; preds = %185, %96
%103 = load i32, i32* %7
%104 = load i32, i32* %11
%105 = icmp sle i32 %103, %104
br i1 %105, label %106, label %188
106: ; preds = %102
%107 = load i32, i32* %7
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %107)
br label %109
109: ; preds = %106, %119
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%111 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%112 = load i32, i32* %10
%113 = icmp slt i32 %112, 0
br i1 %113, label %119, label %114
114: ; preds = %109
%115 = load i32, i32* %10
%116 = load i32, i32* %8
%117 = sub nsw i32 %116, 1
%118 = icmp sgt i32 %115, %117
br i1 %118, label %119, label %123
119: ; preds = %114, %109
%120 = load i32, i32* %8
%121 = sub nsw i32 %120, 1
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0), i32 %121)
br label %109
123: ; preds = %114
br label %124
124: ; preds = %123
%125 = load i32*, i32** %6
%126 = load i32, i32* %10
%127 = call i32 (i32*, i8*, ...) @fprintf(i32* %125, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%129 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %12)
%130 = getelementptr inbounds [10001 x i8], [10001 x i8]* %12, i64 0, i64 0
%131 = load i8, i8* %130
store i8 %131, i8* %13
%132 = load i32*, i32** %6
%133 = load i8, i8* %13
%134 = sext i8 %133 to i32
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %132, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %134)
br label %136
136: ; preds = %124, %146
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%138 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%139 = load i32, i32* %10
%140 = icmp slt i32 %139, 0
br i1 %140, label %146, label %141
141: ; preds = %136
%142 = load i32, i32* %10
%143 = load i32, i32* %8
%144 = sub nsw i32 %143, 1
%145 = icmp sgt i32 %142, %144
br i1 %145, label %146, label %150
146: ; preds = %141, %136
%147 = load i32, i32* %8
%148 = sub nsw i32 %147, 1
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0), i32 %148)
br label %136
150: ; preds = %141
br label %151
151: ; preds = %150
%152 = load i32*, i32** %6
%153 = load i32, i32* %10
%154 = call i32 (i32*, i8*, ...) @fprintf(i32* %152, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %153)
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0))
%156 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %12)
%157 = getelementptr inbounds [10001 x i8], [10001 x i8]* %12, i64 0, i64 0
%158 = load i8, i8* %157
store i8 %158, i8* %13
%159 = load i32*, i32** %6
%160 = load i8, i8* %13
%161 = sext i8 %160 to i32
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %159, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %161)
br label %163
163: ; preds = %151, %180
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0))
%165 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %12)
%166 = getelementptr inbounds [10001 x i8], [10001 x i8]* %12, i64 0, i64 0
%167 = load i8, i8* %166
store i8 %167, i8* %13
%168 = load i8, i8* %13
%169 = sext i8 %168 to i32
%170 = icmp eq i32 %169, 76
br i1 %170, label %175, label %171
171: ; preds = %163
%172 = load i8, i8* %13
%173 = sext i8 %172 to i32
%174 = icmp eq i32 %173, 82
br i1 %174, label %175, label %180
175: ; preds = %171, %163
%176 = load i32*, i32** %6
%177 = load i8, i8* %13
%178 = sext i8 %177 to i32
%179 = call i32 (i32*, i8*, ...) @fprintf(i32* %176, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %178)
br label %182
180: ; preds = %171
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.22, i64 0, i64 0))
br label %163
182: ; preds = %175
%183 = load i32*, i32** %6
%184 = call i32 (i32*, i8*, ...) @fprintf(i32* %183, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
br label %185
185: ; preds = %182
%186 = load i32, i32* %7
%187 = add nsw i32 %186, 1
store i32 %187, i32* %7
br label %102
188: ; preds = %102
%189 = load i8*, i8** %14
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.24, i64 0, i64 0), i8* %189)
%191 = load i8*, i8** %14
%192 = call i32 @free(i8* %191)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c".rule\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [44 x i8] c"How many states are in the Turing machine? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [54 x i8] c"How many accepting states are in the Turing machine? \00"
@.str.7 = [6 x i8] c"%d %d\00"
@.str.8 = [22 x i8] c"Accepting state #%d: \00"
@.str.9 = [35 x i8] c"State has to be between 0 and %d.\0A\00"
@.str.10 = [4 x i8] c" %d\00"
@.str.11 = [27 x i8] c"How many rules are there? \00"
@.str.12 = [5 x i8] c"\0A%d\0A\00"
@.str.13 = [12 x i8] c"\0ARule #%d:\0A\00"
@.str.14 = [13 x i8] c"\09For state: \00"
@.str.15 = [36 x i8] c"\09State has to be between 0 and %d.\0A\00"
@.str.16 = [20 x i8] c"\09For input symbol: \00"
@.str.17 = [3 x i8] c"%s\00"
@.str.18 = [4 x i8] c" %c\00"
@.str.19 = [19 x i8] c"\09Change to state: \00"
@.str.20 = [29 x i8] c"\09Change the tape square to: \00"
@.str.21 = [26 x i8] c"\09Move (L)eft or (R)ight: \00"
@.str.24 = [37 x i8] c"Successfully generated rulefile: %s\0A\00"
@str = [39 x i8] c"Number of states has to be at least 1.\00"
@str.25 = [39 x i8] c"Number of states has to be at least 0.\00"
@str.26 = [21 x i8] c"\09Please type L or R.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10001 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds [10001 x i8], [10001 x i8]* %7, i64 0, i64 0
%13 = tail call dereferenceable_or_null(10000) i8* @malloc(i32 10000)
%14 = icmp eq i32 %0, 2
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = tail call i32 (...) @badargdie()
br label %17
17: ; preds = %15, %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @strcpy(i8* %13, i8* %19)
%21 = tail call i32* @strstr(i8* dereferenceable(1) %13, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = tail call i64 @strcmp(i32* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %23, %17
%27 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%28 = getelementptr i8, i8* %13, i64 %27
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) %28, i8* align 1 dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 6, i1 false)
br label %29
29: ; preds = %26, %23
%30 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = tail call i32 @nofiledie(i8* %13)
br label %34
34: ; preds = %32, %29
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%37 = load i32, i32* %3
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %44, %34
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%42 = load i32, i32* %4
%43 = icmp sgt i32 %42, -1
br i1 %43, label %56, label %50
44: ; preds = %34, %44
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%48 = load i32, i32* %3
%49 = icmp sgt i32 %48, 0
br i1 %49, label %39, label %44
50: ; preds = %39, %50
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.25, i64 0, i64 0))
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%54 = load i32, i32* %4
%55 = icmp sgt i32 %54, -1
br i1 %55, label %56, label %50
56: ; preds = %50, %39
%57 = phi i32 [ %42, %39 ], [ %54, %50 ]
%58 = load i32, i32* %3
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %58, i32 %57)
%60 = load i32, i32* %4
%61 = icmp slt i32 %60, 1
br i1 %61, label %82, label %62
62: ; preds = %56, %77
%63 = phi i32 [ %79, %77 ], [ 1, %56 ]
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %63)
%65 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%66 = load i32, i32* %5
%67 = icmp sgt i32 %66, -1
%68 = load i32, i32* %3
%69 = icmp slt i32 %66, %68
%70 = select i1 %67, i1 %69, i1 false
br i1 %70, label %75, label %71
71: ; preds = %62
%72 = add nsw i32 %68, -1
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %72)
%74 = add nsw i32 %63, -1
br label %77
75: ; preds = %62
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %66)
br label %77
77: ; preds = %75, %71
%78 = phi i32 [ %74, %71 ], [ %63, %75 ]
%79 = add nsw i32 %78, 1
%80 = load i32, i32* %4
%81 = icmp slt i32 %78, %80
br i1 %81, label %62, label %82
82: ; preds = %77, %56
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%84 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%85 = load i32, i32* %6
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %6
%88 = icmp slt i32 %87, 1
br i1 %88, label %157, label %89
89: ; preds = %82, %148
%90 = phi i32 [ %152, %148 ], [ 1, %82 ]
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0), i32 %90)
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%93 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%94 = load i32, i32* %5
%95 = icmp sgt i32 %94, -1
%96 = load i32, i32* %3
%97 = icmp slt i32 %94, %96
%98 = select i1 %95, i1 %97, i1 false
br i1 %98, label %110, label %99
99: ; preds = %89, %99
%100 = phi i32 [ %107, %99 ], [ %96, %89 ]
%101 = add nsw i32 %100, -1
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0), i32 %101)
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%104 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%105 = load i32, i32* %5
%106 = icmp sgt i32 %105, -1
%107 = load i32, i32* %3
%108 = icmp slt i32 %105, %107
%109 = select i1 %106, i1 %108, i1 false
br i1 %109, label %110, label %99
110: ; preds = %99, %89
%111 = phi i32 [ %94, %89 ], [ %105, %99 ]
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %111)
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.16, i64 0, i64 0))
%114 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %7)
%115 = load i8, i8* %12
%116 = sext i8 %115 to i32
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%119 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%120 = load i32, i32* %5
%121 = icmp sgt i32 %120, -1
%122 = load i32, i32* %3
%123 = icmp slt i32 %120, %122
%124 = select i1 %121, i1 %123, i1 false
br i1 %124, label %136, label %125
125: ; preds = %110, %125
%126 = phi i32 [ %133, %125 ], [ %122, %110 ]
%127 = add nsw i32 %126, -1
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.15, i64 0, i64 0), i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i64 0, i64 0))
%130 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%131 = load i32, i32* %5
%132 = icmp sgt i32 %131, -1
%133 = load i32, i32* %3
%134 = icmp slt i32 %131, %133
%135 = select i1 %132, i1 %134, i1 false
br i1 %135, label %136, label %125
136: ; preds = %125, %110
%137 = phi i32 [ %120, %110 ], [ %131, %125 ]
%138 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %137)
%139 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.20, i64 0, i64 0))
%140 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %7)
%141 = load i8, i8* %12
%142 = sext i8 %141 to i32
%143 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %142)
br label %144
144: ; preds = %155, %136
%145 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.21, i64 0, i64 0))
%146 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), [10001 x i8]* %7)
%147 = load i8, i8* %12
switch i8 %147, label %155 [
i8 82, label %148
i8 76, label %148
]
148: ; preds = %144, %144
%149 = zext i8 %147 to i32
%150 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.18, i64 0, i64 0), i32 %149)
%151 = call i32 @fputc(i32 10, i32* %30)
%152 = add nuw nsw i32 %90, 1
%153 = load i32, i32* %6
%154 = icmp slt i32 %90, %153
br i1 %154, label %89, label %157
155: ; preds = %144
%156 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.26, i64 0, i64 0))
br label %144
157: ; preds = %148, %82
%158 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.24, i64 0, i64 0), i8* %13)
%159 = call i32 @free(i8* %13)
ret i32 0
}