int inside_escapesequence(char c) {
  static int inside;
  if (!inside && c != '\33')
    return 0;
  if (inside) {
    if (c == 'm' || c == 'z') {
      int len = inside + 1;
      inside = 0;
      return len;
    }
    inside++;
    return -1;
  } else {
    inside = 1;
    return -1;
  }
}


x86 assembly (clang, -O0):
<inside_escapesequence>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
cmpl   $0x0,0x2f13(%rip)
jne    1130 <inside_escapesequence+0x30>
movsbl -0x5(%rbp),%eax
cmp    $0x1b,%eax
je     1130 <inside_escapesequence+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11a4 <inside_escapesequence+0xa4>
cmpl   $0x0,0x2eed(%rip)
je     1193 <inside_escapesequence+0x93>
movsbl -0x5(%rbp),%eax
cmp    $0x6d,%eax
je     1157 <inside_escapesequence+0x57>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
jne    1178 <inside_escapesequence+0x78>
mov    0x2ec7(%rip),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,0x2eb7(%rip)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <inside_escapesequence+0xa4>
mov    0x2ea6(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e9d(%rip)
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <inside_escapesequence+0xa4>
movl   $0x1,0x2e87(%rip)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<inside_escapesequence>:
mov    0x2f1e(%rip),%ecx
cmp    $0x1b,%dil
je     1113 <inside_escapesequence+0x13>
xor    %eax,%eax
test   %ecx,%ecx
jne    1113 <inside_escapesequence+0x13>
ret
mov    $0xffffffff,%eax
test   %ecx,%ecx
je     1136 <inside_escapesequence+0x36>
cmp    $0x7a,%dil
je     1128 <inside_escapesequence+0x28>
cmp    $0x6d,%dil
jne    1142 <inside_escapesequence+0x42>
add    $0x1,%ecx
xor    %edx,%edx
mov    %ecx,%eax
mov    %edx,0x2eef(%rip)
ret
mov    $0x1,%edx
mov    %edx,0x2ee3(%rip)
ret
add    $0x1,%ecx
mov    %ecx,%edx
mov    %edx,0x2ed7(%rip)
ret

LLVM IR (-O0):
@inside_escapesequence.inside = internal global i32 0
define i32 @inside_escapesequence(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
%5 = load i32, i32* @inside_escapesequence.inside
%6 = icmp ne i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 27
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %2
br label %31
12: ; preds = %7, %1
%13 = load i32, i32* @inside_escapesequence.inside
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %30
15: ; preds = %12
%16 = load i8, i8* %3
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 109
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 122
br i1 %22, label %23, label %27
23: ; preds = %19, %15
%24 = load i32, i32* @inside_escapesequence.inside
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
store i32 0, i32* @inside_escapesequence.inside
%26 = load i32, i32* %4
store i32 %26, i32* %2
br label %31
27: ; preds = %19
%28 = load i32, i32* @inside_escapesequence.inside
%29 = add nsw i32 %28, 1
store i32 %29, i32* @inside_escapesequence.inside
store i32 -1, i32* %2
br label %31
30: ; preds = %12
store i32 1, i32* @inside_escapesequence.inside
store i32 -1, i32* %2
br label %31
31: ; preds = %30, %27, %23, %11
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@inside_escapesequence.inside = internal unnamed_addr global i32 0
define i32 @inside_escapesequence(i8 signext %0) {
%2 = load i32, i32* @inside_escapesequence.inside
%3 = icmp eq i32 %2, 0
%4 = icmp ne i8 %0, 27
%5 = and i1 %4, %3
br i1 %5, label %15, label %6
6: ; preds = %1
br i1 %3, label %12, label %7
7: ; preds = %6
switch i8 %0, label %10 [
i8 122, label %8
i8 109, label %8
]
8: ; preds = %7, %7
%9 = add nsw i32 %2, 1
br label %12
10: ; preds = %7
%11 = add nsw i32 %2, 1
br label %12
12: ; preds = %6, %8, %10
%13 = phi i32 [ %11, %10 ], [ 0, %8 ], [ 1, %6 ]
%14 = phi i32 [ -1, %10 ], [ %9, %8 ], [ -1, %6 ]
store i32 %13, i32* @inside_escapesequence.inside
br label %15
15: ; preds = %12, %1
%16 = phi i32 [ 0, %1 ], [ %14, %12 ]
ret i32 %16
}