#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 /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
void search(char s[][50], char key[50], int start, int end) {
  int mid = (start + end) / 2;
  if (start < end) {
    search(s, key, start, mid);
  }
  if (start < end) {
    search(s, key, mid + 1, end);
  }
  if (start == end && strcmp(s[start], key) == 0) {
    printf("The Element to be searched %s was found", key);
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1176 <search+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <search@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1198 <search+0x68>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
call   1040 <search@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11d6 <search+0xa6>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x32,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d6 <search+0xa6>
mov    -0x10(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebx
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
cmp    %ecx,%edx
jl     114e <search+0x1e>
cmp    %ebx,%r12d
je     1182 <search+0x52>
jmp    119c <search+0x6c>
lea    (%rbx,%r12,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %ebp,%ecx
call   1040 <search@plt>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <search@plt>
cmp    %ebx,%r12d
jne    119c <search+0x6c>
movslq %ebx,%rax
imul   $0x32,%rax,%rax
add    %rax,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a5 <search+0x75>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe54(%rip),%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"The Element to be searched %s was found\00"
define void @search([50 x i8]* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [50 x i8]*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store [50 x i8]* %0, [50 x i8]** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = add nsw i32 %10, %11
%13 = sdiv i32 %12, 2
store i32 %13, i32* %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %4
%18 = load [50 x i8]*, [50 x i8]** %5
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = load i32, i32* %9
br label %22
22: ; preds = %17, %4
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load [50 x i8]*, [50 x i8]** %5
%28 = load i8*, i8** %6
%29 = load i32, i32* %9
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %8
br label %32
32: ; preds = %26, %22
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %48
36: ; preds = %32
%37 = load [50 x i8]*, [50 x i8]** %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [50 x i8], [50 x i8]* %37, i64 %39
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %40, i64 0, i64 0
%42 = load i8*, i8** %6
%43 = call i64 @strcmp(i8* %41, i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %36
%46 = load i8*, i8** %6
%47 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %36, %32
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"The Element to be searched %s was found\00"
define void @search([50 x i8]* %0, i8* %1, i32 %2, i32 %3) {
%5 = add nsw i32 %3, %2
%6 = sdiv i32 %5, 2
%7 = icmp slt i32 %2, %3
br i1 %7, label %8, label %10
8: ; preds = %4
tail call void @search([50 x i8]* %0, i8* %1, i32 %2, i32 %6)
%9 = add nsw i32 %6, 1
tail call void @search([50 x i8]* %0, i8* %1, i32 %9, i32 %3)
br label %10
10: ; preds = %4, %8
%11 = icmp eq i32 %2, %3
br i1 %11, label %12, label %19
12: ; preds = %10
%13 = sext i32 %3 to i64
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %0, i64 %13, i64 0
%15 = tail call i64 @strcmp(i8* %14, i8* %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %19
19: ; preds = %17, %12, %10
ret void
}