#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 strlen(char *);
scalar_t__ strstr(char *, char *);
bool has_double_pair(char *text) {
  int i = 0;
  char pair[3] = {'x', 'x', '\0'};
  for (; i <= strlen(text) - 3; i++) {
    pair[0] = text[i];
    pair[1] = text[i + 1];
    if (strstr(&text[i + 2], pair)) {
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<has_double_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xec6(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xebe(%rip),%al
mov    %al,-0x15(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    $0x3,%ecx
cmp    %ecx,%eax
jg     11c8 <has_double_pair+0xa8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x17(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x16(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    $0x2,%eax
cltq
add    %rax,%rdi
lea    -0x17(%rbp),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11b5 <has_double_pair+0x95>
movl   $0x1,-0x4(%rbp)
jmp    11cf <has_double_pair+0xaf>
jmp    11ba <has_double_pair+0x9a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <has_double_pair+0x27>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_double_pair>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
movb   $0x0,0xe(%rsp)
movw   $0x7878,0xc(%rsp)
lea    0x2(%rdi),%rbx
xor    %r14d,%r14d
lea    0xc(%rsp),%r12
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strlen@plt>
add    $0xfffffffd,%eax
cltq
cmp    %rax,%r13
jg     1190 <has_double_pair+0x70>
movzbl -0x2(%rbx),%eax
mov    %al,0xc(%rsp)
add    $0x1,%r13
movzbl -0x1(%rbx),%eax
mov    %al,0xd(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strstr@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1150 <has_double_pair+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.has_double_pair.pair = [3 x i8] c"xx\00"
define i32 @has_double_pair(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [3 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = bitcast [3 x i8]* %5 to i8*
br label %7
7: ; preds = %37, %1
%8 = load i32, i32* %4
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = sub nsw i32 %10, 3
%12 = icmp sle i32 %8, %11
br i1 %12, label %13, label %40
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
store i8 %18, i8* %19
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 1
store i8 %25, i8* %26
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%33 = call i64 @strstr(i8* %31, i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %13
store i32 1, i32* %2
br label %41
36: ; preds = %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %7
40: ; preds = %7
store i32 0, i32* %2
br label %41
41: ; preds = %40, %35
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@__const.has_double_pair.pair = [3 x i8] c"xx\00"
define i32 @has_double_pair(i8* %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
br label %5
5: ; preds = %11, %1
%6 = phi i64 [ %14, %11 ], [ 0, %1 ]
%7 = call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, -3
%9 = sext i32 %8 to i64
%10 = icmp sgt i64 %6, %9
br i1 %10, label %21, label %11
11: ; preds = %5
%12 = getelementptr inbounds i8, i8* %0, i64 %6
%13 = load i8, i8* %12
store i8 %13, i8* %3
%14 = add nuw nsw i64 %6, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %4
%17 = add nuw nsw i64 %6, 2
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = call i64 @strstr(i8* %18, i8* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %5, label %21
21: ; preds = %5, %11
%22 = phi i32 [ 1, %11 ], [ 0, %5 ]
ret i32 %22
}