#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 */
typedef scalar_t__ u_char;

/* Variables and functions */
scalar_t__ _tolower(scalar_t__);
scalar_t__ *binary_search(scalar_t__ *, scalar_t__ *, scalar_t__ *);
scalar_t__ isupper(scalar_t__);
scalar_t__ *linear_search(scalar_t__ *, scalar_t__ *, scalar_t__ *);
int look(u_char *string, u_char *front, u_char *back) {
  u_char *s;
  for (s = string; *s; s++) {
    if (isupper(*s))
      *s = _tolower(*s);
  }
  front = binary_search(string, front, back);
  front = linear_search(string, front, back);
  return (front != NULL);
}


x86 assembly (clang, -O0):
<look>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ac <look+0x6c>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1196 <look+0x56>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <_tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    119b <look+0x5b>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <look+0x1c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <binary_search@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <linear_search@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<look>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1184 <look+0x44>
mov    %r12,%rbx
jmp    116d <look+0x2d>
xchg   %ax,%ax
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1184 <look+0x44>
call   1040 <isupper@plt>
test   %rax,%rax
je     1160 <look+0x20>
mov    (%rbx),%rdi
call   1060 <_tolower@plt>
mov    %rax,(%rbx)
jmp    1160 <look+0x20>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <binary_search@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <linear_search@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @look(i64* %0, i64* %1, i64* %2) {
%4 = alloca i64*
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64*
store i64* %0, i64** %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%8 = load i64*, i64** %4
store i64* %8, i64** %7
br label %9
9: ; preds = %24, %3
%10 = load i64*, i64** %7
%11 = load i64, i64* %10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i64*, i64** %7
%15 = load i64, i64* %14
%16 = call i64 @isupper(i64 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i64*, i64** %7
%20 = load i64, i64* %19
%21 = call i64 @_tolower(i64 %20)
%22 = load i64*, i64** %7
store i64 %21, i64* %22
br label %23
23: ; preds = %18, %13
br label %24
24: ; preds = %23
%25 = load i64*, i64** %7
%26 = getelementptr inbounds i64, i64* %25, i32 1
store i64* %26, i64** %7
br label %9
27: ; preds = %9
%28 = load i64*, i64** %4
%29 = load i64*, i64** %5
%30 = load i64*, i64** %6
%31 = call i64* @binary_search(i64* %28, i64* %29, i64* %30)
store i64* %31, i64** %5
%32 = load i64*, i64** %4
%33 = load i64*, i64** %5
%34 = load i64*, i64** %6
%35 = call i64* @linear_search(i64* %32, i64* %33, i64* %34)
store i64* %35, i64** %5
%36 = load i64*, i64** %5
%37 = icmp ne i64* %36, null
%38 = zext i1 %37 to i32
ret i32 %38
}

LLVM IR (-O2):
define i32 @look(i64* %0, i64* %1, i64* %2) {
%4 = load i64, i64* %0
%5 = icmp eq i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %3, %14
%7 = phi i64 [ %16, %14 ], [ %4, %3 ]
%8 = phi i64* [ %15, %14 ], [ %0, %3 ]
%9 = tail call i64 @isupper(i64 %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = load i64, i64* %8
%13 = tail call i64 @_tolower(i64 %12)
store i64 %13, i64* %8
br label %14
14: ; preds = %6, %11
%15 = getelementptr inbounds i64, i64* %8, i64 1
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %6
18: ; preds = %14, %3
%19 = tail call i64* @binary_search(i64* %0, i64* %1, i64* %2)
%20 = tail call i64* @linear_search(i64* %0, i64* %19, i64* %2)
%21 = icmp ne i64* %20, null
%22 = zext i1 %21 to i32
ret i32 %22
}