#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 partition(int *const, int *const, int *const, int const, int const,
              int const);
int quicksort(int *const arr, int *const arr1, int *const arr2, int const left,
              int const right, int const size) {
  int pos_pivot;
  static int error = 0;
  if ((error == 0) &&
      ((arr == NULL) || (arr1 == NULL) || (arr2 == NULL) || (left < 0) ||
       (right < 0) || (right >= size) || (size <= 0)))
    return 1;
  if (error == 0)
    error = 1;
  if (left < right) {
    pos_pivot = partition(arr, arr1, arr2, left, right, size);
    quicksort(arr, arr1, arr2, left, pos_pivot - 1, size);
    quicksort(arr, arr1, arr2, pos_pivot + 1, right, size);
  }
  return 0;
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x0,0x2eee(%rip)
jne    11a3 <quicksort+0x83>
cmpq   $0x0,-0x10(%rbp)
je     1197 <quicksort+0x77>
cmpq   $0x0,-0x18(%rbp)
je     1197 <quicksort+0x77>
cmpq   $0x0,-0x20(%rbp)
je     1197 <quicksort+0x77>
cmpl   $0x0,-0x24(%rbp)
jl     1197 <quicksort+0x77>
cmpl   $0x0,-0x28(%rbp)
jl     1197 <quicksort+0x77>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1197 <quicksort+0x77>
cmpl   $0x0,-0x2c(%rbp)
jg     11a3 <quicksort+0x83>
movl   $0x1,-0x4(%rbp)
jmp    122b <quicksort+0x10b>
cmpl   $0x0,0x2e8a(%rip)
jne    11ba <quicksort+0x9a>
movl   $0x1,0x2e7a(%rip)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1224 <quicksort+0x104>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1030 <partition@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x30(%rbp),%r8d
sub    $0x1,%r8d
mov    -0x2c(%rbp),%r9d
call   1040 <quicksort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
call   1040 <quicksort@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x10(%rsp)
test   %rdi,%rdi
sete   %al
mov    %rsi,0x18(%rsp)
test   %rsi,%rsi
sete   %bl
or     %al,%bl
mov    %rdx,0x20(%rsp)
test   %rdx,%rdx
sete   %al
or     %bl,%al
mov    %al,0x7(%rsp)
cmp    %r9d,%r8d
setge  %al
mov    %r9d,0x8(%rsp)
test   %r9d,%r9d
setle  %dl
or     %al,%dl
mov    %dl,0x6(%rsp)
xor    %esi,%esi
mov    0x10(%rsp),%rbp
mov    0x18(%rsp),%r13
mov    0x20(%rsp),%r12
mov    0x8(%rsp),%r15d
cmpb   $0x0,0x2ea9(%rip)
jne    11a9 <quicksort+0x89>
nopl   (%rax)
mov    %ecx,%eax
or     %r8d,%eax
sets   %al
or     0x7(%rsp),%al
or     0x6(%rsp),%al
jne    11fe <quicksort+0xde>
movb   $0x1,0x2e8b(%rip)
cmp    %r8d,%ecx
jge    11fa <quicksort+0xda>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r8d,%ebx
mov    %r15d,%r9d
mov    %ecx,0xc(%rsp)
call   1030 <partition@plt>
mov    %eax,%r14d
lea    -0x1(%r14),%r8d
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    0xc(%rsp),%ecx
mov    %r15d,%r9d
call   1040 <quicksort@plt>
mov    %ebx,%r8d
add    $0x1,%r14d
mov    $0x1,%sil
mov    %r14d,%ecx
cmpb   $0x0,0x2e3e(%rip)
je     1190 <quicksort+0x70>
jmp    11a9 <quicksort+0x89>
xor    %edx,%edx
jmp    1203 <quicksort+0xe3>
mov    $0x1,%edx
xor    %eax,%eax
test   $0x1,%sil
cmove  %edx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@quicksort.error = internal global i32 0
define i32 @quicksort(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%15 = load i32, i32* @quicksort.error
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %40
17: ; preds = %6
%18 = load i32*, i32** %8
%19 = icmp eq i32* %18, null
br i1 %19, label %39, label %20
20: ; preds = %17
%21 = load i32*, i32** %9
%22 = icmp eq i32* %21, null
br i1 %22, label %39, label %23
23: ; preds = %20
%24 = load i32*, i32** %10
%25 = icmp eq i32* %24, null
br i1 %25, label %39, label %26
26: ; preds = %23
%27 = load i32, i32* %11
%28 = icmp slt i32 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %26
%30 = load i32, i32* %12
%31 = icmp slt i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %29
%33 = load i32, i32* %12
%34 = load i32, i32* %13
%35 = icmp sge i32 %33, %34
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = load i32, i32* %13
%38 = icmp sle i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36, %32, %29, %26, %23, %20, %17
store i32 1, i32* %7
br label %73
40: ; preds = %36, %6
%41 = load i32, i32* @quicksort.error
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 1, i32* @quicksort.error
br label %44
44: ; preds = %43, %40
%45 = load i32, i32* %11
%46 = load i32, i32* %12
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %72
48: ; preds = %44
%49 = load i32*, i32** %8
%50 = load i32*, i32** %9
%51 = load i32*, i32** %10
%52 = load i32, i32* %11
%53 = load i32, i32* %12
%54 = load i32, i32* %13
%55 = call i32 @partition(i32* %49, i32* %50, i32* %51, i32 %52, i32 %53, i32 %54)
store i32 %55, i32* %14
%56 = load i32*, i32** %8
%57 = load i32*, i32** %9
%58 = load i32*, i32** %10
%59 = load i32, i32* %11
%60 = load i32, i32* %14
%61 = sub nsw i32 %60, 1
%62 = load i32, i32* %13
%63 = call i32 @quicksort(i32* %56, i32* %57, i32* %58, i32 %59, i32 %61, i32 %62)
%64 = load i32*, i32** %8
%65 = load i32*, i32** %9
%66 = load i32*, i32** %10
%67 = load i32, i32* %14
%68 = add nsw i32 %67, 1
%69 = load i32, i32* %12
%70 = load i32, i32* %13
%71 = call i32 @quicksort(i32* %64, i32* %65, i32* %66, i32 %68, i32 %69, i32 %70)
br label %72
72: ; preds = %48, %44
store i32 0, i32* %7
br label %73
73: ; preds = %72, %39
%74 = load i32, i32* %7
ret i32 %74
}

LLVM IR (-O2):
@quicksort.error = internal unnamed_addr global i1 false
define i32 @quicksort(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp eq i32* %0, null
%8 = icmp eq i32* %1, null
%9 = or i1 %7, %8
%10 = icmp eq i32* %2, null
%11 = or i1 %9, %10
%12 = icmp sge i32 %4, %5
%13 = icmp slt i32 %5, 1
%14 = or i1 %12, %13
br label %15
15: ; preds = %27, %6
%16 = phi i32 [ %3, %6 ], [ %31, %27 ]
%17 = phi i1 [ false, %6 ], [ true, %27 ]
%18 = load i1, i1* @quicksort.error
br i1 %18, label %25, label %19
19: ; preds = %15
%20 = or i32 %16, %4
%21 = icmp slt i32 %20, 0
%22 = or i1 %11, %21
%23 = or i1 %22, %14
br i1 %23, label %32, label %24
24: ; preds = %19
store i1 true, i1* @quicksort.error
br label %25
25: ; preds = %15, %24
%26 = icmp slt i32 %16, %4
br i1 %26, label %27, label %32
27: ; preds = %25
%28 = tail call i32 @partition(i32* %0, i32* %1, i32* %2, i32 %16, i32 %4, i32 %5)
%29 = add nsw i32 %28, -1
%30 = tail call i32 @quicksort(i32* %0, i32* %1, i32* %2, i32 %16, i32 %29, i32 %5)
%31 = add nsw i32 %28, 1
br label %15
32: ; preds = %19, %25
%33 = phi i32 [ 1, %19 ], [ 0, %25 ]
%34 = select i1 %17, i32 0, i32 %33
ret i32 %34
}