char *findSpecDestination(char *spec) {
  char *dest = spec;
  while (*dest != ':' && *dest != '\0') {
    dest++;
  }
  switch (*dest) {
  case ':':
    *dest = '\0';
    return dest + 1;
  case '\0':
    return spec;
  default:
    return spec;
  }
}


x86 assembly (clang, -O0):
<findSpecDestination>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x19(%rbp)
je     1135 <findSpecDestination+0x35>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1145 <findSpecDestination+0x45>
jmp    1156 <findSpecDestination+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1110 <findSpecDestination+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     1196 <findSpecDestination+0x96>
jmp    116d <findSpecDestination+0x6d>
mov    -0x20(%rbp),%eax
sub    $0x3a,%eax
jne    11a3 <findSpecDestination+0xa3>
jmp    117e <findSpecDestination+0x7e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <findSpecDestination+0xab>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <findSpecDestination+0xab>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<findSpecDestination>:
lea    0x1(%rdi),%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl -0x1(%rax),%ecx
test   %cl,%cl
je     1123 <findSpecDestination+0x23>
cmp    $0x3a,%cl
je     1127 <findSpecDestination+0x27>
add    $0x1,%rax
jmp    1110 <findSpecDestination+0x10>
mov    %rdi,%rax
ret
movb   $0x0,-0x1(%rax)
ret

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

LLVM IR (-O2):
define i8* @findSpecDestination(i8* %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 58, label %7
i8 0, label %9
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
store i8 0, i8* %3
%8 = getelementptr inbounds i8, i8* %3, i64 1
br label %9
9: ; preds = %2, %7
%10 = phi i8* [ %8, %7 ], [ %0, %2 ]
ret i8* %10
}