#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*/ printf(char *, char);
int /*<<< orphan*/ putchar(char);
void lisp_quote(char *s) {
  int i;
  putchar('"');
  for (i = 0; s[i]; i++) {
    switch (s[i]) {
    case '\\':
    case '"':
      printf("\\%c", s[i]);
      break;
    default:
      putchar(s[i]);
    }
  }
  putchar('"');
}


x86 assembly (clang, -O0):
<lisp_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x22,%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11be <lisp_quote+0x9e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x10(%rbp)
sub    $0x22,%eax
je     117d <lisp_quote+0x5d>
jmp    116c <lisp_quote+0x4c>
mov    -0x10(%rbp),%eax
sub    $0x5c,%eax
jne    119a <lisp_quote+0x7a>
jmp    117d <lisp_quote+0x5d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe74(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
jmp    11ab <lisp_quote+0x8b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
jmp    11b0 <lisp_quote+0x90>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <lisp_quote+0x1d>
mov    $0x22,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lisp_quote>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x22,%edi
call   1030 <putchar@plt>
mov    (%rbx),%al
test   %al,%al
je     1179 <lisp_quote+0x59>
add    $0x1,%rbx
lea    0xebe(%rip),%r14
jmp    1163 <lisp_quote+0x43>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1179 <lisp_quote+0x59>
movsbl %al,%esi
cmp    $0x5c,%esi
je     1150 <lisp_quote+0x30>
cmp    $0x22,%esi
je     1150 <lisp_quote+0x30>
mov    %esi,%edi
call   1030 <putchar@plt>
jmp    1158 <lisp_quote+0x38>
mov    $0x22,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\\%c\00"
define void @lisp_quote(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 @putchar(i8 signext 34)
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 92, label %19
i32 34, label %19
]
19: ; preds = %12, %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 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %24)
br label %33
26: ; preds = %12
%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, %19
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 34)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\\%c\00"
define void @lisp_quote(i8* nocapture %0) {
%2 = tail call i32 @putchar(i8 signext 34)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1, %13
%6 = phi i64 [ %14, %13 ], [ 0, %1 ]
%7 = phi i8 [ %16, %13 ], [ %3, %1 ]
%8 = sext i8 %7 to i32
switch i32 %8, label %11 [
i32 92, label %9
i32 34, label %9
]
9: ; preds = %5, %5
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %7)
br label %13
11: ; preds = %5
%12 = tail call i32 @putchar(i8 signext %7)
br label %13
13: ; preds = %9, %11
%14 = add nuw i64 %6, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %5
18: ; preds = %13, %1
%19 = tail call i32 @putchar(i8 signext 34)
ret void
}