#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 *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *suppress_quotes_new_string(char *string) {
  char *result;
  if (string == NULL) {
    return NULL;
  }
  result = malloc(sizeof(char) * (strlen(string) + 1));
  if (result == NULL) {
    return NULL;
  }
  if ((string[0] == '"') && (string[strlen(string) - 1] == '"')) {
    strcpy(result, string + 1);
    result[strlen(result) - 1] = '\0';
  } else {
    strcpy(result, string);
  }
  return result;
}


x86 assembly (clang, -O0):
<suppress_quotes_new_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1154 <suppress_quotes_new_string+0x24>
movq   $0x0,-0x8(%rbp)
jmp    120f <suppress_quotes_new_string+0xdf>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1189 <suppress_quotes_new_string+0x59>
movq   $0x0,-0x8(%rbp)
jmp    120f <suppress_quotes_new_string+0xdf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    11fa <suppress_quotes_new_string+0xca>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
jne    11fa <suppress_quotes_new_string+0xca>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1207 <suppress_quotes_new_string+0xd7>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suppress_quotes_new_string>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1188 <suppress_quotes_new_string+0x58>
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1188 <suppress_quotes_new_string+0x58>
mov    %rax,%r14
cmpb   $0x22,(%rbx)
jne    118d <suppress_quotes_new_string+0x5d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x22,-0x1(%rax,%rbx,1)
jne    118d <suppress_quotes_new_string+0x5d>
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
jmp    1198 <suppress_quotes_new_string+0x68>
xor    %r14d,%r14d
jmp    1198 <suppress_quotes_new_string+0x68>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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