#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*/ quick_sort(int *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  int a[100];
  for (int i = 0; i < 100; ++i) {
    a[i] = 100 - i;
  }
  quick_sort(a, 0, 100 - 1);
  for (int i = 0; i < 100; ++i) {
    if (a[i] != i + 1) {
      printf("wrong answer for a[%d] = %d!\n", i, a[i]);
    }
  }
  printf("everyting is fine!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    117d <main+0x5d>
mov    $0x64,%ecx
sub    -0x1a4(%rbp),%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1143 <main+0x23>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x63,%edx
call   1040 <quick_sort@plt>
movl   $0x0,-0x1a8(%rbp)
cmpl   $0x64,-0x1a8(%rbp)
jge    1201 <main+0xe1>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
mov    -0x1a8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
je     11e8 <main+0xc8>
mov    -0x1a8(%rbp),%esi
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    119a <main+0x7a>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xee6(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xee7(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x140(%rsp)
movaps 0xeed(%rip),%xmm0
movaps %xmm0,0x150(%rsp)
movaps 0xeee(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
movaps 0xeef(%rip),%xmm0
movaps %xmm0,0x170(%rsp)
movaps 0xef0(%rip),%xmm0
movaps %xmm0,0x180(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x63,%edx
call   1050 <quick_sort@plt>
lea    0xee2(%rip),%r14
xor    %esi,%esi
jmp    12c9 <main+0x199>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rsi
cmp    $0x64,%rbx
je     12e1 <main+0x1b1>
mov    (%rsp,%rsi,4),%edx
lea    0x1(%rsi),%rbx
cmp    %rdx,%rbx
je     12c0 <main+0x190>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12c0 <main+0x190>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"wrong answer for a[%d] = %d!\0A\00"
@.str.1 = [20 x i8] c"everyting is fine!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %9
9: ; preds = %18, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %7
%14 = sub nsw i32 100, %13
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %16
store i32 %14, i32* %17
br label %18
18: ; preds = %12
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %9
21: ; preds = %9
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 0
%23 = call i32 @quick_sort(i32* %22, i32 0, i32 99)
store i32 0, i32* %8
br label %24
24: ; preds = %43, %21
%25 = load i32, i32* %8
%26 = icmp slt i32 %25, 100
br i1 %26, label %27, label %46
27: ; preds = %24
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
%34 = icmp ne i32 %31, %33
br i1 %34, label %35, label %42
35: ; preds = %27
%36 = load i32, i32* %8
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %6, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %36, i32 %40)
br label %42
42: ; preds = %35, %27
br label %43
43: ; preds = %42
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %24
46: ; preds = %24
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"wrong answer for a[%d] = %d!\0A\00"
@str = [19 x i8] c"everyting is fine!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = bitcast [100 x i32]* %3 to i8*
%5 = bitcast [100 x i32]* %3 to <4 x i32>*
store <4 x i32> <i32 100, i32 99, i32 98, i32 97>, <4 x i32>* %5
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 4
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 96, i32 95, i32 94, i32 93>, <4 x i32>* %7
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 8
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 92, i32 91, i32 90, i32 89>, <4 x i32>* %9
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 12
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 88, i32 87, i32 86, i32 85>, <4 x i32>* %11
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 16
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 84, i32 83, i32 82, i32 81>, <4 x i32>* %13
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 20
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 80, i32 79, i32 78, i32 77>, <4 x i32>* %15
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 24
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 76, i32 75, i32 74, i32 73>, <4 x i32>* %17
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 28
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 72, i32 71, i32 70, i32 69>, <4 x i32>* %19
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 32
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 68, i32 67, i32 66, i32 65>, <4 x i32>* %21
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 36
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 64, i32 63, i32 62, i32 61>, <4 x i32>* %23
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 40
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> <i32 60, i32 59, i32 58, i32 57>, <4 x i32>* %25
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 44
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> <i32 56, i32 55, i32 54, i32 53>, <4 x i32>* %27
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 48
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> <i32 52, i32 51, i32 50, i32 49>, <4 x i32>* %29
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 52
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 48, i32 47, i32 46, i32 45>, <4 x i32>* %31
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 56
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> <i32 44, i32 43, i32 42, i32 41>, <4 x i32>* %33
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 60
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> <i32 40, i32 39, i32 38, i32 37>, <4 x i32>* %35
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 64
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> <i32 36, i32 35, i32 34, i32 33>, <4 x i32>* %37
%38 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 68
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> <i32 32, i32 31, i32 30, i32 29>, <4 x i32>* %39
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 72
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> <i32 28, i32 27, i32 26, i32 25>, <4 x i32>* %41
%42 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 76
%43 = bitcast i32* %42 to <4 x i32>*
store <4 x i32> <i32 24, i32 23, i32 22, i32 21>, <4 x i32>* %43
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 80
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> <i32 20, i32 19, i32 18, i32 17>, <4 x i32>* %45
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 84
%47 = bitcast i32* %46 to <4 x i32>*
store <4 x i32> <i32 16, i32 15, i32 14, i32 13>, <4 x i32>* %47
%48 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 88
%49 = bitcast i32* %48 to <4 x i32>*
store <4 x i32> <i32 12, i32 11, i32 10, i32 9>, <4 x i32>* %49
%50 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 92
%51 = bitcast i32* %50 to <4 x i32>*
store <4 x i32> <i32 8, i32 7, i32 6, i32 5>, <4 x i32>* %51
%52 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 96
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> <i32 4, i32 3, i32 2, i32 1>, <4 x i32>* %53
%54 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%55 = call i32 @quick_sort(i32* %54, i32 0, i32 99)
br label %58
56: ; preds = %68
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
ret i32 0
58: ; preds = %2, %68
%59 = phi i64 [ 0, %2 ], [ %62, %68 ]
%60 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = add nuw nsw i64 %59, 1
%63 = zext i32 %61 to i64
%64 = icmp eq i64 %62, %63
br i1 %64, label %68, label %65
65: ; preds = %58
%66 = trunc i64 %59 to i32
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %66, i32 %61)
br label %68
68: ; preds = %58, %65
%69 = icmp eq i64 %62, 100
br i1 %69, label %56, label %58
}