#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 & 0xff);
    } 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     1271 <output_c_string+0x141>
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    126c <output_c_string+0x13c>
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    1267 <output_c_string+0x137>
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    1262 <output_c_string+0x132>
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    125d <output_c_string+0x12d>
mov    -0x14(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%eax
jne    1249 <output_c_string+0x119>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
and    $0xff,%edx
lea    0xdc1(%rip),%rsi
call   1040 <fprintf@plt>
jmp    1258 <output_c_string+0x128>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    125d <output_c_string+0x12d>
jmp    1262 <output_c_string+0x132>
jmp    1267 <output_c_string+0x137>
jmp    126c <output_c_string+0x13c>
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   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x22,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
lea    0xee3(%rip),%r15
lea    0xea4(%rip),%r12
jmp    117a <output_c_string+0x4a>
xchg   %ax,%ax
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x72,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
movzbl (%rbx),%ebp
add    $0x1,%rbx
cmp    $0xd,%rbp
ja     11b0 <output_c_string+0x80>
movslq (%r12,%rbp,4),%rax
add    %r12,%rax
jmp    *%rax
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,%bpl
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>
nopw   0x0(%rax,%rax,1)
movsbl %bpl,%r13d
mov    %r13d,%edi
call   1050 <isprint@plt>
test   %eax,%eax
je     1207 <output_c_string+0xd7>
mov    %r13d,%edi
jmp    1172 <output_c_string+0x42>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x6e,%edi
jmp    1172 <output_c_string+0x42>
movzbl %bpl,%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
jmp    117a <output_c_string+0x4a>
mov    $0x22,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = %68, %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 %69
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 %68
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 %67
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 %66
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 %65
50: ; preds = %42
%51 = load i32, i32* %5
%52 = call i32 @isprint(i32 %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %50
%55 = load i32*, i32** %3
%56 = load i32, i32* %5
%57 = and i32 %56, 255
%58 = call i32 @fprintf(i32* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %57)
br label %64
59: ; preds = %50
%60 = load i32, i32* %5
%61 = trunc i32 %60 to i8
%62 = load i32*, i32** %3
%63 = call i32 @fputc(i8 signext %61, i32* %62)
br label %64
64: ; preds = %59, %54
br label %65
65: ; preds = %64, %45
br label %66
66: ; preds = %65, %37
br label %67
67: ; preds = %66, %29
br label %68
68: ; preds = %67, %17
br label %8
69: ; preds = %8
%70 = load i32*, i32** %3
%71 = call i32 @fputc(i8 signext 34, i32* %70)
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 %30
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, %28, %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 %28
25: ; preds = %22
%26 = and i32 %8, 255
%27 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %15
28: ; preds = %22
%29 = tail call i32 @fputc(i8 signext %7, i32* %0)
br label %15
30: ; preds = %4
%31 = tail call i32 @fputc(i8 signext 34, i32* %0)
ret void
}