#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 qsort_1(int *, int, int);
int qsort(int a[], int low, int high) {
  int pr;
  pr = qsort_1(a, low, high);
  if (low == pr)
    return 0;
  qsort(a, low, pr - 1);
  qsort(a, pr + 1, high);
}


x86 assembly (clang, -O0):
<qsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <qsort_1@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    115c <qsort+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    1180 <qsort+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <qsort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1030 <qsort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<qsort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
call   1040 <qsort_1@plt>
cmp    %ebp,%eax
je     1165 <qsort+0x45>
mov    %eax,%ebx
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <qsort@plt>
mov    %ebx,%ebp
add    $0x1,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <qsort_1@plt>
mov    %eax,%ebx
cmp    %ebp,%eax
jne    1140 <qsort+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @qsort(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32*, i32** %5
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = call i32 @qsort_1(i32* %9, i32 %10, i32 %11)
store i32 %12, i32* %8
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 0, i32* %4
br label %28
17: ; preds = %3
%18 = load i32*, i32** %5
%19 = load i32, i32* %6
%20 = load i32, i32* %8
%21 = sub nsw i32 %20, 1
%22 = call i32 @qsort(i32* %18, i32 %19, i32 %21)
%23 = load i32*, i32** %5
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %7
%27 = call i32 @qsort(i32* %23, i32 %25, i32 %26)
br label %28
28: ; preds = %17, %16
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @qsort(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @qsort_1(i32* %0, i32 %1, i32 %2)
%5 = icmp eq i32 %4, %1
br i1 %5, label %14, label %6
6: ; preds = %3, %6
%7 = phi i32 [ %12, %6 ], [ %4, %3 ]
%8 = phi i32 [ %11, %6 ], [ %1, %3 ]
%9 = add nsw i32 %7, -1
%10 = tail call i32 @qsort(i32* %0, i32 %8, i32 %9)
%11 = add nsw i32 %7, 1
%12 = tail call i32 @qsort_1(i32* %0, i32 %11, i32 %2)
%13 = icmp eq i32 %12, %11
br i1 %13, label %14, label %6
14: ; preds = %6, %3
ret i32 0
}