#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*/ Rprintf(char *, ...);
int /*<<< orphan*/ swap(int, int, double *, int *, int *, int);
int /*<<< orphan*/ uptoleave(int, int, double *, int *, int *, int);
void upperoutupperin(int outvirt, int k, double *window, int *outlist,
                     int *nrlist, int print_level) {
  int father;
  if (print_level >= 2)
    Rprintf("\nUpperoutUPPERin(%d, %d)\n  ", outvirt, k);
  uptoleave(outvirt, k, window, outlist, nrlist, print_level);
  father = outvirt / 2;
  while (window[outvirt + k] < window[father + k]) {
    swap(outvirt + k, father + k, window, outlist, nrlist, print_level);
    outvirt = father;
    father = outvirt / 2;
  }
  if (print_level >= 2)
    Rprintf("\n");
}


x86 assembly (clang, -O0):
<upperoutupperin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jl     116c <upperoutupperin+0x3c>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <Rprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1040 <uptoleave@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    11fd <upperoutupperin+0xcd>
mov    -0x4(%rbp),%edi
add    -0x8(%rbp),%edi
mov    -0x28(%rbp),%esi
add    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
call   1050 <swap@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
jmp    1195 <upperoutupperin+0x65>
cmpl   $0x2,-0x24(%rbp)
jl     1215 <upperoutupperin+0xe5>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <Rprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upperoutupperin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r12
mov    %esi,%r13d
mov    %edi,%ebp
cmp    $0x2,%r9d
jl     1165 <upperoutupperin+0x35>
lea    0xea7(%rip),%rdi
mov    %ebp,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <Rprintf@plt>
mov    %ebp,%edi
mov    %r13d,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
call   1040 <uptoleave@plt>
mov    %r15,%rcx
mov    %r14d,%r15d
mov    %ebp,%r14d
shr    $0x1f,%r14d
add    %ebp,%r14d
sar    %r14d
add    %r13d,%ebp
movslq %ebp,%rax
lea    (%r14,%r13,1),%esi
movslq %esi,%rdx
movsd  (%r12,%rdx,8),%xmm0
ucomisd (%r12,%rax,8),%xmm0
jbe    11f8 <upperoutupperin+0xc8>
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %r12,%rdx
mov    %rbx,%rbp
mov    %rcx,%rbx
mov    %rbp,%r8
mov    %r15d,%r9d
call   1050 <swap@plt>
mov    %rbx,%rcx
mov    %rbp,%rbx
mov    %r14d,%eax
shr    $0x1f,%eax
add    %r14d,%eax
sar    %eax
add    %r13d,%r14d
movslq %r14d,%rdi
lea    (%rax,%r13,1),%esi
movslq %esi,%rdx
movsd  (%r12,%rdx,8),%xmm0
ucomisd (%r12,%rdi,8),%xmm0
mov    %r14d,%ebp
mov    %eax,%r14d
ja     11b0 <upperoutupperin+0x80>
cmp    $0x2,%r15d
jl     121a <upperoutupperin+0xea>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <Rprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AUpperoutUPPERin(%d, %d)\0A \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @upperoutupperin(i32 %0, i32 %1, double* %2, i32* %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store double* %2, double** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 %5, i32* %12
%14 = load i32, i32* %12
%15 = icmp sge i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @Rprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
br label %20
20: ; preds = %16, %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load double*, double** %9
%24 = load i32*, i32** %10
%25 = load i32*, i32** %11
%26 = load i32, i32* %12
%27 = call i32 @uptoleave(i32 %21, i32 %22, double* %23, i32* %24, i32* %25, i32 %26)
%28 = load i32, i32* %7
%29 = sdiv i32 %28, 2
store i32 %29, i32* %13
br label %30
30: ; preds = %46, %20
%31 = load double*, double** %9
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = add nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %31, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %9
%39 = load i32, i32* %13
%40 = load i32, i32* %8
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %38, i64 %42
%44 = load double, double* %43
%45 = fcmp olt double %37, %44
br i1 %45, label %46, label %61
46: ; preds = %30
%47 = load i32, i32* %7
%48 = load i32, i32* %8
%49 = add nsw i32 %47, %48
%50 = load i32, i32* %13
%51 = load i32, i32* %8
%52 = add nsw i32 %50, %51
%53 = load double*, double** %9
%54 = load i32*, i32** %10
%55 = load i32*, i32** %11
%56 = load i32, i32* %12
%57 = call i32 @swap(i32 %49, i32 %52, double* %53, i32* %54, i32* %55, i32 %56)
%58 = load i32, i32* %13
store i32 %58, i32* %7
%59 = load i32, i32* %7
%60 = sdiv i32 %59, 2
store i32 %60, i32* %13
br label %30
61: ; preds = %30
%62 = load i32, i32* %12
%63 = icmp sge i32 %62, 2
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 (i8*, ...) @Rprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %66
66: ; preds = %64, %61
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"\0AUpperoutUPPERin(%d, %d)\0A \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @upperoutupperin(i32 %0, i32 %1, double* %2, i32* %3, i32* %4, i32 %5) {
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 (i8*, ...) @Rprintf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
br label %10
10: ; preds = %8, %6
%11 = tail call i32 @uptoleave(i32 %0, i32 %1, double* %2, i32* %3, i32* %4, i32 %5)
%12 = sdiv i32 %0, 2
%13 = add nsw i32 %0, %1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %2, i64 %14
%16 = load double, double* %15
%17 = add nsw i32 %12, %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %2, i64 %18
%20 = load double, double* %19
%21 = fcmp olt double %16, %20
br i1 %21, label %22, label %37
22: ; preds = %10, %22
%23 = phi i32 [ %32, %22 ], [ %17, %10 ]
%24 = phi i32 [ %28, %22 ], [ %13, %10 ]
%25 = phi i32 [ %27, %22 ], [ %12, %10 ]
%26 = tail call i32 @swap(i32 %24, i32 %23, double* %2, i32* %3, i32* %4, i32 %5)
%27 = sdiv i32 %25, 2
%28 = add nsw i32 %25, %1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %2, i64 %29
%31 = load double, double* %30
%32 = add nsw i32 %27, %1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %2, i64 %33
%35 = load double, double* %34
%36 = fcmp olt double %31, %35
br i1 %36, label %22, label %37
37: ; preds = %22, %10
br i1 %7, label %38, label %40
38: ; preds = %37
%39 = tail call i32 (i8*, ...) @Rprintf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %37
ret void
}