#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*/ tolower(int /*<<< orphan*/);
void SanitizeString(char *in, char *out) {
  while (*in) {
    if (*in == 27) {
      in += 2;
      continue;
    }
    if (*in < 32) {
      in++;
      continue;
    }
    *out++ = tolower(*in++);
  }
  *out = 0;
}


x86 assembly (clang, -O0):
<SanitizeString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     119e <SanitizeString+0x8e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1b,%eax
jne    114e <SanitizeString+0x3e>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <SanitizeString+0x10>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jge    116f <SanitizeString+0x5f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <SanitizeString+0x10>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1120 <SanitizeString+0x10>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SanitizeString>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     116d <SanitizeString+0x5d>
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2,%ecx
cmp    $0x1b,%al
je     1142 <SanitizeString+0x32>
mov    $0x1,%ecx
cmp    $0x20,%al
jge    114f <SanitizeString+0x3f>
movzbl (%rbx,%rcx,1),%eax
add    %rcx,%rbx
test   %al,%al
jne    1130 <SanitizeString+0x20>
jmp    116d <SanitizeString+0x5d>
movzbl %al,%edi
lea    0x1(%rbx),%r15
call   1030 <tolower@plt>
mov    %al,(%r14)
add    $0x1,%r14
movzbl 0x1(%rbx),%eax
mov    %r15,%rbx
test   %al,%al
jne    1130 <SanitizeString+0x20>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @SanitizeString(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %2, %20
%6 = phi i8 [ %26, %20 ], [ %3, %2 ]
%7 = phi i8* [ %25, %20 ], [ %1, %2 ]
%8 = phi i8* [ %22, %20 ], [ %0, %2 ]
br label %9
9: ; preds = %5, %13
%10 = phi i8 [ %6, %5 ], [ %16, %13 ]
%11 = phi i8* [ %8, %5 ], [ %15, %13 ]
%12 = icmp eq i8 %10, 27
br i1 %12, label %13, label %18
13: ; preds = %9, %18
%14 = phi i64 [ 1, %18 ], [ 2, %9 ]
%15 = getelementptr inbounds i8, i8* %11, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %28, label %9
18: ; preds = %9
%19 = icmp slt i8 %10, 32
br i1 %19, label %13, label %20
20: ; preds = %18
%21 = zext i8 %10 to i32
%22 = getelementptr inbounds i8, i8* %11, i64 1
%23 = tail call i32 @tolower(i32 %21)
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %24, i8* %7
%26 = load i8, i8* %22
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %5
28: ; preds = %20, %13, %2
%29 = phi i8* [ %1, %2 ], [ %7, %13 ], [ %25, %20 ]
store i8 0, i8* %29
ret void
}