#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__ isalphabetic(char);
int strlen(char *);
int findLongWord(char *str) {
  int i, len = 0, length = 0, place = 0, flag = 1, point;
  for (i = 0; i <= strlen(str); ++i) {
    if (isalphabetic(str[i])) {
      if (flag) {
        point = i;
        flag = 0;
      } else {
        ++len;
      }
    } else {
      flag = 1;
      if (len >= length) {
        length = len;
        len = 0;
        place = point;
      }
    }
  }
  return place;
}


x86 assembly (clang, -O0):
<findLongWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11ee <findLongWord+0xce>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalphabetic@plt>
cmp    $0x0,%rax
je     11b0 <findLongWord+0x90>
cmpl   $0x0,-0x1c(%rbp)
je     11a2 <findLongWord+0x82>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
jmp    11ab <findLongWord+0x8b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11db <findLongWord+0xbb>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11d6 <findLongWord+0xb6>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11db <findLongWord+0xbb>
jmp    11e0 <findLongWord+0xc0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <findLongWord+0x2f>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findLongWord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
js     11c2 <findLongWord+0xa2>
xor    %ebp,%ebp
mov    $0x1,%r13d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
xor    %r12d,%r12d
jmp    1195 <findLongWord+0x75>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
test   %r13d,%r13d
sete   %al
mov    0x14(%rsp),%ecx
cmovne %ebp,%ecx
mov    %ecx,0x14(%rsp)
add    %eax,%r12d
xor    %r13d,%r13d
mov    %r12d,%r14d
lea    0x1(%rbp),%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    %r14d,%r12d
cmp    %rax,%rbp
mov    %r15,%rbp
jge    11ca <findLongWord+0xaa>
movsbl (%rbx,%rbp,1),%edi
call   1040 <isalphabetic@plt>
test   %rax,%rax
jne    1160 <findLongWord+0x40>
mov    $0x1,%r13d
cmp    0x10(%rsp),%r12d
jl     1179 <findLongWord+0x59>
xor    %r14d,%r14d
mov    %r12d,0x10(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0xc(%rsp)
jmp    117c <findLongWord+0x5c>
movl   $0x0,0xc(%rsp)
mov    0xc(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @findLongWord(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %1, %24
%5 = phi i64 [ %30, %24 ], [ 0, %1 ]
%6 = phi i32 [ %29, %24 ], [ undef, %1 ]
%7 = phi i32 [ %28, %24 ], [ 1, %1 ]
%8 = phi i32 [ %27, %24 ], [ 0, %1 ]
%9 = phi i32 [ %26, %24 ], [ 0, %1 ]
%10 = phi i32 [ %25, %24 ], [ 0, %1 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %5
%12 = load i8, i8* %11
%13 = tail call i64 @isalphabetic(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %4
%16 = icmp eq i32 %7, 0
%17 = zext i1 %16 to i32
%18 = add nsw i32 %10, %17
%19 = trunc i64 %5 to i32
%20 = select i1 %16, i32 %6, i32 %19
br label %24
21: ; preds = %4
%22 = icmp slt i32 %10, %9
br i1 %22, label %24, label %23
23: ; preds = %21
br label %24
24: ; preds = %15, %23, %21
%25 = phi i32 [ 0, %23 ], [ %10, %21 ], [ %18, %15 ]
%26 = phi i32 [ %10, %23 ], [ %9, %21 ], [ %9, %15 ]
%27 = phi i32 [ %6, %23 ], [ %8, %21 ], [ %8, %15 ]
%28 = phi i32 [ 1, %23 ], [ 1, %21 ], [ 0, %15 ]
%29 = phi i32 [ %6, %23 ], [ %6, %21 ], [ %20, %15 ]
%30 = add nuw nsw i64 %5, 1
%31 = tail call i32 @strlen(i8* %0)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %5, %32
br i1 %33, label %4, label %34
34: ; preds = %24, %1
%35 = phi i32 [ 0, %1 ], [ %27, %24 ]
ret i32 %35
}