#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 atoi(char *);
int /*<<< orphan*/ bogoSort(int *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("ERROR: Must provide at least one argument!\n");
    exit(1);
  }
  int a[argc - 1];
  for (int i = 1; i < argc; i++) {
    a[i - 1] = atoi(argv[i]);
  }
  bogoSort(a, argc - 1);
  printf("Done sorting... Result is {");
  for (int i = 0; i < argc - 1; i++) {
    printf("%d, ", a[i]);
  }
  printf("\b\b}\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1178 <main+0x38>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e6 <main+0xa6>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a9 <main+0x69>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <bogoSort@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1242 <main+0x102>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120a <main+0xca>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    1205 <main+0xb5>
mov    %rsi,%r12
lea    -0x1(%rdi),%r14d
mov    %rsp,%r13
lea    0xf(,%r14,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rdi,-0x30(%rbp)
mov    %edi,%ebx
add    $0xffffffffffffffff,%rbx
xor    %r15d,%r15d
mov    0x8(%r12,%r15,8),%rdi
call   1060 <atoi@plt>
mov    %eax,0x0(%r13,%r15,4)
add    $0x1,%r15
cmp    %r15,%rbx
jne    1190 <main+0x40>
mov    %r13,%rdi
mov    %r14d,%esi
call   1030 <bogoSort@plt>
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x2,-0x30(%rbp)
jl     11e8 <main+0x98>
lea    0xe4e(%rip),%r15
xor    %ebx,%ebx
mov    0x0(%r13,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11d0 <main+0x80>
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"ERROR: Must provide at least one argument!\0A\00"
@.str.1 = [28 x i8] c"Done sorting... Result is {\00"
@.str.2 = [5 x i8] c"%d, \00"
@.str.3 = [5 x i8] c"\08\08}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %6
%20 = alloca i32, i64 %18
store i64 %18, i64* %7
store i32 1, i32* %8
br label %21
21: ; preds = %36, %15
%22 = load i32, i32* %8
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = load i32, i32* %8
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %20, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %25
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %21
39: ; preds = %21
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = call i32 @bogoSort(i32* %20, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %9
br label %44
44: ; preds = %55, %39
%45 = load i32, i32* %9
%46 = load i32, i32* %4
%47 = sub nsw i32 %46, 1
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %58
49: ; preds = %44
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %20, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %49
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %44
58: ; preds = %44
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8*, i8** %6
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"Done sorting... Result is {\00"
@.str.2 = [5 x i8] c"%d, \00"
@str = [4 x i8] c"\08\08}\00"
@str.4 = [43 x i8] c"ERROR: Must provide at least one argument!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = add nsw i32 %0, -1
%9 = zext i32 %8 to i64
%10 = alloca i32, i64 %9
%11 = zext i32 %0 to i64
br label %16
12: ; preds = %16
%13 = call i32 @bogoSort(i32* %10, i32 %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp sgt i32 %0, 1
br i1 %15, label %27, label %25
16: ; preds = %7, %16
%17 = phi i64 [ 1, %7 ], [ %23, %16 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = add nsw i64 %17, -1
%22 = getelementptr inbounds i32, i32* %10, i64 %21
store i32 %20, i32* %22
%23 = add nuw nsw i64 %17, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %12, label %16
25: ; preds = %27, %12
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret i32 0
27: ; preds = %12, %27
%28 = phi i64 [ %32, %27 ], [ 0, %12 ]
%29 = getelementptr inbounds i32, i32* %10, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i64 %28, 1
%33 = icmp eq i64 %32, %9
br i1 %33, label %25, label %27
}