#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int a[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}, mid, l = 0, u = 13,
      s, flag = 0;
  printf("\n Enter the element to search ");
  scanf("%d", &s);
  while (l <= u) {
    mid = (l + u) / 2;
    if (a[mid] > s)
      u = mid - 1;
    else if (a[mid] < s)
      l = mid + 1;
    else {
      printf("\n Element found at Index %d ", mid + 1);
      flag = 1;
      break;
    }
  }
  if (flag == 0)
    printf("\n Element Not found ");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x40(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x34,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x48(%rbp)
movl   $0xd,-0x4c(%rbp)
movl   $0x0,-0x54(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     1205 <main+0xd5>
mov    -0x48(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x44(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
cmp    -0x50(%rbp),%eax
jle    11bc <main+0x8c>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1200 <main+0xd0>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
cmp    -0x50(%rbp),%eax
jge    11db <main+0xab>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11fb <main+0xcb>
mov    -0x44(%rbp),%esi
add    $0x1,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x54(%rbp)
jmp    1205 <main+0xd5>
jmp    1200 <main+0xd0>
jmp    1180 <main+0x50>
cmpl   $0x0,-0x54(%rbp)
jne    121d <main+0xed>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xf08(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0xd,%edx
mov    0xc(%rsp),%eax
lea    0xeaa(%rip),%rcx
jmp    1169 <main+0x49>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%esi
mov    %esi,%edx
cmp    %edx,%ebx
jg     118c <main+0x6c>
lea    (%rdx,%rbx,1),%edi
mov    %edi,%esi
shr    $0x1f,%esi
add    %edi,%esi
sar    %esi
movslq %esi,%rdi
mov    (%rcx,%rdi,4),%edi
cmp    %eax,%edi
jg     1160 <main+0x40>
add    $0x1,%esi
cmp    %eax,%edi
jge    119c <main+0x7c>
mov    %esi,%ebx
cmp    %edx,%ebx
jle    1169 <main+0x49>
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11aa <main+0x8a>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.a = [13 x i32] [i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15, i32 17, i32 19, i32 21, i32 23, i32 25]
@.str = [31 x i8] c"\0A Enter the element to search \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0A Element found at Index %d \00"
@.str.3 = [21 x i8] c"\0A Element Not found \00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
br label %6
6: ; preds = %0, %22
%7 = phi i32 [ 13, %0 ], [ %24, %22 ]
%8 = phi i32 [ 0, %0 ], [ %23, %22 ]
%9 = add nsw i32 %7, %8
%10 = sdiv i32 %9, 2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [13 x i32], [13 x i32]* @__const.main.a, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = icmp sgt i32 %13, %5
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = add nsw i32 %10, -1
br label %22
17: ; preds = %6
%18 = icmp slt i32 %13, %5
%19 = add nsw i32 %10, 1
br i1 %18, label %22, label %20
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %28
22: ; preds = %17, %15
%23 = phi i32 [ %8, %15 ], [ %19, %17 ]
%24 = phi i32 [ %16, %15 ], [ %7, %17 ]
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %6
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %20, %26
ret void
}