#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__ isalnum(char);
void RemoveColorEscapeSequences(char *text) {
  int i, l;
  l = 0;
  for (i = 0; text[i]; i++) {
    if (((&text[i]) && *(&text[i]) == '^' && *((&text[i]) + 1) &&
         isalnum(*((&text[i]) + 1)))) {
      i++;
      continue;
    }
    if (text[i] > 0x7E)
      continue;
    text[l++] = text[i];
  }
  text[l] = '\0';
}


x86 assembly (clang, -O0):
<RemoveColorEscapeSequences>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11ee <RemoveColorEscapeSequences+0xde>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
cmp    $0x0,%rax
je     11a6 <RemoveColorEscapeSequences+0x96>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5e,%eax
jne    11a6 <RemoveColorEscapeSequences+0x96>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a6 <RemoveColorEscapeSequences+0x96>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl 0x1(%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     11a6 <RemoveColorEscapeSequences+0x96>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e0 <RemoveColorEscapeSequences+0xd0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    11c0 <RemoveColorEscapeSequences+0xb0>
jmp    11e0 <RemoveColorEscapeSequences+0xd0>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x10(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <RemoveColorEscapeSequences+0x1a>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RemoveColorEscapeSequences>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %r14d,%r14d
jmp    1131 <RemoveColorEscapeSequences+0x21>
mov    $0x5e,%al
movslq %r14d,%rcx
add    $0x1,%r14d
mov    %al,(%r15,%rcx,1)
add    $0x1,%ebp
movslq %ebp,%rbx
movzbl (%r15,%rbx,1),%eax
cmp    $0x5e,%al
je     1150 <RemoveColorEscapeSequences+0x40>
test   %al,%al
je     117a <RemoveColorEscapeSequences+0x6a>
cmp    $0x7f,%al
jne    1123 <RemoveColorEscapeSequences+0x13>
jmp    112e <RemoveColorEscapeSequences+0x1e>
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%r15,%rbx,1),%eax
test   %al,%al
je     1121 <RemoveColorEscapeSequences+0x11>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     116f <RemoveColorEscapeSequences+0x5f>
add    $0x1,%ebp
add    $0x1,%ebp
jmp    1131 <RemoveColorEscapeSequences+0x21>
movzbl (%r15,%rbx,1),%eax
cmp    $0x7f,%al
jne    1123 <RemoveColorEscapeSequences+0x13>
jmp    112e <RemoveColorEscapeSequences+0x1e>
movslq %r14d,%rax
movb   $0x0,(%r15,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @RemoveColorEscapeSequences(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %67, %1
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %70
12: ; preds = %5
%13 = load i8*, i8** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %47
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 94
br i1 %25, label %26, label %47
26: ; preds = %18
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %26
%36 = load i8*, i8** %2
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = load i8, i8* %40
%42 = call i64 @isalnum(i8 signext %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %35
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %67
47: ; preds = %35, %26, %18, %12
%48 = load i8*, i8** %2
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp sgt i32 %53, 126
br i1 %54, label %55, label %56
55: ; preds = %47
br label %67
56: ; preds = %47
%57 = load i8*, i8** %2
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = load i8*, i8** %2
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
%65 = sext i32 %63 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
store i8 %61, i8* %66
br label %67
67: ; preds = %56, %55, %44
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %5
70: ; preds = %5
%71 = load i8*, i8** %2
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 0, i8* %74
ret void
}

LLVM IR (-O2):
define void @RemoveColorEscapeSequences(i8* nocapture %0) {
br label %2
2: ; preds = %27, %1
%3 = phi i32 [ 0, %1 ], [ %30, %27 ]
%4 = phi i32 [ 0, %1 ], [ %29, %27 ]
%5 = sext i32 %3 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
switch i8 %7, label %19 [
i8 0, label %31
i8 94, label %8
]
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = tail call i64 @isalnum(i8 signext %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = add nsw i32 %3, 1
br label %27
17: ; preds = %12
%18 = load i8, i8* %6
br label %19
19: ; preds = %17, %2
%20 = phi i8 [ %18, %17 ], [ %7, %2 ]
%21 = icmp eq i8 %20, 127
br i1 %21, label %27, label %22
22: ; preds = %8, %19
%23 = phi i8 [ %20, %19 ], [ 94, %8 ]
%24 = add nsw i32 %4, 1
%25 = sext i32 %4 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
store i8 %23, i8* %26
br label %27
27: ; preds = %19, %22, %15
%28 = phi i32 [ %16, %15 ], [ %3, %19 ], [ %3, %22 ]
%29 = phi i32 [ %4, %15 ], [ %4, %19 ], [ %24, %22 ]
%30 = add nsw i32 %28, 1
br label %2
31: ; preds = %2
%32 = sext i32 %4 to i64
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
ret void
}