#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*/ putchar(char);
void print_escape(char *str) {
  for (; *str; str++) {
    switch (*str) {
    case ' ':
    case '\t':
      putchar('_');
      break;
    case '/':
      putchar('-');
      break;
    default:
      putchar(*str);
    }
  }
}


x86 assembly (clang, -O0):
<print_escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a3 <print_escape+0x93>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
sub    $0x9,%eax
je     1163 <print_escape+0x53>
jmp    1141 <print_escape+0x31>
mov    -0xc(%rbp),%eax
sub    $0x20,%eax
je     1163 <print_escape+0x53>
jmp    1152 <print_escape+0x42>
mov    -0xc(%rbp),%eax
sub    $0x2f,%eax
je     1172 <print_escape+0x62>
jmp    1181 <print_escape+0x71>
mov    $0x5f,%edi
call   1030 <putchar@plt>
jmp    118d <print_escape+0x7d>
mov    $0x2d,%edi
call   1030 <putchar@plt>
jmp    118d <print_escape+0x7d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
jmp    1192 <print_escape+0x82>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <print_escape+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_escape>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     114d <print_escape+0x3d>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    1135 <print_escape+0x25>
mov    %eax,%ecx
movsbl %cl,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     114d <print_escape+0x3d>
movsbl %al,%edx
mov    $0x5f,%cl
cmp    $0x9,%edx
je     1122 <print_escape+0x12>
cmp    $0x20,%edx
je     1122 <print_escape+0x12>
cmp    $0x2f,%edx
jne    1120 <print_escape+0x10>
mov    $0x2d,%cl
jmp    1122 <print_escape+0x12>
pop    %rbx
ret

LLVM IR (-O0):
define void @print_escape(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %20, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %15 [
i32 32, label %11
i32 9, label %11
i32 47, label %13
]
11: ; preds = %7, %7
%12 = call i32 @putchar(i8 signext 95)
br label %19
13: ; preds = %7
%14 = call i32 @putchar(i8 signext 45)
br label %19
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = call i32 @putchar(i8 signext %17)
br label %19
19: ; preds = %15, %13, %11
br label %20
20: ; preds = %19
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %2
br label %3
23: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @print_escape(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1, %10
%5 = phi i8 [ %14, %10 ], [ %2, %1 ]
%6 = phi i8* [ %13, %10 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
switch i32 %7, label %9 [
i32 32, label %10
i32 9, label %10
i32 47, label %8
]
8: ; preds = %4
br label %10
9: ; preds = %4
br label %10
10: ; preds = %4, %4, %8, %9
%11 = phi i8 [ 45, %8 ], [ %5, %9 ], [ 95, %4 ], [ 95, %4 ]
%12 = tail call i32 @putchar(i8 signext %11)
%13 = getelementptr inbounds i8, i8* %6, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %4
16: ; preds = %10, %1
ret void
}