#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 *strchr(char const *, char);
bool quoted_text(const char *s, char quote_char, const char **rest) {
  if (*s == quote_char) {
    const char *end_quote = strchr(s + 1, quote_char);
    if (end_quote) {
      if (rest)
        *rest = end_quote + 1;
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<quoted_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1184 <quoted_text+0x74>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
movsbl -0x11(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117f <quoted_text+0x6f>
cmpq   $0x0,-0x20(%rbp)
je     1173 <quoted_text+0x63>
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    118b <quoted_text+0x7b>
jmp    1184 <quoted_text+0x74>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quoted_text>:
push   %rbx
cmp    %sil,(%rdi)
jne    1141 <quoted_text+0x31>
mov    %rdx,%rbx
add    $0x1,%rdi
movsbl %sil,%esi
call   1030 <strchr@plt>
test   %rbx,%rbx
je     1137 <quoted_text+0x27>
test   %rax,%rax
je     1137 <quoted_text+0x27>
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
mov    $0x1,%ecx
test   %rax,%rax
jne    1143 <quoted_text+0x33>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

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

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