#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_string(FILE *os, const char *s, unsigned len) {
  unsigned i;
  fprintf(os, "\"");
  for (i = 0; i < len; ++i) {
    switch (s[i]) {
    case '\a':
      fprintf(os, "\\a");
      break;
    case '\b':
      fprintf(os, "\\b");
      break;
    case '\f':
      fprintf(os, "\\f");
      break;
    case '\n':
      fprintf(os, "\\n");
      break;
    case '\r':
      fprintf(os, "\\r");
      break;
    case '\t':
      fprintf(os, "\\t");
      break;
    case '\v':
      fprintf(os, "\\v");
      break;
    case '\xc2':
      break;
    case '\\':
      fprintf(os, "\\\\");
      break;
    case '\"':
      fprintf(os, "\\\"");
      break;
    default:
      if (s[i] >= ' ' && s[i] <= '~')
        fprintf(os, "%c", s[i]);
      else
        fprintf(os, "\\x%02x", (unsigned)(unsigned char)s[i]);
    }
  }
  fprintf(os, "\"");
}


x86 assembly (clang, -O0):
<print_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeeb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1350 <print_string+0x240>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0xffffffc2,%eax
je     129e <print_string+0x18e>
jmp    1164 <print_string+0x54>
mov    -0x1c(%rbp),%eax
sub    $0x7,%eax
je     11fd <print_string+0xed>
jmp    1175 <print_string+0x65>
mov    -0x1c(%rbp),%eax
sub    $0x8,%eax
je     1214 <print_string+0x104>
jmp    1186 <print_string+0x76>
mov    -0x1c(%rbp),%eax
sub    $0x9,%eax
je     1270 <print_string+0x160>
jmp    1197 <print_string+0x87>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1242 <print_string+0x132>
jmp    11a8 <print_string+0x98>
mov    -0x1c(%rbp),%eax
sub    $0xb,%eax
je     1287 <print_string+0x177>
jmp    11b9 <print_string+0xa9>
mov    -0x1c(%rbp),%eax
sub    $0xc,%eax
je     122b <print_string+0x11b>
jmp    11ca <print_string+0xba>
mov    -0x1c(%rbp),%eax
sub    $0xd,%eax
je     1259 <print_string+0x149>
jmp    11db <print_string+0xcb>
mov    -0x1c(%rbp),%eax
sub    $0x22,%eax
je     12ba <print_string+0x1aa>
jmp    11ec <print_string+0xdc>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     12a3 <print_string+0x193>
jmp    12d1 <print_string+0x1c1>
mov    -0x8(%rbp),%rdi
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xda8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x8(%rbp),%rdi
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jl     131b <print_string+0x20b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jg     131b <print_string+0x20b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%edx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1338 <print_string+0x228>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movzbl (%rax,%rcx,1),%edx
lea    0xced(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    133d <print_string+0x22d>
jmp    1342 <print_string+0x232>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <print_string+0x2c>
mov    -0x8(%rbp),%rdi
lea    0xcbe(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x22,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %ebp,%ebp
je     1286 <print_string+0x156>
mov    %ebp,%r13d
lea    0xe9e(%rip),%rbp
lea    0x1004(%rip),%r12
xor    %r15d,%r15d
jmp    1195 <print_string+0x65>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xfd9(%rip),%rdi
nop
mov    %rbx,%rcx
call   1050 <fwrite@plt>
add    $0x1,%r15
cmp    %r15,%r13
je     1286 <print_string+0x156>
movsbl (%r14,%r15,1),%edi
lea    -0x7(%rdi),%eax
cmp    $0x55,%eax
ja     11bf <print_string+0x8f>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf9e(%rip),%rdi
jmp    1180 <print_string+0x50>
cmp    $0xffffffc2,%edi
je     1188 <print_string+0x58>
lea    -0x7f(%rdi),%eax
cmp    $0xa1,%al
jae    1279 <print_string+0x149>
movzbl %dil,%edx
mov    %rbx,%rdi
lea    0xf96(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1188 <print_string+0x58>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf70(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf57(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf4a(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf28(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf18(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xf0e(%rip),%rdi
jmp    1180 <print_string+0x50>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
jmp    1180 <print_string+0x50>
mov    %rbx,%rsi
call   1030 <fputc@plt>
jmp    1188 <print_string+0x58>
mov    $0x22,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
@.str.1 = [3 x i8] c"\\a\00"
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\\\\00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.10 = [3 x i8] c"%c\00"
@.str.11 = [7 x i8] c"\\x%02x\00"
define void @print_string(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32*, i32** %4
%9 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %10
10: ; preds = %85, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %88
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i32, i32* %7
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %49 [
i32 7, label %21
i32 8, label %24
i32 12, label %27
i32 10, label %30
i32 13, label %33
i32 9, label %36
i32 11, label %39
i32 -62, label %42
i32 92, label %43
i32 34, label %46
]
21: ; preds = %14
%22 = load i32*, i32** %4
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %84
24: ; preds = %14
%25 = load i32*, i32** %4
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %84
27: ; preds = %14
%28 = load i32*, i32** %4
%29 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %84
30: ; preds = %14
%31 = load i32*, i32** %4
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %84
33: ; preds = %14
%34 = load i32*, i32** %4
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %84
36: ; preds = %14
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %84
39: ; preds = %14
%40 = load i32*, i32** %4
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %84
42: ; preds = %14
br label %84
43: ; preds = %14
%44 = load i32*, i32** %4
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %84
46: ; preds = %14
%47 = load i32*, i32** %4
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %84
49: ; preds = %14
%50 = load i8*, i8** %5
%51 = load i32, i32* %7
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp sge i32 %55, 32
br i1 %56, label %57, label %74
57: ; preds = %49
%58 = load i8*, i8** %5
%59 = load i32, i32* %7
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp sle i32 %63, 126
br i1 %64, label %65, label %74
65: ; preds = %57
%66 = load i32*, i32** %4
%67 = load i8*, i8** %5
%68 = load i32, i32* %7
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32 %72)
br label %83
74: ; preds = %57, %49
%75 = load i32*, i32** %4
%76 = load i8*, i8** %5
%77 = load i32, i32* %7
%78 = zext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8, i8* %79
%81 = zext i8 %80 to i32
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %74, %65
br label %84
84: ; preds = %83, %46, %43, %42, %39, %36, %33, %30, %27, %24, %21
br label %85
85: ; preds = %84
%86 = load i32, i32* %7
%87 = add i32 %86, 1
store i32 %87, i32* %7
br label %10
88: ; preds = %10
%89 = load i32*, i32** %4
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"\\a\00"
@.str.2 = [3 x i8] c"\\b\00"
@.str.3 = [3 x i8] c"\\f\00"
@.str.4 = [3 x i8] c"\\n\00"
@.str.5 = [3 x i8] c"\\r\00"
@.str.6 = [3 x i8] c"\\t\00"
@.str.7 = [3 x i8] c"\\v\00"
@.str.8 = [3 x i8] c"\\\\\00"
@.str.9 = [3 x i8] c"\\\22\00"
@.str.11 = [7 x i8] c"\\x%02x\00"
define void @print_string(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @fputc(i32 34, i32* %0)
%5 = icmp eq i32 %2, 0
br i1 %5, label %42, label %6
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %39
%9 = phi i64 [ 0, %6 ], [ %40, %39 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %31 [
i32 7, label %13
i32 8, label %15
i32 12, label %17
i32 10, label %19
i32 13, label %21
i32 9, label %23
i32 11, label %25
i32 -62, label %39
i32 92, label %27
i32 34, label %29
]
13: ; preds = %8
%14 = 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 %39
15: ; preds = %8
%16 = 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 %39
17: ; preds = %8
%18 = 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 %39
19: ; preds = %8
%20 = 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 %39
21: ; preds = %8
%22 = 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 %39
23: ; preds = %8
%24 = 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 %39
25: ; preds = %8
%26 = 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 %39
27: ; preds = %8
%28 = 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 %39
29: ; preds = %8
%30 = 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 %39
31: ; preds = %8
%32 = add i8 %11, -127
%33 = icmp ult i8 %32, -95
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = tail call i32 @fputc(i32 %12, i32* %0)
br label %39
36: ; preds = %31
%37 = zext i8 %11 to i32
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %13, %15, %17, %19, %21, %23, %25, %8, %27, %29, %36, %34
%40 = add nuw nsw i64 %9, 1
%41 = icmp eq i64 %40, %7
br i1 %41, label %42, label %8
42: ; preds = %39, %3
%43 = tail call i32 @fputc(i32 34, i32* %0)
ret void
}