#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 *, ...);
void print_quote(char *p) {
  while (*p) {
    if (*p == '\"' || *p == '\\') {
      printf("\\");
    }
    printf("%c", *p);
    p++;
  }
}


x86 assembly (clang, -O0):
<print_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117d <print_quote+0x6d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     1149 <print_quote+0x39>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1157 <print_quote+0x47>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <print_quote+0xc>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [2 x i8] c"\\\00"
@.str.1 = [3 x i8] c"%c\00"
define void @print_quote(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %19, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 34
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %19
17: ; preds = %12, %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %3
26: ; preds = %3
ret void
}

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