#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 getLastLessThanIdx(int *, int /*<<< orphan*/, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ my_qsort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char const *argv[]) {
  int *test = (int *)malloc(sizeof(int) * 3);
  test[0] = 3;
  test[1] = 2;
  test[2] = 4;
  my_qsort(test, 0, 2);
  printf("%d\n", getLastLessThanIdx(test, 0, 2, 6));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,0x8(%rax)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <my_qsort@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x6,%ecx
call   1040 <getLastLessThanIdx@plt>
mov    %eax,%esi
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xc,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movabs $0x200000003,%rax
mov    %rax,(%rbx)
movl   $0x4,0x8(%rbx)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1060 <my_qsort@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x6,%ecx
call   1040 <getLastLessThanIdx@plt>
lea    0xe74(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @malloc(i32 12)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 3, i32* %10
%11 = load i32*, i32** %6
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 2, i32* %12
%13 = load i32*, i32** %6
%14 = getelementptr inbounds i32, i32* %13, i64 2
store i32 4, i32* %14
%15 = load i32*, i32** %6
%16 = call i32 @my_qsort(i32* %15, i32 0, i32 2)
%17 = load i32*, i32** %6
%18 = call i32 @getLastLessThanIdx(i32* %17, i32 0, i32 2, i32 6)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 12)
%4 = inttoptr i64 %3 to i32*
store i32 3, i32* %4
%5 = getelementptr inbounds i32, i32* %4, i64 1
store i32 2, i32* %5
%6 = getelementptr inbounds i32, i32* %4, i64 2
store i32 4, i32* %6
%7 = tail call i32 @my_qsort(i32* %4, i32 0, i32 2)
%8 = tail call i32 @getLastLessThanIdx(i32* %4, i32 0, i32 2, i32 6)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
ret i32 0
}