#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__ isspace(char);
unsigned find_token_len(char *cp) {
  unsigned len = 0;
  for (; *cp; ++cp) {
    if (isspace(*cp)) {
      return len;
    }
    if (*cp == '#') {
      return len;
    }
    ++len;
  }
  return len;
}


x86 assembly (clang, -O0):
<find_token_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1186 <find_token_len+0x76>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1151 <find_token_len+0x41>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <find_token_len+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    116c <find_token_len+0x5c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118c <find_token_len+0x7c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1123 <find_token_len+0x13>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_token_len>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1159 <find_token_len+0x49>
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1155 <find_token_len+0x45>
cmpb   $0x23,(%r14,%rbx,1)
je     115b <find_token_len+0x4b>
add    $0x1,%ebp
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <find_token_len+0x20>
mov    %ebx,%ebp
jmp    115b <find_token_len+0x4b>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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