#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 *calloc(int, int);
int /*<<< orphan*/ free(char *);
char *makename(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
const char *remove_quotes_pair(const char *text) {
  static char single_quote = '\'';
  static char double_quote = '\"';
  char quote = 0;
  const char *p = text;
  int len = strlen(text);
  if (len < 2) {
    return p;
  }
  if (p[0] == single_quote) {
    quote = single_quote;
  } else {
    if (p[0] == double_quote) {
      quote = double_quote;
    } else {
      return p;
    }
  }
  {
    if (p[len - 1] == quote) {
      char *altered = calloc(1, len + 1);
      const char *str2 = 0;
      strcpy(altered, p + 1);
      altered[len - 2] = '\0';
      str2 = makename(altered);
      free(altered);
      return str2;
    }
  }
  return p;
}


x86 assembly (clang, -O0):
<remove_quotes_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    118b <remove_quotes_pair+0x3b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <remove_quotes_pair+0x11b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
movsbl 0x2eaf(%rip),%ecx
cmp    %ecx,%eax
jne    11af <remove_quotes_pair+0x5f>
mov    0x2ea1(%rip),%al
mov    %al,-0x11(%rbp)
jmp    11e5 <remove_quotes_pair+0x95>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
movsbl 0x2e8c(%rip),%ecx
cmp    %ecx,%eax
jne    11d3 <remove_quotes_pair+0x83>
mov    0x2e7e(%rip),%al
mov    %al,-0x11(%rbp)
jmp    11e0 <remove_quotes_pair+0x90>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <remove_quotes_pair+0x11b>
jmp    11e5 <remove_quotes_pair+0x95>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1263 <remove_quotes_pair+0x113>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
call   1050 <makename@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <remove_quotes_pair+0x11b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_quotes_pair>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1060 <strlen@plt>
cmp    $0x2,%eax
jl     11c3 <remove_quotes_pair+0x73>
mov    %eax,%r14d
mov    (%rbx),%al
cmp    $0x27,%al
je     1176 <remove_quotes_pair+0x26>
cmp    $0x22,%al
jne    11c3 <remove_quotes_pair+0x73>
mov    $0x22,%eax
jmp    117b <remove_quotes_pair+0x2b>
mov    $0x27,%eax
lea    -0x1(%r14),%ecx
movsbl (%rbx,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11c3 <remove_quotes_pair+0x73>
lea    0x1(%r14),%esi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,%r15
add    $0x1,%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
add    $0xfffffffe,%r14d
movb   $0x0,(%r15,%r14,1)
mov    %r15,%rdi
call   1050 <makename@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@remove_quotes_pair.single_quote = internal global i8 39
@remove_quotes_pair.double_quote = internal global i8 34
define i8* @remove_quotes_pair(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i8 0, i8* %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = load i8*, i8** %5
store i8* %15, i8** %2
br label %70
16: ; preds = %1
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8, i8* @remove_quotes_pair.single_quote
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = load i8, i8* @remove_quotes_pair.single_quote
store i8 %25, i8* %4
br label %39
26: ; preds = %16
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8, i8* @remove_quotes_pair.double_quote
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %30, %32
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = load i8, i8* @remove_quotes_pair.double_quote
store i8 %35, i8* %4
br label %38
36: ; preds = %26
%37 = load i8*, i8** %5
store i8* %37, i8** %2
br label %70
38: ; preds = %34
br label %39
39: ; preds = %38, %24
%40 = load i8*, i8** %5
%41 = load i32, i32* %6
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %46, %48
br i1 %49, label %50, label %68
50: ; preds = %39
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
%53 = call i8* @calloc(i32 1, i32 %52)
store i8* %53, i8** %7
store i8* null, i8** %8
%54 = load i8*, i8** %7
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i64 1
%57 = call i32 @strcpy(i8* %54, i8* %56)
%58 = load i8*, i8** %7
%59 = load i32, i32* %6
%60 = sub nsw i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
store i8 0, i8* %62
%63 = load i8*, i8** %7
%64 = call i8* @makename(i8* %63)
store i8* %64, i8** %8
%65 = load i8*, i8** %7
%66 = call i32 @free(i8* %65)
%67 = load i8*, i8** %8
store i8* %67, i8** %2
br label %70
68: ; preds = %39
%69 = load i8*, i8** %5
store i8* %69, i8** %2
br label %70
70: ; preds = %68, %50, %36, %14
%71 = load i8*, i8** %2
ret i8* %71
}

LLVM IR (-O2):
define i8* @remove_quotes_pair(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %25, label %4
4: ; preds = %1
%5 = load i8, i8* %0
switch i8 %5, label %25 [
i8 39, label %7
i8 34, label %6
]
6: ; preds = %4
br label %7
7: ; preds = %4, %6
%8 = phi i32 [ 34, %6 ], [ 39, %4 ]
%9 = add nsw i32 %2, -1
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %8, %13
br i1 %14, label %15, label %25
15: ; preds = %7
%16 = add nuw nsw i32 %2, 1
%17 = tail call i8* @calloc(i32 1, i32 %16)
%18 = getelementptr inbounds i8, i8* %0, i64 1
%19 = tail call i32 @strcpy(i8* %17, i8* %18)
%20 = add nsw i32 %2, -2
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %17, i64 %21
store i8 0, i8* %22
%23 = tail call i8* @makename(i8* %17)
%24 = tail call i32 @free(i8* %17)
br label %25
25: ; preds = %7, %4, %1, %15
%26 = phi i8* [ %23, %15 ], [ %0, %1 ], [ %0, %4 ], [ %0, %7 ]
ret i8* %26
}