#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 int int64_t;

/* Variables and functions */
int /*<<< orphan*/ isalpha(char const);
int64_t match_c_preproc(const char *str) {
  if (*str == '#') {
    const char *itr = str + 1;
    while (*itr) {
      if (!isalpha(*itr))
        break;
      itr++;
    }
    return itr - str;
  }
  return 0;
}


x86 assembly (clang, -O0):
<match_c_preproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    1183 <match_c_preproc+0x73>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1170 <match_c_preproc+0x60>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalpha@plt>
cmp    $0x0,%eax
jne    115f <match_c_preproc+0x4f>
jmp    1170 <match_c_preproc+0x60>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <match_c_preproc+0x28>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    118a <match_c_preproc+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_c_preproc>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
cmpb   $0x23,(%rdi)
jne    114c <match_c_preproc+0x3c>
mov    %rdi,%r14
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rbx
movzbl (%r14,%rcx,1),%eax
test   %al,%al
je     114c <match_c_preproc+0x3c>
movsbl %al,%edi
call   1030 <isalpha@plt>
lea    0x1(%rbx),%rcx
test   %eax,%eax
jne    1130 <match_c_preproc+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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