program main
	implicit none
    integer::n,i
    real(8)::t
    integer,allocatable::x(:),y(:)
    read(*,*) n
    allocate(x(n))
    allocate(y(n))
    
    read(*,*) x
    y=x
    call heapsort(n,y)
    
    t=(real(y(n/2),kind=8)+real(y(n/2 +1),kind=8))/2.0_8
    
    do i=1,n
    	if(real(x(i),8)<t)then
        	write(*,*) y(n/2 +1)
        else
        	write(*,*) y(n/2)
        end if
    end do
    
    deallocate(x)
    deallocate(y)
    
    
    stop
contains
	subroutine heapsort(n,array)
        implicit none
        integer,intent(in) :: n
        integer,intent(inout) :: array(1:n)
       
        integer ::i,k,j,l
        double precision :: t
       
        if(n.le.0)then
           write(6,*)"Error, at heapsort"; stop
        endif
        if(n.eq.1)return
      
        l=n/2+1
        k=n
        do while(k.ne.1)
           if(l.gt.1)then
              l=l-1
              t=array(L)
           else
              t=array(k)
              array(k)=array(1)
              k=k-1
              if(k.eq.1) then
                 array(1)=t
                 exit
              end if
           end if
           i=l
           j=l+l
           do while(j.le.k)
              if(j.lt.k)then
                 if(array(j).lt.array(j+1))j=j+1
              end if
              if (t.lt.array(j))then
                 array(i)=array(j)
                 i=j
                 j=j+j
              else
                 j=k+1
              endif
           end do
           array(i)=t
        end do
      
        return
    end subroutine heapsort
end program main
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEx.0 = internal unnamed_addr global ptr null
@_QFEx.8 = internal unnamed_addr global i64 0
@_QFEy.0 = internal unnamed_addr global ptr null
@_QFEy.7 = internal unnamed_addr global i64 1
@_QFEy.8 = internal unnamed_addr global i64 0
@_QQcl.7f484604e628cbf7314adce0026cf6b2 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6092/source.f\00"
@_QQcl.4572726F722C2061742068656170736F7274 = linkonce constant [18 x i8] c"Error, at heapsort"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #2 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7f484604e628cbf7314adce0026cf6b2, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  %9 = shl nuw nsw i64 %8, 2
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEx.8, align 8, !tbaa !7
  %11 = call ptr @malloc(i64 %9)
  store ptr %11, ptr @_QFEy.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEy.7, align 8, !tbaa !7
  store i64 %8, ptr @_QFEy.8, align 8, !tbaa !7
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7f484604e628cbf7314adce0026cf6b2, i32 10)
  %.unpack = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack500.unpack.unpack502 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack500.unpack.unpack502, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %12, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %.unpack505 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack505651 = ptrtoint ptr %.unpack505 to i64
  %.unpack512.unpack.unpack514 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack517 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.unpack517654 = ptrtoint ptr %.unpack517 to i64
  %.not = icmp eq ptr %.unpack517, null
  br i1 %.not, label %84, label %15

15:                                               ; preds = %0
  %.unpack524.unpack.unpack526 = load i64, ptr @_QFEy.8, align 8, !tbaa !7
  %.not623 = icmp eq i64 %.unpack524.unpack.unpack526, %.unpack512.unpack.unpack514
  br i1 %.not623, label %.preheader, label %31

.preheader:                                       ; preds = %15
  %16 = icmp sgt i64 %.unpack512.unpack.unpack514, 0
  br i1 %16, label %.lr.ph625.preheader, label %._crit_edge

.lr.ph625.preheader:                              ; preds = %.preheader
  %min.iters.check658 = icmp ult i64 %.unpack512.unpack.unpack514, 8
  %17 = sub i64 %.unpack517654, %.unpack505651
  %diff.check655 = icmp ult i64 %17, 32
  %or.cond = select i1 %min.iters.check658, i1 true, i1 %diff.check655
  br i1 %or.cond, label %.lr.ph625.preheader688, label %vector.ph659

vector.ph659:                                     ; preds = %.lr.ph625.preheader
  %n.vec661 = and i64 %.unpack512.unpack.unpack514, -8
  br label %vector.body664

vector.body664:                                   ; preds = %vector.body664, %vector.ph659
  %index665 = phi i64 [ 0, %vector.ph659 ], [ %index.next668, %vector.body664 ]
  %18 = getelementptr i32, ptr %.unpack505, i64 %index665
  %wide.load666 = load <4 x i32>, ptr %18, align 4, !tbaa !3
  %19 = getelementptr i32, ptr %18, i64 4
  %wide.load667 = load <4 x i32>, ptr %19, align 4, !tbaa !3
  %20 = getelementptr i32, ptr %.unpack517, i64 %index665
  store <4 x i32> %wide.load666, ptr %20, align 4, !tbaa !3
  %21 = getelementptr i32, ptr %20, i64 4
  store <4 x i32> %wide.load667, ptr %21, align 4, !tbaa !3
  %index.next668 = add nuw i64 %index665, 8
  %22 = icmp eq i64 %index.next668, %n.vec661
  br i1 %22, label %middle.block656, label %vector.body664, !llvm.loop !9

middle.block656:                                  ; preds = %vector.body664
  %cmp.n663 = icmp eq i64 %.unpack512.unpack.unpack514, %n.vec661
  br i1 %cmp.n663, label %._crit_edge, label %.lr.ph625.preheader688

.lr.ph625.preheader688:                           ; preds = %.lr.ph625.preheader, %middle.block656
  %.ph689 = phi i64 [ 0, %.lr.ph625.preheader ], [ %n.vec661, %middle.block656 ]
  %23 = xor i64 %.ph689, -1
  %24 = add i64 %.unpack512.unpack.unpack514, %23
  %xtraiter693 = and i64 %.unpack512.unpack.unpack514, 3
  %lcmp.mod694.not = icmp eq i64 %xtraiter693, 0
  br i1 %lcmp.mod694.not, label %.lr.ph625.prol.loopexit, label %.lr.ph625.prol

.lr.ph625.prol:                                   ; preds = %.lr.ph625.preheader688, %.lr.ph625.prol
  %25 = phi i64 [ %28, %.lr.ph625.prol ], [ %.ph689, %.lr.ph625.preheader688 ]
  %prol.iter695 = phi i64 [ %prol.iter695.next, %.lr.ph625.prol ], [ 0, %.lr.ph625.preheader688 ]
  %26 = getelementptr i32, ptr %.unpack505, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !3
  %28 = add nuw nsw i64 %25, 1
  %29 = getelementptr i32, ptr %.unpack517, i64 %25
  store i32 %27, ptr %29, align 4, !tbaa !3
  %prol.iter695.next = add i64 %prol.iter695, 1
  %prol.iter695.cmp.not = icmp eq i64 %prol.iter695.next, %xtraiter693
  br i1 %prol.iter695.cmp.not, label %.lr.ph625.prol.loopexit, label %.lr.ph625.prol, !llvm.loop !12

.lr.ph625.prol.loopexit:                          ; preds = %.lr.ph625.prol, %.lr.ph625.preheader688
  %.unr696 = phi i64 [ %.ph689, %.lr.ph625.preheader688 ], [ %28, %.lr.ph625.prol ]
  %30 = icmp ult i64 %24, 3
  br i1 %30, label %._crit_edge, label %.lr.ph625

31:                                               ; preds = %15
  %32 = shl i64 %.unpack512.unpack.unpack514, 2
  %33 = call ptr @malloc(i64 %32)
  %34 = icmp sgt i64 %.unpack512.unpack.unpack514, 0
  br i1 %34, label %.lr.ph.preheader, label %.thread622

.lr.ph.preheader:                                 ; preds = %31
  %35 = ptrtoint ptr %33 to i64
  %min.iters.check = icmp ult i64 %.unpack512.unpack.unpack514, 8
  %36 = sub i64 %35, %.unpack505651
  %diff.check = icmp ult i64 %36, 32
  %or.cond684 = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond684, label %.lr.ph.preheader690, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %.unpack512.unpack.unpack514, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %37 = getelementptr i32, ptr %.unpack505, i64 %index
  %wide.load = load <4 x i32>, ptr %37, align 4, !tbaa !3
  %38 = getelementptr i32, ptr %37, i64 4
  %wide.load652 = load <4 x i32>, ptr %38, align 4, !tbaa !3
  %39 = getelementptr i32, ptr %33, i64 %index
  store <4 x i32> %wide.load, ptr %39, align 4, !tbaa !3
  %40 = getelementptr i32, ptr %39, i64 4
  store <4 x i32> %wide.load652, ptr %40, align 4, !tbaa !3
  %index.next = add nuw i64 %index, 8
  %41 = icmp eq i64 %index.next, %n.vec
  br i1 %41, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %.unpack512.unpack.unpack514, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader690

.lr.ph.preheader690:                              ; preds = %.lr.ph.preheader, %middle.block
  %.ph691 = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %42 = xor i64 %.ph691, -1
  %43 = add i64 %.unpack512.unpack.unpack514, %42
  %xtraiter = and i64 %.unpack512.unpack.unpack514, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader690, %.lr.ph.prol
  %44 = phi i64 [ %47, %.lr.ph.prol ], [ %.ph691, %.lr.ph.preheader690 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader690 ]
  %45 = getelementptr i32, ptr %.unpack505, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = add nuw nsw i64 %44, 1
  %48 = getelementptr i32, ptr %33, i64 %44
  store i32 %46, ptr %48, align 4, !tbaa !3
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !15

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader690
  %.unr = phi i64 [ %.ph691, %.lr.ph.preheader690 ], [ %47, %.lr.ph.prol ]
  %49 = icmp ult i64 %43, 3
  br i1 %49, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %50 = phi i64 [ %65, %.lr.ph ], [ %.unr, %.lr.ph.prol.loopexit ]
  %51 = getelementptr i32, ptr %.unpack505, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !3
  %53 = add nuw nsw i64 %50, 1
  %54 = getelementptr i32, ptr %33, i64 %50
  store i32 %52, ptr %54, align 4, !tbaa !3
  %55 = getelementptr i32, ptr %.unpack505, i64 %53
  %56 = load i32, ptr %55, align 4, !tbaa !3
  %57 = add nuw nsw i64 %50, 2
  %58 = getelementptr i32, ptr %33, i64 %53
  store i32 %56, ptr %58, align 4, !tbaa !3
  %59 = getelementptr i32, ptr %.unpack505, i64 %57
  %60 = load i32, ptr %59, align 4, !tbaa !3
  %61 = add nuw nsw i64 %50, 3
  %62 = getelementptr i32, ptr %33, i64 %57
  store i32 %60, ptr %62, align 4, !tbaa !3
  %63 = getelementptr i32, ptr %.unpack505, i64 %61
  %64 = load i32, ptr %63, align 4, !tbaa !3
  %65 = add nuw nsw i64 %50, 4
  %66 = getelementptr i32, ptr %33, i64 %61
  store i32 %64, ptr %66, align 4, !tbaa !3
  %exitcond.not.3 = icmp eq i64 %65, %.unpack512.unpack.unpack514
  br i1 %exitcond.not.3, label %.loopexit, label %.lr.ph, !llvm.loop !16

.lr.ph625:                                        ; preds = %.lr.ph625.prol.loopexit, %.lr.ph625
  %67 = phi i64 [ %82, %.lr.ph625 ], [ %.unr696, %.lr.ph625.prol.loopexit ]
  %68 = getelementptr i32, ptr %.unpack505, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !3
  %70 = add nuw nsw i64 %67, 1
  %71 = getelementptr i32, ptr %.unpack517, i64 %67
  store i32 %69, ptr %71, align 4, !tbaa !3
  %72 = getelementptr i32, ptr %.unpack505, i64 %70
  %73 = load i32, ptr %72, align 4, !tbaa !3
  %74 = add nuw nsw i64 %67, 2
  %75 = getelementptr i32, ptr %.unpack517, i64 %70
  store i32 %73, ptr %75, align 4, !tbaa !3
  %76 = getelementptr i32, ptr %.unpack505, i64 %74
  %77 = load i32, ptr %76, align 4, !tbaa !3
  %78 = add nuw nsw i64 %67, 3
  %79 = getelementptr i32, ptr %.unpack517, i64 %74
  store i32 %77, ptr %79, align 4, !tbaa !3
  %80 = getelementptr i32, ptr %.unpack505, i64 %78
  %81 = load i32, ptr %80, align 4, !tbaa !3
  %82 = add nuw nsw i64 %67, 4
  %83 = getelementptr i32, ptr %.unpack517, i64 %78
  store i32 %81, ptr %83, align 4, !tbaa !3
  %exitcond632.not.3 = icmp eq i64 %82, %.unpack512.unpack.unpack514
  br i1 %exitcond632.not.3, label %._crit_edge, label %.lr.ph625, !llvm.loop !17

84:                                               ; preds = %0
  %85 = shl i64 %.unpack512.unpack.unpack514, 2
  %86 = call ptr @malloc(i64 %85)
  %87 = icmp sgt i64 %.unpack512.unpack.unpack514, 0
  br i1 %87, label %.lr.ph627.preheader, label %.loopexit.thread

.lr.ph627.preheader:                              ; preds = %84
  %88 = ptrtoint ptr %86 to i64
  %min.iters.check673 = icmp ult i64 %.unpack512.unpack.unpack514, 8
  %89 = sub i64 %88, %.unpack505651
  %diff.check670 = icmp ult i64 %89, 32
  %or.cond685 = select i1 %min.iters.check673, i1 true, i1 %diff.check670
  br i1 %or.cond685, label %.lr.ph627.preheader686, label %vector.ph674

vector.ph674:                                     ; preds = %.lr.ph627.preheader
  %n.vec676 = and i64 %.unpack512.unpack.unpack514, -8
  br label %vector.body679

vector.body679:                                   ; preds = %vector.body679, %vector.ph674
  %index680 = phi i64 [ 0, %vector.ph674 ], [ %index.next683, %vector.body679 ]
  %90 = getelementptr i32, ptr %.unpack505, i64 %index680
  %wide.load681 = load <4 x i32>, ptr %90, align 4, !tbaa !3
  %91 = getelementptr i32, ptr %90, i64 4
  %wide.load682 = load <4 x i32>, ptr %91, align 4, !tbaa !3
  %92 = getelementptr i32, ptr %86, i64 %index680
  store <4 x i32> %wide.load681, ptr %92, align 4, !tbaa !3
  %93 = getelementptr i32, ptr %92, i64 4
  store <4 x i32> %wide.load682, ptr %93, align 4, !tbaa !3
  %index.next683 = add nuw i64 %index680, 8
  %94 = icmp eq i64 %index.next683, %n.vec676
  br i1 %94, label %middle.block671, label %vector.body679, !llvm.loop !18

middle.block671:                                  ; preds = %vector.body679
  %cmp.n678 = icmp eq i64 %.unpack512.unpack.unpack514, %n.vec676
  br i1 %cmp.n678, label %.loopexit, label %.lr.ph627.preheader686

.lr.ph627.preheader686:                           ; preds = %.lr.ph627.preheader, %middle.block671
  %.ph687 = phi i64 [ 0, %.lr.ph627.preheader ], [ %n.vec676, %middle.block671 ]
  %95 = xor i64 %.ph687, -1
  %96 = add i64 %.unpack512.unpack.unpack514, %95
  %xtraiter697 = and i64 %.unpack512.unpack.unpack514, 3
  %lcmp.mod698.not = icmp eq i64 %xtraiter697, 0
  br i1 %lcmp.mod698.not, label %.lr.ph627.prol.loopexit, label %.lr.ph627.prol

.lr.ph627.prol:                                   ; preds = %.lr.ph627.preheader686, %.lr.ph627.prol
  %97 = phi i64 [ %100, %.lr.ph627.prol ], [ %.ph687, %.lr.ph627.preheader686 ]
  %prol.iter699 = phi i64 [ %prol.iter699.next, %.lr.ph627.prol ], [ 0, %.lr.ph627.preheader686 ]
  %98 = getelementptr i32, ptr %.unpack505, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !3
  %100 = add nuw nsw i64 %97, 1
  %101 = getelementptr i32, ptr %86, i64 %97
  store i32 %99, ptr %101, align 4, !tbaa !3
  %prol.iter699.next = add i64 %prol.iter699, 1
  %prol.iter699.cmp.not = icmp eq i64 %prol.iter699.next, %xtraiter697
  br i1 %prol.iter699.cmp.not, label %.lr.ph627.prol.loopexit, label %.lr.ph627.prol, !llvm.loop !19

.lr.ph627.prol.loopexit:                          ; preds = %.lr.ph627.prol, %.lr.ph627.preheader686
  %.unr700 = phi i64 [ %.ph687, %.lr.ph627.preheader686 ], [ %100, %.lr.ph627.prol ]
  %102 = icmp ult i64 %96, 3
  br i1 %102, label %.loopexit, label %.lr.ph627

.lr.ph627:                                        ; preds = %.lr.ph627.prol.loopexit, %.lr.ph627
  %103 = phi i64 [ %118, %.lr.ph627 ], [ %.unr700, %.lr.ph627.prol.loopexit ]
  %104 = getelementptr i32, ptr %.unpack505, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !3
  %106 = add nuw nsw i64 %103, 1
  %107 = getelementptr i32, ptr %86, i64 %103
  store i32 %105, ptr %107, align 4, !tbaa !3
  %108 = getelementptr i32, ptr %.unpack505, i64 %106
  %109 = load i32, ptr %108, align 4, !tbaa !3
  %110 = add nuw nsw i64 %103, 2
  %111 = getelementptr i32, ptr %86, i64 %106
  store i32 %109, ptr %111, align 4, !tbaa !3
  %112 = getelementptr i32, ptr %.unpack505, i64 %110
  %113 = load i32, ptr %112, align 4, !tbaa !3
  %114 = add nuw nsw i64 %103, 3
  %115 = getelementptr i32, ptr %86, i64 %110
  store i32 %113, ptr %115, align 4, !tbaa !3
  %116 = getelementptr i32, ptr %.unpack505, i64 %114
  %117 = load i32, ptr %116, align 4, !tbaa !3
  %118 = add nuw nsw i64 %103, 4
  %119 = getelementptr i32, ptr %86, i64 %114
  store i32 %117, ptr %119, align 4, !tbaa !3
  %exitcond633.not.3 = icmp eq i64 %118, %.unpack512.unpack.unpack514
  br i1 %exitcond633.not.3, label %.loopexit, label %.lr.ph627, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %.lr.ph627.prol.loopexit, %.lr.ph627, %middle.block, %middle.block671
  %.ph = phi ptr [ %86, %middle.block671 ], [ %33, %middle.block ], [ %86, %.lr.ph627 ], [ %86, %.lr.ph627.prol.loopexit ], [ %33, %.lr.ph ], [ %33, %.lr.ph.prol.loopexit ]
  br i1 %.not, label %.loopexit.thread, label %.thread622

.thread622:                                       ; preds = %31, %.loopexit
  %.ph642 = phi ptr [ %.ph, %.loopexit ], [ %33, %31 ]
  call void @free(ptr nonnull %.unpack517)
  br label %.loopexit.thread

.loopexit.thread:                                 ; preds = %84, %.thread622, %.loopexit
  %.ph639 = phi ptr [ %.ph642, %.thread622 ], [ %.ph, %.loopexit ], [ %86, %84 ]
  store ptr %.ph639, ptr @_QFEy.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEy.7, align 8, !tbaa !7
  store i64 %.unpack512.unpack.unpack514, ptr @_QFEy.8, align 8, !tbaa !7
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph625.prol.loopexit, %.lr.ph625, %middle.block656, %.preheader, %.loopexit.thread
  %.unpack529 = phi ptr [ %.ph639, %.loopexit.thread ], [ %.unpack517, %.preheader ], [ %.unpack517, %middle.block656 ], [ %.unpack517, %.lr.ph625 ], [ %.unpack517, %.lr.ph625.prol.loopexit ]
  call void @_QFPheapsort(ptr nonnull %2, ptr %.unpack529)
  %.unpack541 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.unpack548.unpack.unpack = load i64, ptr @_QFEy.7, align 8, !tbaa !7
  %120 = load i32, ptr %2, align 4, !tbaa !3
  %121 = sdiv i32 %120, 2
  %122 = sext i32 %121 to i64
  %123 = sub i64 %122, %.unpack548.unpack.unpack
  %124 = getelementptr i32, ptr %.unpack541, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !3
  %126 = sitofp i32 %125 to double
  %127 = add nsw i32 %121, 1
  %128 = sext i32 %127 to i64
  %129 = sub i64 %128, %.unpack548.unpack.unpack
  %130 = getelementptr i32, ptr %.unpack541, i64 %129
  %131 = load i32, ptr %130, align 4, !tbaa !3
  %132 = sitofp i32 %131 to double
  %133 = fadd contract double %126, %132
  %134 = fmul contract double %133, 5.000000e-01
  %135 = icmp sgt i32 %120, 0
  br i1 %135, label %.lr.ph629.preheader, label %._crit_edge630

.lr.ph629.preheader:                              ; preds = %._crit_edge
  %136 = zext i32 %120 to i64
  br label %.lr.ph629

.lr.ph629:                                        ; preds = %.lr.ph629.preheader, %151
  %indvars.iv = phi i64 [ 1, %.lr.ph629.preheader ], [ %indvars.iv.next, %151 ]
  %.unpack577 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %137 = add nsw i64 %indvars.iv, -1
  %138 = getelementptr i32, ptr %.unpack577, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !3
  %140 = sitofp i32 %139 to double
  %141 = fcmp ogt double %134, %140
  br i1 %141, label %142, label %147

142:                                              ; preds = %.lr.ph629
  %143 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7f484604e628cbf7314adce0026cf6b2, i32 18)
  %144 = load i32, ptr %2, align 4, !tbaa !3
  %145 = sdiv i32 %144, 2
  %146 = add nsw i32 %145, 1
  br label %151

147:                                              ; preds = %.lr.ph629
  %148 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7f484604e628cbf7314adce0026cf6b2, i32 20)
  %149 = load i32, ptr %2, align 4, !tbaa !3
  %150 = sdiv i32 %149, 2
  br label %151

151:                                              ; preds = %142, %147
  %.sink649 = phi i32 [ %146, %142 ], [ %150, %147 ]
  %.sink644 = phi ptr [ %143, %142 ], [ %148, %147 ]
  %.unpack601.sink = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.unpack608.unpack.unpack.sink = load i64, ptr @_QFEy.7, align 8, !tbaa !7
  %152 = sext i32 %.sink649 to i64
  %153 = sub i64 %152, %.unpack608.unpack.unpack.sink
  %154 = getelementptr i32, ptr %.unpack601.sink, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !3
  %156 = call i1 @_FortranAioOutputInteger32(ptr %.sink644, i32 %155)
  %157 = call i32 @_FortranAioEndIoStatement(ptr %.sink644)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond635.not = icmp eq i64 %indvars.iv, %136
  br i1 %exitcond635.not, label %._crit_edge630.loopexit, label %.lr.ph629

._crit_edge630.loopexit:                          ; preds = %151
  %.unpack565.pre = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  br label %._crit_edge630

._crit_edge630:                                   ; preds = %._crit_edge630.loopexit, %._crit_edge
  %.unpack565 = phi ptr [ %.unpack565.pre, %._crit_edge630.loopexit ], [ %.unpack541, %._crit_edge ]
  %.unpack553 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  call void @free(ptr %.unpack553)
  store ptr null, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 0, ptr @_QFEx.8, align 8, !tbaa !7
  call void @free(ptr %.unpack565)
  store ptr null, ptr @_QFEy.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEy.7, align 8, !tbaa !7
  store i64 0, ptr @_QFEy.8, align 8, !tbaa !7
  %158 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

define void @_QFPheapsort(ptr nocapture readonly %0, ptr nocapture %1) local_unnamed_addr {
  %3 = load i32, ptr %0, align 4, !tbaa !3
  %4 = icmp slt i32 %3, 1
  br i1 %4, label %5, label %10

5:                                                ; preds = %2
  %6 = tail call ptr @_FortranAioBeginExternalListOutput(i32 6, ptr nonnull @_QQcl.7f484604e628cbf7314adce0026cf6b2, i32 39)
  %7 = tail call i1 @_FortranAioOutputAscii(ptr %6, ptr nonnull @_QQcl.4572726F722C2061742068656170736F7274, i64 18)
  %8 = tail call i32 @_FortranAioEndIoStatement(ptr %6)
  %9 = tail call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

10:                                               ; preds = %2
  %11 = icmp eq i32 %3, 1
  br i1 %11, label %91, label %12

12:                                               ; preds = %10
  %13 = lshr i32 %3, 1
  %14 = add nuw nsw i32 %13, 1
  br label %15

15:                                               ; preds = %.split47.us, %12
  %.026 = phi i32 [ %3, %12 ], [ %.127.fr, %.split47.us ]
  %.025 = phi i32 [ %14, %12 ], [ %.1, %.split47.us ]
  %16 = icmp sgt i32 %.025, 1
  br i1 %16, label %17, label %23

17:                                               ; preds = %15
  %18 = add nsw i32 %.025, -1
  %19 = zext i32 %18 to i64
  %20 = add nsw i64 %19, -1
  %21 = getelementptr i32, ptr %1, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !3
  br label %32

23:                                               ; preds = %15
  %24 = zext i32 %.026 to i64
  %25 = add nsw i64 %24, -1
  %26 = getelementptr i32, ptr %1, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !3
  %28 = load i32, ptr %1, align 4, !tbaa !3
  store i32 %28, ptr %26, align 4, !tbaa !3
  %29 = add i32 %.026, -1
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %23
  store i32 %27, ptr %1, align 4, !tbaa !3
  br label %91

32:                                               ; preds = %17, %23
  %.127 = phi i32 [ %.026, %17 ], [ %29, %23 ]
  %.1 = phi i32 [ %18, %17 ], [ 1, %23 ]
  %.0.in = phi i32 [ %22, %17 ], [ %27, %23 ]
  %.127.fr = freeze i32 %.127
  %33 = shl nuw i32 %.1, 1
  %.not3441 = icmp sgt i32 %33, %.127.fr
  br i1 %.not3441, label %.split47.us, label %.lr.ph.lr.ph

.lr.ph.lr.ph:                                     ; preds = %32
  %.not.not = icmp eq i32 %.127.fr, 2147483647
  br i1 %.not.not, label %.lr.ph.preheader, label %.lr.ph.us

.lr.ph.preheader:                                 ; preds = %.lr.ph.lr.ph
  %.127.fr.le = freeze i32 %.127
  %34 = add i32 %.127.fr.le, 1
  %.not = icmp eq i32 %34, 2147483647
  %35 = sext i32 %34 to i64
  %36 = add nsw i64 %35, -1
  %37 = getelementptr i32, ptr %1, i64 %36
  %38 = getelementptr i32, ptr %1, i64 %35
  br label %59

.lr.ph.us:                                        ; preds = %.lr.ph.lr.ph, %.split.us.us
  %.028.ph43.us = phi i32 [ %58, %.split.us.us ], [ %33, %.lr.ph.lr.ph ]
  %.030.ph42.us = phi i32 [ %.129.us.us, %.split.us.us ], [ %.1, %.lr.ph.lr.ph ]
  %39 = icmp slt i32 %.028.ph43.us, %.127.fr
  br i1 %39, label %40, label %49

40:                                               ; preds = %.lr.ph.us
  %41 = sext i32 %.028.ph43.us to i64
  %42 = add nsw i64 %41, -1
  %43 = getelementptr i32, ptr %1, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !3
  %45 = getelementptr i32, ptr %1, i64 %41
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = icmp slt i32 %44, %46
  %48 = zext i1 %47 to i32
  %spec.select.us.us = or i32 %.028.ph43.us, %48
  br label %49

49:                                               ; preds = %40, %.lr.ph.us
  %.129.us.us = phi i32 [ %.028.ph43.us, %.lr.ph.us ], [ %spec.select.us.us, %40 ]
  %50 = sext i32 %.129.us.us to i64
  %51 = add nsw i64 %50, -1
  %52 = getelementptr i32, ptr %1, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !3
  %54 = icmp slt i32 %.0.in, %53
  br i1 %54, label %.split.us.us, label %.split47.us

.split.us.us:                                     ; preds = %49
  %55 = sext i32 %.030.ph42.us to i64
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %1, i64 %56
  store i32 %53, ptr %57, align 4, !tbaa !3
  %58 = shl i32 %.129.us.us, 1
  %.not34.us = icmp sgt i32 %58, %.127.fr
  br i1 %.not34.us, label %.split47.us, label %.lr.ph.us

59:                                               ; preds = %.split, %.lr.ph.preheader
  %.028.ph43 = phi i32 [ %87, %.split ], [ %33, %.lr.ph.preheader ]
  %.030.ph42 = phi i32 [ %.129.lcssa, %.split ], [ %.1, %.lr.ph.preheader ]
  %60 = sext i32 %.028.ph43 to i64
  %61 = add nsw i64 %60, -1
  %62 = getelementptr i32, ptr %1, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !3
  %64 = getelementptr i32, ptr %1, i64 %60
  %65 = load i32, ptr %64, align 4, !tbaa !3
  %66 = icmp slt i32 %63, %65
  %67 = zext i1 %66 to i32
  %spec.select.peel = or i32 %.028.ph43, %67
  %68 = sext i32 %spec.select.peel to i64
  %69 = add nsw i64 %68, -1
  %70 = getelementptr i32, ptr %1, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !3
  %72 = icmp slt i32 %.0.in, %71
  br i1 %72, label %.split, label %.peel.next

.peel.next:                                       ; preds = %59, %78
  br i1 %.not, label %78, label %73

73:                                               ; preds = %.peel.next
  %74 = load i32, ptr %37, align 4, !tbaa !3
  %75 = load i32, ptr %38, align 4, !tbaa !3
  %76 = icmp slt i32 %74, %75
  %77 = zext i1 %76 to i32
  %spec.select = add nsw i32 %34, %77
  br label %78

78:                                               ; preds = %73, %.peel.next
  %.129 = phi i32 [ 2147483647, %.peel.next ], [ %spec.select, %73 ]
  %79 = sext i32 %.129 to i64
  %80 = add nsw i64 %79, -1
  %81 = getelementptr i32, ptr %1, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !3
  %83 = icmp slt i32 %.0.in, %82
  br i1 %83, label %.split, label %.peel.next, !llvm.loop !21

.split:                                           ; preds = %78, %59
  %.129.lcssa = phi i32 [ %spec.select.peel, %59 ], [ %.129, %78 ]
  %.lcssa = phi i32 [ %71, %59 ], [ %82, %78 ]
  %84 = sext i32 %.030.ph42 to i64
  %85 = add nsw i64 %84, -1
  %86 = getelementptr i32, ptr %1, i64 %85
  store i32 %.lcssa, ptr %86, align 4, !tbaa !3
  %87 = shl i32 %.129.lcssa, 1
  br label %59

.split47.us:                                      ; preds = %.split.us.us, %49, %32
  %.030.ph.lcssa = phi i32 [ %.1, %32 ], [ %.030.ph42.us, %49 ], [ %.129.us.us, %.split.us.us ]
  %88 = sext i32 %.030.ph.lcssa to i64
  %89 = add nsw i64 %88, -1
  %90 = getelementptr i32, ptr %1, i64 %89
  store i32 %.0.in, ptr %90, align 4, !tbaa !3
  br label %15

91:                                               ; preds = %31, %10
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { noreturn }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !10, !11}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !11}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !10}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.peeled.count", i32 1}
