int change_state(int cur_char, int last_char) {
  extern int state;
  if (state == 0) {
    if (cur_char == '"') {
      state = 2;
    } else if (cur_char == '\'') {
      state = 1;
    } else if (last_char == '#' && cur_char == 'd') {
      state = 3;
    } else if (last_char == '/' && cur_char == '*') {
      state = 4;
    } else {
      state = 0;
    }
  } else if (state == 1) {
    if (cur_char == '\'') {
      state = 0;
    } else {
      state = 1;
    }
  } else if (state == 2) {
    if (cur_char == '"') {
      state = 0;
    } else {
      state = 2;
    }
  } else if (state == 3) {
    if (cur_char == '\n') {
      state = 0;
    } else {
      state = 3;
    }
  } else if (state == 4) {
    if (last_char == '*' && cur_char == '/') {
      state = 0;
    } else {
      state = 4;
    }
  } else {
  }
  return state;
}


x86 assembly (clang, -O0):
<change_state>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2ecf(%rip),%rax
cmpl   $0x0,(%rax)
jne    11bf <change_state+0xbf>
cmpl   $0x22,-0x4(%rbp)
jne    1136 <change_state+0x36>
mov    0x2eb5(%rip),%rax
movl   $0x2,(%rax)
jmp    11ba <change_state+0xba>
cmpl   $0x27,-0x4(%rbp)
jne    1152 <change_state+0x52>
mov    0x2e99(%rip),%rax
movl   $0x1,(%rax)
jmp    11b5 <change_state+0xb5>
cmpl   $0x23,-0x8(%rbp)
jne    1178 <change_state+0x78>
cmpl   $0x64,-0x4(%rbp)
jne    1178 <change_state+0x78>
mov    0x2e73(%rip),%rax
movl   $0x3,(%rax)
jmp    11b0 <change_state+0xb0>
cmpl   $0x2f,-0x8(%rbp)
jne    119e <change_state+0x9e>
cmpl   $0x2a,-0x4(%rbp)
jne    119e <change_state+0x9e>
mov    0x2e4d(%rip),%rax
movl   $0x4,(%rax)
jmp    11ab <change_state+0xab>
mov    0x2e3b(%rip),%rax
movl   $0x0,(%rax)
jmp    11b0 <change_state+0xb0>
jmp    11b5 <change_state+0xb5>
jmp    11ba <change_state+0xba>
jmp    12da <change_state+0x1da>
mov    0x2e1a(%rip),%rax
cmpl   $0x1,(%rax)
jne    11fd <change_state+0xfd>
cmpl   $0x27,-0x4(%rbp)
jne    11eb <change_state+0xeb>
mov    0x2e00(%rip),%rax
movl   $0x0,(%rax)
jmp    11f8 <change_state+0xf8>
mov    0x2dee(%rip),%rax
movl   $0x1,(%rax)
jmp    12d5 <change_state+0x1d5>
mov    0x2ddc(%rip),%rax
cmpl   $0x2,(%rax)
jne    123b <change_state+0x13b>
cmpl   $0x22,-0x4(%rbp)
jne    1229 <change_state+0x129>
mov    0x2dc2(%rip),%rax
movl   $0x0,(%rax)
jmp    1236 <change_state+0x136>
mov    0x2db0(%rip),%rax
movl   $0x2,(%rax)
jmp    12d0 <change_state+0x1d0>
mov    0x2d9e(%rip),%rax
cmpl   $0x3,(%rax)
jne    1279 <change_state+0x179>
cmpl   $0xa,-0x4(%rbp)
jne    1267 <change_state+0x167>
mov    0x2d84(%rip),%rax
movl   $0x0,(%rax)
jmp    1274 <change_state+0x174>
mov    0x2d72(%rip),%rax
movl   $0x3,(%rax)
jmp    12cb <change_state+0x1cb>
mov    0x2d60(%rip),%rax
cmpl   $0x4,(%rax)
jne    12c1 <change_state+0x1c1>
cmpl   $0x2a,-0x8(%rbp)
jne    12af <change_state+0x1af>
cmpl   $0x2f,-0x4(%rbp)
jne    12af <change_state+0x1af>
mov    0x2d3c(%rip),%rax
movl   $0x0,(%rax)
jmp    12bc <change_state+0x1bc>
mov    0x2d2a(%rip),%rax
movl   $0x4,(%rax)
jmp    12c6 <change_state+0x1c6>
jmp    12c6 <change_state+0x1c6>
jmp    12cb <change_state+0x1cb>
jmp    12d0 <change_state+0x1d0>
jmp    12d5 <change_state+0x1d5>
jmp    12da <change_state+0x1da>
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_state>:
mov    0x2ed9(%rip),%rcx
mov    (%rcx),%eax
cmp    $0x4,%rax
ja     117d <change_state+0x7d>
lea    0xeea(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
cmp    $0x22,%edi
je     1165 <change_state+0x65>
cmp    $0x27,%edi
jne    116c <change_state+0x6c>
mov    $0x1,%eax
jmp    117b <change_state+0x7b>
xor    %eax,%eax
cmp    $0x27,%edi
setne  %al
jmp    117b <change_state+0x7b>
xor    %eax,%eax
cmp    $0x22,%edi
setne  %al
add    %eax,%eax
jmp    117b <change_state+0x7b>
xor    %eax,%eax
cmp    $0xa,%edi
setne  %al
lea    (%rax,%rax,2),%eax
jmp    117b <change_state+0x7b>
xor    $0x2a,%esi
xor    $0x2f,%edi
xor    %eax,%eax
or     %esi,%edi
setne  %al
shl    $0x2,%eax
jmp    117b <change_state+0x7b>
mov    $0x2,%eax
jmp    117b <change_state+0x7b>
cmp    $0x64,%edi
jne    117e <change_state+0x7e>
mov    $0x3,%eax
cmp    $0x23,%esi
jne    117e <change_state+0x7e>
mov    %eax,(%rcx)
ret
xor    $0x2f,%esi
xor    $0x2a,%edi
xor    %eax,%eax
or     %esi,%edi
sete   %al
jmp    1160 <change_state+0x60>

LLVM IR (-O0):
@state = external global i32
define i32 @change_state(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* @state
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %2
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 34
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* @state
br label %33
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 39
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 1, i32* @state
br label %32
15: ; preds = %11
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 35
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 100
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 3, i32* @state
br label %31
22: ; preds = %18, %15
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 47
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 42
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 4, i32* @state
br label %30
29: ; preds = %25, %22
store i32 0, i32* @state
br label %30
30: ; preds = %29, %28
br label %31
31: ; preds = %30, %21
br label %32
32: ; preds = %31, %14
br label %33
33: ; preds = %32, %10
br label %78
34: ; preds = %2
%35 = load i32, i32* @state
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 39
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 0, i32* @state
br label %42
41: ; preds = %37
store i32 1, i32* @state
br label %42
42: ; preds = %41, %40
br label %77
43: ; preds = %34
%44 = load i32, i32* @state
%45 = icmp eq i32 %44, 2
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 34
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* @state
br label %51
50: ; preds = %46
store i32 2, i32* @state
br label %51
51: ; preds = %50, %49
br label %76
52: ; preds = %43
%53 = load i32, i32* @state
%54 = icmp eq i32 %53, 3
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = load i32, i32* %3
%57 = icmp eq i32 %56, 10
br i1 %57, label %58, label %59
58: ; preds = %55
store i32 0, i32* @state
br label %60
59: ; preds = %55
store i32 3, i32* @state
br label %60
60: ; preds = %59, %58
br label %75
61: ; preds = %52
%62 = load i32, i32* @state
%63 = icmp eq i32 %62, 4
br i1 %63, label %64, label %73
64: ; preds = %61
%65 = load i32, i32* %4
%66 = icmp eq i32 %65, 42
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i32, i32* %3
%69 = icmp eq i32 %68, 47
br i1 %69, label %70, label %71
70: ; preds = %67
store i32 0, i32* @state
br label %72
71: ; preds = %67, %64
store i32 4, i32* @state
br label %72
72: ; preds = %71, %70
br label %74
73: ; preds = %61
br label %74
74: ; preds = %73, %72
br label %75
75: ; preds = %74, %60
br label %76
76: ; preds = %75, %51
br label %77
77: ; preds = %76, %42
br label %78
78: ; preds = %77, %33
%79 = load i32, i32* @state
ret i32 %79
}

LLVM IR (-O2):
@state = external global i32
define i32 @change_state(i32 %0, i32 %1) {
%3 = load i32, i32* @state
switch i32 %3, label %31 [
i32 0, label %4
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %24
]
4: ; preds = %2
switch i32 %0, label %6 [
i32 34, label %29
i32 39, label %5
]
5: ; preds = %4
br label %29
6: ; preds = %4
%7 = icmp eq i32 %1, 35
%8 = icmp eq i32 %0, 100
%9 = and i1 %8, %7
br i1 %9, label %29, label %10
10: ; preds = %6
%11 = icmp eq i32 %1, 47
%12 = icmp eq i32 %0, 42
%13 = and i1 %12, %11
%14 = select i1 %13, i32 4, i32 0
br label %29
15: ; preds = %2
%16 = icmp ne i32 %0, 39
%17 = zext i1 %16 to i32
br label %29
18: ; preds = %2
%19 = icmp eq i32 %0, 34
%20 = select i1 %19, i32 0, i32 2
br label %29
21: ; preds = %2
%22 = icmp eq i32 %0, 10
%23 = select i1 %22, i32 0, i32 3
br label %29
24: ; preds = %2
%25 = icmp eq i32 %1, 42
%26 = icmp eq i32 %0, 47
%27 = and i1 %26, %25
%28 = select i1 %27, i32 0, i32 4
br label %29
29: ; preds = %24, %21, %18, %15, %10, %6, %4, %5
%30 = phi i32 [ 1, %5 ], [ 2, %4 ], [ 3, %6 ], [ %14, %10 ], [ %17, %15 ], [ %20, %18 ], [ %23, %21 ], [ %28, %24 ]
store i32 %30, i32* @state
br label %31
31: ; preds = %29, %2
%32 = phi i32 [ %3, %2 ], [ %30, %29 ]
ret i32 %32
}