#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 */
size_t label_length(char *buffer, bool strict_mode) {
  size_t length = 0;
  for (; buffer[length]; length++) {
    switch (buffer[length]) {
    case '\n':
    case ' ':
      if (strict_mode) {
        return 0;
      }
    case ':':
    case '=':
      return length;
    default:
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<label_length>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     11b9 <label_length+0xb9>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa,%eax
je     1175 <label_length+0x75>
jmp    1142 <label_length+0x42>
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
je     1175 <label_length+0x75>
jmp    1153 <label_length+0x53>
mov    -0x24(%rbp),%eax
sub    $0x3a,%eax
je     1191 <label_length+0x91>
jmp    1164 <label_length+0x64>
mov    -0x24(%rbp),%eax
sub    $0x3d,%eax
je     1191 <label_length+0x91>
jmp    119e <label_length+0x9e>
cmpl   $0x0,-0x14(%rbp)
je     118c <label_length+0x8c>
movq   $0x0,-0x8(%rbp)
jmp    11c1 <label_length+0xc1>
jmp    1191 <label_length+0x91>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c1 <label_length+0xc1>
jmp    11a3 <label_length+0xa3>
jmp    11a8 <label_length+0xa8>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1113 <label_length+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<label_length>:
mov    (%rdi),%cl
test   %cl,%cl
je     114f <label_length+0x4f>
xor    %eax,%eax
jmp    111d <label_length+0x1d>
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rdi,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
je     114f <label_length+0x4f>
movsbl %cl,%ecx
cmp    $0x39,%ecx
jg     1140 <label_length+0x40>
cmp    $0xa,%ecx
je     114b <label_length+0x4b>
cmp    $0x20,%ecx
jne    1110 <label_length+0x10>
jmp    114b <label_length+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x3a,%ecx
je     114a <label_length+0x4a>
cmp    $0x3d,%ecx
jne    1110 <label_length+0x10>
ret
test   %esi,%esi
je     114a <label_length+0x4a>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i64 @label_length(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %12
%6 = phi i8 [ %15, %12 ], [ %3, %2 ]
%7 = phi i64 [ %13, %12 ], [ 0, %2 ]
%8 = sext i8 %6 to i32
switch i32 %8, label %12 [
i32 10, label %9
i32 32, label %9
i32 58, label %11
i32 61, label %11
]
9: ; preds = %5, %5
%10 = icmp eq i32 %1, 0
br i1 %10, label %11, label %17
11: ; preds = %5, %5, %9
br label %17
12: ; preds = %5
%13 = add i64 %7, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %12, %2, %9, %11
%18 = phi i64 [ %7, %11 ], [ 0, %9 ], [ 0, %2 ], [ 0, %12 ]
ret i64 %18
}