#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*/ isprint(unsigned char);
void strip_evil_characters(char *badstring) {
  unsigned char *s = (unsigned char *)badstring;
  if (!s)
    return;
  for (; *s; ++s) {
    *s &= '\177';
    if (*s == '\033')
      *s = '[';
    if (!isprint(*s))
      *s = '_';
  }
  return;
}


x86 assembly (clang, -O0):
<strip_evil_characters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <strip_evil_characters+0x24>
jmp    11a0 <strip_evil_characters+0x90>
jmp    1139 <strip_evil_characters+0x29>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119b <strip_evil_characters+0x8b>
mov    -0x10(%rbp),%rax
movzbl (%rax),%ecx
and    $0x7f,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x1b,%eax
jne    1169 <strip_evil_characters+0x59>
mov    -0x10(%rbp),%rax
movb   $0x5b,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
jne    1185 <strip_evil_characters+0x75>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
jmp    118a <strip_evil_characters+0x7a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1139 <strip_evil_characters+0x29>
jmp    11a0 <strip_evil_characters+0x90>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_evil_characters>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     1159 <strip_evil_characters+0x49>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1159 <strip_evil_characters+0x49>
mov    $0x5b,%ebp
jmp    113c <strip_evil_characters+0x2c>
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1159 <strip_evil_characters+0x49>
and    $0x7f,%al
cmp    $0x1b,%al
movzbl %al,%eax
cmove  %ebp,%eax
mov    %al,(%rbx)
movzbl %al,%edi
call   1030 <isprint@plt>
test   %eax,%eax
jne    1130 <strip_evil_characters+0x20>
movb   $0x5f,(%rbx)
jmp    1130 <strip_evil_characters+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @strip_evil_characters(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
br label %37
8: ; preds = %1
br label %9
9: ; preds = %33, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 127
%18 = trunc i32 %17 to i8
store i8 %18, i8* %14
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp eq i32 %21, 27
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i8*, i8** %3
store i8 91, i8* %24
br label %25
25: ; preds = %23, %13
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = call i32 @isprint(i8 zeroext %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = load i8*, i8** %3
store i8 95, i8* %31
br label %32
32: ; preds = %30, %25
br label %33
33: ; preds = %32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
br label %9
36: ; preds = %9
br label %37
37: ; preds = %36, %7
ret void
}

LLVM IR (-O2):
define void @strip_evil_characters(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %15
%7 = phi i8 [ %17, %15 ], [ %4, %3 ]
%8 = phi i8* [ %16, %15 ], [ %0, %3 ]
%9 = and i8 %7, 127
%10 = icmp eq i8 %9, 27
%11 = select i1 %10, i8 91, i8 %9
store i8 %11, i8* %8
%12 = tail call i32 @isprint(i8 zeroext %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %6
store i8 95, i8* %8
br label %15
15: ; preds = %6, %14
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %15, %3, %1
ret void
}