#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*/ c40_printf(char *, unsigned long, ...);
void search(unsigned long parms[]) {
  if (parms[1] == 0xFFFFFFFF)
    return;
  while (parms[0] != parms[1])
    if (*((unsigned long *)parms[0]++) == parms[2]) {
      c40_printf("%x found at address %x.\n", parms[2], --parms[0]);
      return;
    }
  c40_printf("%x not found.\n", parms[2]);
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xffffffff,%ecx
cmp    %rcx,0x8(%rax)
jne    1134 <search+0x24>
jmp    11b4 <search+0xa4>
jmp    1139 <search+0x29>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x8(%rcx),%rax
je     119e <search+0x8e>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%rax
mov    -0x8(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    1199 <search+0x89>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,(%rax)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <c40_printf@plt>
jmp    11b4 <search+0xa4>
jmp    1139 <search+0x29>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <c40_printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
mov    0x8(%rdi),%rax
mov    $0xffffffff,%ecx
cmp    %rcx,%rax
jne    111f <search+0xf>
ret
mov    (%rdi),%rcx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rcx,%rax
je     115d <search+0x4d>
lea    0x1(%rcx),%rdx
mov    %rdx,(%rdi)
mov    (%rcx),%rsi
mov    %rdx,%rcx
cmp    0x10(%rdi),%rsi
jne    1130 <search+0x20>
add    $0xffffffffffffffff,%rdx
mov    %rdx,(%rdi)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
jmp    1030 <c40_printf@plt>
mov    0x10(%rdi),%rsi
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
jmp    1030 <c40_printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"%x found at address %x.\0A\00"
@.str.1 = [15 x i8] c"%x not found.\0A\00"
define void @search(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = getelementptr inbounds i64, i64* %3, i64 1
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 4294967295
br i1 %6, label %7, label %8
7: ; preds = %1
br label %43
8: ; preds = %1
br label %9
9: ; preds = %37, %8
%10 = load i64*, i64** %2
%11 = getelementptr inbounds i64, i64* %10, i64 0
%12 = load i64, i64* %11
%13 = load i64*, i64** %2
%14 = getelementptr inbounds i64, i64* %13, i64 1
%15 = load i64, i64* %14
%16 = icmp ne i64 %12, %15
br i1 %16, label %17, label %38
17: ; preds = %9
%18 = load i64*, i64** %2
%19 = getelementptr inbounds i64, i64* %18, i64 0
%20 = load i64, i64* %19
%21 = add i64 %20, 1
store i64 %21, i64* %19
%22 = inttoptr i64 %20 to i64*
%23 = load i64, i64* %22
%24 = load i64*, i64** %2
%25 = getelementptr inbounds i64, i64* %24, i64 2
%26 = load i64, i64* %25
%27 = icmp eq i64 %23, %26
br i1 %27, label %28, label %37
28: ; preds = %17
%29 = load i64*, i64** %2
%30 = getelementptr inbounds i64, i64* %29, i64 2
%31 = load i64, i64* %30
%32 = load i64*, i64** %2
%33 = getelementptr inbounds i64, i64* %32, i64 0
%34 = load i64, i64* %33
%35 = add i64 %34, -1
store i64 %35, i64* %33
%36 = call i32 (i8*, i64, ...) @c40_printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %31, i64 %35)
br label %43
37: ; preds = %17
br label %9
38: ; preds = %9
%39 = load i64*, i64** %2
%40 = getelementptr inbounds i64, i64* %39, i64 2
%41 = load i64, i64* %40
%42 = call i32 (i8*, i64, ...) @c40_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %41)
br label %43
43: ; preds = %38, %28, %7
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"%x found at address %x.\0A\00"
@.str.1 = [15 x i8] c"%x not found.\0A\00"
define void @search(i64* nocapture %0) {
%2 = getelementptr inbounds i64, i64* %0, i64 1
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 4294967295
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = getelementptr inbounds i64, i64* %0, i64 2
%7 = load i64, i64* %0
br label %8
8: ; preds = %5, %11
%9 = phi i64 [ %7, %5 ], [ %12, %11 ]
%10 = icmp eq i64 %9, %3
br i1 %10, label %19, label %11
11: ; preds = %8
%12 = add i64 %9, 1
store i64 %12, i64* %0
%13 = inttoptr i64 %9 to i64*
%14 = load i64, i64* %13
%15 = load i64, i64* %6
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %8
17: ; preds = %11
store i64 %9, i64* %0
%18 = tail call i32 (i8*, i64, ...) @c40_printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %9)
br label %22
19: ; preds = %8
%20 = load i64, i64* %6
%21 = tail call i32 (i8*, i64, ...) @c40_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %20)
br label %22
22: ; preds = %1, %19, %17
ret void
}