#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 threeSumClosestPartition(int *, int, int);
void threeSumClosestQSort(int *nums, int start, int end) {
  int p = threeSumClosestPartition(nums, start, end);
  if (p > start + 1) {
    threeSumClosestQSort(nums, start, p - 1);
  }
  if (p < end - 1) {
    threeSumClosestQSort(nums, p + 1, end);
  }
}


x86 assembly (clang, -O0):
<threeSumClosestQSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <threeSumClosestPartition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jle    1167 <threeSumClosestQSort+0x47>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1030 <threeSumClosestQSort@plt>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    118a <threeSumClosestQSort+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <threeSumClosestQSort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<threeSumClosestQSort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%r15
lea    -0x1(%r14),%ebp
jmp    1148 <threeSumClosestQSort+0x28>
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r12d
cmp    %ebp,%ebx
jge    1171 <threeSumClosestQSort+0x51>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1040 <threeSumClosestPartition@plt>
mov    %eax,%ebx
lea    0x1(%r12),%eax
cmp    %eax,%ebx
jle    1140 <threeSumClosestQSort+0x20>
lea    -0x1(%rbx),%edx
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <threeSumClosestQSort@plt>
jmp    1140 <threeSumClosestQSort+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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