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

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readTransition(int **, int);
int /*<<< orphan*/ scanf(char *, ...);
void isAccepted(char str[], int stateCount) {
  int i, j, ch0;
  char test[10];
  int symbol, state;
  int transition[stateCount][2];
  int final = stateCount - 1;
  readTransition(transition, stateCount);
  do {
    state = 0;
    printf("Enter Test String:");
    scanf("%s", test);
    for (i = 0; test[i] != '\0'; ++i) {
      if (state == -1)
        break;
      symbol = test[i] - 48;
      state = transition[state][symbol];
    }
    if (state == final)
      printf("\nAccepted\n");
    else
      printf("\nRejected\n");
    printf("\nTry Again Press 1\n");
    scanf("%d", &ch0);
  } while (ch0 == 1);
}


x86 assembly (clang, -O0):
<isAccepted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x50(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0xc(%rbp),%esi
call   1030 <readTransition@plt>
movl   $0x0,-0x2c(%rbp)
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x22(%rbp),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movsbl -0x22(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11fa <isAccepted+0xca>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11c4 <isAccepted+0x94>
jmp    11fa <isAccepted+0xca>
mov    -0x50(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl -0x22(%rbp,%rcx,1),%ecx
sub    $0x30,%ecx
mov    %ecx,-0x28(%rbp)
movslq -0x2c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a3 <isAccepted+0x73>
mov    -0x2c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    1217 <isAccepted+0xe7>
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
jmp    1223 <isAccepted+0xf3>
lea    0xe03(%rip),%rdi
call   1040 <printf@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
je     1177 <isAccepted+0x47>
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isAccepted>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,-0x40(%rbp)
mov    %esi,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x1(%rsi),%r12d
mov    %rbx,%rdi
call   1040 <readTransition@plt>
lea    0xea4(%rip),%r13
lea    0xe90(%rip),%r14
lea    -0x2c(%rbp),%r15
jmp    11c5 <isAccepted+0x85>
nopl   0x0(%rax)
cmp    %r12d,%eax
lea    0xe7f(%rip),%rdi
lea    0xe95(%rip),%rax
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x1,-0x2c(%rbp)
jne    122a <isAccepted+0xea>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3b(%rip),%rdi
lea    -0x36(%rbp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    -0x36(%rbp),%cl
mov    $0x0,%eax
test   %cl,%cl
je     1190 <isAccepted+0x50>
xor    %eax,%eax
lea    -0x35(%rbp),%rdx
cs nopw 0x0(%rax,%rax,1)
nop
movsbq %cl,%rcx
cltq
lea    (%rbx,%rax,8),%rax
mov    -0xc0(%rax,%rcx,4),%eax
movzbl (%rdx),%ecx
test   %cl,%cl
je     1190 <isAccepted+0x50>
add    $0x1,%rdx
cmp    $0xffffffff,%eax
jne    1200 <isAccepted+0xc0>
jmp    1190 <isAccepted+0x50>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter Test String:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [11 x i8] c"\0AAccepted\0A\00"
@.str.3 = [11 x i8] c"\0ARejected\0A\00"
@.str.4 = [20 x i8] c"\0ATry Again Press 1\0A\00"
@.str.5 = [3 x i8] c"%d\00"
define void @isAccepted(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %11
%17 = alloca [2 x i32], i64 %15
store i64 %15, i64* %12
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %13
%20 = bitcast [2 x i32]* %17 to i32**
%21 = load i32, i32* %4
%22 = call i32 @readTransition(i32** %20, i32 %21)
br label %23
23: ; preds = %66, %2
store i32 0, i32* %10
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %25)
store i32 0, i32* %5
br label %27
27: ; preds = %52, %23
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %55
34: ; preds = %27
%35 = load i32, i32* %10
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %38
37: ; preds = %34
br label %55
38: ; preds = %34
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = sub nsw i32 %43, 48
store i32 %44, i32* %9
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 %46
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %47, i64 0, i64 %49
%51 = load i32, i32* %50
store i32 %51, i32* %10
br label %52
52: ; preds = %38
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %27
55: ; preds = %37, %27
%56 = load i32, i32* %10
%57 = load i32, i32* %13
%58 = icmp eq i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %63
61: ; preds = %55
%62 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %61, %59
%64 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%65 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %7)
br label %66
66: ; preds = %63
%67 = load i32, i32* %7
%68 = icmp eq i32 %67, 1
br i1 %68, label %23, label %69
69: ; preds = %66
%70 = load i8*, i8** %11
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Enter Test String:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.5 = [3 x i8] c"%d\00"
@str = [10 x i8] c"\0ARejected\00"
@str.6 = [19 x i8] c"\0ATry Again Press 1\00"
@str.7 = [10 x i8] c"\0AAccepted\00"
define void @isAccepted(i8* nocapture readnone %0, i32 %1) {
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = zext i32 %1 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i32*, i64 %7
%10 = add nsw i32 %1, -1
%11 = call i32 @readTransition(i32** %9, i32 %1)
br label %12
12: ; preds = %34, %2
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%15 = load i8, i8* %6
%16 = icmp eq i8 %15, 0
br i1 %16, label %34, label %17
17: ; preds = %12, %17
%18 = phi i64 [ %28, %17 ], [ 0, %12 ]
%19 = phi i8 [ %30, %17 ], [ %15, %12 ]
%20 = phi i32 [ %27, %17 ], [ 0, %12 ]
%21 = sext i8 %19 to i64
%22 = add nsw i64 %21, -48
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds i32*, i32** %9, i64 %23
%25 = bitcast i32** %24 to [2 x i32]*
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %25, i64 0, i64 %22
%27 = load i32, i32* %26
%28 = add nuw nsw i64 %18, 1
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
%32 = icmp eq i32 %27, -1
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %34, label %17
34: ; preds = %17, %12
%35 = phi i32 [ 0, %12 ], [ %27, %17 ]
%36 = icmp eq i32 %35, %10
%37 = select i1 %36, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0)
%38 = call i32 @puts(i8* dereferenceable(1) %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%41 = load i32, i32* %3
%42 = icmp eq i32 %41, 1
br i1 %42, label %12, label %43
43: ; preds = %34
ret void
}