#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*/ printf(char *, ...);
void color_print(char *string) {
  char c = *string++;
  while (c != '\0') {
    switch (c) {
    case 'a':;
    case 'A':
      printf("\33[37;42m");
      break;
    case 'c':;
    case 'C':
      printf("\33[37;44m");
      break;
    case 'g':;
    case 'G':
      printf("\33[37;40m");
      break;
    case 't':;
    case 'T':
      printf("\33[37;41m");
      break;
    case '-':
      printf("\33[47;30m");
      break;
    default:
      printf("\33[0m");
    }
    printf("%c", c);
    c = (*string++);
  }
  printf("\33[0m\n");
}


x86 assembly (clang, -O0):
<color_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x0,%eax
je     1213 <color_print+0x103>
movsbl -0x9(%rbp),%eax
add    $0xffffffd3,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x47,%eax
ja     11da <color_print+0xca>
mov    -0x18(%rbp),%rax
lea    0xea2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    116c <color_print+0x5c>
lea    0xfad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <color_print+0xd8>
jmp    1184 <color_print+0x74>
lea    0xf9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <color_print+0xd8>
jmp    119c <color_print+0x8c>
lea    0xf8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <color_print+0xd8>
jmp    11b4 <color_print+0xa4>
lea    0xf80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <color_print+0xd8>
lea    0xf76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <color_print+0xd8>
lea    0xf6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x9(%rbp),%esi
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
jmp    1130 <color_print+0x20>
lea    0xf3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11d7 <color_print+0xa7>
mov    %rdi,%rbx
add    $0x1,%rbx
lea    0xfcd(%rip),%r15
lea    0xea6(%rip),%r13
lea    0xfd1(%rip),%rbp
lea    0xfd3(%rip),%r12
jmp    119a <color_print+0x6a>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11d7 <color_print+0xa7>
movsbl %al,%r14d
lea    -0x2d(%r14),%eax
cmp    $0x47,%eax
ja     11ce <color_print+0x9e>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
mov    %r15,%rdi
jmp    *%rax
lea    0xf6e(%rip),%rdi
jmp    1180 <color_print+0x50>
nopl   (%rax)
mov    %rbp,%rdi
jmp    1180 <color_print+0x50>
lea    0xf78(%rip),%rdi
jmp    1180 <color_print+0x50>
lea    0xf78(%rip),%rdi
jmp    1180 <color_print+0x50>
lea    0xf6f(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"\1B[37;42m\00"
@.str.1 = [9 x i8] c"\1B[37;44m\00"
@.str.2 = [9 x i8] c"\1B[37;40m\00"
@.str.3 = [9 x i8] c"\1B[37;41m\00"
@.str.4 = [9 x i8] c"\1B[47;30m\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
@.str.6 = [3 x i8] c"%c\00"
@.str.7 = [6 x i8] c"\1B[0m\0A\00"
define void @color_print(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i32 1
store i8* %5, i8** %2
%6 = load i8, i8* %4
store i8 %6, i8* %3
br label %7
7: ; preds = %30, %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %37
11: ; preds = %7
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
switch i32 %13, label %28 [
i32 97, label %14
i32 65, label %15
i32 99, label %17
i32 67, label %18
i32 103, label %20
i32 71, label %21
i32 116, label %23
i32 84, label %24
i32 45, label %26
]
14: ; preds = %11
br label %15
15: ; preds = %11, %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %30
17: ; preds = %11
br label %18
18: ; preds = %11, %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %30
20: ; preds = %11
br label %21
21: ; preds = %11, %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %30
23: ; preds = %11
br label %24
24: ; preds = %11, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %30
26: ; preds = %11
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %30
28: ; preds = %11
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %21, %18, %15
%31 = load i8, i8* %3
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %2
%36 = load i8, i8* %34
store i8 %36, i8* %3
br label %7
37: ; preds = %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"\1B[37;42m\00"
@.str.1 = [9 x i8] c"\1B[37;44m\00"
@.str.2 = [9 x i8] c"\1B[37;40m\00"
@.str.3 = [9 x i8] c"\1B[37;41m\00"
@.str.4 = [9 x i8] c"\1B[47;30m\00"
@str = [5 x i8] c"\1B[0m\00"
define void @color_print(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %14
%5 = phi i8 [ %18, %14 ], [ %2, %1 ]
%6 = phi i8* [ %7, %14 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = sext i8 %5 to i32
switch i32 %8, label %13 [
i32 97, label %14
i32 65, label %14
i32 99, label %9
i32 67, label %9
i32 103, label %10
i32 71, label %10
i32 116, label %11
i32 84, label %11
i32 45, label %12
]
9: ; preds = %4, %4
br label %14
10: ; preds = %4, %4
br label %14
11: ; preds = %4, %4
br label %14
12: ; preds = %4
br label %14
13: ; preds = %4
br label %14
14: ; preds = %4, %4, %13, %12, %11, %10, %9
%15 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0), %13 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %4 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15)
%17 = tail call i32 @putchar(i32 %8)
%18 = load i8, i8* %7
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %14, %1
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
}