#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 */
scalar_t__ isspace(char const);
char *sqlite3_mprintf(char *, char const *);
scalar_t__ strlen(char *);
char *spellfix1Dequote(const char *zIn) {
  char *zOut;
  int i, j;
  char c;
  while (isspace(zIn[0]))
    zIn++;
  zOut = sqlite3_mprintf("%s", zIn);
  if (zOut == 0)
    return 0;
  i = (int)strlen(zOut);
  zOut[i] = 0;
  c = zOut[0];
  if (c == '\'' || c == '"') {
    for (i = 1, j = 0; 1; i++) {
      zOut[j++] = zOut[i];
      if (zOut[i] == c) {
        if (zOut[i + 1] == c) {
          i++;
        } else {
          zOut[j - 1] = 0;
          break;
        }
      }
    }
  }
  return zOut;
}


x86 assembly (clang, -O0):
<spellfix1Dequote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1163 <spellfix1Dequote+0x33>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <spellfix1Dequote+0xc>
mov    -0x10(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1050 <sqlite3_mprintf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118f <spellfix1Dequote+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    1285 <spellfix1Dequote+0x155>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x27,%eax
je     11ca <spellfix1Dequote+0x9a>
movsbl -0x21(%rbp),%eax
cmp    $0x22,%eax
jne    127d <spellfix1Dequote+0x14d>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    11e7 <spellfix1Dequote+0xb7>
jmp    1278 <spellfix1Dequote+0x148>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    1265 <spellfix1Dequote+0x135>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x21(%rbp),%ecx
cmp    %ecx,%eax
jne    124a <spellfix1Dequote+0x11a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1260 <spellfix1Dequote+0x130>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1278 <spellfix1Dequote+0x148>
jmp    1265 <spellfix1Dequote+0x135>
jmp    126a <spellfix1Dequote+0x13a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d8 <spellfix1Dequote+0xa8>
jmp    127d <spellfix1Dequote+0x14d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spellfix1Dequote>:
push   %rbx
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <spellfix1Dequote+0x10>
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
call   1050 <sqlite3_mprintf@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11bc <spellfix1Dequote+0x8c>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
mov    (%rbx),%dil
cmp    $0x27,%dil
je     1186 <spellfix1Dequote+0x56>
cmp    $0x22,%dil
jne    11bc <spellfix1Dequote+0x8c>
mov    $0x1,%edx
xor    %ecx,%ecx
jmp    1197 <spellfix1Dequote+0x67>
nop
add    $0x1,%edx
add    $0x1,%rcx
movslq %edx,%rsi
movzbl (%rbx,%rsi,1),%eax
mov    %al,(%rbx,%rcx,1)
cmp    %dil,(%rbx,%rsi,1)
jne    1190 <spellfix1Dequote+0x60>
cmp    %dil,0x1(%rbx,%rsi,1)
jne    11b6 <spellfix1Dequote+0x86>
add    $0x1,%rsi
mov    %esi,%edx
jmp    1190 <spellfix1Dequote+0x60>
mov    %ecx,%eax
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8* @spellfix1Dequote(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
br label %8
8: ; preds = %14, %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = call i64 @isspace(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
br label %8
17: ; preds = %8
%18 = load i8*, i8** %3
%19 = call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %17
store i8* null, i8** %2
br label %91
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = call i64 @strlen(i8* %24)
%26 = trunc i64 %25 to i32
store i32 %26, i32* %5
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
store i8 %33, i8* %7
%34 = load i8, i8* %7
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 39
br i1 %36, label %41, label %37
37: ; preds = %23
%38 = load i8, i8* %7
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 34
br i1 %40, label %41, label %89
41: ; preds = %37, %23
store i32 1, i32* %5
store i32 0, i32* %6
br label %42
42: ; preds = %85, %41
br i1 true, label %43, label %88
43: ; preds = %42
%44 = load i8*, i8** %4
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = load i8*, i8** %4
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
store i8 %48, i8* %53
%54 = load i8*, i8** %4
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = load i8, i8* %7
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %59, %61
br i1 %62, label %63, label %84
63: ; preds = %43
%64 = load i8*, i8** %4
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = load i8, i8* %7
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %70, %72
br i1 %73, label %74, label %77
74: ; preds = %63
%75 = load i32, i32* %5
%76 = add nsw i32 %75, 1
store i32 %76, i32* %5
br label %83
77: ; preds = %63
%78 = load i8*, i8** %4
%79 = load i32, i32* %6
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
store i8 0, i8* %82
br label %88
83: ; preds = %74
br label %84
84: ; preds = %83, %43
br label %85
85: ; preds = %84
%86 = load i32, i32* %5
%87 = add nsw i32 %86, 1
store i32 %87, i32* %5
br label %42
88: ; preds = %77, %42
br label %89
89: ; preds = %88, %37
%90 = load i8*, i8** %4
store i8* %90, i8** %2
br label %91
91: ; preds = %89, %22
%92 = load i8*, i8** %2
ret i8* %92
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i8* @spellfix1Dequote(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = tail call i8* @sqlite3_mprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%10 = icmp eq i8* %9, null
br i1 %10, label %40, label %11
11: ; preds = %8
%12 = tail call i64 @strlen(i8* %9)
%13 = shl i64 %12, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8, i8* %9, i64 %14
store i8 0, i8* %15
%16 = load i8, i8* %9
switch i8 %16, label %40 [
i8 39, label %17
i8 34, label %17
]
17: ; preds = %11, %11
br label %18
18: ; preds = %17, %37
%19 = phi i64 [ %24, %37 ], [ 0, %17 ]
%20 = phi i32 [ %39, %37 ], [ 1, %17 ]
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %9, i64 %21
%23 = load i8, i8* %22
%24 = add nuw i64 %19, 1
%25 = getelementptr inbounds i8, i8* %9, i64 %19
store i8 %23, i8* %25
%26 = load i8, i8* %22
%27 = icmp eq i8 %26, %16
br i1 %27, label %28, label %37
28: ; preds = %18
%29 = add nsw i32 %20, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %9, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, %16
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = and i64 %19, 4294967295
%36 = getelementptr inbounds i8, i8* %9, i64 %35
store i8 0, i8* %36
br label %40
37: ; preds = %28, %18
%38 = phi i32 [ %20, %18 ], [ %29, %28 ]
%39 = add nsw i32 %38, 1
br label %18
40: ; preds = %34, %11, %8
ret i8* %9
}