#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 *, int);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void print_escaped_char(FILE *f, int c) {
  if (c == '\n')
    fputs("\\n", f);
  else if (c == '\\' || c == '\'')
    fprintf(f, "\\%c", c);
  else if (c < 0x20 || c >= 0x7f)
    fprintf(f, "\\x%02x", 0xff & c);
  else
    fputc(c, f);
}


x86 assembly (clang, -O0):
<print_escaped_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    115e <print_escaped_char+0x2e>
mov    -0x8(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <fputs@plt>
jmp    11d2 <print_escaped_char+0xa2>
cmpl   $0x5c,-0xc(%rbp)
je     1172 <print_escaped_char+0x42>
cmpl   $0x27,-0xc(%rbp)
jne    118a <print_escaped_char+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11cd <print_escaped_char+0x9d>
cmpl   $0x20,-0xc(%rbp)
jl     119e <print_escaped_char+0x6e>
cmpl   $0x7f,-0xc(%rbp)
jl     11bc <print_escaped_char+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
and    $0xff,%edx
lea    0xe55(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11c8 <print_escaped_char+0x98>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <fputc@plt>
jmp    11cd <print_escaped_char+0x9d>
jmp    11d2 <print_escaped_char+0xa2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_escaped_char>:
mov    %esi,%edx
mov    %rdi,%rcx
cmp    $0x5c,%esi
je     115a <print_escaped_char+0x2a>
cmp    $0x27,%edx
je     115a <print_escaped_char+0x2a>
cmp    $0xa,%edx
jne    1169 <print_escaped_char+0x39>
lea    0xeb5(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
jmp    1050 <fwrite@plt>
lea    0xea2(%rip),%rsi
mov    %rcx,%rdi
jmp    1040 <fprintf@plt>
lea    -0x7f(%rdx),%eax
cmp    $0xffffffa0,%eax
ja     1183 <print_escaped_char+0x53>
movzbl %dl,%edx
lea    0xe8c(%rip),%rsi
mov    %rcx,%rdi
jmp    1040 <fprintf@plt>
mov    %edx,%edi
mov    %rcx,%rsi
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\n\00"
@.str.1 = [4 x i8] c"\\%c\00"
@.str.2 = [7 x i8] c"\\x%02x\00"
define void @print_escaped_char(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 10
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32*, i32** %3
%9 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
br label %37
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 92
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 39
br i1 %15, label %16, label %20
16: ; preds = %13, %10
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %36
20: ; preds = %13
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 32
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp sge i32 %24, 127
br i1 %25, label %26, label %31
26: ; preds = %23, %20
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = and i32 255, %28
%30 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %35
31: ; preds = %23
%32 = load i32, i32* %4
%33 = load i32*, i32** %3
%34 = call i32 @fputc(i32 %32, i32* %33)
br label %35
35: ; preds = %31, %26
br label %36
36: ; preds = %35, %16
br label %37
37: ; preds = %36, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\n\00"
@.str.1 = [4 x i8] c"\\%c\00"
@.str.2 = [7 x i8] c"\\x%02x\00"
define void @print_escaped_char(i32* nocapture %0, i32 %1) {
switch i32 %1, label %7 [
i32 10, label %3
i32 92, label %5
i32 39, label %5
]
3: ; preds = %2
%4 = 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 %15
5: ; preds = %2, %2
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %15
7: ; preds = %2
%8 = add i32 %1, -127
%9 = icmp ult i32 %8, -95
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = and i32 %1, 255
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %15
13: ; preds = %7
%14 = tail call i32 @fputc(i32 %1, i32* %0)
br label %15
15: ; preds = %5, %13, %10, %3
ret void
}