#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 /*<<< orphan*/ memmove(char *, char *, int);
int strlen(char *);
void clean_quotes(char *s) {
  int c, len;
  c = s[0];
  if (c != '\"' && c != '\'')
    return;
  len = strlen(s);
  memmove(s, &s[1], len);
  len--;
  if (s[len - 1] == c)
    s[len - 1] = '\0';
}


x86 assembly (clang, -O0):
<clean_quotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x22,-0xc(%rbp)
je     114f <clean_quotes+0x2f>
cmpl   $0x27,-0xc(%rbp)
je     114f <clean_quotes+0x2f>
jmp    11a3 <clean_quotes+0x83>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    -0x10(%rbp),%edx
call   1040 <memmove@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    -0xc(%rbp),%eax
jne    11a3 <clean_quotes+0x83>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_quotes>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%r14b
cmp    $0x27,%r14b
je     1136 <clean_quotes+0x16>
cmp    $0x22,%r14b
jne    115d <clean_quotes+0x3d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbx),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1040 <memmove@plt>
movslq %ebp,%rax
cmp    %r14b,-0x2(%rax,%rbx,1)
jne    115d <clean_quotes+0x3d>
movb   $0x0,-0x2(%rbx,%rax,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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