#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*/ HDOWN(double *, int *, int *, int, int, int *);
int /*<<< orphan*/ HUP(double *, int *, int *, int, int *);
void HCHANGE(double HA[], int HJ[], int HK[], int N, int K, double V, int JV,
             int *HOPS) {
  double V1;
  V1 = HA[K];
  HA[K] = V;
  HJ[K] = JV;
  HK[JV] = K;
  if (V1 < V)
    HUP(HA, HJ, HK, K, HOPS);
  else
    HDOWN(HA, HJ, HK, N, K, HOPS);
}


x86 assembly (clang, -O0):
<HCHANGE>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b9 <HCHANGE+0x99>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%r8
call   1040 <HUP@plt>
jmp    11d5 <HCHANGE+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    0x10(%rbp),%r9
call   1030 <HDOWN@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HCHANGE>:
mov    0x8(%rsp),%r10
movslq %r8d,%r11
ucomisd (%rdi,%r11,8),%xmm0
movsd  %xmm0,(%rdi,%r11,8)
mov    %r9d,(%rsi,%r11,4)
movslq %r9d,%rax
mov    %r11d,(%rdx,%rax,4)
jbe    114c <HCHANGE+0x2c>
mov    %r8d,%ecx
mov    %r10,%r8
jmp    1040 <HUP@plt>
mov    %r10,%r9
jmp    1030 <HDOWN@plt>

LLVM IR (-O0):
define void @HCHANGE(double* %0, i32* %1, i32* %2, i32 %3, i32 %4, double %5, i32 %6, i32* %7) {
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%16 = alloca i32*
%17 = alloca double
store double* %0, double** %9
store i32* %1, i32** %10
store i32* %2, i32** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store double %5, double* %14
store i32 %6, i32* %15
store i32* %7, i32** %16
%18 = load double*, double** %9
%19 = load i32, i32* %13
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
store double %22, double* %17
%23 = load double, double* %14
%24 = load double*, double** %9
%25 = load i32, i32* %13
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
store double %23, double* %27
%28 = load i32, i32* %15
%29 = load i32*, i32** %10
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
%33 = load i32, i32* %13
%34 = load i32*, i32** %11
%35 = load i32, i32* %15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
%38 = load double, double* %17
%39 = load double, double* %14
%40 = fcmp olt double %38, %39
br i1 %40, label %41, label %48
41: ; preds = %8
%42 = load double*, double** %9
%43 = load i32*, i32** %10
%44 = load i32*, i32** %11
%45 = load i32, i32* %13
%46 = load i32*, i32** %16
%47 = call i32 @HUP(double* %42, i32* %43, i32* %44, i32 %45, i32* %46)
br label %56
48: ; preds = %8
%49 = load double*, double** %9
%50 = load i32*, i32** %10
%51 = load i32*, i32** %11
%52 = load i32, i32* %12
%53 = load i32, i32* %13
%54 = load i32*, i32** %16
%55 = call i32 @HDOWN(double* %49, i32* %50, i32* %51, i32 %52, i32 %53, i32* %54)
br label %56
56: ; preds = %48, %41
ret void
}

LLVM IR (-O2):
define void @HCHANGE(double* %0, i32* %1, i32* %2, i32 %3, i32 %4, double %5, i32 %6, i32* %7) {
%9 = sext i32 %4 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
store double %5, double* %10
%12 = getelementptr inbounds i32, i32* %1, i64 %9
store i32 %6, i32* %12
%13 = sext i32 %6 to i64
%14 = getelementptr inbounds i32, i32* %2, i64 %13
store i32 %4, i32* %14
%15 = fcmp olt double %11, %5
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = tail call i32 @HUP(double* %0, i32* %1, i32* %2, i32 %4, i32* %7)
br label %20
18: ; preds = %8
%19 = tail call i32 @HDOWN(double* %0, i32* %1, i32* %2, i32 %3, i32 %4, i32* %7)
br label %20
20: ; preds = %18, %16
ret void
}