#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 */
int /*<<< orphan*/ isalpha(char);
int next_pos(char *seq, int len, int p) {
  p++;
  if (p >= len)
    return (len - 1);
  while (!isalpha(seq[p]) && p < len)
    p++;
  return p;
}


x86 assembly (clang, -O0):
<next_pos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1145 <next_pos+0x35>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    119b <next_pos+0x8b>
jmp    114a <next_pos+0x3a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalpha@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1177 <next_pos+0x67>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setl   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1187 <next_pos+0x77>
jmp    1195 <next_pos+0x85>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <next_pos+0x3a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_pos>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
lea    0x1(%r12),%eax
cmp    %esi,%eax
jge    1150 <next_pos+0x40>
mov    %rdi,%r14
movslq %eax,%rbx
movslq %esi,%r15
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <isalpha@plt>
add    $0x1,%r12d
test   %eax,%eax
jne    1156 <next_pos+0x46>
lea    0x1(%rbx),%rax
cmp    %r15,%rbx
mov    %rax,%rbx
jl     1130 <next_pos+0x20>
jmp    1156 <next_pos+0x46>
add    $0xffffffff,%esi
mov    %esi,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @next_pos(i8* nocapture %0, i32 %1, i32 %2) {
%4 = add i32 %2, 1
%5 = icmp slt i32 %4, %1
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = sext i32 %1 to i64
br label %11
9: ; preds = %3
%10 = add nsw i32 %1, -1
br label %22
11: ; preds = %6, %11
%12 = phi i64 [ %7, %6 ], [ %19, %11 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = tail call i32 @isalpha(i8 signext %14)
%16 = icmp eq i32 %15, 0
%17 = icmp slt i64 %12, %8
%18 = select i1 %16, i1 %17, i1 false
%19 = add nsw i64 %12, 1
br i1 %18, label %11, label %20
20: ; preds = %11
%21 = trunc i64 %12 to i32
br label %22
22: ; preds = %20, %9
%23 = phi i32 [ %10, %9 ], [ %21, %20 ]
ret i32 %23
}