#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 */
size_t strlen(char *);
char *trim_quote(char *s) {
  char *start, *end;
  size_t len;
  len = strlen(s);
  start = s;
  end = s + len - 1;
  while ((*start) && ((*start) == '\'' || (*start) == '"'))
    start++;
  while (end >= start && ((*end) == '\'' || (*end) == '"'))
    (*(end--)) = '\0';
  return start;
}


x86 assembly (clang, -O0):
<trim_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1181 <trim_quote+0x71>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x27,%ecx
mov    %al,-0x22(%rbp)
je     117b <trim_quote+0x6b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1191 <trim_quote+0x81>
jmp    11a2 <trim_quote+0x92>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1141 <trim_quote+0x31>
jmp    11a7 <trim_quote+0x97>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x23(%rbp)
jb     11e5 <trim_quote+0xd5>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x27,%ecx
mov    %al,-0x24(%rbp)
je     11df <trim_quote+0xcf>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x24(%rbp)
mov    -0x24(%rbp),%al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    11f5 <trim_quote+0xe5>
jmp    120c <trim_quote+0xfc>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    11a7 <trim_quote+0x97>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_quote>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    %rbx,%rax
jmp    1134 <trim_quote+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%edx
cmp    $0x22,%dl
je     1130 <trim_quote+0x20>
cmp    $0x27,%dl
je     1130 <trim_quote+0x20>
add    %rbx,%rcx
add    $0xffffffffffffffff,%rcx
jmp    1157 <trim_quote+0x47>
nopw   0x0(%rax,%rax,1)
movb   $0x0,(%rcx)
add    $0xffffffffffffffff,%rcx
cmp    %rax,%rcx
jb     1169 <trim_quote+0x59>
movzbl (%rcx),%edx
cmp    $0x27,%dl
je     1150 <trim_quote+0x40>
cmp    $0x22,%dl
je     1150 <trim_quote+0x40>
pop    %rbx
ret

LLVM IR (-O0):
define i8* @trim_quote(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %5
%8 = load i8*, i8** %2
store i8* %8, i8** %3
%9 = load i8*, i8** %2
%10 = load i64, i64* %5
%11 = getelementptr inbounds i8, i8* %9, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -1
store i8* %12, i8** %4
br label %13
13: ; preds = %32, %1
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 39
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 34
br label %28
28: ; preds = %23, %18
%29 = phi i1 [ true, %18 ], [ %27, %23 ]
br label %30
30: ; preds = %28, %13
%31 = phi i1 [ false, %13 ], [ %29, %28 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %13
35: ; preds = %30
br label %36
36: ; preds = %54, %35
%37 = load i8*, i8** %4
%38 = load i8*, i8** %3
%39 = icmp uge i8* %37, %38
br i1 %39, label %40, label %52
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 39
br i1 %44, label %50, label %45
45: ; preds = %40
%46 = load i8*, i8** %4
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 34
br label %50
50: ; preds = %45, %40
%51 = phi i1 [ true, %40 ], [ %49, %45 ]
br label %52
52: ; preds = %50, %36
%53 = phi i1 [ false, %36 ], [ %51, %50 ]
br i1 %53, label %54, label %57
54: ; preds = %52
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i32 -1
store i8* %56, i8** %4
store i8 0, i8* %55
br label %36
57: ; preds = %52
%58 = load i8*, i8** %3
ret i8* %58
}

LLVM IR (-O2):
define i8* @trim_quote(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
br label %3
3: ; preds = %10, %1
%4 = phi i8* [ %0, %1 ], [ %11, %10 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 34, label %10
i8 39, label %10
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %0, i64 %2
%8 = getelementptr inbounds i8, i8* %7, i64 -1
%9 = icmp ult i8* %8, %4
br i1 %9, label %18, label %12
10: ; preds = %3, %3
%11 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
12: ; preds = %6, %15
%13 = phi i8* [ %16, %15 ], [ %8, %6 ]
%14 = load i8, i8* %13
switch i8 %14, label %18 [
i8 39, label %15
i8 34, label %15
]
15: ; preds = %12, %12
store i8 0, i8* %13
%16 = getelementptr inbounds i8, i8* %13, i64 -1
%17 = icmp ult i8* %16, %4
br i1 %17, label %18, label %12
18: ; preds = %15, %12, %6
ret i8* %4
}