#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 char u_char;

/* Variables and functions */
char _tolower(char);
char *binary_search(char *, char *, char *);
scalar_t__ isupper(char);
char *linear_search(char *, char *, char *);
char *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;
}


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
cmpb   $0x0,(%rax)
je     11a9 <look+0x69>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     1193 <look+0x53>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1060 <_tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
jmp    1198 <look+0x58>
mov    -0x20(%rbp),%rax
add    $0x1,%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)
mov    -0x10(%rbp),%rax
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),%al
test   %al,%al
je     1185 <look+0x45>
mov    %r12,%rbx
jmp    116c <look+0x2c>
nopl   0x0(%rax)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1185 <look+0x45>
movsbl %al,%edi
call   1040 <isupper@plt>
test   %rax,%rax
je     1160 <look+0x20>
movsbl (%rbx),%edi
call   1060 <_tolower@plt>
mov    %al,(%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
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <linear_search@plt>

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

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