#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 *strdup(char *);
int strlen(char *);
int rpn_strip_quotes(char **str) {
  int _lg, _retcode;
  char *_new_str;
  _lg = strlen(*str);
  if ((*str)[0] != '"' || (*str)[_lg - 1] != '"') {
    _retcode = (2);
  } else {
    _new_str = strdup(*str);
    _new_str[_lg - 1] = 0;
    _new_str++;
    *str = _new_str;
    _retcode = (0);
  }
  return _retcode;
}


x86 assembly (clang, -O0):
<rpn_strip_quotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    116b <rpn_strip_quotes+0x4b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
je     1177 <rpn_strip_quotes+0x57>
movl   $0x2,-0x10(%rbp)
jmp    11b6 <rpn_strip_quotes+0x96>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpn_strip_quotes>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    (%rbx),%rdi
mov    $0x2,%eax
cmpb   $0x22,(%rdi)
jne    115d <rpn_strip_quotes+0x3d>
movslq %ecx,%r14
cmpb   $0x22,-0x1(%r14,%rdi,1)
jne    115d <rpn_strip_quotes+0x3d>
call   1040 <strdup@plt>
movb   $0x0,-0x1(%rax,%r14,1)
add    $0x1,%rax
mov    %rax,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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