#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 */
scalar_t__ isprint(char);
char *ReturnChar(char *str) {
  static char buf[2048];
  char *ptr = buf;
  *ptr = '\0';
  while (*str) {
    if (isprint(*str)) {
      *ptr++ = *str++;
    } else {
      switch (*str) {
      case ' ':
        *ptr++ = *str;
        break;
      case '\r':
        *ptr++ = '\\';
        *ptr++ = 'r';
        break;
      }
      str++;
    }
    *ptr = '\0';
  }
  return buf;
}


x86 assembly (clang, -O0):
<ReturnChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f1d(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f9 <ReturnChar+0xe9>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isprint@plt>
cmp    $0x0,%rax
je     1178 <ReturnChar+0x68>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11ed <ReturnChar+0xdd>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0xd,%eax
je     11bd <ReturnChar+0xad>
jmp    1190 <ReturnChar+0x80>
mov    -0x14(%rbp),%eax
sub    $0x20,%eax
jne    11e1 <ReturnChar+0xd1>
jmp    11a1 <ReturnChar+0x91>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    11e1 <ReturnChar+0xd1>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5c,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x72,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    112e <ReturnChar+0x1e>
lea    0x2e40(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReturnChar>:
push   %r14
push   %rbx
push   %rax
movb   $0x0,0x2f25(%rip)
mov    (%rdi),%al
test   %al,%al
je     1182 <ReturnChar+0x72>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0x2f11(%rip),%r14
jmp    1156 <ReturnChar+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %cl,(%r14)
add    $0x1,%r14
movb   $0x0,(%r14)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1182 <ReturnChar+0x72>
movsbl %al,%edi
call   1030 <isprint@plt>
movzbl -0x1(%rbx),%ecx
test   %rax,%rax
jne    1140 <ReturnChar+0x30>
movsbl %cl,%eax
cmp    $0xd,%eax
je     1176 <ReturnChar+0x66>
cmp    $0x20,%eax
je     1140 <ReturnChar+0x30>
jmp    1147 <ReturnChar+0x37>
movw   $0x725c,(%r14)
add    $0x2,%r14
jmp    1147 <ReturnChar+0x37>
lea    0x2eb7(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ReturnChar.buf = internal global [2048 x i8] zeroinitializer
define i8* @ReturnChar(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @ReturnChar.buf, i64 0, i64 0), i8** %3
%4 = load i8*, i8** %3
store i8 0, i8* %4
br label %5
5: ; preds = %37, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %39
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = call i64 @isprint(i8 signext %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
%17 = load i8, i8* %15
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 %17, i8* %18
br label %37
20: ; preds = %9
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
switch i32 %23, label %34 [
i32 32, label %24
i32 13, label %29
]
24: ; preds = %20
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
store i8 %26, i8* %27
br label %34
29: ; preds = %20
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
store i8 92, i8* %30
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
store i8 114, i8* %32
br label %34
34: ; preds = %20, %29, %24
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %37
37: ; preds = %34, %14
%38 = load i8*, i8** %3
store i8 0, i8* %38
br label %5
39: ; preds = %5
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @ReturnChar.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@ReturnChar.buf = internal global [2048 x i8] zeroinitializer
define i8* @ReturnChar(i8* nocapture %0) {
store i8 0, i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @ReturnChar.buf, i64 0, i64 0)
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %25, label %4
4: ; preds = %1, %20
%5 = phi i8 [ %23, %20 ], [ %2, %1 ]
%6 = phi i8* [ %21, %20 ], [ getelementptr inbounds ([2048 x i8], [2048 x i8]* @ReturnChar.buf, i64 0, i64 0), %1 ]
%7 = phi i8* [ %22, %20 ], [ %0, %1 ]
%8 = tail call i64 @isprint(i8 signext %5)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %7
br i1 %9, label %13, label %11
11: ; preds = %4
%12 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %10, i8* %6
br label %20
13: ; preds = %4
%14 = sext i8 %10 to i32
switch i32 %14, label %20 [
i32 32, label %15
i32 13, label %17
]
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %10, i8* %6
br label %20
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %6, i64 1
store i8 92, i8* %6
%19 = getelementptr inbounds i8, i8* %6, i64 2
store i8 114, i8* %18
br label %20
20: ; preds = %15, %17, %13, %11
%21 = phi i8* [ %12, %11 ], [ %6, %13 ], [ %19, %17 ], [ %16, %15 ]
%22 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %4
25: ; preds = %20, %1
ret i8* getelementptr inbounds ([2048 x i8], [2048 x i8]* @ReturnChar.buf, i64 0, i64 0)
}