#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*/ putchar(char);
void prolog_quote(char *s) {
  int i;
  putchar('\'');
  for (i = 0; s[i]; i++) {
    switch (s[i]) {
    case '\'':
      putchar(s[i]);
    default:
      putchar(s[i]);
    }
  }
  putchar('\'');
}


x86 assembly (clang, -O0):
<prolog_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x27,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     118c <prolog_quote+0x7c>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%al
sub    $0x27,%al
jne    1168 <prolog_quote+0x58>
jmp    1157 <prolog_quote+0x47>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    117e <prolog_quote+0x6e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <prolog_quote+0x1d>
mov    $0x27,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prolog_quote>:
push   %rbx
mov    %rdi,%rbx
mov    $0x27,%edi
call   1030 <putchar@plt>
jmp    1139 <prolog_quote+0x29>
mov    $0x27,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x27,%al
je     1120 <prolog_quote+0x10>
test   %al,%al
jne    112d <prolog_quote+0x1d>
mov    $0x27,%edi
pop    %rbx
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @prolog_quote(i8* nocapture %0) {
%2 = tail call i32 @putchar(i8 signext 39)
br label %3
3: ; preds = %10, %1
%4 = phi i64 [ %13, %10 ], [ 0, %1 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %10 [
i8 0, label %14
i8 39, label %7
]
7: ; preds = %3
%8 = tail call i32 @putchar(i8 signext 39)
%9 = load i8, i8* %5
br label %10
10: ; preds = %3, %7
%11 = phi i8 [ %6, %3 ], [ %9, %7 ]
%12 = tail call i32 @putchar(i8 signext %11)
%13 = add nuw i64 %4, 1
br label %3
14: ; preds = %3
%15 = tail call i32 @putchar(i8 signext 39)
ret void
}