#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 /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int main(void) {
  int ret = 0;
  int i = 0;
  int a[] = {2, 8, 7, 1, 3, 5, 6, 4};
  printf("\nThis program sorts the following array using quicksort:\n\t");
  while (i < 8)
    printf("%d ", a[i++]);
  quicksort(a, 0, 8);
  printf("\nThe sorted array is:\n\t");
  i = 0;
  while (i < 8)
    printf("%d ", a[i++]);
  printf("\n");
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x8,-0xc(%rbp)
jge    11a5 <main+0x85>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1177 <main+0x57>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <quicksort@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11f8 <main+0xd8>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ca <main+0xaa>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xefa(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <quicksort@plt>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [8 x i32] [i32 2, i32 8, i32 7, i32 1, i32 3, i32 5, i32 6, i32 4]
@.str = [59 x i8] c"\0AThis program sorts the following array using quicksort:\0A\09\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [24 x i8] c"\0AThe sorted array is:\0A\09\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = bitcast [8 x i32]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %7
17: ; preds = %7
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%19 = call i32 @quicksort(i32* %18, i32 0, i32 8)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %21
21: ; preds = %24, %17
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %21
31: ; preds = %21
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@__const.main.a = [8 x i32] [i32 2, i32 8, i32 7, i32 1, i32 3, i32 5, i32 6, i32 4]
@.str = [59 x i8] c"\0AThis program sorts the following array using quicksort:\0A\09\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [24 x i8] c"\0AThe sorted array is:\0A\09\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2)
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 8)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 7)
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 5)
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 6)
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%20 = call i32 @quicksort(i32* %4, i32 0, i32 8)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %4
%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 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %8
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %10
%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 = load i32, i32* %12
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %14
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %16
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %18
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = call i32 @putchar(i32 10)
ret i32 0
}