#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 EOF;
char getchar();
int /*<<< orphan*/ printf(char *, int, char);
int /*<<< orphan*/ putchar(char);
int main() {
  int state = 1;
  char c;
  while ((c = getchar()) != EOF) {
    switch (state) {
    case 1:
      if (c == '/') {
        state = 2;
      } else if (c == '"') {
        state = 8;
        putchar(c);
      } else if (c == '\'') {
        state = 6;
        putchar(c);
      } else {
        putchar(c);
      }
      break;
    case 2:
      if (c == '/')
        state = 3;
      else if (c == '*')
        state = 4;
      else {
        state = 1;
        putchar('/');
        putchar(c);
      }
      break;
    case 3:
      if (c == '\n') {
        state = 1;
        putchar(c);
      }
      break;
    case 4:
      if (c == '*')
        state = 5;
      break;
    case 5:
      if (c == '/')
        state = 1;
      else
        state = 4;
      break;
    case 6:
      if (c == '\'')
        state = 1;
      else if (c == '\\')
        state = 7;
      putchar(c);
      break;
    case 7:
      state = 6;
      putchar(c);
      break;
    case 8:
      if (c == '"')
        state = 1;
      else if (c == '\\')
        state = 9;
      putchar(c);
      break;
    case 9:
      state = 8;
      putchar(c);
      break;
    default:
      printf("Error, current state: %d, current char: %c", state, c);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
mov    0x2e8e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1387 <main+0x257>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x8,%eax
ja     1363 <main+0x233>
mov    -0x18(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
jne    11a7 <main+0x77>
movl   $0x2,-0x8(%rbp)
jmp    11fe <main+0xce>
movsbl -0x9(%rbp),%eax
cmp    $0x22,%eax
jne    11c9 <main+0x99>
movl   $0x8,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    11f9 <main+0xc9>
movsbl -0x9(%rbp),%eax
cmp    $0x27,%eax
jne    11eb <main+0xbb>
movl   $0x6,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    11f4 <main+0xc4>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    11f9 <main+0xc9>
jmp    11fe <main+0xce>
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
jne    121c <main+0xec>
movl   $0x3,-0x8(%rbp)
jmp    1254 <main+0x124>
movsbl -0x9(%rbp),%eax
cmp    $0x2a,%eax
jne    1235 <main+0x105>
movl   $0x4,-0x8(%rbp)
jmp    124f <main+0x11f>
movl   $0x1,-0x8(%rbp)
mov    $0x2f,%edi
call   1030 <putchar@plt>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1254 <main+0x124>
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    1276 <main+0x146>
movl   $0x1,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0x2a,%eax
jne    128f <main+0x15f>
movl   $0x5,-0x8(%rbp)
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0x2f,%eax
jne    12ad <main+0x17d>
movl   $0x1,-0x8(%rbp)
jmp    12b4 <main+0x184>
movl   $0x4,-0x8(%rbp)
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0x27,%eax
jne    12d2 <main+0x1a2>
movl   $0x1,-0x8(%rbp)
jmp    12eb <main+0x1bb>
movsbl -0x9(%rbp),%eax
cmp    $0x5c,%eax
jne    12e6 <main+0x1b6>
movl   $0x7,-0x8(%rbp)
jmp    12eb <main+0x1bb>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1382 <main+0x252>
movl   $0x6,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1382 <main+0x252>
movsbl -0x9(%rbp),%eax
cmp    $0x22,%eax
jne    1327 <main+0x1f7>
movl   $0x1,-0x8(%rbp)
jmp    1340 <main+0x210>
movsbl -0x9(%rbp),%eax
cmp    $0x5c,%eax
jne    133b <main+0x20b>
movl   $0x9,-0x8(%rbp)
jmp    1340 <main+0x210>
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1382 <main+0x252>
movl   $0x8,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1382 <main+0x252>
mov    -0x8(%rbp),%esi
lea    0xcb7(%rip),%rdi
movsbl -0x9(%rbp),%edx
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    138e <main+0x25e>
jmp    1146 <main+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9d(%rip),%r15
cmp    (%r15),%al
jne    1161 <main+0x31>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
mov    $0x1,%r12d
lea    0xe90(%rip),%r13
mov    $0x1,%r14d
xor    %ebp,%ebp
jmp    119e <main+0x6e>
xor    %r14d,%r14d
cmp    $0x2a,%bl
sete   %r14b
or     $0x4,%r14d
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r15),%al
je     1150 <main+0x20>
lea    -0x1(%r14),%eax
cmp    $0x8,%eax
ja     12ad <main+0x17d>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
cmp    $0x2f,%bl
je     128d <main+0x15d>
cmp    $0x27,%bl
je     1298 <main+0x168>
cmp    $0x22,%bl
jne    127a <main+0x14a>
mov    $0x22,%edi
jmp    1255 <main+0x125>
cmp    $0x2f,%bl
je     1265 <main+0x135>
cmp    $0x2a,%bl
jne    1270 <main+0x140>
mov    $0x4,%r14d
jmp    1190 <main+0x60>
mov    $0x3,%r14d
cmp    $0xa,%bl
jne    1190 <main+0x60>
mov    $0xa,%edi
jmp    127d <main+0x14d>
xor    %eax,%eax
cmp    $0x2f,%bl
setne  %al
lea    (%rax,%rax,2),%r14d
add    $0x1,%r14d
jmp    1190 <main+0x60>
xor    %r14d,%r14d
cmp    $0x5c,%bl
sete   %r14b
or     $0x6,%r14d
cmp    $0x27,%bl
jmp    1241 <main+0x111>
movsbl %bl,%edi
jmp    129d <main+0x16d>
xor    %r14d,%r14d
cmp    $0x5c,%bl
sete   %r14b
or     $0x8,%r14d
cmp    $0x22,%bl
cmove  %r12d,%r14d
movsbl %bl,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x60>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    $0x8,%r14d
jmp    1190 <main+0x60>
mov    $0x3,%r14d
jmp    1190 <main+0x60>
mov    $0x2f,%edi
call   1030 <putchar@plt>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    $0x1,%r14d
jmp    1190 <main+0x60>
mov    $0x2,%r14d
jmp    1190 <main+0x60>
mov    $0x27,%edi
call   1030 <putchar@plt>
mov    $0x6,%r14d
jmp    1190 <main+0x60>
movsbl %bl,%edx
lea    0xd6d(%rip),%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    $0x1,%ebp
jmp    1150 <main+0x20>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [43 x i8] c"Error, current state: %d, current char: %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %112, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %3
%6 = sext i8 %5 to i32
%7 = load i8, i8* @EOF
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %113
10: ; preds = %4
%11 = load i32, i32* %2
switch i32 %11, label %108 [
i32 1, label %12
i32 2, label %37
i32 3, label %53
i32 4, label %61
i32 5, label %67
i32 6, label %74
i32 7, label %88
i32 8, label %91
i32 9, label %105
]
12: ; preds = %10
%13 = load i8, i8* %3
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 47
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 2, i32* %2
br label %36
17: ; preds = %12
%18 = load i8, i8* %3
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 34
br i1 %20, label %21, label %24
21: ; preds = %17
store i32 8, i32* %2
%22 = load i8, i8* %3
%23 = call i32 @putchar(i8 signext %22)
br label %35
24: ; preds = %17
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 39
br i1 %27, label %28, label %31
28: ; preds = %24
store i32 6, i32* %2
%29 = load i8, i8* %3
%30 = call i32 @putchar(i8 signext %29)
br label %34
31: ; preds = %24
%32 = load i8, i8* %3
%33 = call i32 @putchar(i8 signext %32)
br label %34
34: ; preds = %31, %28
br label %35
35: ; preds = %34, %21
br label %36
36: ; preds = %35, %16
br label %112
37: ; preds = %10
%38 = load i8, i8* %3
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 47
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 3, i32* %2
br label %52
42: ; preds = %37
%43 = load i8, i8* %3
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 42
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 4, i32* %2
br label %51
47: ; preds = %42
store i32 1, i32* %2
%48 = call i32 @putchar(i8 signext 47)
%49 = load i8, i8* %3
%50 = call i32 @putchar(i8 signext %49)
br label %51
51: ; preds = %47, %46
br label %52
52: ; preds = %51, %41
br label %112
53: ; preds = %10
%54 = load i8, i8* %3
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 10
br i1 %56, label %57, label %60
57: ; preds = %53
store i32 1, i32* %2
%58 = load i8, i8* %3
%59 = call i32 @putchar(i8 signext %58)
br label %60
60: ; preds = %57, %53
br label %112
61: ; preds = %10
%62 = load i8, i8* %3
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 42
br i1 %64, label %65, label %66
65: ; preds = %61
store i32 5, i32* %2
br label %66
66: ; preds = %65, %61
br label %112
67: ; preds = %10
%68 = load i8, i8* %3
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 47
br i1 %70, label %71, label %72
71: ; preds = %67
store i32 1, i32* %2
br label %73
72: ; preds = %67
store i32 4, i32* %2
br label %73
73: ; preds = %72, %71
br label %112
74: ; preds = %10
%75 = load i8, i8* %3
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 39
br i1 %77, label %78, label %79
78: ; preds = %74
store i32 1, i32* %2
br label %85
79: ; preds = %74
%80 = load i8, i8* %3
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 92
br i1 %82, label %83, label %84
83: ; preds = %79
store i32 7, i32* %2
br label %84
84: ; preds = %83, %79
br label %85
85: ; preds = %84, %78
%86 = load i8, i8* %3
%87 = call i32 @putchar(i8 signext %86)
br label %112
88: ; preds = %10
store i32 6, i32* %2
%89 = load i8, i8* %3
%90 = call i32 @putchar(i8 signext %89)
br label %112
91: ; preds = %10
%92 = load i8, i8* %3
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 34
br i1 %94, label %95, label %96
95: ; preds = %91
store i32 1, i32* %2
br label %102
96: ; preds = %91
%97 = load i8, i8* %3
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 92
br i1 %99, label %100, label %101
100: ; preds = %96
store i32 9, i32* %2
br label %101
101: ; preds = %100, %96
br label %102
102: ; preds = %101, %95
%103 = load i8, i8* %3
%104 = call i32 @putchar(i8 signext %103)
br label %112
105: ; preds = %10
store i32 8, i32* %2
%106 = load i8, i8* %3
%107 = call i32 @putchar(i8 signext %106)
br label %112
108: ; preds = %10
%109 = load i32, i32* %2
%110 = load i8, i8* %3
%111 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %109, i8 signext %110)
store i32 1, i32* %1
br label %114
112: ; preds = %105, %102, %88, %85, %73, %66, %60, %52, %36
br label %4
113: ; preds = %4
store i32 0, i32* %1
br label %114
114: ; preds = %113, %108
%115 = load i32, i32* %1
ret i32 %115
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [43 x i8] c"Error, current state: %d, current char: %c\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %52, label %4
4: ; preds = %0, %47
%5 = phi i8 [ %49, %47 ], [ %1, %0 ]
%6 = phi i32 [ %48, %47 ], [ 1, %0 ]
switch i32 %6, label %45 [
i32 1, label %7
i32 2, label %14
i32 3, label %19
i32 4, label %23
i32 5, label %26
i32 6, label %29
i32 7, label %35
i32 8, label %37
i32 9, label %43
]
7: ; preds = %4
switch i8 %5, label %12 [
i8 47, label %47
i8 34, label %8
i8 39, label %10
]
8: ; preds = %7
%9 = tail call i32 @putchar(i8 signext 34)
br label %47
10: ; preds = %7
%11 = tail call i32 @putchar(i8 signext 39)
br label %47
12: ; preds = %7
%13 = tail call i32 @putchar(i8 signext %5)
br label %47
14: ; preds = %4
switch i8 %5, label %16 [
i8 47, label %47
i8 42, label %15
]
15: ; preds = %14
br label %47
16: ; preds = %14
%17 = tail call i32 @putchar(i8 signext 47)
%18 = tail call i32 @putchar(i8 signext %5)
br label %47
19: ; preds = %4
%20 = icmp eq i8 %5, 10
br i1 %20, label %21, label %47
21: ; preds = %19
%22 = tail call i32 @putchar(i8 signext 10)
br label %47
23: ; preds = %4
%24 = icmp eq i8 %5, 42
%25 = select i1 %24, i32 5, i32 4
br label %47
26: ; preds = %4
%27 = icmp eq i8 %5, 47
%28 = select i1 %27, i32 1, i32 4
br label %47
29: ; preds = %4
%30 = icmp eq i8 %5, 92
%31 = select i1 %30, i32 7, i32 6
%32 = icmp eq i8 %5, 39
%33 = select i1 %32, i32 1, i32 %31
%34 = tail call i32 @putchar(i8 signext %5)
br label %47
35: ; preds = %4
%36 = tail call i32 @putchar(i8 signext %5)
br label %47
37: ; preds = %4
%38 = icmp eq i8 %5, 92
%39 = select i1 %38, i32 9, i32 8
%40 = icmp eq i8 %5, 34
%41 = select i1 %40, i32 1, i32 %39
%42 = tail call i32 @putchar(i8 signext %5)
br label %47
43: ; preds = %4
%44 = tail call i32 @putchar(i8 signext %5)
br label %47
45: ; preds = %4
%46 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %6, i8 signext %5)
br label %52
47: ; preds = %23, %26, %14, %7, %19, %21, %16, %15, %10, %12, %8, %43, %37, %35, %29
%48 = phi i32 [ 8, %43 ], [ %41, %37 ], [ 6, %35 ], [ %33, %29 ], [ 1, %21 ], [ 3, %19 ], [ 4, %15 ], [ 1, %16 ], [ 8, %8 ], [ 6, %10 ], [ 1, %12 ], [ 2, %7 ], [ 3, %14 ], [ %25, %23 ], [ %28, %26 ]
%49 = tail call signext i8 (...) @getchar()
%50 = load i8, i8* @EOF
%51 = icmp eq i8 %49, %50
br i1 %51, label %52, label %4
52: ; preds = %47, %0, %45
%53 = phi i32 [ 1, %45 ], [ 0, %0 ], [ 0, %47 ]
ret i32 %53
}