#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 int /*<<< orphan*/ a;

/* Variables and functions */
int findRank(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int a[] = {10, 30, 60, 100, 1, 2, 7, 9, 80, 40, 55, 22, 99};
  int size = sizeof(a) / sizeof(a[0]);
  int num = 30;
  printf("The rank of %d is %d", num, findRank(a, size, num));
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
movl   $0xd,-0x54(%rbp)
movl   $0x1e,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
call   1030 <findRank@plt>
mov    -0x5c(%rbp),%esi
mov    %eax,%edx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    0xef6(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xd,%esi
mov    $0x1e,%edx
call   1040 <findRank@plt>
lea    0xeba(%rip),%rdi
mov    $0x1e,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [13 x i32] [i32 10, i32 30, i32 60, i32 100, i32 1, i32 2, i32 7, i32 9, i32 80, i32 40, i32 55, i32 22, i32 99]
@.str = [21 x i8] c"The rank of %d is %d\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [13 x i32]* %6 to i8*
store i32 13, i32* %7
store i32 30, i32* %8
%10 = load i32, i32* %8
%11 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @findRank(i32* %11, i32 %12, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [13 x i32] [i32 10, i32 30, i32 60, i32 100, i32 1, i32 2, i32 7, i32 9, i32 80, i32 40, i32 55, i32 22, i32 99]
@.str = [21 x i8] c"The rank of %d is %d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i32]
%4 = bitcast [13 x i32]* %3 to i8*
%5 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%6 = call i32 @findRank(i32* %5, i32 13, i32 30)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 30, i32 %6)
%8 = call i32 @putchar(i32 10)
ret i32 0
}