#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*/ free(char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
char *stripquotes(char *s) {
  char *start, *end, *copy;
  start = strchr(s, '"');
  if (!start)
    return s;
  end = strchr(start + 1, '"');
  if (!end)
    return s;
  *end = '\0';
  copy = strdup(start + 1);
  strcpy(s, copy);
  free(copy);
  return s;
}


x86 assembly (clang, -O0):
<stripquotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1176 <stripquotes+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <stripquotes+0x9a>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a4 <stripquotes+0x64>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <stripquotes+0x9a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripquotes>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1190 <stripquotes+0x50>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x22,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1190 <stripquotes+0x50>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @stripquotes(i8* returned %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 34)
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = tail call i8* @strchr(i8* %5, i8 signext 34)
%7 = icmp eq i8* %6, null
br i1 %7, label %12, label %8
8: ; preds = %4
store i8 0, i8* %6
%9 = tail call i8* @strdup(i8* %5)
%10 = tail call i32 @strcpy(i8* %0, i8* %9)
%11 = tail call i32 @free(i8* %9)
br label %12
12: ; preds = %4, %1, %8
ret i8* %0
}