#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 */
typedef char wchar_t;

/* Variables and functions */
scalar_t__ iswalnum(char const);
scalar_t__ iswspace(char const);
int /*<<< orphan*/ iswupper(int /*<<< orphan*/);
int might_be_header(const wchar_t *line) {
  if (!iswupper(*line++))
    return 0;
  while (*line && (iswalnum(*line) || *line == '-'))
    ++line;
  return (*line == ':' && iswspace(line[1]));
}


x86 assembly (clang, -O0):
<might_be_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1030 <iswupper@plt>
cmp    $0x0,%eax
jne    1168 <might_be_header+0x38>
movl   $0x0,-0x4(%rbp)
jmp    120e <might_be_header+0xde>
jmp    116d <might_be_header+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     11b6 <might_be_header+0x86>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <iswalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x12(%rbp)
jne    11b0 <might_be_header+0x80>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c6 <might_be_header+0x96>
jmp    11d7 <might_be_header+0xa7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116d <might_be_header+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x13(%rbp)
jne    1203 <might_be_header+0xd3>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1050 <iswspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<might_be_header>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <iswupper@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1195 <might_be_header+0x65>
mov    0x1(%rbx),%al
test   %al,%al
je     1195 <might_be_header+0x65>
add    $0x2,%rbx
jmp    116b <might_be_header+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1195 <might_be_header+0x65>
movsbl %al,%edi
call   1040 <iswalnum@plt>
test   %rax,%rax
jne    1160 <might_be_header+0x30>
movzbl -0x1(%rbx),%eax
cmp    $0x2d,%al
je     1160 <might_be_header+0x30>
cmp    $0x3a,%al
jne    1195 <might_be_header+0x65>
movsbl (%rbx),%edi
call   1050 <iswspace@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @might_be_header(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i32 1
store i8* %5, i8** %3
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
%8 = call i32 @iswupper(i32 %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %48
11: ; preds = %1
br label %12
12: ; preds = %31, %11
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = call i64 @iswalnum(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ true, %17 ], [ %26, %22 ]
br label %29
29: ; preds = %27, %12
%30 = phi i1 [ false, %12 ], [ %28, %27 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %3
br label %12
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 58
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = load i8, i8* %41
%43 = call i64 @iswspace(i8 signext %42)
%44 = icmp ne i64 %43, 0
br label %45
45: ; preds = %39, %34
%46 = phi i1 [ false, %34 ], [ %44, %39 ]
%47 = zext i1 %46 to i32
store i32 %47, i32* %2
br label %48
48: ; preds = %45, %10
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
define i32 @might_be_header(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = tail call i32 @iswupper(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %28, label %6
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %28, label %10
10: ; preds = %6, %18
%11 = phi i8 [ %20, %18 ], [ %8, %6 ]
%12 = phi i8* [ %19, %18 ], [ %7, %6 ]
%13 = phi i8* [ %12, %18 ], [ %0, %6 ]
%14 = tail call i64 @iswalnum(i8 signext %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = load i8, i8* %12
switch i8 %17, label %28 [
i8 45, label %18
i8 58, label %22
]
18: ; preds = %16, %10
%19 = getelementptr inbounds i8, i8* %12, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %28, label %10
22: ; preds = %16
%23 = getelementptr inbounds i8, i8* %13, i64 2
%24 = load i8, i8* %23
%25 = tail call i64 @iswspace(i8 signext %24)
%26 = icmp ne i64 %25, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %18, %16, %6, %22, %1
%29 = phi i32 [ 0, %1 ], [ %27, %22 ], [ 0, %6 ], [ 0, %16 ], [ 0, %18 ]
ret i32 %29
}