#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_quoted_string(FILE *f, char *val) {
  for (char *c = val; *c; c++) {
    switch (*c) {
    case 0x27:
      fprintf(f, "\\\'");
      break;
    case 0x22:
      fprintf(f, "\\\"");
      break;
    case 0x3f:
      fprintf(f, "\\?");
      break;
    case 0x5c:
      fprintf(f, "\\\\");
      break;
    case 0x07:
      fprintf(f, "\\a");
      break;
    case 0x08:
      fprintf(f, "\\b");
      break;
    case 0x0c:
      fprintf(f, "\\f");
      break;
    case 0x0a:
      fprintf(f, "\\n");
      break;
    case 0x0d:
      fprintf(f, "\\r");
      break;
    case 0x09:
      fprintf(f, "\\t");
      break;
    case 0x0b:
      fprintf(f, "\\v");
      break;
    default:
      fprintf(f, "%c", *c);
    }
  }
}


x86 assembly (clang, -O0):
<print_quoted_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     128e <print_quoted_string+0x17e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xfffffff9,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x55,%eax
ja     125f <print_quoted_string+0x14f>
mov    -0x20(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xfeb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xfd7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xfc3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xfaf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf9b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf87(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf73(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf4b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf37(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
lea    0xf23(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1278 <print_quoted_string+0x168>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
lea    0xf08(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    127d <print_quoted_string+0x16d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <print_quoted_string+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_quoted_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     1277 <print_quoted_string+0x157>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
lea    0xeba(%rip),%rbp
lea    0x100b(%rip),%r15
lea    0x100a(%rip),%r12
lea    0x1006(%rip),%r13
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
lea    -0x7(%rdi),%eax
cmp    $0x55,%eax
ja     120a <print_quoted_string+0xea>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfda(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfc7(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfbd(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfa1(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf94(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf75(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf68(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1268 <print_quoted_string+0x148>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf36(%rip),%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    1260 <print_quoted_string+0x140>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rcx
call   1040 <fwrite@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <print_quoted_string+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\\'\00"
@.str.1 = [3 x i8] c"\\\22\00"
@.str.2 = [3 x i8] c"\\?\00"
@.str.3 = [3 x i8] c"\\\\\00"
@.str.4 = [3 x i8] c"\\a\00"
@.str.5 = [3 x i8] c"\\b\00"
@.str.6 = [3 x i8] c"\\f\00"
@.str.7 = [3 x i8] c"\\n\00"
@.str.8 = [3 x i8] c"\\r\00"
@.str.9 = [3 x i8] c"\\t\00"
@.str.10 = [3 x i8] c"\\v\00"
@.str.11 = [3 x i8] c"%c\00"
define void @print_quoted_string(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
store i8* %6, i8** %5
br label %7
7: ; preds = %55, %2
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %58
11: ; preds = %7
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
switch i32 %14, label %48 [
i32 39, label %15
i32 34, label %18
i32 63, label %21
i32 92, label %24
i32 7, label %27
i32 8, label %30
i32 12, label %33
i32 10, label %36
i32 13, label %39
i32 9, label %42
i32 11, label %45
]
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %54
18: ; preds = %11
%19 = load i32*, i32** %3
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %54
21: ; preds = %11
%22 = load i32*, i32** %3
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %54
24: ; preds = %11
%25 = load i32*, i32** %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %54
27: ; preds = %11
%28 = load i32*, i32** %3
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %54
30: ; preds = %11
%31 = load i32*, i32** %3
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %54
33: ; preds = %11
%34 = load i32*, i32** %3
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %54
36: ; preds = %11
%37 = load i32*, i32** %3
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %54
39: ; preds = %11
%40 = load i32*, i32** %3
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %54
42: ; preds = %11
%43 = load i32*, i32** %3
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %54
45: ; preds = %11
%46 = load i32*, i32** %3
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
br label %54
48: ; preds = %11
%49 = load i32*, i32** %3
%50 = load i8*, i8** %5
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15
br label %55
55: ; preds = %54
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %5
br label %7
58: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\'\00"
@.str.1 = [3 x i8] c"\\\22\00"
@.str.2 = [3 x i8] c"\\?\00"
@.str.3 = [3 x i8] c"\\\\\00"
@.str.4 = [3 x i8] c"\\a\00"
@.str.5 = [3 x i8] c"\\b\00"
@.str.6 = [3 x i8] c"\\f\00"
@.str.7 = [3 x i8] c"\\n\00"
@.str.8 = [3 x i8] c"\\r\00"
@.str.9 = [3 x i8] c"\\t\00"
@.str.10 = [3 x i8] c"\\v\00"
define void @print_quoted_string(i32* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %34, %2
ret void
6: ; preds = %2, %34
%7 = phi i8 [ %36, %34 ], [ %3, %2 ]
%8 = phi i8* [ %35, %34 ], [ %1, %2 ]
%9 = sext i8 %7 to i32
switch i32 %9, label %32 [
i32 39, label %10
i32 34, label %12
i32 63, label %14
i32 92, label %16
i32 7, label %18
i32 8, label %20
i32 12, label %22
i32 10, label %24
i32 13, label %26
i32 9, label %28
i32 11, label %30
]
10: ; preds = %6
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
12: ; preds = %6
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
14: ; preds = %6
%15 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
16: ; preds = %6
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
18: ; preds = %6
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
20: ; preds = %6
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
22: ; preds = %6
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
24: ; preds = %6
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
26: ; preds = %6
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
28: ; preds = %6
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
30: ; preds = %6
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %34
32: ; preds = %6
%33 = tail call i32 @fputc(i32 %9, i32* %0)
br label %34
34: ; preds = %10, %12, %14, %16, %18, %20, %22, %24, %26, %28, %30, %32
%35 = getelementptr inbounds i8, i8* %8, i64 1
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %5, label %6
}