#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 */
int strlen(char *);
char *string_trim_quotes(char *s) {
  char *front, *back;
  front = s;
  back = s + strlen(s) - 1;
  while (*front == '\'' || *front == '"') {
    if (*back != *front)
      break;
    *back = 0;
    back--;
    front++;
  }
  return front;
}


x86 assembly (clang, -O0):
<string_trim_quotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x27,%ecx
mov    %al,-0x21(%rbp)
je     116e <string_trim_quotes+0x5e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117e <string_trim_quotes+0x6e>
jmp    11bd <string_trim_quotes+0xad>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1199 <string_trim_quotes+0x89>
jmp    11bd <string_trim_quotes+0xad>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1149 <string_trim_quotes+0x39>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_trim_quotes>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%ecx
cmp    $0x27,%cl
je     113d <string_trim_quotes+0x2d>
cmp    $0x22,%cl
jne    114e <string_trim_quotes+0x3e>
cmp    %cl,(%rax)
jne    114e <string_trim_quotes+0x3e>
movb   $0x0,(%rax)
add    $0x1,%rbx
add    $0xffffffffffffffff,%rax
jmp    1130 <string_trim_quotes+0x20>
mov    %rbx,%rax
pop    %rbx
ret

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

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