#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);
size_t next_letter_at(const char *const str, size_t starts_at) {
  for (size_t i = starts_at; str[i]; i++)
    if (isalpha(str[i]))
      return i;
  return (size_t)(-1);
}


x86 assembly (clang, -O0):
<next_letter_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1178 <next_letter_at+0x68>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalpha@plt>
cmp    $0x0,%rax
je     1162 <next_letter_at+0x52>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1180 <next_letter_at+0x70>
jmp    1167 <next_letter_at+0x57>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <next_letter_at+0x18>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_letter_at>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi,%rsi,1),%al
mov    $0xffffffffffffffff,%r14
test   %al,%al
je     1150 <next_letter_at+0x40>
mov    %rsi,%rbx
mov    %rdi,%r15
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isalpha@plt>
test   %rax,%rax
jne    114d <next_letter_at+0x3d>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <next_letter_at+0x20>
jmp    1150 <next_letter_at+0x40>
mov    %rbx,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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