#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 fn_cl_65_91_97_122(char const *);
int fn_qtg_5_8_cl_65_91_97_122(const char *text) {
  int pos = 0, p = 0, count = 0;
  while (count < 8 && (p = fn_cl_65_91_97_122(text + pos)) != -1) {
    pos += p;
    count++;
  }
  if (count >= 5)
    return pos;
  return -1;
}


x86 assembly (clang, -O0):
<fn_qtg_5_8_cl_65_91_97_122>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jge    115c <fn_qtg_5_8_cl_65_91_97_122+0x4c>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    116c <fn_qtg_5_8_cl_65_91_97_122+0x5c>
jmp    1183 <fn_qtg_5_8_cl_65_91_97_122+0x73>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <fn_qtg_5_8_cl_65_91_97_122+0x21>
cmpl   $0x5,-0x1c(%rbp)
jl     1198 <fn_qtg_5_8_cl_65_91_97_122+0x88>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119f <fn_qtg_5_8_cl_65_91_97_122+0x8f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn_qtg_5_8_cl_65_91_97_122>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1030 <fn_cl_65_91_97_122@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %eax,%ebx
movslq %eax,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %eax,%ebp
add    %ebx,%ebp
movslq %ebp,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %eax,%ebx
add    %ebp,%ebx
movslq %ebx,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %eax,%ebp
add    %ebx,%ebp
movslq %ebp,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %eax,%r15d
add    %ebp,%r15d
movslq %r15d,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11cb <fn_qtg_5_8_cl_65_91_97_122+0xbb>
mov    %eax,%r14d
add    %r15d,%r14d
movslq %r14d,%rdi
add    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
cmp    $0xffffffff,%eax
je     11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
add    %r14d,%eax
movslq %eax,%r14
add    %r14,%r12
mov    %r12,%rdi
call   1030 <fn_cl_65_91_97_122@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
cmovne %eax,%ecx
add    %ecx,%r14d
jmp    11ce <fn_qtg_5_8_cl_65_91_97_122+0xbe>
mov    %r15d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @fn_qtg_5_8_cl_65_91_97_122(i8* %0) {
%2 = tail call i32 @fn_cl_65_91_97_122(i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %47, label %4
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i32 @fn_cl_65_91_97_122(i8* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %47, label %9
9: ; preds = %4
%10 = add nsw i32 %7, %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @fn_cl_65_91_97_122(i8* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %47, label %15
15: ; preds = %9
%16 = add nsw i32 %13, %10
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = tail call i32 @fn_cl_65_91_97_122(i8* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %47, label %21
21: ; preds = %15
%22 = add nsw i32 %19, %16
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
%25 = tail call i32 @fn_cl_65_91_97_122(i8* %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %47, label %27
27: ; preds = %21
%28 = add nsw i32 %25, %22
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = tail call i32 @fn_cl_65_91_97_122(i8* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %47, label %33
33: ; preds = %27
%34 = add nsw i32 %31, %28
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %0, i64 %35
%37 = tail call i32 @fn_cl_65_91_97_122(i8* %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %47, label %39
39: ; preds = %33
%40 = add nsw i32 %37, %34
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %0, i64 %41
%43 = tail call i32 @fn_cl_65_91_97_122(i8* %42)
%44 = icmp eq i32 %43, -1
%45 = select i1 %44, i32 0, i32 %43
%46 = add nsw i32 %40, %45
br label %47
47: ; preds = %39, %33, %27, %21, %15, %9, %4, %1
%48 = phi i32 [ -1, %1 ], [ -1, %4 ], [ -1, %9 ], [ -1, %15 ], [ -1, %21 ], [ %28, %27 ], [ %34, %33 ], [ %46, %39 ]
ret i32 %48
}