#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 /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void print_char(FILE *f, int ch) {
  if (ch == '\n')
    fprintf(f, "\\n");
  else if (ch == '\\' || ch == '\'' || ch == '$' || ch == ')' || ch == ',')
    fprintf(f, "\\%c", ch);
  else if (ch < ' ')
    fprintf(f, "\\x%02x", ch);
  else if (ch < 0x7f)
    putc(ch, f);
  else if (ch <= 0xffff)
    fprintf(f, "\\u%04x", ch);
  else
    fprintf(f, "\\u+%06x", ch);
}


x86 assembly (clang, -O0):
<print_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    1150 <print_char+0x30>
mov    -0x8(%rbp),%rdi
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122b <print_char+0x10b>
cmpl   $0x5c,-0xc(%rbp)
je     1182 <print_char+0x62>
cmpl   $0x27,-0xc(%rbp)
je     1182 <print_char+0x62>
cmpl   $0x24,-0xc(%rbp)
je     1182 <print_char+0x62>
cmpl   $0x29,-0xc(%rbp)
je     1182 <print_char+0x62>
cmpl   $0x2c,-0xc(%rbp)
jne    119c <print_char+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1226 <print_char+0x106>
cmpl   $0x20,-0xc(%rbp)
jge    11c0 <print_char+0xa0>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1221 <print_char+0x101>
cmpl   $0x7f,-0xc(%rbp)
jge    11db <print_char+0xbb>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
jmp    121c <print_char+0xfc>
cmpl   $0xffff,-0xc(%rbp)
jg     1202 <print_char+0xe2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1217 <print_char+0xf7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    121c <print_char+0xfc>
jmp    1221 <print_char+0x101>
jmp    1226 <print_char+0x106>
jmp    122b <print_char+0x10b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_char>:
mov    %esi,%edx
mov    %rdi,%rcx
lea    -0x24(%rdx),%eax
cmp    $0x38,%eax
ja     115e <print_char+0x2e>
movabs $0x100000000000129,%rsi
bt     %rax,%rsi
jae    115e <print_char+0x2e>
lea    0xeaf(%rip),%rsi
mov    %rcx,%rdi
xor    %eax,%eax
jmp    1040 <fprintf@plt>
cmp    $0xa,%edx
jne    1179 <print_char+0x49>
lea    0xe96(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
jmp    1050 <fwrite@plt>
cmp    $0x1f,%edx
jg     1187 <print_char+0x57>
lea    0xe82(%rip),%rsi
jmp    1154 <print_char+0x24>
cmp    $0x7e,%edx
ja     1196 <print_char+0x66>
mov    %edx,%edi
mov    %rcx,%rsi
jmp    1030 <putc@plt>
cmp    $0xffff,%edx
ja     11a7 <print_char+0x77>
lea    0xe69(%rip),%rsi
jmp    1154 <print_char+0x24>
lea    0xe67(%rip),%rsi
jmp    1154 <print_char+0x24>

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"
@.str.3 = [7 x i8] c"\\u%04x\00"
@.str.4 = [8 x i8] c"\\u+%06x\00"
define void @print_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 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %58
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 92
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 39
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 36
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 41
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 44
br i1 %24, label %25, label %29
25: ; preds = %22, %19, %16, %13, %10
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %57
29: ; preds = %22
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 32
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32*, i32** %3
%34 = load i32, i32* %4
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %56
36: ; preds = %29
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 127
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* %4
%41 = load i32*, i32** %3
%42 = call i32 @putc(i32 %40, i32* %41)
br label %55
43: ; preds = %36
%44 = load i32, i32* %4
%45 = icmp sle i32 %44, 65535
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = load i32*, i32** %3
%48 = load i32, i32* %4
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %48)
br label %54
50: ; preds = %43
%51 = load i32*, i32** %3
%52 = load i32, i32* %4
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %50, %46
br label %55
55: ; preds = %54, %39
br label %56
56: ; preds = %55, %32
br label %57
57: ; preds = %56, %25
br label %58
58: ; preds = %57, %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"
@.str.3 = [7 x i8] c"\\u%04x\00"
@.str.4 = [8 x i8] c"\\u+%06x\00"
define void @print_char(i32* nocapture %0, i32 %1) {
switch i32 %1, label %7 [
i32 10, label %3
i32 92, label %5
i32 44, label %5
i32 41, label %5
i32 39, label %5
i32 36, 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 %21
5: ; preds = %2, %2, %2, %2, %2
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %21
7: ; preds = %2
%8 = icmp slt i32 %1, 32
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %21
11: ; preds = %7
%12 = icmp ult i32 %1, 127
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @putc(i32 %1, i32* %0)
br label %21
15: ; preds = %11
%16 = icmp ult i32 %1, 65536
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %1)
br label %21
19: ; preds = %15
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %21
21: ; preds = %5, %13, %19, %17, %9, %3
ret void
}