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

/* Variables and functions */
int /*<<< orphan*/ ce_utf8_strlen_between(char const *, char const *);
char *strchr(char const *, char const);
int64_t match_python_string(const char *str) {
  if (*str == '\'' || *str == '"') {
    const char *match = str;
    while (match) {
      match = strchr(match + 1, *str);
      if (match && *(match - 1) != '\\') {
        return ce_utf8_strlen_between(str, match);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_python_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     114c <match_python_string+0x2c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11b2 <match_python_string+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ad <match_python_string+0x8d>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a8 <match_python_string+0x88>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
je     11a8 <match_python_string+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ce_utf8_strlen_between@plt>
mov    %eax,-0x4(%rbp)
jmp    11b9 <match_python_string+0x99>
jmp    1154 <match_python_string+0x34>
jmp    11b2 <match_python_string+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_python_string>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x27,%al
je     1130 <match_python_string+0x10>
cmp    $0x22,%al
jne    116a <match_python_string+0x4a>
movsbl %al,%ebp
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rax
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116a <match_python_string+0x4a>
cmpb   $0x5c,-0x1(%rax)
je     1140 <match_python_string+0x20>
mov    %rbx,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ce_utf8_strlen_between@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @match_python_string(i8* %0) {
%2 = load i8, i8* %0
switch i8 %2, label %15 [
i8 39, label %3
i8 34, label %3
]
3: ; preds = %1, %1
br label %4
4: ; preds = %3, %9
%5 = phi i8* [ %7, %9 ], [ %0, %3 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = tail call i8* @strchr(i8* %6, i8 signext %2)
%8 = icmp eq i8* %7, null
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %7, i64 -1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 92
br i1 %12, label %4, label %13
13: ; preds = %9
%14 = tail call i32 @ce_utf8_strlen_between(i8* %0, i8* %7)
br label %15
15: ; preds = %4, %1, %13
%16 = phi i32 [ %14, %13 ], [ 0, %1 ], [ 0, %4 ]
ret i32 %16
}