#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 *strchr(char const *, char const);
char *unquote(char const *str) {
  if (str && (*str == '"' || *str == '\'')) {
    char *p = strchr(str + 1, *str);
    if (p != NULL)
      *p = '\0';
    return (char *)(*++str ? str : NULL);
  }
  return (char *)str;
}


x86 assembly (clang, -O0):
<unquote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b2 <unquote+0xa2>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1147 <unquote+0x37>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    11b2 <unquote+0xa2>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1171 <unquote+0x61>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     119a <unquote+0x8a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11a5 <unquote+0x95>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    11a5 <unquote+0x95>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <unquote+0xaa>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unquote>:
push   %rbx
test   %rdi,%rdi
je     1145 <unquote+0x35>
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x27,%al
je     1123 <unquote+0x13>
cmp    $0x22,%al
jne    1147 <unquote+0x37>
add    $0x1,%rbx
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     113a <unquote+0x2a>
movb   $0x0,(%rax)
xor    %eax,%eax
cmpb   $0x0,(%rbx)
cmove  %rax,%rbx
jmp    1147 <unquote+0x37>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

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

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