#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 */
typedef int int64_t;

/* Variables and functions */
int64_t match_c_character_literal(const char *str) {
  if (*str == '\'') {
    switch (str[1]) {
    case 0:
      return 0;
    case '\'':
      return 2;
    case '\\':
      if (!str[2])
        return 0;
      if (str[3] == '\'')
        return 4;
    default:
      if (str[2] == '\'')
        return 3;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_c_character_literal>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    11cd <match_c_character_literal+0xcd>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1152 <match_c_character_literal+0x52>
jmp    1130 <match_c_character_literal+0x30>
mov    -0x14(%rbp),%eax
sub    $0x27,%eax
je     115e <match_c_character_literal+0x5e>
jmp    1141 <match_c_character_literal+0x41>
mov    -0x14(%rbp),%eax
sub    $0x5c,%eax
je     116a <match_c_character_literal+0x6a>
jmp    11a6 <match_c_character_literal+0xa6>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <match_c_character_literal+0xd4>
movl   $0x2,-0x4(%rbp)
jmp    11d4 <match_c_character_literal+0xd4>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x2(%rax)
jne    1184 <match_c_character_literal+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <match_c_character_literal+0xd4>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x27,%eax
jne    11a1 <match_c_character_literal+0xa1>
movl   $0x4,-0x4(%rbp)
jmp    11d4 <match_c_character_literal+0xd4>
jmp    11a6 <match_c_character_literal+0xa6>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x27,%eax
jne    11c3 <match_c_character_literal+0xc3>
movl   $0x3,-0x4(%rbp)
jmp    11d4 <match_c_character_literal+0xd4>
jmp    11c8 <match_c_character_literal+0xc8>
jmp    11cd <match_c_character_literal+0xcd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_c_character_literal>:
cmpb   $0x27,(%rdi)
jne    113d <match_c_character_literal+0x3d>
movsbl 0x1(%rdi),%eax
test   %eax,%eax
je     1129 <match_c_character_literal+0x29>
cmp    $0x27,%eax
je     112a <match_c_character_literal+0x2a>
cmp    $0x5c,%eax
jne    1130 <match_c_character_literal+0x30>
mov    0x2(%rdi),%cl
test   %cl,%cl
je     113d <match_c_character_literal+0x3d>
mov    $0x4,%eax
cmpb   $0x27,0x3(%rdi)
jne    1133 <match_c_character_literal+0x33>
ret
mov    $0x2,%eax
ret
mov    0x2(%rdi),%cl
mov    $0x3,%eax
cmp    $0x27,%cl
je     1129 <match_c_character_literal+0x29>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @match_c_character_literal(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 39
br i1 %7, label %8, label %38
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %29 [
i32 0, label %13
i32 39, label %14
i32 92, label %15
]
13: ; preds = %8
store i32 0, i32* %2
br label %39
14: ; preds = %8
store i32 2, i32* %2
br label %39
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %15
store i32 0, i32* %2
br label %39
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 39
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 4, i32* %2
br label %39
28: ; preds = %21
br label %29
29: ; preds = %8, %28
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 39
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 3, i32* %2
br label %39
36: ; preds = %29
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37, %1
store i32 0, i32* %2
br label %39
39: ; preds = %38, %35, %27, %20, %14, %13
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
define i32 @match_c_character_literal(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 39
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %8 [
i32 0, label %24
i32 39, label %11
i32 92, label %12
]
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
br label %20
11: ; preds = %4
br label %24
12: ; preds = %4
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 39
br i1 %19, label %24, label %20
20: ; preds = %8, %16
%21 = phi i8 [ %10, %8 ], [ %14, %16 ]
%22 = icmp eq i8 %21, 39
br i1 %22, label %24, label %23
23: ; preds = %20, %1
br label %24
24: ; preds = %20, %16, %12, %4, %23, %11
%25 = phi i32 [ 0, %23 ], [ 2, %11 ], [ %7, %4 ], [ 0, %12 ], [ 4, %16 ], [ 3, %20 ]
ret i32 %25
}