#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 bogosort(int *, size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int main(void) {
  int arr[8] = {2, 1, 3, 4, 5, 7, 9, 10};
  size_t size = sizeof(arr) / sizeof(arr[0]);
  int err = bogosort(arr, size);
  if (err) {
    printf("Encountered error!\n");
    return err;
  } else {
    for (size_t i = 0; i < size; ++i)
      printf("%i ", arr[i]);
    putchar(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x8,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <bogosort@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     11a6 <main+0x76>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f4 <main+0xc4>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    11e3 <main+0xb3>
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11ae <main+0x7e>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x8,%esi
call   1060 <bogosort@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1182 <main+0x42>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
jmp    1202 <main+0xc2>
mov    (%rsp),%esi
lea    0xe94(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arr = [8 x i32] [i32 2, i32 1, i32 3, i32 4, i32 5, i32 7, i32 9, i32 10]
@.str = [20 x i8] c"Encountered error!\0A\00"
@.str.1 = [4 x i8] c"%i \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
store i32 0, i32* %1
%6 = bitcast [8 x i32]* %2 to i8*
store i64 8, i64* %3
%7 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%8 = load i64, i64* %3
%9 = call i32 @bogosort(i32* %7, i64 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* %4
store i32 %14, i32* %1
br label %31
15: ; preds = %0
store i64 0, i64* %5
br label %16
16: ; preds = %25, %15
%17 = load i64, i64* %5
%18 = load i64, i64* %3
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %16
%21 = load i64, i64* %5
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %20
%26 = load i64, i64* %5
%27 = add i64 %26, 1
store i64 %27, i64* %5
br label %16
28: ; preds = %16
%29 = call i32 @putchar(i32 10)
br label %30
30: ; preds = %28
store i32 0, i32* %1
br label %31
31: ; preds = %30, %12
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@__const.main.arr = [8 x i32] [i32 2, i32 1, i32 3, i32 4, i32 5, i32 7, i32 9, i32 10]
@.str.1 = [4 x i8] c"%i \00"
@str = [19 x i8] c"Encountered error!\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%4 = call i32 @bogosort(i32* %3, i64 8)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %31
6: ; preds = %0
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%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 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = call i32 @putchar(i32 10)
br label %33
31: ; preds = %0
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %6, %31
ret i32 %4
}