#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);
char *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *parser_remove_quotes(char *string) {
  char *new;
  if (string[0] != '"')
    return strdup(string);
  new = calloc(strlen(string) - 1, sizeof(char));
  strncpy(new, string + 1, strlen(string) - 2);
  new[strlen(string) - 2] = 0;
  return new;
}


x86 assembly (clang, -O0):
<parser_remove_quotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     116e <parser_remove_quotes+0x2e>
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11e2 <parser_remove_quotes+0xa2>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
sub    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
sub    $0x2,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser_remove_quotes>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
cmpb   $0x22,(%rdi)
jne    1198 <parser_remove_quotes+0x58>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r14
lea    0x1(%rbx),%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x2(%rax),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x2(%rax,%r14,1)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <strdup@plt>

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

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