#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 *sqlite3_malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *unquote(char const *in) {
  char c, *ret;
  int i;
  ret = sqlite3_malloc(strlen(in) + 1);
  if (ret) {
    c = in[0];
    if ((c == '"') || (c == '\'')) {
      i = strlen(in + 1);
      if ((i > 0) && (in[i] == c)) {
        strcpy(ret, in + 1);
        ret[i - 1] = '\0';
        return ret;
      }
    }
    strcpy(ret, in);
  }
  return ret;
}


x86 assembly (clang, -O0):
<unquote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
call   1050 <sqlite3_malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f4 <unquote+0xc4>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x22,%eax
je     1181 <unquote+0x51>
movsbl -0x11(%rbp),%eax
cmp    $0x27,%eax
jne    11e7 <unquote+0xb7>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    11e2 <unquote+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11e2 <unquote+0xb2>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fc <unquote+0xcc>
jmp    11e7 <unquote+0xb7>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unquote>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <sqlite3_malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     119b <unquote+0x6b>
mov    (%rbx),%bpl
cmp    $0x27,%bpl
je     115f <unquote+0x2f>
cmp    $0x22,%bpl
jne    1190 <unquote+0x60>
lea    0x1(%rbx),%r12
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1190 <unquote+0x60>
mov    %eax,%r15d
mov    %eax,%eax
cmp    %bpl,(%rbx,%rax,1)
jne    1190 <unquote+0x60>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
add    $0xffffffff,%r15d
movb   $0x0,(%r14,%r15,1)
jmp    119b <unquote+0x6b>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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