char *bash_color(const char *txt) {
  const char *point;
  char *point2;
  static char buf[8192 * 4];
  buf[0] = '\0';
  point2 = buf;
  for (point = txt; *point; point++) {
    if (*point == '{' && *(point + 1) != '\0') {
      point++;
      continue;
    }
    *point2 = *point;
    *++point2 = '\0';
  }
  *point2 = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<bash_color>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movb   $0x0,0x2f21(%rip)
lea    0x2f1a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1191 <bash_color+0x91>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7b,%eax
jne    1161 <bash_color+0x61>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1161 <bash_color+0x61>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1180 <bash_color+0x80>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1122 <bash_color+0x22>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e91(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bash_color>:
movb   $0x0,0x2f29(%rip)
lea    0x2f22(%rip),%rax
jmp    1122 <bash_color+0x22>
test   %cl,%cl
je     113a <bash_color+0x3a>
mov    %cl,(%rax)
movb   $0x0,0x1(%rax)
add    $0x1,%rax
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x7b,%cl
jne    1110 <bash_color+0x10>
cmpb   $0x0,0x1(%rdi)
je     1114 <bash_color+0x14>
add    $0x1,%rdi
add    $0x1,%rdi
jmp    1122 <bash_color+0x22>
movb   $0x0,(%rax)
lea    0x2eec(%rip),%rax
ret

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

LLVM IR (-O2):
@bash_color.buf = internal global [32768 x i8] zeroinitializer
define i8* @bash_color(i8* nocapture %0) {
store i8 0, i8* getelementptr inbounds ([32768 x i8], [32768 x i8]* @bash_color.buf, i64 0, i64 0)
br label %2
2: ; preds = %12, %1
%3 = phi i8* [ %0, %1 ], [ %15, %12 ]
%4 = phi i8* [ getelementptr inbounds ([32768 x i8], [32768 x i8]* @bash_color.buf, i64 0, i64 0), %1 ], [ %14, %12 ]
%5 = load i8, i8* %3
switch i8 %5, label %10 [
i8 0, label %16
i8 123, label %6
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2, %6
store i8 %5, i8* %4
%11 = getelementptr inbounds i8, i8* %4, i64 1
store i8 0, i8* %11
br label %12
12: ; preds = %6, %10
%13 = phi i8* [ %3, %10 ], [ %7, %6 ]
%14 = phi i8* [ %11, %10 ], [ %4, %6 ]
%15 = getelementptr inbounds i8, i8* %13, i64 1
br label %2
16: ; preds = %2
store i8 0, i8* %4
ret i8* getelementptr inbounds ([32768 x i8], [32768 x i8]* @bash_color.buf, i64 0, i64 0)
}