#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*/ arr;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int selection(int *, int /*<<< orphan*/, int, int);
int main(int argc, char *argv[]) {
  int arr[] = {10, 30, 60, 100, 1, 2, 7, 9, 80, 40, 55, 22, 99};
  int size = sizeof(arr) / sizeof(arr[0]);
  int i;
  for (i = 1; i <= size; ++i) {
    int ele = selection(arr, 0, size - 1, i);
    printf("The rank %d element is %d\n", i, arr[ele]);
  }
  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   $0x1,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jg     11b1 <main+0x81>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
sub    $0x1,%edx
mov    -0x58(%rbp),%ecx
xor    %esi,%esi
call   1030 <selection@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x58(%rbp),%esi
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1169 <main+0x39>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    0xf01(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xee6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x1,%ebx
mov    %rsp,%r14
lea    0xecf(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
mov    %ebx,%ecx
call   1030 <selection@plt>
cltq
mov    (%rsp,%rax,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0xe,%ebx
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.arr = [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 = [27 x i8] c"The rank %d element is %d\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [13 x i32]* %6 to i8*
store i32 13, i32* %7
store i32 1, i32* %8
br label %11
11: ; preds = %27, %2
%12 = load i32, i32* %8
%13 = load i32, i32* %7
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%17 = load i32, i32* %7
%18 = sub nsw i32 %17, 1
%19 = load i32, i32* %8
%20 = call i32 @selection(i32* %16, i32 0, i32 %18, i32 %19)
store i32 %20, i32* %9
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %25)
br label %27
27: ; preds = %15
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %11
30: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [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 = [27 x i8] c"The rank %d element is %d\0A\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
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 1, %2 ], [ %13, %6 ]
%8 = call i32 @selection(i32* %5, i32 0, i32 12, i32 %7)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11)
%13 = add nuw nsw i32 %7, 1
%14 = icmp eq i32 %13, 14
br i1 %14, label %15, label %6
15: ; preds = %6
ret i32 0
}