#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 *trimquotes(char *str) {
  while (*str == '"')
    str++;
  if (*str == 0)
    return str;
  char *end = str + strlen(str) - 1;
  while (end > str && (*end == '"'))
    end--;
  *(end + 1) = 0;
  return str;
}


x86 assembly (clang, -O0):
<trimquotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    113d <trimquotes+0x2d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    111c <trimquotes+0xc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115a <trimquotes+0x4a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d3 <trimquotes+0xc3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%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    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jbe    11a2 <trimquotes+0x92>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11b2 <trimquotes+0xa2>
jmp    11c3 <trimquotes+0xb3>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    117f <trimquotes+0x6f>
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimquotes>:
push   %rbx
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%eax
cmp    $0x22,%al
jne    112d <trimquotes+0x1d>
add    $0x1,%rbx
jmp    1120 <trimquotes+0x10>
test   %al,%al
je     115a <trimquotes+0x4a>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
lea    -0x1(%rbx),%rdx
nop
mov    %rdx,%rcx
lea    (%rdx,%rax,1),%rsi
cmp    %rbx,%rsi
jbe    1155 <trimquotes+0x45>
lea    -0x1(%rcx),%rdx
cmpb   $0x22,(%rsi)
je     1140 <trimquotes+0x30>
movb   $0x0,0x1(%rcx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

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

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