#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*/ pushHeap(int *, int *, double *, int /*<<< orphan*/, int);
int makeThreshHeap(int *p, int *q, double *v, int arraySize, double thresh) {
  int i, heapsize;
  heapsize = 0;
  for (i = 1; i < arraySize; i++)
    if (v[q[i]] < thresh)
      pushHeap(p, q, v, heapsize++, i);
  return (heapsize);
}


x86 assembly (clang, -O0):
<makeThreshHeap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119d <makeThreshHeap+0x8d>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118a <makeThreshHeap+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%r8d
call   1030 <pushHeap@plt>
jmp    118f <makeThreshHeap+0x7f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113a <makeThreshHeap+0x2a>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeThreshHeap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%eax
xor    %ecx,%ecx
cmp    $0x2,%eax
jl     1172 <makeThreshHeap+0x62>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %eax,%r13d
xor    %ecx,%ecx
mov    $0x1,%ebx
movsd  %xmm0,(%rsp)
jmp    1149 <makeThreshHeap+0x39>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     1172 <makeThreshHeap+0x62>
movslq (%r12,%rbx,4),%rax
ucomisd (%r14,%rax,8),%xmm0
jbe    1140 <makeThreshHeap+0x30>
lea    0x1(%rcx),%ebp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %ebx,%r8d
call   1030 <pushHeap@plt>
movsd  (%rsp),%xmm0
mov    %ebp,%ecx
jmp    1140 <makeThreshHeap+0x30>
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @makeThreshHeap(i32* %0, i32* %1, double* %2, i32 %3, double %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store double* %2, double** %8
store i32 %3, i32* %9
store double %4, double* %10
store i32 0, i32* %12
store i32 1, i32* %11
br label %13
13: ; preds = %38, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %41
17: ; preds = %13
%18 = load double*, double** %8
%19 = load i32*, i32** %7
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %18, i64 %24
%26 = load double, double* %25
%27 = load double, double* %10
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %37
29: ; preds = %17
%30 = load i32*, i32** %6
%31 = load i32*, i32** %7
%32 = load double*, double** %8
%33 = load i32, i32* %12
%34 = add nsw i32 %33, 1
store i32 %34, i32* %12
%35 = load i32, i32* %11
%36 = call i32 @pushHeap(i32* %30, i32* %31, double* %32, i32 %33, i32 %35)
br label %37
37: ; preds = %29, %17
br label %38
38: ; preds = %37
%39 = load i32, i32* %11
%40 = add nsw i32 %39, 1
store i32 %40, i32* %11
br label %13
41: ; preds = %13
%42 = load i32, i32* %12
ret i32 %42
}

LLVM IR (-O2):
define i32 @makeThreshHeap(i32* %0, i32* %1, double* %2, i32 %3, double %4) {
%6 = icmp sgt i32 %3, 1
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %22
%10 = phi i64 [ 1, %7 ], [ %24, %22 ]
%11 = phi i32 [ 0, %7 ], [ %23, %22 ]
%12 = getelementptr inbounds i32, i32* %1, i64 %10
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = load double, double* %15
%17 = fcmp olt double %16, %4
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = add nsw i32 %11, 1
%20 = trunc i64 %10 to i32
%21 = tail call i32 @pushHeap(i32* %0, i32* %1, double* %2, i32 %11, i32 %20)
br label %22
22: ; preds = %9, %18
%23 = phi i32 [ %19, %18 ], [ %11, %9 ]
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %26, label %9
26: ; preds = %22, %5
%27 = phi i32 [ 0, %5 ], [ %23, %22 ]
ret i32 %27
}