#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__ isalpha(char const);
scalar_t__ isspace(char const);
char *detect_field(const char *line) {
  while (isspace(*line))
    line++;
  return ((isalpha(*line) && ':' == *(line + 1)) ? (char *)line : NULL);
}


x86 assembly (clang, -O0):
<detect_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1153 <detect_field+0x33>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <detect_field+0xc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     118b <detect_field+0x6b>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%ecx
mov    $0x3a,%eax
cmp    %ecx,%eax
jne    118b <detect_field+0x6b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1196 <detect_field+0x76>
xor    %eax,%eax
mov    %rax,-0x10(%rbp)
jmp    1196 <detect_field+0x76>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detect_field>:
push   %rbx
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    1130 <detect_field+0x10>
movsbl (%rbx),%edi
call   1040 <isalpha@plt>
test   %rax,%rax
je     115b <detect_field+0x3b>
xor    %eax,%eax
cmpb   $0x3a,0x1(%rbx)
cmove  %rbx,%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @detect_field(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %8, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = call i64 @isspace(i8 signext %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
br label %3
11: ; preds = %3
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i64 @isalpha(i8 signext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 58, %20
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i8*, i8** %2
br label %25
24: ; preds = %16, %11
br label %25
25: ; preds = %24, %22
%26 = phi i8* [ %23, %22 ], [ null, %24 ]
ret i8* %26
}

LLVM IR (-O2):
define i8* @detect_field(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = load i8, i8* %3
%10 = tail call i64 @isalpha(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i8, i8* %7
%14 = icmp eq i8 %13, 58
%15 = select i1 %14, i8* %3, i8* null
br label %16
16: ; preds = %12, %8
%17 = phi i8* [ null, %8 ], [ %15, %12 ]
ret i8* %17
}