#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*/ printf(char *, ...);
int randInt(int, int);
int /*<<< orphan*/ sortAsc(int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
scalar_t__ verifyOrder(int *);
int main() {
  int i, ints[100];
  srand((unsigned)time(NULL));
  printf("Unsorted:\n");
  for (i = 0; i < 100; i++) {
    ints[i] = randInt(1, 10);
    printf("%d ", ints[i]);
  }
  printf("\n\n");
  printf("Sorted:\n");
  sortAsc(ints);
  for (i = 0; i < 100; i++) {
    printf("%d ", ints[i]);
  }
  printf("\n\n");
  printf("Array is sorted: %s\n", verifyOrder(ints) ? "TRUE" : "FALSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11e4 <main+0x84>
mov    $0x1,%edi
mov    $0xa,%esi
call   1070 <randInt@plt>
mov    %eax,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
movslq -0x8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1197 <main+0x37>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rdi
call   1050 <sortAsc@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1244 <main+0xe4>
movslq -0x8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1213 <main+0xb3>
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rdi
call   1080 <verifyOrder@plt>
mov    %rax,%rcx
lea    0xdcd(%rip),%rsi
lea    0xdc1(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
lea    0xe65(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    $0x1,%edi
mov    $0xa,%esi
call   1080 <randInt@plt>
mov    %eax,(%rsp,%rbx,4)
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11a0 <main+0x30>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1060 <sortAsc@plt>
lea    0xe11(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1200 <main+0x90>
lea    0xdf9(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1090 <verifyOrder@plt>
test   %rax,%rax
lea    0xde9(%rip),%rax
lea    0xddd(%rip),%rsi
cmove  %rax,%rsi
lea    0xdbd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Unsorted:\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [9 x i8] c"Sorted:\0A\00"
@.str.4 = [21 x i8] c"Array is sorted: %s\0A\00"
@.str.5 = [5 x i8] c"TRUE\00"
@.str.6 = [6 x i8] c"FALSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
store i32 0, i32* %1
%4 = call i64 @time(i32* null)
%5 = trunc i64 %4 to i32
%6 = call i32 @srand(i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = call i32 @randInt(i32 1, i32 10)
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %14
store i32 %12, i32* %15
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %11
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %8
24: ; preds = %8
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%28 = call i32 @sortAsc(i32* %27)
store i32 0, i32* %2
br label %29
29: ; preds = %38, %24
%30 = load i32, i32* %2
%31 = icmp slt i32 %30, 100
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %29
41: ; preds = %29
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%44 = call i64 @verifyOrder(i32* %43)
%45 = icmp ne i64 %44, 0
%46 = zext i1 %45 to i64
%47 = select i1 %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %47)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d \00"
@.str.4 = [21 x i8] c"Array is sorted: %s\0A\00"
@.str.5 = [5 x i8] c"TRUE\00"
@.str.6 = [6 x i8] c"FALSE\00"
@str = [10 x i8] c"Unsorted:\00"
@str.8 = [8 x i8] c"Sorted:\00"
@str.9 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %0, %7
%8 = phi i64 [ 0, %0 ], [ %12, %7 ]
%9 = tail call i32 @randInt(i32 1, i32 10)
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %8
store i32 %9, i32* %10
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, 100
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.8, i64 0, i64 0))
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%18 = call i32 @sortAsc(i32* %17)
br label %19
19: ; preds = %14, %19
%20 = phi i64 [ 0, %14 ], [ %24, %19 ]
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, 100
br i1 %25, label %26, label %19
26: ; preds = %19
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%28 = call i64 @verifyOrder(i32* %17)
%29 = icmp eq i64 %28, 0
%30 = select i1 %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %30)
ret i32 0
}