#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__ ispunct(char const);
size_t oplen(const char *s) {
  const char *ss = s;
  while ((ispunct(*s) || isalpha(*s)) && !(*s == '(' || *s == ')')) {
    s++;
  }
  return s - ss;
}


x86 assembly (clang, -O0):
<oplen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <ispunct@plt>
cmp    $0x0,%rax
jne    1168 <oplen+0x48>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1195 <oplen+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x28,%ecx
mov    %al,-0x12(%rbp)
je     118d <oplen+0x6d>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11a5 <oplen+0x85>
jmp    11b6 <oplen+0x96>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1134 <oplen+0x14>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oplen>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <ispunct@plt>
test   %rax,%rax
jne    114e <oplen+0x2e>
movsbl (%r14,%rbx,1),%edi
call   1040 <isalpha@plt>
test   %rax,%rax
je     115f <oplen+0x3f>
movzbl (%r14,%rbx,1),%eax
and    $0xfe,%al
cmp    $0x28,%al
je     115f <oplen+0x3f>
add    $0x1,%rbx
jmp    1130 <oplen+0x10>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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