#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);
int strlen(char *);
void col2pos1(char *seq, int cstart, int *pstart) {
  int i, ix;
  ix = 0;
  if (cstart < 0) {
    (*pstart) = -1;
    return;
  }
  for (i = 0; i < strlen(seq); i++) {
    if (isalpha(seq[i]))
      ix++;
    if (i == cstart)
      break;
  }
  (*pstart) = ix - 1;
}


x86 assembly (clang, -O0):
<col2pos1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1153 <col2pos1+0x33>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    11ca <col2pos1+0xaa>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11be <col2pos1+0x9e>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     119a <col2pos1+0x7a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ab <col2pos1+0x8b>
jmp    11be <col2pos1+0x9e>
jmp    11b0 <col2pos1+0x90>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <col2pos1+0x3a>
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<col2pos1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    $0xffffffff,%ebp
test   %esi,%esi
js     117c <col2pos1+0x5c>
mov    %esi,%r15d
mov    %rdi,%r12
call   1030 <strlen@plt>
test   %eax,%eax
jle    117c <col2pos1+0x5c>
mov    %r15d,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl (%r12,%rbx,1),%edi
call   1040 <isalpha@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
cmp    %rbx,%r15
je     1179 <col2pos1+0x59>
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <col2pos1+0x30>
add    $0xffffffff,%ebp
mov    %ebp,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @col2pos1(i8* %0, i32 %1, i32* nocapture writeonly %2) {
%4 = icmp slt i32 %1, 0
br i1 %4, label %27, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = zext i32 %1 to i64
br label %14
10: ; preds = %14
%11 = tail call i32 @strlen(i8* %0)
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %24, %12
br i1 %13, label %14, label %25
14: ; preds = %8, %10
%15 = phi i64 [ 0, %8 ], [ %24, %10 ]
%16 = phi i32 [ 0, %8 ], [ %22, %10 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
%19 = tail call i64 @isalpha(i8 signext %18)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %16, %21
%23 = icmp eq i64 %15, %9
%24 = add nuw nsw i64 %15, 1
br i1 %23, label %25, label %10
25: ; preds = %14, %10
%26 = add nsw i32 %22, -1
br label %27
27: ; preds = %5, %25, %3
%28 = phi i32 [ -1, %3 ], [ -1, %5 ], [ %26, %25 ]
store i32 %28, i32* %2
ret void
}