#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 strlen(char *);
char *dequote(char *ptr) {
  int len;
  len = strlen(ptr);
  if (ptr[len - 1] == '"') {
    ptr[len - 1] = '\0';
    len--;
  }
  if (ptr[0] == '"') {
    ptr++;
    len--;
  }
  if (len <= 0)
    ptr = NULL;
  return ptr;
}


x86 assembly (clang, -O0):
<dequote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    115c <dequote+0x4c>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1181 <dequote+0x71>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     1193 <dequote+0x83>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dequote>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
cmpb   $0x22,-0x1(%rbx,%rcx,1)
jne    112d <dequote+0x1d>
add    $0xffffffffffffffff,%rcx
movb   $0x0,(%rbx,%rcx,1)
mov    %ecx,%eax
xor    %ecx,%ecx
cmpb   $0x22,(%rbx)
sete   %cl
lea    (%rcx,%rbx,1),%rdx
sub    %ecx,%eax
xor    %ecx,%ecx
test   %eax,%eax
cmovg  %rdx,%rcx
mov    %rcx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @dequote(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 34
br i1 %7, label %8, label %9
8: ; preds = %1
store i8 0, i8* %5
br label %9
9: ; preds = %8, %1
%10 = phi i32 [ %3, %8 ], [ %2, %1 ]
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 34
%13 = zext i1 %12 to i64
%14 = getelementptr i8, i8* %0, i64 %13
%15 = sext i1 %12 to i32
%16 = add nsw i32 %10, %15
%17 = icmp slt i32 %16, 1
%18 = select i1 %17, i8* null, i8* %14
ret i8* %18
}