#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 search(int *, int, int);
int main(int argc, char *argv[]) {
  int nums[] = {4, 5, 6, 0, 1, 2};
  for (int i = 0; i < 6; ++i) {
    if (!(search(nums, 6, nums[i]) == i)) {
      printf("assert fail: %s\n", "search");
      return -1;
    };
  }
  printf("everything is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    11bb <main+0x9b>
lea    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
mov    $0x6,%esi
call   1040 <search@plt>
cmp    -0x34(%rbp),%eax
je     11a8 <main+0x88>
lea    0xe8a(%rip),%rdi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <main+0xb0>
jmp    11ad <main+0x8d>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115e <main+0x3e>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xed5(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x6,%esi
mov    $0x4,%edx
call   1050 <search@plt>
test   %eax,%eax
jne    11e6 <main+0xb6>
mov    0x4(%rsp),%edx
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <search@plt>
cmp    $0x1,%eax
jne    11e6 <main+0xb6>
mov    0x8(%rsp),%edx
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <search@plt>
cmp    $0x2,%eax
jne    11e6 <main+0xb6>
mov    0xc(%rsp),%edx
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <search@plt>
cmp    $0x3,%eax
jne    11e6 <main+0xb6>
mov    0x10(%rsp),%edx
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <search@plt>
cmp    $0x4,%eax
jne    11e6 <main+0xb6>
mov    0x14(%rsp),%edx
mov    %rsp,%rdi
mov    $0x6,%esi
call   1050 <search@plt>
cmp    $0x5,%eax
jne    11e6 <main+0xb6>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe2b(%rip),%rdi
lea    0xe35(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.nums = [6 x i32] [i32 4, i32 5, i32 6, i32 0, i32 1, i32 2]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [7 x i8] c"search\00"
@.str.2 = [21 x i8] c"everything is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [6 x i32]* %6 to i8*
store i32 0, i32* %7
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 6
br i1 %11, label %12, label %27
12: ; preds = %9
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @search(i32* %13, i32 6, i32 %17)
%19 = load i32, i32* %7
%20 = icmp eq i32 %18, %19
br i1 %20, label %23, label %21
21: ; preds = %12
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %29
23: ; preds = %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %9
27: ; preds = %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %29
29: ; preds = %27, %21
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@__const.main.nums = [6 x i32] [i32 4, i32 5, i32 6, i32 0, i32 1, i32 2]
@.str = [17 x i8] c"assert fail: %s\0A\00"
@.str.1 = [7 x i8] c"search\00"
@str = [20 x i8] c"everything is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = call i32 @search(i32* %5, i32 6, i32 4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %35
8: ; preds = %2
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%10 = load i32, i32* %9
%11 = call i32 @search(i32* %5, i32 6, i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %35
13: ; preds = %8
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%15 = load i32, i32* %14
%16 = call i32 @search(i32* %5, i32 6, i32 %15)
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %35
18: ; preds = %13
%19 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%20 = load i32, i32* %19
%21 = call i32 @search(i32* %5, i32 6, i32 %20)
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %35
23: ; preds = %18
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%25 = load i32, i32* %24
%26 = call i32 @search(i32* %5, i32 6, i32 %25)
%27 = icmp eq i32 %26, 4
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%30 = load i32, i32* %29
%31 = call i32 @search(i32* %5, i32 6, i32 %30)
%32 = icmp eq i32 %31, 5
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %37
35: ; preds = %28, %23, %18, %13, %8, %2
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
%38 = phi i32 [ 0, %33 ], [ -1, %35 ]
ret i32 %38
}