#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
void main() {
  int transition[4][2] = {{0, 1}, {2, 1}, {0, 3}, {3, 3}};
  char str[10], ch;
  int symbol, state = 0;
  int i;
  printf("Enter String: ");
  for (i = 0;; ++i) {
    ch = getchar();
    if (ch == ' ' || ch == '\n')
      break;
    else
      str[i] = ch;
  }
  str[i] = '\0';
  for (i = 0; str[i] != '\0'; ++i) {
    symbol = str[i] - 48;
    state = transition[state][symbol];
  }
  if (state != 3)
    printf("\nRejected\n");
  else
    printf("\nAccepted\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xece(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x2b(%rbp)
movsbl -0x2b(%rbp),%eax
cmp    $0x20,%eax
je     1192 <main+0x72>
movsbl -0x2b(%rbp),%eax
cmp    $0xa,%eax
jne    1197 <main+0x77>
jmp    11b5 <main+0x95>
mov    -0x2b(%rbp),%cl
movslq -0x38(%rbp),%rax
mov    %cl,-0x2a(%rbp,%rax,1)
jmp    11a7 <main+0x87>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    116e <main+0x4e>
movslq -0x38(%rbp),%rax
movb   $0x0,-0x2a(%rbp,%rax,1)
movl   $0x0,-0x38(%rbp)
movslq -0x38(%rbp),%rax
movsbl -0x2a(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     120d <main+0xed>
movslq -0x38(%rbp),%rax
movsbl -0x2a(%rbp,%rax,1),%eax
sub    $0x30,%eax
mov    %eax,-0x30(%rbp)
movslq -0x34(%rbp),%rcx
lea    -0x20(%rbp),%rax
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c5 <main+0xa5>
cmpl   $0x3,-0x34(%rbp)
je     1228 <main+0x108>
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
jmp    1234 <main+0x114>
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1169 <main+0x39>
cmp    $0x20,%al
je     1169 <main+0x39>
mov    %al,0x6(%rsp,%rbx,1)
add    $0x1,%rbx
jmp    1150 <main+0x20>
mov    %ebx,%eax
movb   $0x0,0x6(%rsp,%rax,1)
mov    0x6(%rsp),%cl
test   %cl,%cl
je     11c4 <main+0x94>
lea    0x7(%rsp),%rax
xor    %edx,%edx
lea    0xe7a(%rip),%rsi
cs nopw 0x0(%rax,%rax,1)
movsbq %cl,%rcx
movslq %edx,%rdx
lea    (%rsi,%rdx,8),%rdx
mov    -0xc0(%rdx,%rcx,4),%edx
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1190 <main+0x60>
cmp    $0x3,%edx
lea    0xe78(%rip),%rax
lea    0xe7b(%rip),%rdi
cmove  %rax,%rdi
jmp    11cb <main+0x9b>
lea    0xe6e(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@__const.main.transition = [4 x [2 x i32]] [[2 x i32] [i32 0, i32 1], [2 x i32] [i32 2, i32 1], [2 x i32] [i32 0, i32 3], [2 x i32] [i32 3, i32 3]]
@.str = [15 x i8] c"Enter String: \00"
@str = [10 x i8] c"\0AAccepted\00"
@str.3 = [10 x i8] c"\0ARejected\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %7, %0
%5 = phi i64 [ %9, %7 ], [ 0, %0 ]
%6 = tail call signext i8 (...) @getchar()
switch i8 %6, label %7 [
i8 32, label %10
i8 10, label %10
]
7: ; preds = %4
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %5
store i8 %6, i8* %8
%9 = add nuw i64 %5, 1
br label %4
10: ; preds = %4, %4
%11 = and i64 %5, 4294967295
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %11
store i8 0, i8* %12
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, 0
br i1 %14, label %31, label %15
15: ; preds = %10, %15
%16 = phi i64 [ %24, %15 ], [ 0, %10 ]
%17 = phi i8 [ %26, %15 ], [ %13, %10 ]
%18 = phi i32 [ %23, %15 ], [ 0, %10 ]
%19 = sext i8 %17 to i64
%20 = add nsw i64 %19, -48
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds [4 x [2 x i32]], [4 x [2 x i32]]* @__const.main.transition, i64 0, i64 %21, i64 %20
%23 = load i32, i32* %22
%24 = add nuw nsw i64 %16, 1
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %15
28: ; preds = %15
%29 = icmp eq i32 %23, 3
%30 = select i1 %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0)
br label %31
31: ; preds = %28, %10
%32 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0), %10 ], [ %30, %28 ]
%33 = tail call i32 @puts(i8* dereferenceable(1) %32)
ret void
}