#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__ tolower(char);
int has_more_than_2eq(char *w) {
  char *c;
  int equal;
  while (*w) {
    c = w + 1;
    equal = 1;
    while (*c) {
      if (tolower(*w) == tolower(*c))
        equal++;
      c++;
    }
    if (equal > 2)
      return 1;
    w++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<has_more_than_2eq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b6 <has_more_than_2eq+0xa6>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118f <has_more_than_2eq+0x7f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jne    117e <has_more_than_2eq+0x6e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113c <has_more_than_2eq+0x2c>
cmpl   $0x2,-0x1c(%rbp)
jle    11a5 <has_more_than_2eq+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11bd <has_more_than_2eq+0xad>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    111c <has_more_than_2eq+0xc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_more_than_2eq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     11b7 <has_more_than_2eq+0xa7>
mov    %rdi,%r12
lea    0x3(%rdi),%r15
nop
cmpb   $0x0,0x1(%r12)
je     11b7 <has_more_than_2eq+0xa7>
movsbl %al,%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movsbl 0x1(%r12),%edi
call   1030 <tolower@plt>
xor    %ebx,%ebx
cmp    %rax,%rbp
sete   %bl
add    $0x1,%ebx
cmpb   $0x0,0x2(%r12)
je     119a <has_more_than_2eq+0x8a>
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r12),%edi
call   1030 <tolower@plt>
mov    %rax,%r13
movsbl -0x1(%rbp),%edi
call   1030 <tolower@plt>
xor    %ecx,%ecx
cmp    %rax,%r13
sete   %cl
add    %ecx,%ebx
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    1170 <has_more_than_2eq+0x60>
cmp    $0x3,%ebx
jae    11b1 <has_more_than_2eq+0xa1>
add    $0x1,%r12
mov    (%r12),%al
add    $0x1,%r15
test   %al,%al
jne    1130 <has_more_than_2eq+0x20>
jmp    11b7 <has_more_than_2eq+0xa7>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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