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

/* Variables and functions */
int /*<<< orphan*/ Error(char *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ selectSort(int *, int);
void main(void) {
  int x[] = {-1, 3, 6, 9, 88, 100, 2, 0};
  int len = sizeof(x) / sizeof(x[0]);
  selectSort(x, len - 1);
  for (int i = 0; i < len; i++)
    printf("value of x[%i]:%d.\n", i, x[i]);
  char errm[] = "No errors.";
  Error(errm);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x8,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
call   1050 <selectSort@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b2 <main+0x82>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1181 <main+0x51>
mov    0xe7b(%rip),%rax
mov    %rax,-0x33(%rbp)
mov    0xe78(%rip),%ax
mov    %ax,-0x2b(%rbp)
mov    0xe70(%rip),%al
mov    %al,-0x29(%rbp)
lea    -0x33(%rbp),%rdi
call   1030 <Error@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x7,%esi
call   1050 <selectSort@plt>
mov    (%rsp),%edx
lea    0xebd(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
movabs $0x726f727265206f4e,%rax
72 6f 72
mov    %rax,0x20(%rsp)
movl   $0x2e7372,0x27(%rsp)
lea    0x20(%rsp),%rdi
call   1030 <Error@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.x = [8 x i32] [i32 -1, i32 3, i32 6, i32 9, i32 88, i32 100, i32 2, i32 0]
@.str = [20 x i8] c"value of x[%i]:%d.\0A\00"
@__const.main.errm = [11 x i8] c"No errors.\00"
define void @main() {
%1 = alloca [8 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = bitcast [8 x i32]* %1 to i8*
store i32 8, i32* %2
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%7 = load i32, i32* %2
%8 = sub nsw i32 %7, 1
%9 = call i32 @selectSort(i32* %6, i32 %8)
store i32 0, i32* %3
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %10
24: ; preds = %10
%25 = bitcast [11 x i8]* %4 to i8*
%26 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%27 = call i32 @Error(i8* %26)
ret void
}

LLVM IR (-O2):
@__const.main.x = [8 x i32] [i32 -1, i32 3, i32 6, i32 9, i32 88, i32 100, i32 2, i32 0]
@.str = [20 x i8] c"value of x[%i]:%d.\0A\00"
@__const.main.errm = [11 x i8] c"No errors.\00"
define void @main() {
%1 = alloca [8 x i32]
%2 = alloca [11 x i8]
%3 = bitcast [8 x i32]* %1 to i8*
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%5 = call i32 @selectSort(i32* %4, i32 7)
%6 = load i32, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 0, i32 %6)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 1, i32 %9)
%11 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2, i32 %12)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 3, i32 %15)
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 4, i32 %18)
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 5, i32 %21)
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 6, i32 %24)
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 7, i32 %27)
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%30 = call i32 @Error(i8* %29)
ret void
}