#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 *, ...);
int strlen(char *);
void print_quoted(char *path, char *quote) {
  int len = strlen(path);
  printf("\"");
  for (int i = 0; i < len; i++) {
    if (path[i] != '"') {
      printf("%c", path[i]);
    } else {
      printf("%s", quote);
    }
  }
  printf("\"");
}


x86 assembly (clang, -O0):
<print_quoted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <print_quoted+0x96>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
je     1191 <print_quoted+0x71>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a3 <print_quoted+0x83>
mov    -0x10(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a8 <print_quoted+0x88>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <print_quoted+0x31>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_quoted>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    $0x22,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    1187 <print_quoted+0x57>
mov    %ebp,%ebp
lea    0xea4(%rip),%r15
xor    %ebx,%ebx
jmp    1176 <print_quoted+0x46>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1187 <print_quoted+0x57>
movsbl (%r12,%rbx,1),%edi
cmp    $0x22,%edi
je     1160 <print_quoted+0x30>
call   1030 <putchar@plt>
jmp    116d <print_quoted+0x3d>
mov    $0x22,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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