#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 *, unsigned int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ isprint(unsigned int);
void output_c_string(FILE *out, const char *z) {
  unsigned int c;
  fputc('"', out);
  while ((c = *(z++)) != 0) {
    if (c == '\\') {
      fputc(c, out);
      fputc(c, out);
    } else if (c == '\t') {
      fputc('\\', out);
      fputc('t', out);
    } else if (c == '\n') {
      fputc('\\', out);
      fputc('n', out);
    } else if (c == '\r') {
      fputc('\\', out);
      fputc('r', out);
    } else if (!isprint(c)) {
      fprintf(out, "\\%03o", c);
    } else {
      fputc(c, out);
    }
  }
  fputc('"', out);
}


x86 assembly (clang, -O0):
<output_c_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    $0x22,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     126b <output_c_string+0x13b>
cmpl   $0x5c,-0x14(%rbp)
jne    1199 <output_c_string+0x69>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1266 <output_c_string+0x136>
cmpl   $0x9,-0x14(%rbp)
jne    11c4 <output_c_string+0x94>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x74,%edi
call   1030 <fputc@plt>
jmp    1261 <output_c_string+0x131>
cmpl   $0xa,-0x14(%rbp)
jne    11ef <output_c_string+0xbf>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x6e,%edi
call   1030 <fputc@plt>
jmp    125c <output_c_string+0x12c>
cmpl   $0xd,-0x14(%rbp)
jne    121a <output_c_string+0xea>
mov    -0x8(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x72,%edi
call   1030 <fputc@plt>
jmp    1257 <output_c_string+0x127>
mov    -0x14(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%eax
jne    1243 <output_c_string+0x113>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdc7(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1252 <output_c_string+0x122>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1257 <output_c_string+0x127>
jmp    125c <output_c_string+0x12c>
jmp    1261 <output_c_string+0x131>
jmp    1266 <output_c_string+0x136>
jmp    114e <output_c_string+0x1e>
mov    -0x8(%rbp),%rsi
mov    $0x22,%edi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_c_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x22,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
lea    0xee6(%rip),%r15
lea    0xea7(%rip),%r12
jmp    117a <output_c_string+0x4a>
nopl   0x0(%rax,%rax,1)
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x72,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0xd,%rax
ja     11b0 <output_c_string+0x80>
movslq (%r12,%rax,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x74,%edi
jmp    1172 <output_c_string+0x42>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x5c,%al
jne    11d0 <output_c_string+0xa0>
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x5c,%edi
jmp    1172 <output_c_string+0x42>
nopl   0x0(%rax,%rax,1)
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <isprint@plt>
test   %eax,%eax
je     1207 <output_c_string+0xd7>
mov    %ebp,%edi
jmp    1172 <output_c_string+0x42>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x6e,%edi
jmp    1172 <output_c_string+0x42>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <fprintf@plt>
jmp    117a <output_c_string+0x4a>
mov    $0x22,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\\%03o\00"
define void @output_c_string(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i32*, i32** %3
%7 = call i32 @fputc(i8 signext 34, i32* %6)
br label %8
8: ; preds = %67, %2
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %4
%11 = load i8, i8* %9
%12 = sext i8 %11 to i32
store i32 %12, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %68
14: ; preds = %8
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 92
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i32, i32* %5
%19 = trunc i32 %18 to i8
%20 = load i32*, i32** %3
%21 = call i32 @fputc(i8 signext %19, i32* %20)
%22 = load i32, i32* %5
%23 = trunc i32 %22 to i8
%24 = load i32*, i32** %3
%25 = call i32 @fputc(i8 signext %23, i32* %24)
br label %67
26: ; preds = %14
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 9
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32*, i32** %3
%31 = call i32 @fputc(i8 signext 92, i32* %30)
%32 = load i32*, i32** %3
%33 = call i32 @fputc(i8 signext 116, i32* %32)
br label %66
34: ; preds = %26
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i32*, i32** %3
%39 = call i32 @fputc(i8 signext 92, i32* %38)
%40 = load i32*, i32** %3
%41 = call i32 @fputc(i8 signext 110, i32* %40)
br label %65
42: ; preds = %34
%43 = load i32, i32* %5
%44 = icmp eq i32 %43, 13
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i32*, i32** %3
%47 = call i32 @fputc(i8 signext 92, i32* %46)
%48 = load i32*, i32** %3
%49 = call i32 @fputc(i8 signext 114, i32* %48)
br label %64
50: ; preds = %42
%51 = load i32, i32* %5
%52 = call i32 @isprint(i32 %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %58, label %54
54: ; preds = %50
%55 = load i32*, i32** %3
%56 = load i32, i32* %5
%57 = call i32 @fprintf(i32* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %56)
br label %63
58: ; preds = %50
%59 = load i32, i32* %5
%60 = trunc i32 %59 to i8
%61 = load i32*, i32** %3
%62 = call i32 @fputc(i8 signext %60, i32* %61)
br label %63
63: ; preds = %58, %54
br label %64
64: ; preds = %63, %45
br label %65
65: ; preds = %64, %37
br label %66
66: ; preds = %65, %29
br label %67
67: ; preds = %66, %17
br label %8
68: ; preds = %8
%69 = load i32*, i32** %3
%70 = call i32 @fputc(i8 signext 34, i32* %69)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\\%03o\00"
define void @output_c_string(i32* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 @fputc(i8 signext 34, i32* %0)
br label %4
4: ; preds = %15, %2
%5 = phi i8* [ %1, %2 ], [ %6, %15 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
switch i8 %7, label %22 [
i8 0, label %29
i8 92, label %9
i8 9, label %12
i8 10, label %16
i8 13, label %19
]
9: ; preds = %4
%10 = tail call i32 @fputc(i8 signext 92, i32* %0)
%11 = tail call i32 @fputc(i8 signext 92, i32* %0)
br label %15
12: ; preds = %4
%13 = tail call i32 @fputc(i8 signext 92, i32* %0)
%14 = tail call i32 @fputc(i8 signext 116, i32* %0)
br label %15
15: ; preds = %12, %19, %27, %25, %16, %9
br label %4
16: ; preds = %4
%17 = tail call i32 @fputc(i8 signext 92, i32* %0)
%18 = tail call i32 @fputc(i8 signext 110, i32* %0)
br label %15
19: ; preds = %4
%20 = tail call i32 @fputc(i8 signext 92, i32* %0)
%21 = tail call i32 @fputc(i8 signext 114, i32* %0)
br label %15
22: ; preds = %4
%23 = tail call i32 @isprint(i32 %8)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %15
27: ; preds = %22
%28 = tail call i32 @fputc(i8 signext %7, i32* %0)
br label %15
29: ; preds = %4
%30 = tail call i32 @fputc(i8 signext 34, i32* %0)
ret void
}