#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ isEmptyLineCL(char *);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
void stripQuotesCL(char *str) {
  char quote;
  char *pos;
  int i;
  if (str[0] == '\'') {
    quote = '\'';
  } else if (str[0] == '\"') {
    quote = '\"';
  } else {
    fprintf(stderr, "### error, string not properly quoted: %s\n", str);
    exit(6);
  }
  pos = strrchr(str, quote);
  if (pos == str) {
    fprintf(stderr, "### error, string not properly quoted: %s\n", str);
    exit(6);
  }
  if (!isEmptyLineCL(pos + 1)) {
    fprintf(stderr, "### error, trailing characters at end of string: %s\n",
            str);
    exit(6);
  }
  for (i = 1; (str + i) != pos; i++) {
    str[i - 1] = str[i];
  }
  str[i - 1] = '\0';
}


x86 assembly (clang, -O0):
<stripQuotesCL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1165 <stripQuotesCL+0x25>
movb   $0x27,-0x9(%rbp)
jmp    11a6 <stripQuotesCL+0x66>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    117e <stripQuotesCL+0x3e>
movb   $0x22,-0x9(%rbp)
jmp    11a1 <stripQuotesCL+0x61>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x6,%edi
call   1060 <exit@plt>
jmp    11a6 <stripQuotesCL+0x66>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11e8 <stripQuotesCL+0xa8>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe27(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x6,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1050 <isEmptyLineCL@plt>
cmp    $0x0,%eax
jne    1221 <stripQuotesCL+0xe1>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x6,%edi
call   1060 <exit@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
cmp    -0x18(%rbp),%rax
je     1266 <stripQuotesCL+0x126>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1228 <stripQuotesCL+0xe8>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stripQuotesCL>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%al
cmp    $0x27,%al
je     1164 <stripQuotesCL+0x14>
cmp    $0x22,%al
jne    11b3 <stripQuotesCL+0x63>
mov    $0x22,%al
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strrchr@plt>
cmp    %r14,%rax
je     11b3 <stripQuotesCL+0x63>
mov    %rax,%r15
lea    0x1(%rax),%rdi
call   1050 <isEmptyLineCL@plt>
test   %eax,%eax
je     11c5 <stripQuotesCL+0x75>
lea    0x1(%r14),%rsi
cmp    %r15,%rsi
je     11a6 <stripQuotesCL+0x56>
mov    %r14,%rbx
not    %rbx
add    %r15,%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
call   1060 <memmove@plt>
movslq %ebx,%rax
jmp    11a8 <stripQuotesCL+0x58>
xor    %eax,%eax
movb   $0x0,(%r14,%rax,1)
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
jmp    11d5 <stripQuotesCL+0x85>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x6,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"### error, string not properly quoted: %s\0A\00"
@.str.1 = [53 x i8] c"### error, trailing characters at end of string: %s\0A\00"
define void @stripQuotesCL(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 39
br i1 %10, label %11, label %12
11: ; preds = %1
store i8 39, i8* %3
br label %25
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 34
br i1 %17, label %18, label %19
18: ; preds = %12
store i8 34, i8* %3
br label %24
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 6)
unreachable
24: ; preds = %18
br label %25
25: ; preds = %24, %11
%26 = load i8*, i8** %2
%27 = load i8, i8* %3
%28 = call i8* @strrchr(i8* %26, i8 signext %27)
store i8* %28, i8** %4
%29 = load i8*, i8** %4
%30 = load i8*, i8** %2
%31 = icmp eq i8* %29, %30
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %2
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 6)
unreachable
37: ; preds = %25
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
%40 = call i32 @isEmptyLineCL(i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %2
%45 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%46 = call i32 @exit(i32 6)
unreachable
47: ; preds = %37
store i32 1, i32* %5
br label %48
48: ; preds = %66, %47
%49 = load i8*, i8** %2
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8*, i8** %4
%54 = icmp ne i8* %52, %53
br i1 %54, label %55, label %69
55: ; preds = %48
%56 = load i8*, i8** %2
%57 = load i32, i32* %5
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = load i8*, i8** %2
%62 = load i32, i32* %5
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
store i8 %60, i8* %65
br label %66
66: ; preds = %55
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %48
69: ; preds = %48
%70 = load i8*, i8** %2
%71 = load i32, i32* %5
%72 = sub nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %70, i64 %73
store i8 0, i8* %74
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"### error, string not properly quoted: %s\0A\00"
@.str.1 = [53 x i8] c"### error, trailing characters at end of string: %s\0A\00"
define void @stripQuotesCL(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = load i8, i8* %0
switch i8 %3, label %5 [
i8 39, label %9
i8 34, label %4
]
4: ; preds = %1
br label %9
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 6)
unreachable
9: ; preds = %1, %4
%10 = phi i8 [ 34, %4 ], [ %3, %1 ]
%11 = tail call i8* @strrchr(i8* %0, i8 signext %10)
%12 = ptrtoint i8* %11 to i64
%13 = icmp eq i8* %11, %0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = tail call i32 @exit(i32 6)
unreachable
18: ; preds = %9
%19 = getelementptr inbounds i8, i8* %11, i64 1
%20 = tail call i32 @isEmptyLineCL(i8* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %32, label %22
22: ; preds = %18
%23 = getelementptr i8, i8* %0, i64 1
%24 = icmp eq i8* %23, %11
br i1 %24, label %36, label %25
25: ; preds = %22
%26 = xor i64 %2, -1
%27 = add i64 %26, %12
%28 = xor i64 %2, -1
%29 = add i64 %28, %12
%30 = shl i64 %29, 32
%31 = ashr exact i64 %30, 32
br label %36
32: ; preds = %18
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%35 = tail call i32 @exit(i32 6)
unreachable
36: ; preds = %25, %22
%37 = phi i64 [ 0, %22 ], [ %31, %25 ]
%38 = getelementptr inbounds i8, i8* %0, i64 %37
store i8 0, i8* %38
ret void
}