#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*/ strcpy(char *, char *);
void make_single_quotes_double_single_quotes(char *d) {
  char tmp[131072];
  char *tmp_ptr = tmp;
  strcpy(tmp, d);
  while (*tmp_ptr) {
    if (*tmp_ptr == '\'') {
      if (tmp_ptr == tmp) {
        if (*(tmp_ptr + 1) && *(tmp_ptr + 1) != '\'') {
          *d++ = '\'';
          *d++ = *tmp_ptr++;
        } else {
          *d++ = *tmp_ptr++;
        }
      } else if (!*(tmp_ptr + 1)) {
        if (*(tmp_ptr - 1) && *(tmp_ptr - 1) != '\'') {
          *d++ = '\'';
          *d++ = *tmp_ptr++;
        } else {
          *d++ = *tmp_ptr++;
        }
      } else if (*(tmp_ptr + 1) && *(tmp_ptr + 1) != '\'' && *(tmp_ptr - 1) &&
                 *(tmp_ptr - 1) != '\'') {
        *d++ = '\'';
        *d++ = *tmp_ptr++;
      } else {
        *d++ = *tmp_ptr++;
      }
    } else {
      *d++ = *tmp_ptr++;
    }
  }
  *d = '\0';
}


x86 assembly (clang, -O0):
<make_single_quotes_double_single_quotes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20020,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x20010(%rbp),%rax
mov    %rax,-0x20018(%rbp)
lea    -0x20010(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20018(%rbp),%rax
cmpb   $0x0,(%rax)
je     13a3 <make_single_quotes_double_single_quotes+0x293>
mov    -0x20018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    1376 <make_single_quotes_double_single_quotes+0x266>
mov    -0x20018(%rbp),%rax
lea    -0x20010(%rbp),%rcx
cmp    %rcx,%rax
jne    120b <make_single_quotes_double_single_quotes+0xfb>
mov    -0x20018(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11de <make_single_quotes_double_single_quotes+0xce>
mov    -0x20018(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x27,%eax
je     11de <make_single_quotes_double_single_quotes+0xce>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x27,(%rax)
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1206 <make_single_quotes_double_single_quotes+0xf6>
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1371 <make_single_quotes_double_single_quotes+0x261>
mov    -0x20018(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    12b0 <make_single_quotes_double_single_quotes+0x1a0>
mov    -0x20018(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x0,%eax
je     1283 <make_single_quotes_double_single_quotes+0x173>
mov    -0x20018(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x27,%eax
je     1283 <make_single_quotes_double_single_quotes+0x173>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x27,(%rax)
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    12ab <make_single_quotes_double_single_quotes+0x19b>
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    136c <make_single_quotes_double_single_quotes+0x25c>
mov    -0x20018(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     133f <make_single_quotes_double_single_quotes+0x22f>
mov    -0x20018(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x27,%eax
je     133f <make_single_quotes_double_single_quotes+0x22f>
mov    -0x20018(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x0,%eax
je     133f <make_single_quotes_double_single_quotes+0x22f>
mov    -0x20018(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x27,%eax
je     133f <make_single_quotes_double_single_quotes+0x22f>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x27,(%rax)
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1367 <make_single_quotes_double_single_quotes+0x257>
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    136c <make_single_quotes_double_single_quotes+0x25c>
jmp    1371 <make_single_quotes_double_single_quotes+0x261>
jmp    139e <make_single_quotes_double_single_quotes+0x28e>
mov    -0x20018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20018(%rbp)
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    113d <make_single_quotes_double_single_quotes+0x2d>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_single_quotes_double_single_quotes>:
push   %rbx
sub    $0x20000,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
jmp    113b <make_single_quotes_double_single_quotes+0x2b>
nopw   0x0(%rax,%rax,1)
movb   $0x27,(%rbx)
add    $0x1,%rbx
add    $0x1,%rax
movzbl (%rsp,%rax,1),%ecx
cmp    $0x27,%cl
je     1150 <make_single_quotes_double_single_quotes+0x40>
test   %cl,%cl
je     1189 <make_single_quotes_double_single_quotes+0x79>
mov    %cl,(%rbx)
jmp    1133 <make_single_quotes_double_single_quotes+0x23>
nopl   0x0(%rax)
test   %rax,%rax
je     116c <make_single_quotes_double_single_quotes+0x5c>
movzbl 0x1(%rsp,%rax,1),%ecx
cmp    $0x27,%cl
je     1130 <make_single_quotes_double_single_quotes+0x20>
test   %cl,%cl
movzbl -0x1(%rsp,%rax,1),%ecx
test   %cl,%cl
jne    1175 <make_single_quotes_double_single_quotes+0x65>
jmp    1130 <make_single_quotes_double_single_quotes+0x20>
movzbl 0x1(%rsp),%ecx
test   %cl,%cl
je     1130 <make_single_quotes_double_single_quotes+0x20>
cmp    $0x27,%cl
je     1130 <make_single_quotes_double_single_quotes+0x20>
movw   $0x2727,(%rbx)
add    $0x2,%rbx
add    $0x1,%rax
jmp    113b <make_single_quotes_double_single_quotes+0x2b>
movb   $0x0,(%rbx)
add    $0x20000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @make_single_quotes_double_single_quotes(i8* %0) {
%2 = alloca i8*
%3 = alloca [131072 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = getelementptr inbounds [131072 x i8], [131072 x i8]* %3, i64 0, i64 0
store i8* %5, i8** %4
%6 = getelementptr inbounds [131072 x i8], [131072 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
br label %9
9: ; preds = %128, %1
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %129
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 39
br i1 %17, label %18, label %122
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds [131072 x i8], [131072 x i8]* %3, i64 0, i64 0
%21 = icmp eq i8* %19, %20
br i1 %21, label %22, label %49
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 39
br i1 %33, label %34, label %42
34: ; preds = %28
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
store i8 39, i8* %35
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %4
%39 = load i8, i8* %37
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %2
store i8 %39, i8* %40
br label %48
42: ; preds = %28, %22
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %4
%45 = load i8, i8* %43
%46 = load i8*, i8** %2
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %2
store i8 %45, i8* %46
br label %48
48: ; preds = %42, %34
br label %121
49: ; preds = %18
%50 = load i8*, i8** %4
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = icmp ne i8 %52, 0
br i1 %53, label %81, label %54
54: ; preds = %49
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 -1
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %74
60: ; preds = %54
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 -1
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 39
br i1 %65, label %66, label %74
66: ; preds = %60
%67 = load i8*, i8** %2
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %2
store i8 39, i8* %67
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i32 1
store i8* %70, i8** %4
%71 = load i8, i8* %69
%72 = load i8*, i8** %2
%73 = getelementptr inbounds i8, i8* %72, i32 1
store i8* %73, i8** %2
store i8 %71, i8* %72
br label %80
74: ; preds = %60, %54
%75 = load i8*, i8** %4
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %4
%77 = load i8, i8* %75
%78 = load i8*, i8** %2
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %2
store i8 %77, i8* %78
br label %80
80: ; preds = %74, %66
br label %120
81: ; preds = %49
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 1
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %113
87: ; preds = %81
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i64 1
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp ne i32 %91, 39
br i1 %92, label %93, label %113
93: ; preds = %87
%94 = load i8*, i8** %4
%95 = getelementptr inbounds i8, i8* %94, i64 -1
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %113
99: ; preds = %93
%100 = load i8*, i8** %4
%101 = getelementptr inbounds i8, i8* %100, i64 -1
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp ne i32 %103, 39
br i1 %104, label %105, label %113
105: ; preds = %99
%106 = load i8*, i8** %2
%107 = getelementptr inbounds i8, i8* %106, i32 1
store i8* %107, i8** %2
store i8 39, i8* %106
%108 = load i8*, i8** %4
%109 = getelementptr inbounds i8, i8* %108, i32 1
store i8* %109, i8** %4
%110 = load i8, i8* %108
%111 = load i8*, i8** %2
%112 = getelementptr inbounds i8, i8* %111, i32 1
store i8* %112, i8** %2
store i8 %110, i8* %111
br label %119
113: ; preds = %99, %93, %87, %81
%114 = load i8*, i8** %4
%115 = getelementptr inbounds i8, i8* %114, i32 1
store i8* %115, i8** %4
%116 = load i8, i8* %114
%117 = load i8*, i8** %2
%118 = getelementptr inbounds i8, i8* %117, i32 1
store i8* %118, i8** %2
store i8 %116, i8* %117
br label %119
119: ; preds = %113, %105
br label %120
120: ; preds = %119, %80
br label %121
121: ; preds = %120, %48
br label %128
122: ; preds = %13
%123 = load i8*, i8** %4
%124 = getelementptr inbounds i8, i8* %123, i32 1
store i8* %124, i8** %4
%125 = load i8, i8* %123
%126 = load i8*, i8** %2
%127 = getelementptr inbounds i8, i8* %126, i32 1
store i8* %127, i8** %2
store i8 %125, i8* %126
br label %128
128: ; preds = %122, %121
br label %9
129: ; preds = %9
%130 = load i8*, i8** %2
store i8 0, i8* %130
ret void
}

LLVM IR (-O2):
define void @make_single_quotes_double_single_quotes(i8* %0) {
%2 = alloca [131072 x i8]
%3 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 0
%4 = call i32 @strcpy(i8* %3, i8* %0)
%5 = getelementptr inbounds [131072 x i8], [131072 x i8]* %2, i64 0, i64 1
br label %6
6: ; preds = %40, %1
%7 = phi i8* [ %0, %1 ], [ %41, %40 ]
%8 = phi i8* [ %3, %1 ], [ %42, %40 ]
%9 = load i8, i8* %8
switch i8 %9, label %38 [
i8 0, label %43
i8 39, label %10
]
10: ; preds = %6
%11 = icmp eq i8* %8, %3
br i1 %11, label %12, label %19
12: ; preds = %10
%13 = load i8, i8* %5
switch i8 %13, label %14 [
i8 0, label %17
i8 39, label %17
]
14: ; preds = %12
%15 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
%16 = getelementptr inbounds i8, i8* %7, i64 2
store i8 39, i8* %15
br label %40
17: ; preds = %12, %12
%18 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
br label %40
19: ; preds = %10
%20 = getelementptr inbounds i8, i8* %8, i64 1
%21 = load i8, i8* %20
switch i8 %21, label %30 [
i8 0, label %22
i8 39, label %36
]
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %8, i64 -1
%24 = load i8, i8* %23
switch i8 %24, label %25 [
i8 0, label %28
i8 39, label %28
]
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
%27 = getelementptr inbounds i8, i8* %7, i64 2
store i8 39, i8* %26
br label %40
28: ; preds = %22, %22
%29 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
br label %40
30: ; preds = %19
%31 = getelementptr inbounds i8, i8* %8, i64 -1
%32 = load i8, i8* %31
switch i8 %32, label %33 [
i8 0, label %36
i8 39, label %36
]
33: ; preds = %30
%34 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
%35 = getelementptr inbounds i8, i8* %7, i64 2
store i8 39, i8* %34
br label %40
36: ; preds = %30, %30, %19
%37 = getelementptr inbounds i8, i8* %7, i64 1
store i8 39, i8* %7
br label %40
38: ; preds = %6
%39 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %9, i8* %7
br label %40
40: ; preds = %17, %14, %33, %36, %25, %28, %38
%41 = phi i8* [ %16, %14 ], [ %18, %17 ], [ %35, %33 ], [ %37, %36 ], [ %27, %25 ], [ %29, %28 ], [ %39, %38 ]
%42 = getelementptr inbounds i8, i8* %8, i64 1
br label %6
43: ; preds = %6
store i8 0, i8* %7
ret void
}