#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 *strpbrk(char *, char *);
char *end_quote(char *s) {
  char qc;
  char *q;
  qc = *s;
  while (1) {
    q = strpbrk(s + 1, "\"\'");
    if (!q)
      return 0;
    if ((*q == qc) && (*(q - 1) != '\\'))
      return q;
    s = q;
  }
}


x86 assembly (clang, -O0):
<end_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    0xecc(%rip),%rsi
call   1030 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1155 <end_quote+0x45>
movq   $0x0,-0x8(%rbp)
jmp    1193 <end_quote+0x83>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1186 <end_quote+0x76>
mov    -0x20(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x5c,%eax
je     1186 <end_quote+0x76>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1193 <end_quote+0x83>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1125 <end_quote+0x15>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<end_quote>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%bl
add    $0x1,%rdi
lea    0xedf(%rip),%rsi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     1160 <end_quote+0x50>
lea    0xece(%rip),%r14
jmp    1154 <end_quote+0x44>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rax
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strpbrk@plt>
test   %rax,%rax
je     1160 <end_quote+0x50>
cmp    %bl,(%rax)
jne    1140 <end_quote+0x30>
cmpb   $0x5c,-0x1(%rax)
je     1140 <end_quote+0x30>
jmp    1162 <end_quote+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\22'\00"
define i8* @end_quote(i8* %0) {
%2 = load i8, i8* %0
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = tail call i8* @strpbrk(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %1, %14
%7 = phi i8* [ %16, %14 ], [ %4, %1 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, %2
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 -1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 92
br i1 %13, label %14, label %18
14: ; preds = %10, %6
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = tail call i8* @strpbrk(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %6
18: ; preds = %14, %10, %1
%19 = phi i8* [ null, %1 ], [ %7, %10 ], [ null, %14 ]
ret i8* %19
}