#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 */

/* Variables and functions */
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int strlen(char *);
void print_unescaped(char *str) {
  char *p = strchr(str, '\n');
  if (p != NULL) {
    *p = 0;
  }
  while ((p = strchr(str, '\\')) != NULL) {
    switch (p[1]) {
    case 0:
      break;
    case 'f':
      *p = '\f';
      break;
    case 'n':
      *p = '\n';
      break;
    case 'r':
      *p = '\r';
      break;
    case 't':
      *p = '\t';
      break;
    default:
      *p = p[1];
    }
    fwrite(str, 1, p - str + 1, stdout);
    str = p + 2;
  }
  fwrite(str, 1, strlen(str), stdout);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_unescaped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1170 <print_unescaped+0x30>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    1175 <print_unescaped+0x35>
mov    -0x8(%rbp),%rdi
mov    $0x5c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1268 <print_unescaped+0x128>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     11ed <print_unescaped+0xad>
jmp    11a9 <print_unescaped+0x69>
mov    -0x14(%rbp),%eax
sub    $0x66,%eax
je     11f2 <print_unescaped+0xb2>
jmp    11ba <print_unescaped+0x7a>
mov    -0x14(%rbp),%eax
sub    $0x6e,%eax
je     11fe <print_unescaped+0xbe>
jmp    11cb <print_unescaped+0x8b>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     120a <print_unescaped+0xca>
jmp    11dc <print_unescaped+0x9c>
mov    -0x14(%rbp),%eax
sub    $0x74,%eax
je     1216 <print_unescaped+0xd6>
jmp    1222 <print_unescaped+0xe2>
jmp    122f <print_unescaped+0xef>
mov    -0x10(%rbp),%rax
movb   $0xc,(%rax)
jmp    122f <print_unescaped+0xef>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
jmp    122f <print_unescaped+0xef>
mov    -0x10(%rbp),%rax
movb   $0xd,(%rax)
jmp    122f <print_unescaped+0xef>
mov    -0x10(%rbp),%rax
movb   $0x9,(%rax)
jmp    122f <print_unescaped+0xef>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
mov    0x2d95(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1060 <fwrite@plt>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1175 <print_unescaped+0x35>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
mov    0x2d5a(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1060 <fwrite@plt>
lea    0xd67(%rip),%rdi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_unescaped>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     115d <print_unescaped+0x1d>
movb   $0x0,(%rax)
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11fc <print_unescaped+0xbc>
mov    %rax,%r14
mov    0x2e63(%rip),%r15
lea    0xe7c(%rip),%r12
jmp    11c7 <print_unescaped+0x87>
mov    $0x9,%cl
nopl   0x0(%rax,%rax,1)
mov    %cl,(%r14)
mov    %r14d,%edx
sub    %ebx,%edx
add    $0x1,%edx
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <fwrite@plt>
mov    %r14,%rbx
add    $0x2,%rbx
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1050 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     11fc <print_unescaped+0xbc>
movzbl 0x1(%r14),%eax
movsbl %al,%ecx
lea    -0x66(%rcx),%edx
cmp    $0xe,%edx
ja     11f0 <print_unescaped+0xb0>
mov    $0xc,%cl
movslq (%r12,%rdx,4),%rdx
add    %r12,%rdx
jmp    *%rdx
mov    $0xa,%cl
jmp    1190 <print_unescaped+0x50>
cs nopw 0x0(%rax,%rax,1)
test   %ecx,%ecx
je     1193 <print_unescaped+0x53>
mov    %eax,%ecx
jmp    1190 <print_unescaped+0x50>
mov    $0xd,%cl
jmp    1190 <print_unescaped+0x50>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    0x2dd5(%rip),%rcx
mov    (%rcx),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1060 <fwrite@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @print_unescaped(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strchr(i8* %4, i8 signext 10)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i8*, i8** %3
store i8 0, i8* %9
br label %10
10: ; preds = %8, %1
br label %11
11: ; preds = %34, %10
%12 = load i8*, i8** %2
%13 = call i8* @strchr(i8* %12, i8 signext 92)
store i8* %13, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %47
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %29 [
i32 0, label %20
i32 102, label %21
i32 110, label %23
i32 114, label %25
i32 116, label %27
]
20: ; preds = %15
br label %34
21: ; preds = %15
%22 = load i8*, i8** %3
store i8 12, i8* %22
br label %34
23: ; preds = %15
%24 = load i8*, i8** %3
store i8 10, i8* %24
br label %34
25: ; preds = %15
%26 = load i8*, i8** %3
store i8 13, i8* %26
br label %34
27: ; preds = %15
%28 = load i8*, i8** %3
store i8 9, i8* %28
br label %34
29: ; preds = %15
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = load i8*, i8** %3
store i8 %32, i8* %33
br label %34
34: ; preds = %29, %27, %25, %23, %21, %20
%35 = load i8*, i8** %2
%36 = load i8*, i8** %3
%37 = load i8*, i8** %2
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %37 to i64
%40 = sub i64 %38, %39
%41 = add nsw i64 %40, 1
%42 = trunc i64 %41 to i32
%43 = load i32, i32* @stdout
%44 = call i32 @fwrite(i8* %35, i32 1, i32 %42, i32 %43)
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 2
store i8* %46, i8** %2
br label %11
47: ; preds = %11
%48 = load i8*, i8** %2
%49 = load i8*, i8** %2
%50 = call i32 @strlen(i8* %49)
%51 = load i32, i32* @stdout
%52 = call i32 @fwrite(i8* %48, i32 1, i32 %50, i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @print_unescaped(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%3 = icmp eq i8* %2, null
br i1 %3, label %5, label %4
4: ; preds = %1
store i8 0, i8* %2
br label %5
5: ; preds = %4, %1
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 92)
%7 = icmp eq i8* %6, null
br i1 %7, label %31, label %8
8: ; preds = %5, %20
%9 = phi i8* [ %29, %20 ], [ %6, %5 ]
%10 = phi i8* [ %28, %20 ], [ %0, %5 ]
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %17 [
i32 0, label %20
i32 102, label %18
i32 110, label %14
i32 114, label %15
i32 116, label %16
]
14: ; preds = %8
br label %18
15: ; preds = %8
br label %18
16: ; preds = %8
br label %18
17: ; preds = %8
br label %18
18: ; preds = %8, %14, %15, %16, %17
%19 = phi i8 [ %12, %17 ], [ 9, %16 ], [ 13, %15 ], [ 10, %14 ], [ 12, %8 ]
store i8 %19, i8* %9
br label %20
20: ; preds = %18, %8
%21 = ptrtoint i8* %9 to i64
%22 = ptrtoint i8* %10 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = add i32 %24, 1
%26 = load i32, i32* @stdout
%27 = tail call i32 @fwrite(i8* %10, i32 1, i32 %25, i32 %26)
%28 = getelementptr inbounds i8, i8* %9, i64 2
%29 = tail call i8* @strchr(i8* dereferenceable(1) %28, i8 signext 92)
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %8
31: ; preds = %20, %5
%32 = phi i8* [ %0, %5 ], [ %28, %20 ]
%33 = tail call i32 @strlen(i8* %32)
%34 = load i32, i32* @stdout
%35 = tail call i32 @fwrite(i8* %32, i32 1, i32 %33, i32 %34)
%36 = tail call i32 @putchar(i32 10)
ret void
}