#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*/ error(char *const, char *);
scalar_t__ malloc(int);
int strlen(char *);
char *dequote(char *s) {
  static char *sbuf = NULL;
  char *t;
  int i;
  if (s[0] != '\'')
    return s;
  else if ((i = strlen(s)) < 2)
    return s;
  else if (s[i - 1] != '\'')
    error((char *const)"Illegal string passed to dequote: %s", s);
  if (sbuf == NULL)
    sbuf = (char *)malloc(65535);
  t = sbuf;
  s++;
  while (*s != '\0') {
    if (*s == '\'')
      s++;
    *t = *s;
    s++;
    t++;
  }
  *t = '\0';
  return sbuf;
}


x86 assembly (clang, -O0):
<dequote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     1159 <dequote+0x29>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    124c <dequote+0x11c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x2,%eax
jge    117b <dequote+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    124c <dequote+0x11c>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
je     11a5 <dequote+0x75>
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdi
call   1050 <error@plt>
jmp    11aa <dequote+0x7a>
jmp    11af <dequote+0x7f>
cmpq   $0x0,0x2e89(%rip)
jne    11ce <dequote+0x9e>
mov    $0xffff,%edi
call   1040 <malloc@plt>
mov    %rax,0x2e72(%rip)
mov    0x2e6b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     123a <dequote+0x10a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1211 <dequote+0xe1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e5 <dequote+0xb5>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2df8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dequote>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x27,(%rdi)
jne    1146 <dequote+0x16>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jge    114b <dequote+0x1b>
mov    %rbx,%rax
pop    %rbx
ret
add    $0xffffffff,%eax
cmpb   $0x27,(%rbx,%rax,1)
je     1163 <dequote+0x33>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
call   1050 <error@plt>
mov    0x2ed6(%rip),%rax
test   %rax,%rax
jne    1180 <dequote+0x50>
mov    $0xffff,%edi
call   1040 <malloc@plt>
mov    %rax,0x2ec0(%rip)
mov    %rax,%rcx
jmp    119e <dequote+0x6e>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x2(%rbx),%edx
add    $0x2,%rbx
mov    %dl,(%rcx)
add    $0x1,%rcx
movzbl 0x1(%rbx),%edx
cmp    $0x27,%dl
je     1190 <dequote+0x60>
test   %dl,%dl
je     11b1 <dequote+0x81>
add    $0x1,%rbx
jmp    1198 <dequote+0x68>
movb   $0x0,(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
@dequote.sbuf = internal global i8* null
@.str = [37 x i8] c"Illegal string passed to dequote: %s\00"
define i8* @dequote(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 39
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i8*, i8** %3
store i8* %12, i8** %2
br label %67
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %5
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i8*, i8** %3
store i8* %18, i8** %2
br label %67
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 39
br i1 %27, label %28, label %31
28: ; preds = %19
%29 = load i8*, i8** %3
%30 = call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %19
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
%34 = load i8*, i8** @dequote.sbuf
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i64 @malloc(i32 65535)
%38 = inttoptr i64 %37 to i8*
store i8* %38, i8** @dequote.sbuf
br label %39
39: ; preds = %36, %33
%40 = load i8*, i8** @dequote.sbuf
store i8* %40, i8** %4
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %3
br label %43
43: ; preds = %56, %39
%44 = load i8*, i8** %3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %64
48: ; preds = %43
%49 = load i8*, i8** %3
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 39
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %3
br label %56
56: ; preds = %53, %48
%57 = load i8*, i8** %3
%58 = load i8, i8* %57
%59 = load i8*, i8** %4
store i8 %58, i8* %59
%60 = load i8*, i8** %3
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %3
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %4
br label %43
64: ; preds = %43
%65 = load i8*, i8** %4
store i8 0, i8* %65
%66 = load i8*, i8** @dequote.sbuf
store i8* %66, i8** %2
br label %67
67: ; preds = %64, %17, %11
%68 = load i8*, i8** %2
ret i8* %68
}

LLVM IR (-O2):
@dequote.sbuf = internal unnamed_addr global i8* null
@.str = [37 x i8] c"Illegal string passed to dequote: %s\00"
define i8* @dequote(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 39
br i1 %3, label %4, label %36
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp slt i32 %5, 2
br i1 %6, label %36, label %7
7: ; preds = %4
%8 = add nsw i32 %5, -1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 39
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = tail call i32 @error(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %15
15: ; preds = %13, %7
%16 = load i8*, i8** @dequote.sbuf
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = tail call i64 @malloc(i32 65535)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** @dequote.sbuf
br label %21
21: ; preds = %18, %15
%22 = phi i8* [ %20, %18 ], [ %16, %15 ]
br label %23
23: ; preds = %31, %21
%24 = phi i8* [ %0, %21 ], [ %33, %31 ]
%25 = phi i8* [ %22, %21 ], [ %34, %31 ]
%26 = getelementptr inbounds i8, i8* %24, i64 1
%27 = load i8, i8* %26
switch i8 %27, label %31 [
i8 0, label %35
i8 39, label %28
]
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %24, i64 2
%30 = load i8, i8* %29
br label %31
31: ; preds = %23, %28
%32 = phi i8 [ %30, %28 ], [ %27, %23 ]
%33 = phi i8* [ %29, %28 ], [ %26, %23 ]
store i8 %32, i8* %25
%34 = getelementptr inbounds i8, i8* %25, i64 1
br label %23
35: ; preds = %23
store i8 0, i8* %25
br label %36
36: ; preds = %4, %1, %35
%37 = phi i8* [ %22, %35 ], [ %0, %1 ], [ %0, %4 ]
ret i8* %37
}