#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 /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  FILE *f1;
  int *delta;
  int alphabet_size;
  int accept_set_size;
  char alphabet[10];
  int acceptState[10];
  int states[10];
  int s1, s2, n, cc;
  char temp, c;
  int currentState, startState, numStates;
  int nextState;
  int tempChar;
  char stopChar;
  f1 = fopen("DFA.txt", "r");
  fscanf(f1, "%d", &numStates);
  printf("Num States: %d\n", numStates);
  for (int i = 0; i < numStates; i++) {
    fscanf(f1, "%d", &states[i]);
    printf("States: %d\n", states[i]);
  }
  fscanf(f1, "%d", &alphabet_size);
  printf("Alph. Size: %d\n", alphabet_size);
  for (int i = 0; i < alphabet_size; i++) {
    fscanf(f1, " %c", &alphabet[i]);
    printf("Char in Alph: %c\n", alphabet[i]);
  }
  fscanf(f1, " %c", &stopChar);
  printf("Stop Char: %c\n", stopChar);
  fscanf(f1, "%d", &startState);
  printf("Start State: %d\n", startState);
  fscanf(f1, "%d", &accept_set_size);
  for (int i = 0; i < accept_set_size; i++) {
    fscanf(f1, "%d", &acceptState[i]);
  }
  n = numStates * alphabet_size;
  delta = (int *)(malloc(n * sizeof(int)));
  for (int i = 0; i < n; i++) {
    fscanf(f1, "%d %c %d", &s1, &c, &s2);
    cc = ((int)c) - 97;
    delta[s1 * 2 + cc] = s2;
  }
  fclose(f1);
  for (int i = 0; i < n; i++) {
    printf("\n delta[%d] = %d\n", i, delta[i]);
  }
  currentState = startState;
  printf("\nPlease enter a number of a's and b's, followed by a %c.\n",
         stopChar);
  while (1) {
    scanf("%c", &temp);
    tempChar = temp - 'a';
    if (tempChar == stopChar - 'a') {
      break;
    } else if (tempChar == 0 || tempChar == 1) {
      nextState = delta[currentState * 2 + tempChar];
      currentState = nextState;
    } else if (tempChar == -98 || tempChar == -87) {
      break;
    } else {
      printf("Illegal character.\n");
      exit(0);
    }
  }
  if (currentState == acceptState[0]) {
    printf("\nAccept.\n");
  } else {
    printf("\nReject.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe78(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    -0xb0(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0xb0(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
cmp    -0xb0(%rbp),%eax
jge    1239 <main+0xc9>
mov    -0x10(%rbp),%rdi
movslq -0xc0(%rbp),%rax
lea    -0x90(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
movslq -0xc0(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    11d0 <main+0x60>
mov    -0x10(%rbp),%rdi
lea    0xe22(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12c7 <main+0x157>
mov    -0x10(%rbp),%rdi
movslq -0xc4(%rbp),%rax
lea    -0x2a(%rbp),%rdx
add    %rax,%rdx
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
movslq -0xc4(%rbp),%rax
movsbl -0x2a(%rbp,%rax,1),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    126a <main+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xd58(%rip),%rsi
lea    -0xb9(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movsbl -0xb9(%rbp),%esi
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd66(%rip),%rsi
lea    -0xac(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0xac(%rbp),%esi
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd39(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movl   $0x0,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1389 <main+0x219>
mov    -0x10(%rbp),%rdi
movslq -0xc8(%rbp),%rax
lea    -0x60(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    1342 <main+0x1d2>
mov    -0xb0(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
movslq -0x9c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jge    1435 <main+0x2c5>
mov    -0x10(%rbp),%rdi
lea    0xc8a(%rip),%rsi
lea    -0x94(%rbp),%rdx
lea    -0xa2(%rbp),%rcx
lea    -0x98(%rbp),%r8
mov    $0x0,%al
call   1050 <fscanf@plt>
movsbl -0xa2(%rbp),%eax
sub    $0x61,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x98(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x94(%rbp),%ecx
shl    $0x1,%ecx
add    -0xa0(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    13b9 <main+0x249>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0xd0(%rbp)
mov    -0xd0(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jge    1490 <main+0x320>
mov    -0xd0(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0xd0(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xbf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
jmp    1448 <main+0x2d8>
mov    -0xac(%rbp),%eax
mov    %eax,-0xa8(%rbp)
movsbl -0xb9(%rbp),%esi
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb73(%rip),%rdi
lea    -0xa1(%rbp),%rsi
call   1070 <scanf@plt>
movsbl -0xa1(%rbp),%eax
sub    $0x61,%eax
mov    %eax,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
movsbl -0xb9(%rbp),%ecx
sub    $0x61,%ecx
cmp    %ecx,%eax
jne    14f1 <main+0x381>
jmp    1579 <main+0x409>
cmpl   $0x0,-0xb8(%rbp)
je     150b <main+0x39b>
cmpl   $0x1,-0xb8(%rbp)
jne    153b <main+0x3cb>
mov    -0x18(%rbp),%rax
mov    -0xa8(%rbp),%ecx
shl    $0x1,%ecx
add    -0xb8(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
jmp    156f <main+0x3ff>
cmpl   $0xffffff9e,-0xb8(%rbp)
je     1555 <main+0x3e5>
cmpl   $0xffffffa9,-0xb8(%rbp)
jne    155a <main+0x3ea>
jmp    1579 <main+0x409>
lea    0xb54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    1574 <main+0x404>
jmp    14b1 <main+0x341>
mov    -0xa8(%rbp),%eax
cmp    -0x60(%rbp),%eax
jne    159b <main+0x42b>
lea    0xb3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15a9 <main+0x439>
lea    0xb31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe68(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
lea    0xeb8(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x10(%rsp),%esi
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x10(%rsp)
jle    121e <main+0x9e>
lea    0x70(%rsp),%rbx
lea    0xe84(%rip),%r14
lea    0xe25(%rip),%r12
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
movslq 0x10(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11f0 <main+0x70>
lea    0xe41(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x14(%rsp),%esi
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x14(%rsp)
jle    1292 <main+0x112>
lea    0xdd6(%rip),%r14
lea    0xdd3(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
lea    (%rsp,%rbp,1),%rdx
add    $0x36,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
movsbl 0x36(%rsp,%rbp,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
movslq 0x14(%rsp),%rax
cmp    %rax,%rbp
jl     1260 <main+0xe0>
lea    0xd91(%rip),%rsi
lea    0xd(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
movsbl 0xd(%rsp),%esi
lea    0xd8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xda4(%rip),%rbx
lea    0x18(%rsp),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x18(%rsp),%esi
lea    0xd70(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1c(%rsp),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
cmpl   $0x0,0x1c(%rsp)
jle    1332 <main+0x1b2>
lea    0x40(%rsp),%rbx
lea    0xd5b(%rip),%r14
xor    %ebp,%ebp
nopl   (%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fscanf@plt>
add    $0x1,%rbp
movslq 0x1c(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1310 <main+0x190>
mov    0x14(%rsp),%r12d
imul   0x10(%rsp),%r12d
lea    0x0(,%r12,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
jle    13eb <main+0x26b>
lea    0x24(%rsp),%r13
lea    0xf(%rsp),%rbx
lea    0x20(%rsp),%rbp
mov    %r12,0x28(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
lea    0xce6(%rip),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1060 <fscanf@plt>
movsbq 0xf(%rsp),%rax
movslq 0x24(%rsp),%rcx
lea    (%rax,%rcx,2),%rax
mov    0x20(%rsp),%ecx
mov    %ecx,-0x184(%r14,%rax,4)
ff
add    $0xffffffff,%r12d
jne    1370 <main+0x1f0>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x28(%rsp),%rax
test   %eax,%eax
jle    13f3 <main+0x273>
mov    %eax,%ebx
lea    0xca4(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbp,4),%edx
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    13d0 <main+0x250>
jmp    13f3 <main+0x273>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x18(%rsp),%ebp
movsbl 0xd(%rsp),%esi
lea    0xc78(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc1a(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xe(%rsp),%al
cmp    0xd(%rsp),%al
je     1476 <main+0x2f6>
lea    0xbff(%rip),%r15
lea    0xe(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%eax
lea    -0x61(%rax),%ecx
cmp    $0x1,%ecx
ja     146c <main+0x2ec>
lea    (%rcx,%rbp,2),%eax
cltq
mov    (%r14,%rax,4),%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
movzbl 0xe(%rsp),%eax
cmp    0xd(%rsp),%al
jne    1440 <main+0x2c0>
jmp    1476 <main+0x2f6>
cmp    $0xffffffff,%eax
je     1476 <main+0x2f6>
cmp    $0xa,%eax
jne    14a5 <main+0x325>
cmp    0x40(%rsp),%ebp
lea    0xc50(%rip),%rax
lea    0xc40(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc09(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"DFA.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"Num States: %d\0A\00"
@.str.4 = [12 x i8] c"States: %d\0A\00"
@.str.5 = [16 x i8] c"Alph. Size: %d\0A\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [18 x i8] c"Char in Alph: %c\0A\00"
@.str.8 = [15 x i8] c"Stop Char: %c\0A\00"
@.str.9 = [17 x i8] c"Start State: %d\0A\00"
@.str.10 = [9 x i8] c"%d %c %d\00"
@.str.11 = [18 x i8] c"\0A delta[%d] = %d\0A\00"
@.str.12 = [58 x i8] c"\0APlease enter a number of a's and b's, followed by a %c.\0A\00"
@.str.13 = [3 x i8] c"%c\00"
@.str.14 = [20 x i8] c"Illegal character.\0A\00"
@.str.15 = [10 x i8] c"\0AAccept.\0A\00"
@.str.16 = [10 x i8] c"\0AReject.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [10 x i8]
%7 = alloca [10 x i32]
%8 = alloca [10 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i8
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i8
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 0, i32* %1
%26 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %2
%27 = load i32*, i32** %2
%28 = call i32 (i32*, i8*, ...) @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %17)
%29 = load i32, i32* %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %29)
store i32 0, i32* %21
br label %31
31: ; preds = %46, %0
%32 = load i32, i32* %21
%33 = load i32, i32* %17
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = load i32*, i32** %2
%37 = load i32, i32* %21
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %38
%40 = call i32 (i32*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %39)
%41 = load i32, i32* %21
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %35
%47 = load i32, i32* %21
%48 = add nsw i32 %47, 1
store i32 %48, i32* %21
br label %31
49: ; preds = %31
%50 = load i32*, i32** %2
%51 = call i32 (i32*, i8*, ...) @fscanf(i32* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%52 = load i32, i32* %4
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %52)
store i32 0, i32* %22
br label %54
54: ; preds = %70, %49
%55 = load i32, i32* %22
%56 = load i32, i32* %4
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %73
58: ; preds = %54
%59 = load i32*, i32** %2
%60 = load i32, i32* %22
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %61
%63 = call i32 (i32*, i8*, ...) @fscanf(i32* %59, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %62)
%64 = load i32, i32* %22
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %58
%71 = load i32, i32* %22
%72 = add nsw i32 %71, 1
store i32 %72, i32* %22
br label %54
73: ; preds = %54
%74 = load i32*, i32** %2
%75 = call i32 (i32*, i8*, ...) @fscanf(i32* %74, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %20)
%76 = load i8, i8* %20
%77 = sext i8 %76 to i32
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %77)
%79 = load i32*, i32** %2
%80 = call i32 (i32*, i8*, ...) @fscanf(i32* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%81 = load i32, i32* %16
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %81)
%83 = load i32*, i32** %2
%84 = call i32 (i32*, i8*, ...) @fscanf(i32* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
store i32 0, i32* %23
br label %85
85: ; preds = %95, %73
%86 = load i32, i32* %23
%87 = load i32, i32* %5
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %98
89: ; preds = %85
%90 = load i32*, i32** %2
%91 = load i32, i32* %23
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %92
%94 = call i32 (i32*, i8*, ...) @fscanf(i32* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %93)
br label %95
95: ; preds = %89
%96 = load i32, i32* %23
%97 = add nsw i32 %96, 1
store i32 %97, i32* %23
br label %85
98: ; preds = %85
%99 = load i32, i32* %17
%100 = load i32, i32* %4
%101 = mul nsw i32 %99, %100
store i32 %101, i32* %11
%102 = load i32, i32* %11
%103 = sext i32 %102 to i64
%104 = mul i64 %103, 4
%105 = trunc i64 %104 to i32
%106 = call i64 @malloc(i32 %105)
%107 = inttoptr i64 %106 to i32*
store i32* %107, i32** %3
store i32 0, i32* %24
br label %108
108: ; preds = %126, %98
%109 = load i32, i32* %24
%110 = load i32, i32* %11
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %129
112: ; preds = %108
%113 = load i32*, i32** %2
%114 = call i32 (i32*, i8*, ...) @fscanf(i32* %113, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32* %9, i8* %14, i32* %10)
%115 = load i8, i8* %14
%116 = sext i8 %115 to i32
%117 = sub nsw i32 %116, 97
store i32 %117, i32* %12
%118 = load i32, i32* %10
%119 = load i32*, i32** %3
%120 = load i32, i32* %9
%121 = mul nsw i32 %120, 2
%122 = load i32, i32* %12
%123 = add nsw i32 %121, %122
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i32, i32* %119, i64 %124
store i32 %118, i32* %125
br label %126
126: ; preds = %112
%127 = load i32, i32* %24
%128 = add nsw i32 %127, 1
store i32 %128, i32* %24
br label %108
129: ; preds = %108
%130 = load i32*, i32** %2
%131 = call i32 @fclose(i32* %130)
store i32 0, i32* %25
br label %132
132: ; preds = %144, %129
%133 = load i32, i32* %25
%134 = load i32, i32* %11
%135 = icmp slt i32 %133, %134
br i1 %135, label %136, label %147
136: ; preds = %132
%137 = load i32, i32* %25
%138 = load i32*, i32** %3
%139 = load i32, i32* %25
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %138, i64 %140
%142 = load i32, i32* %141
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %137, i32 %142)
br label %144
144: ; preds = %136
%145 = load i32, i32* %25
%146 = add nsw i32 %145, 1
store i32 %146, i32* %25
br label %132
147: ; preds = %132
%148 = load i32, i32* %16
store i32 %148, i32* %15
%149 = load i8, i8* %20
%150 = sext i8 %149 to i32
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.12, i64 0, i64 0), i32 %150)
br label %152
152: ; preds = %147, %190
%153 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %13)
%154 = load i8, i8* %13
%155 = sext i8 %154 to i32
%156 = sub nsw i32 %155, 97
store i32 %156, i32* %19
%157 = load i32, i32* %19
%158 = load i8, i8* %20
%159 = sext i8 %158 to i32
%160 = sub nsw i32 %159, 97
%161 = icmp eq i32 %157, %160
br i1 %161, label %162, label %163
162: ; preds = %152
br label %191
163: ; preds = %152
%164 = load i32, i32* %19
%165 = icmp eq i32 %164, 0
br i1 %165, label %169, label %166
166: ; preds = %163
%167 = load i32, i32* %19
%168 = icmp eq i32 %167, 1
br i1 %168, label %169, label %179
169: ; preds = %166, %163
%170 = load i32*, i32** %3
%171 = load i32, i32* %15
%172 = mul nsw i32 %171, 2
%173 = load i32, i32* %19
%174 = add nsw i32 %172, %173
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i32, i32* %170, i64 %175
%177 = load i32, i32* %176
store i32 %177, i32* %18
%178 = load i32, i32* %18
store i32 %178, i32* %15
br label %189
179: ; preds = %166
%180 = load i32, i32* %19
%181 = icmp eq i32 %180, -98
br i1 %181, label %185, label %182
182: ; preds = %179
%183 = load i32, i32* %19
%184 = icmp eq i32 %183, -87
br i1 %184, label %185, label %186
185: ; preds = %182, %179
br label %191
186: ; preds = %182
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0))
%188 = call i32 @exit(i32 0)
unreachable
189: ; preds = %169
br label %190
190: ; preds = %189
br label %152
191: ; preds = %185, %162
%192 = load i32, i32* %15
%193 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%194 = load i32, i32* %193
%195 = icmp eq i32 %192, %194
br i1 %195, label %196, label %198
196: ; preds = %191
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
br label %200
198: ; preds = %191
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
br label %200
200: ; preds = %198, %196
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"DFA.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [16 x i8] c"Num States: %d\0A\00"
@.str.4 = [12 x i8] c"States: %d\0A\00"
@.str.5 = [16 x i8] c"Alph. Size: %d\0A\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [18 x i8] c"Char in Alph: %c\0A\00"
@.str.8 = [15 x i8] c"Stop Char: %c\0A\00"
@.str.9 = [17 x i8] c"Start State: %d\0A\00"
@.str.10 = [9 x i8] c"%d %c %d\00"
@.str.11 = [18 x i8] c"\0A delta[%d] = %d\0A\00"
@.str.12 = [58 x i8] c"\0APlease enter a number of a's and b's, followed by a %c.\0A\00"
@.str.13 = [3 x i8] c"%c\00"
@str = [19 x i8] c"Illegal character.\00"
@str.17 = [9 x i8] c"\0AReject.\00"
@str.18 = [9 x i8] c"\0AAccept.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca [10 x i32]
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = bitcast i32* %1 to i8*
%14 = bitcast i32* %2 to i8*
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%16 = bitcast [10 x i32]* %4 to i8*
%17 = bitcast [10 x i32]* %5 to i8*
%18 = bitcast i32* %6 to i8*
%19 = bitcast i32* %7 to i8*
%20 = bitcast i32* %10 to i8*
%21 = bitcast i32* %11 to i8*
%22 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %11)
%24 = load i32, i32* %11
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %11
%27 = icmp sgt i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %34, %0
%29 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
%33 = icmp sgt i32 %32, 0
br i1 %33, label %55, label %44
34: ; preds = %0, %34
%35 = phi i64 [ %40, %34 ], [ 0, %0 ]
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %35
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %36)
%38 = load i32, i32* %36
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = add nuw nsw i64 %35, 1
%41 = load i32, i32* %11
%42 = sext i32 %41 to i64
%43 = icmp slt i64 %40, %42
br i1 %43, label %34, label %28
44: ; preds = %55, %28
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %12)
%46 = load i8, i8* %12
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%50 = load i32, i32* %10
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %50)
%52 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%53 = load i32, i32* %2
%54 = icmp sgt i32 %53, 0
br i1 %54, label %76, label %66
55: ; preds = %28, %55
%56 = phi i64 [ %62, %55 ], [ 0, %28 ]
%57 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %56
%58 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %57)
%59 = load i8, i8* %57
%60 = sext i8 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %60)
%62 = add nuw nsw i64 %56, 1
%63 = load i32, i32* %1
%64 = sext i32 %63 to i64
%65 = icmp slt i64 %62, %64
br i1 %65, label %55, label %44
66: ; preds = %76, %44
%67 = load i32, i32* %11
%68 = load i32, i32* %1
%69 = mul nsw i32 %68, %67
%70 = shl i32 %69, 2
%71 = call i64 @malloc(i32 %70)
%72 = inttoptr i64 %71 to i32*
%73 = icmp sgt i32 %69, 0
br i1 %73, label %88, label %74
74: ; preds = %66
%75 = call i32 @fclose(i32* %22)
br label %102
76: ; preds = %44, %76
%77 = phi i64 [ %80, %76 ], [ 0, %44 ]
%78 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %77
%79 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %78)
%80 = add nuw nsw i64 %77, 1
%81 = load i32, i32* %2
%82 = sext i32 %81 to i64
%83 = icmp slt i64 %80, %82
br i1 %83, label %76, label %66
84: ; preds = %88
%85 = call i32 @fclose(i32* %22)
br i1 %73, label %86, label %102
86: ; preds = %84
%87 = zext i32 %69 to i64
br label %111
88: ; preds = %66, %88
%89 = phi i32 [ %100, %88 ], [ 0, %66 ]
%90 = call i32 (i32*, i8*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32* %6, i8* %9, i32* %7)
%91 = load i8, i8* %9
%92 = sext i8 %91 to i32
%93 = add nsw i32 %92, -97
%94 = load i32, i32* %7
%95 = load i32, i32* %6
%96 = shl nsw i32 %95, 1
%97 = add nsw i32 %93, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %72, i64 %98
store i32 %94, i32* %99
%100 = add nuw nsw i32 %89, 1
%101 = icmp eq i32 %100, %69
br i1 %101, label %84, label %88
102: ; preds = %111, %74, %84
%103 = load i32, i32* %10
%104 = load i8, i8* %12
%105 = sext i8 %104 to i32
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.12, i64 0, i64 0), i32 %105)
%107 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %8)
%108 = load i8, i8* %8
%109 = load i8, i8* %12
%110 = icmp eq i8 %108, %109
br i1 %110, label %139, label %119
111: ; preds = %86, %111
%112 = phi i64 [ 0, %86 ], [ %117, %111 ]
%113 = getelementptr inbounds i32, i32* %72, i64 %112
%114 = load i32, i32* %113
%115 = trunc i64 %112 to i32
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0), i32 %115, i32 %114)
%117 = add nuw nsw i64 %112, 1
%118 = icmp eq i64 %117, %87
br i1 %118, label %102, label %111
119: ; preds = %102, %125
%120 = phi i8 [ %132, %125 ], [ %108, %102 ]
%121 = phi i32 [ %130, %125 ], [ %103, %102 ]
%122 = sext i8 %120 to i32
%123 = add nsw i32 %122, -97
%124 = icmp ult i32 %123, 2
br i1 %124, label %125, label %135
125: ; preds = %119
%126 = shl nsw i32 %121, 1
%127 = add nuw nsw i32 %123, %126
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i32, i32* %72, i64 %128
%130 = load i32, i32* %129
%131 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %8)
%132 = load i8, i8* %8
%133 = load i8, i8* %12
%134 = icmp eq i8 %132, %133
br i1 %134, label %139, label %119
135: ; preds = %119
switch i32 %122, label %136 [
i32 10, label %139
i32 -1, label %139
]
136: ; preds = %135
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%138 = call i32 @exit(i32 0)
unreachable
139: ; preds = %125, %102, %135, %135
%140 = phi i32 [ %121, %135 ], [ %121, %135 ], [ %103, %102 ], [ %130, %125 ]
%141 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%142 = load i32, i32* %141
%143 = icmp eq i32 %140, %142
%144 = select i1 %143, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.18, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0)
%145 = call i32 @puts(i8* dereferenceable(1) %144)
ret i32 0
}