#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*/ is_sorted(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
void main() {
  int input[] = {0, -1, -2, -1, 10, 3, 8};
  quick_sort(input, 0, 6);
  if (!is_sorted(input, 7)) {
    printf("Input array has not been sorted!\n");
  } else {
    printf("Input array is sorted.\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    0xeb9(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <quick_sort@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
call   1030 <is_sorted@plt>
cmp    $0x0,%eax
jne    119a <main+0x6a>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
jmp    11a6 <main+0x76>
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movups 0xed0(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <quick_sort@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <is_sorted@plt>
test   %eax,%eax
lea    0xea8(%rip),%rax
lea    0xec2(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.input = [7 x i32] [i32 0, i32 -1, i32 -2, i32 -1, i32 10, i32 3, i32 8]
@.str = [34 x i8] c"Input array has not been sorted!\0A\00"
@.str.1 = [24 x i8] c"Input array is sorted.\0A\00"
define void @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @quick_sort(i32* %3, i32 0, i32 6)
%5 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%6 = call i32 @is_sorted(i32* %5, i32 7)
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
ret void
}

LLVM IR (-O2):
@__const.main.input = [7 x i32] [i32 0, i32 -1, i32 -2, i32 -1, i32 10, i32 3, i32 8]
@str = [33 x i8] c"Input array has not been sorted!\00"
@str.2 = [23 x i8] c"Input array is sorted.\00"
define void @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @quick_sort(i32* %3, i32 0, i32 6)
%5 = call i32 @is_sorted(i32* %3, i32 7)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
ret void
}