char *whatColor(char *str, char *pos) {
  static char col[2];
  col[0] = '\0';
  while (str != pos) {
    if (*str == '&' || *str == '^' || *str == '}') {
      col[0] = *str;
      ++str;
      if (!str) {
        col[1] = '\0';
        break;
      }
      col[1] = *str;
    }
    ++str;
  }
  return col;
}


x86 assembly (clang, -O0):
<whatColor>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,0x2f0e(%rip)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     119d <whatColor+0x9d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x26,%eax
je     1151 <whatColor+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
je     1151 <whatColor+0x51>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7d,%eax
jne    118c <whatColor+0x8c>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2ec4(%rip)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1180 <whatColor+0x80>
movb   $0x0,0x2ea7(%rip)
jmp    119d <whatColor+0x9d>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2e96(%rip)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1113 <whatColor+0x13>
lea    0x2e7d(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<whatColor>:
movb   $0x0,0x2f1a(%rip)
jmp    1128 <whatColor+0x28>
nopl   0x0(%rax)
mov    %al,0x2f0b(%rip)
movzbl 0x1(%rdi),%eax
add    $0x1,%rdi
mov    %al,0x2efe(%rip)
add    $0x1,%rdi
cmp    %rsi,%rdi
je     113e <whatColor+0x3e>
movzbl (%rdi),%eax
cmp    $0x26,%al
je     1110 <whatColor+0x10>
cmp    $0x7d,%al
je     1110 <whatColor+0x10>
cmp    $0x5e,%al
je     1110 <whatColor+0x10>
jmp    1124 <whatColor+0x24>
lea    0x2edc(%rip),%rax
ret

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

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