#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*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
void print_sym(FILE *out, int sym) {
  if (sym == '\n') {
    fputs("\\n", out);
  } else if (sym == '"') {
    fputs("\\\"", out);
  } else if (sym == '\\') {
    fputs("\\\\", out);
  } else {
    fputc(sym, out);
  }
}


x86 assembly (clang, -O0):
<print_sym>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    114e <print_sym+0x2e>
mov    -0x8(%rbp),%rsi
lea    0xebc(%rip),%rdi
call   1030 <fputs@plt>
jmp    11a2 <print_sym+0x82>
cmpl   $0x22,-0xc(%rbp)
jne    116d <print_sym+0x4d>
mov    -0x8(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1030 <fputs@plt>
jmp    119d <print_sym+0x7d>
cmpl   $0x5c,-0xc(%rbp)
jne    118c <print_sym+0x6c>
mov    -0x8(%rbp),%rsi
lea    0xe84(%rip),%rdi
call   1030 <fputs@plt>
jmp    1198 <print_sym+0x78>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <fputc@plt>
jmp    119d <print_sym+0x7d>
jmp    11a2 <print_sym+0x82>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sym>:
mov    %rdi,%rcx
cmp    $0x5c,%esi
je     113b <print_sym+0x1b>
cmp    $0x22,%esi
je     1144 <print_sym+0x24>
cmp    $0xa,%esi
jne    115a <print_sym+0x3a>
lea    0xec7(%rip),%rdi
jmp    114b <print_sym+0x2b>
lea    0xec4(%rip),%rdi
jmp    114b <print_sym+0x2b>
lea    0xeb8(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
jmp    1040 <fwrite@plt>
mov    %esi,%edi
mov    %rcx,%rsi
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\\n\00"
@.str.1 = [3 x i8] c"\\\22\00"
@.str.2 = [3 x i8] c"\\\\\00"
define void @print_sym(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 %28
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 34
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32*, i32** %3
%15 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
br label %27
16: ; preds = %10
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 92
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32*, i32** %3
%21 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %20)
br label %26
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i32*, i32** %3
%25 = call i32 @fputc(i32 %23, i32* %24)
br label %26
26: ; preds = %22, %19
br label %27
27: ; preds = %26, %13
br label %28
28: ; preds = %27, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\n\00"
@.str.1 = [3 x i8] c"\\\22\00"
@.str.2 = [3 x i8] c"\\\\\00"
define void @print_sym(i32* nocapture %0, i32 %1) {
switch i32 %1, label %9 [
i32 10, label %3
i32 34, label %5
i32 92, label %7
]
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 %11
5: ; preds = %2
%6 = 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 %11
7: ; preds = %2
%8 = 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 %11
9: ; preds = %2
%10 = tail call i32 @fputc(i32 %1, i32* %0)
br label %11
11: ; preds = %5, %9, %7, %3
ret void
}