#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 getIntArray(int, int *, int /*<<< orphan*/);
int /*<<< orphan*/ printIntArray(int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ selectionSort(int, int *);
int main(void) {
  int x[10];
  int hmny;
  hmny = getIntArray(10, x, 0);
  if (hmny == 0)
    printf("This is the empty array!\n");
  else {
    printf("The array was: \n");
    printIntArray(hmny, x);
    selectionSort(hmny, x);
    printf("The sorted array is: \n");
    printIntArray(hmny, x);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0xa,%edi
xor    %edx,%edx
call   1060 <getIntArray@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    117d <main+0x3d>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <main+0x79>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <printIntArray@plt>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1040 <selectionSort@plt>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <printIntArray@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%rsi
mov    $0xa,%edi
xor    %edx,%edx
call   1060 <getIntArray@plt>
test   %eax,%eax
je     1197 <main+0x57>
mov    %eax,%ebx
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <printIntArray@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <selectionSort@plt>
lea    0xe8a(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <printIntArray@plt>
jmp    11a3 <main+0x63>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"This is the empty array!\0A\00"
@.str.1 = [17 x i8] c"The array was: \0A\00"
@.str.2 = [23 x i8] c"The sorted array is: \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%5 = call i32 @getIntArray(i32 10, i32* %4, i32 0)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %22
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%14 = call i32 @printIntArray(i32 %12, i32* %13)
%15 = load i32, i32* %3
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%17 = call i32 @selectionSort(i32 %15, i32* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%21 = call i32 @printIntArray(i32 %19, i32* %20)
br label %22
22: ; preds = %10, %8
ret i32 0
}

LLVM IR (-O2):
@str = [16 x i8] c"The array was: \00"
@str.3 = [22 x i8] c"The sorted array is: \00"
@str.4 = [25 x i8] c"This is the empty array!\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i32 @getIntArray(i32 10, i32* %3, i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.4, i64 0, i64 0))
br label %14
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%10 = call i32 @printIntArray(i32 %4, i32* %3)
%11 = call i32 @selectionSort(i32 %4, i32* %3)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.3, i64 0, i64 0))
%13 = call i32 @printIntArray(i32 %4, i32* %3)
br label %14
14: ; preds = %8, %6
ret i32 0
}