program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n,ans
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n,m
    ans=0
    allocate(x(n),y(n))
    do i=1,n

        read(*,*)x(i),y(i)
    end do
    call m2sort(x,y)
    do i=1,n
        if(y(i)<m)then
            ans=ans+x(i)*y(i)
            m=m-y(i)
        else
            ans=ans+x(i)*m
            write(*,*)ans
            stop
        end if
    end do


        stop
        contains
        recursive subroutine m2sort(x,y)
    implicit none
    integer(8), intent(inout) :: x(:),y(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:),tmp2(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call m2sort(x(:mid),y(:mid))
    call m2sort(x(mid+1:),y(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n),tmp2(n))
    tmp(:) = x(:)
    tmp2(:)=y(:)
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
      tmp2(k) = y(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        y(k)=tmp2(i)
        i = i + 1
      else
        x(k) = tmp(j)
        y(k)=tmp2(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp,tmp2)
    return
  end subroutine m2sort
end program sample
  


; 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.8 = internal unnamed_addr global i64 0
@_QQcl.85d50e53c1d55c714d411a30e6c09ac1 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4762/source.f\00"
@_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 { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.85d50e53c1d55c714d411a30e6c09ac1, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 8)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 8)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %9 = load i64, ptr %4, align 8, !tbaa !3
  %10 = call i64 @llvm.smax.i64(i64 %9, i64 0)
  %11 = shl i64 %10, 3
  %12 = call ptr @malloc(i64 %11)
  store ptr %12, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %10, ptr @_QFEx.8, align 8, !tbaa !7
  %13 = call ptr @malloc(i64 %11)
  store ptr %13, ptr @_QFEy.0, align 8, !tbaa !7
  store i64 %10, ptr @_QFEy.8, align 8, !tbaa !7
  %14 = icmp sgt i64 %9, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %15 = phi i64 [ %24, %.lr.ph ], [ 1, %0 ]
  %16 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.85d50e53c1d55c714d411a30e6c09ac1, i32 13)
  %.unpack432 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %17 = add i64 %15, -1
  %18 = getelementptr i64, ptr %.unpack432, i64 %17
  %19 = call i1 @_FortranAioInputInteger(ptr %16, ptr %18, i32 8)
  %.unpack444 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %20 = add i64 %15, -1
  %21 = getelementptr i64, ptr %.unpack444, i64 %20
  %22 = call i1 @_FortranAioInputInteger(ptr %16, ptr %21, i32 8)
  %23 = call i32 @_FortranAioEndIoStatement(ptr %16)
  %24 = add nuw i64 %15, 1
  %exitcond.not = icmp eq i64 %15, %9
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.unpack.pre = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack379.unpack.unpack381.pre = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %.unpack384.pre = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.unpack391.unpack.unpack393.pre = load i64, ptr @_QFEy.8, align 8, !tbaa !7
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.unpack391.unpack.unpack393 = phi i64 [ %.unpack391.unpack.unpack393.pre, %._crit_edge.loopexit ], [ %10, %0 ]
  %.unpack384 = phi ptr [ %.unpack384.pre, %._crit_edge.loopexit ], [ %13, %0 ]
  %.unpack379.unpack.unpack381 = phi i64 [ %.unpack379.unpack.unpack381.pre, %._crit_edge.loopexit ], [ %10, %0 ]
  %.unpack = phi ptr [ %.unpack.pre, %._crit_edge.loopexit ], [ %12, %0 ]
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 1
  store i64 8, 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 %2, 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 %2, 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 %2, i64 0, i32 4
  store i8 10, 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 %2, 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 %2, 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 %2, 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 %2, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack379.unpack.unpack381, 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 %2, i64 0, i32 7, i64 0, i64 2
  store i64 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  store ptr %.unpack384, ptr %1, align 8, !tbaa !7
  %.fca.1.gep123 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep123, align 8, !tbaa !7
  %.fca.2.gep125 = 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.gep125, align 8, !tbaa !7
  %.fca.3.gep127 = 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.gep127, align 4, !tbaa !7
  %.fca.4.gep129 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep129, align 1, !tbaa !7
  %.fca.5.gep131 = 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.gep131, align 2, !tbaa !7
  %.fca.6.gep133 = 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.gep133, align 1, !tbaa !7
  %.fca.7.0.0.gep135 = 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.gep135, align 8, !tbaa !7
  %.fca.7.0.1.gep137 = 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 %.unpack391.unpack.unpack393, ptr %.fca.7.0.1.gep137, align 8, !tbaa !7
  %.fca.7.0.2.gep139 = 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 8, ptr %.fca.7.0.2.gep139, align 8, !tbaa !7
  call void @_QFPm2sort(ptr nonnull %2, ptr nonnull %1)
  %25 = load i64, ptr %4, align 8, !tbaa !3
  %26 = icmp sgt i64 %25, 0
  br i1 %26, label %.lr.ph462, label %._crit_edge463

.lr.ph462:                                        ; preds = %._crit_edge
  %.promoted = load i64, ptr %3, align 8, !tbaa !3
  %.unpack396 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %.unpack420 = load ptr, ptr @_QFEx.0, align 8
  br label %27

27:                                               ; preds = %.lr.ph462, %36
  %.0460 = phi i64 [ 1, %.lr.ph462 ], [ %40, %36 ]
  %.0350459 = phi i64 [ 0, %.lr.ph462 ], [ %38, %36 ]
  %28 = phi i64 [ %.promoted, %.lr.ph462 ], [ %39, %36 ]
  %29 = add i64 %.0460, -1
  %30 = getelementptr i64, ptr %.unpack396, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !3
  %32 = icmp sgt i64 %28, %31
  %33 = add i64 %.0460, -1
  %34 = getelementptr i64, ptr %.unpack420, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !3
  br i1 %32, label %36, label %41

36:                                               ; preds = %27
  %37 = mul i64 %35, %31
  %38 = add i64 %37, %.0350459
  %39 = sub i64 %28, %31
  store i64 %39, ptr %3, align 8, !tbaa !3
  %40 = add nuw i64 %.0460, 1
  %exitcond467.not = icmp eq i64 %.0460, %25
  br i1 %exitcond467.not, label %._crit_edge463, label %27

41:                                               ; preds = %27
  %42 = mul i64 %35, %28
  %43 = add i64 %42, %.0350459
  %44 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.85d50e53c1d55c714d411a30e6c09ac1, i32 22)
  %45 = call i1 @_FortranAioOutputInteger64(ptr %44, i64 %43)
  %46 = call i32 @_FortranAioEndIoStatement(ptr %44)
  %47 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

._crit_edge463:                                   ; preds = %36, %._crit_edge
  %48 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

; Function Attrs: nounwind
define void @_QFPm2sort(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr #3 {
  %3 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %4 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %5 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %6 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %7 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 1
  %8 = load i64, ptr %7, align 8, !tbaa !7
  %9 = icmp eq i64 %8, 1
  br i1 %9, label %151, label %10

10:                                               ; preds = %2
  %11 = sdiv i64 %8, 2
  %12 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 2
  %13 = load i64, ptr %12, align 8, !tbaa !7
  %14 = load ptr, ptr %0, align 8, !tbaa !7
  %15 = tail call i64 @llvm.smax.i64(i64 %11, i64 0)
  store ptr %14, ptr %6, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %6, i64 0, i32 1
  store i64 8, 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 %6, 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 %6, 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 %6, i64 0, i32 4
  store i8 10, 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 %6, 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 %6, 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 %6, 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 %6, i64 0, i32 7, i64 0, i64 1
  store i64 %15, 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 %6, i64 0, i32 7, i64 0, i64 2
  store i64 %13, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %16 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  %17 = load i64, ptr %16, align 8, !tbaa !7
  %18 = load ptr, ptr %1, align 8, !tbaa !7
  store ptr %18, ptr %5, align 8, !tbaa !7
  %.fca.1.gep54 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep54, align 8, !tbaa !7
  %.fca.2.gep56 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep56, align 8, !tbaa !7
  %.fca.3.gep58 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep58, align 4, !tbaa !7
  %.fca.4.gep60 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep60, align 1, !tbaa !7
  %.fca.5.gep62 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep62, align 2, !tbaa !7
  %.fca.6.gep64 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep64, align 1, !tbaa !7
  %.fca.7.0.0.gep66 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep66, align 8, !tbaa !7
  %.fca.7.0.1.gep68 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 7, i64 0, i64 1
  store i64 %15, ptr %.fca.7.0.1.gep68, align 8, !tbaa !7
  %.fca.7.0.2.gep70 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %5, i64 0, i32 7, i64 0, i64 2
  store i64 %17, ptr %.fca.7.0.2.gep70, align 8, !tbaa !7
  call void @_QFPm2sort(ptr nonnull %6, ptr nonnull %5)
  %19 = load i64, ptr %12, align 8, !tbaa !7
  %20 = load ptr, ptr %0, align 8, !tbaa !7
  %21 = mul i64 %19, %11
  %22 = getelementptr i8, ptr %20, i64 %21
  %23 = sub i64 %8, %11
  %24 = tail call i64 @llvm.smax.i64(i64 %23, i64 0)
  store ptr %22, ptr %4, align 8, !tbaa !7
  %.fca.1.gep74 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep74, align 8, !tbaa !7
  %.fca.2.gep76 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep76, align 8, !tbaa !7
  %.fca.3.gep78 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep78, align 4, !tbaa !7
  %.fca.4.gep80 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep80, align 1, !tbaa !7
  %.fca.5.gep82 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep82, align 2, !tbaa !7
  %.fca.6.gep84 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep84, align 1, !tbaa !7
  %.fca.7.0.0.gep86 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep86, align 8, !tbaa !7
  %.fca.7.0.1.gep88 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 1
  store i64 %24, ptr %.fca.7.0.1.gep88, align 8, !tbaa !7
  %.fca.7.0.2.gep90 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 2
  store i64 %19, ptr %.fca.7.0.2.gep90, align 8, !tbaa !7
  %25 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  %26 = load i64, ptr %25, align 8, !tbaa !7
  %27 = load i64, ptr %16, align 8, !tbaa !7
  %28 = load ptr, ptr %1, align 8, !tbaa !7
  %29 = mul i64 %27, %11
  %30 = getelementptr i8, ptr %28, i64 %29
  %31 = sub i64 %26, %11
  %32 = tail call i64 @llvm.smax.i64(i64 %31, i64 0)
  store ptr %30, ptr %3, align 8, !tbaa !7
  %.fca.1.gep94 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep94, align 8, !tbaa !7
  %.fca.2.gep96 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep96, align 8, !tbaa !7
  %.fca.3.gep98 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep98, align 4, !tbaa !7
  %.fca.4.gep100 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep100, align 1, !tbaa !7
  %.fca.5.gep102 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep102, align 2, !tbaa !7
  %.fca.6.gep104 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep104, align 1, !tbaa !7
  %.fca.7.0.0.gep106 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep106, align 8, !tbaa !7
  %.fca.7.0.1.gep108 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 1
  store i64 %32, ptr %.fca.7.0.1.gep108, align 8, !tbaa !7
  %.fca.7.0.2.gep110 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 2
  store i64 %27, ptr %.fca.7.0.2.gep110, align 8, !tbaa !7
  call void @_QFPm2sort(ptr nonnull %4, ptr nonnull %3)
  %33 = tail call i64 @llvm.smax.i64(i64 %8, i64 0)
  %34 = shl i64 %33, 3
  %35 = tail call ptr @malloc(i64 %34)
  %36 = tail call ptr @malloc(i64 %34)
  %.not130 = icmp slt i64 %8, 1
  br i1 %.not130, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %37 = load i64, ptr %12, align 8, !tbaa !7
  %38 = load ptr, ptr %0, align 8, !tbaa !7
  %39 = add nsw i64 %33, -1
  %xtraiter = and i64 %33, 3
  %40 = icmp ult i64 %39, 3
  br i1 %40, label %.preheader122.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %33, 9223372036854775804
  br label %50

.preheader122.unr-lcssa:                          ; preds = %50, %.lr.ph
  %.unr = phi i64 [ 0, %.lr.ph ], [ %67, %50 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader122, label %.epil.preheader

.epil.preheader:                                  ; preds = %.preheader122.unr-lcssa, %.epil.preheader
  %41 = phi i64 [ %42, %.epil.preheader ], [ %.unr, %.preheader122.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %.preheader122.unr-lcssa ]
  %42 = add nuw nsw i64 %41, 1
  %43 = mul i64 %37, %41
  %44 = getelementptr i8, ptr %38, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !3
  %46 = getelementptr i64, ptr %35, i64 %41
  store i64 %45, ptr %46, align 8, !tbaa !3
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader122, label %.epil.preheader, !llvm.loop !9

.preheader122:                                    ; preds = %.epil.preheader, %.preheader122.unr-lcssa
  br i1 %.not130, label %._crit_edge, label %.lr.ph123

.lr.ph123:                                        ; preds = %.preheader122
  %47 = load i64, ptr %16, align 8, !tbaa !7
  %48 = load ptr, ptr %1, align 8, !tbaa !7
  %xtraiter135 = and i64 %33, 3
  %49 = icmp ult i64 %39, 3
  br i1 %49, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph123.new

.lr.ph123.new:                                    ; preds = %.lr.ph123
  %unroll_iter139 = and i64 %33, 9223372036854775804
  br label %72

50:                                               ; preds = %50, %.lr.ph.new
  %51 = phi i64 [ 0, %.lr.ph.new ], [ %67, %50 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %50 ]
  %52 = or i64 %51, 1
  %53 = mul i64 %37, %51
  %54 = getelementptr i8, ptr %38, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !3
  %56 = getelementptr i64, ptr %35, i64 %51
  store i64 %55, ptr %56, align 8, !tbaa !3
  %57 = or i64 %51, 2
  %58 = mul i64 %37, %52
  %59 = getelementptr i8, ptr %38, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !3
  %61 = getelementptr i64, ptr %35, i64 %52
  store i64 %60, ptr %61, align 8, !tbaa !3
  %62 = or i64 %51, 3
  %63 = mul i64 %37, %57
  %64 = getelementptr i8, ptr %38, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !3
  %66 = getelementptr i64, ptr %35, i64 %57
  store i64 %65, ptr %66, align 8, !tbaa !3
  %67 = add nuw nsw i64 %51, 4
  %68 = mul i64 %37, %62
  %69 = getelementptr i8, ptr %38, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !3
  %71 = getelementptr i64, ptr %35, i64 %62
  store i64 %70, ptr %71, align 8, !tbaa !3
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader122.unr-lcssa, label %50

72:                                               ; preds = %72, %.lr.ph123.new
  %73 = phi i64 [ 0, %.lr.ph123.new ], [ %89, %72 ]
  %niter140 = phi i64 [ 0, %.lr.ph123.new ], [ %niter140.next.3, %72 ]
  %74 = or i64 %73, 1
  %75 = mul i64 %47, %73
  %76 = getelementptr i8, ptr %48, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !3
  %78 = getelementptr i64, ptr %36, i64 %73
  store i64 %77, ptr %78, align 8, !tbaa !3
  %79 = or i64 %73, 2
  %80 = mul i64 %47, %74
  %81 = getelementptr i8, ptr %48, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !3
  %83 = getelementptr i64, ptr %36, i64 %74
  store i64 %82, ptr %83, align 8, !tbaa !3
  %84 = or i64 %73, 3
  %85 = mul i64 %47, %79
  %86 = getelementptr i8, ptr %48, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !3
  %88 = getelementptr i64, ptr %36, i64 %79
  store i64 %87, ptr %88, align 8, !tbaa !3
  %89 = add nuw nsw i64 %73, 4
  %90 = mul i64 %47, %84
  %91 = getelementptr i8, ptr %48, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !3
  %93 = getelementptr i64, ptr %36, i64 %84
  store i64 %92, ptr %93, align 8, !tbaa !3
  %niter140.next.3 = add i64 %niter140, 4
  %niter140.ncmp.3 = icmp eq i64 %niter140.next.3, %unroll_iter139
  br i1 %niter140.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %72

._crit_edge.loopexit.unr-lcssa:                   ; preds = %72, %.lr.ph123
  %.unr137 = phi i64 [ 0, %.lr.ph123 ], [ %89, %72 ]
  %lcmp.mod138.not = icmp eq i64 %xtraiter135, 0
  br i1 %lcmp.mod138.not, label %._crit_edge, label %.epil.preheader134

.epil.preheader134:                               ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader134
  %94 = phi i64 [ %95, %.epil.preheader134 ], [ %.unr137, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter136 = phi i64 [ %epil.iter136.next, %.epil.preheader134 ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %95 = add nuw nsw i64 %94, 1
  %96 = mul i64 %47, %94
  %97 = getelementptr i8, ptr %48, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !3
  %99 = getelementptr i64, ptr %36, i64 %94
  store i64 %98, ptr %99, align 8, !tbaa !3
  %epil.iter136.next = add i64 %epil.iter136, 1
  %epil.iter136.cmp.not = icmp eq i64 %epil.iter136.next, %xtraiter135
  br i1 %epil.iter136.cmp.not, label %._crit_edge, label %.epil.preheader134, !llvm.loop !11

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader134, %10, %.preheader122
  %100 = icmp sgt i64 %23, 0
  br i1 %100, label %.lr.ph125, label %.preheader

.lr.ph125:                                        ; preds = %._crit_edge
  %101 = add i64 %11, %8
  %102 = load ptr, ptr %0, align 8, !tbaa !7
  %103 = load i64, ptr %12, align 8, !tbaa !7
  %104 = load ptr, ptr %1, align 8, !tbaa !7
  %105 = load i64, ptr %16, align 8, !tbaa !7
  br label %109

.preheader:                                       ; preds = %109, %._crit_edge
  %106 = icmp sgt i64 %8, 0
  br i1 %106, label %.lr.ph128.preheader, label %._crit_edge129

.lr.ph128.preheader:                              ; preds = %.preheader
  %107 = load ptr, ptr %0, align 8, !tbaa !7
  %108 = load i64, ptr %12, align 8, !tbaa !7
  br label %.lr.ph128

109:                                              ; preds = %.lr.ph125, %109
  %110 = phi i64 [ %23, %.lr.ph125 ], [ %122, %109 ]
  %111 = phi i64 [ %8, %.lr.ph125 ], [ %116, %109 ]
  %112 = sub i64 %101, %111
  %113 = mul i64 %103, %112
  %114 = getelementptr i8, ptr %102, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !3
  %116 = add i64 %111, -1
  %117 = getelementptr i64, ptr %35, i64 %116
  store i64 %115, ptr %117, align 8, !tbaa !3
  %118 = mul i64 %105, %112
  %119 = getelementptr i8, ptr %104, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !3
  %121 = getelementptr i64, ptr %36, i64 %116
  store i64 %120, ptr %121, align 8, !tbaa !3
  %122 = add nsw i64 %110, -1
  %123 = icmp ugt i64 %110, 1
  br i1 %123, label %109, label %.preheader

.lr.ph128:                                        ; preds = %.lr.ph128.preheader, %149
  %124 = phi i64 [ %150, %149 ], [ 1, %.lr.ph128.preheader ]
  %.0127 = phi i64 [ %.1, %149 ], [ 1, %.lr.ph128.preheader ]
  %.0111126 = phi i64 [ %.1112, %149 ], [ %8, %.lr.ph128.preheader ]
  %125 = add i64 %.0127, -1
  %126 = getelementptr i64, ptr %35, i64 %125
  %127 = load i64, ptr %126, align 8, !tbaa !3
  %128 = add i64 %.0111126, -1
  %129 = getelementptr i64, ptr %35, i64 %128
  %130 = load i64, ptr %129, align 8, !tbaa !3
  %.not = icmp sgt i64 %127, %130
  %131 = add nsw i64 %124, -1
  %132 = mul i64 %108, %131
  %133 = getelementptr i8, ptr %107, i64 %132
  br i1 %.not, label %142, label %134

134:                                              ; preds = %.lr.ph128
  store i64 %127, ptr %133, align 8, !tbaa !3
  %135 = getelementptr i64, ptr %36, i64 %125
  %136 = load i64, ptr %135, align 8, !tbaa !3
  %137 = load ptr, ptr %1, align 8, !tbaa !7
  %138 = load i64, ptr %16, align 8, !tbaa !7
  %139 = mul i64 %138, %131
  %140 = getelementptr i8, ptr %137, i64 %139
  store i64 %136, ptr %140, align 8, !tbaa !3
  %141 = add i64 %.0127, 1
  br label %149

142:                                              ; preds = %.lr.ph128
  store i64 %130, ptr %133, align 8, !tbaa !3
  %143 = getelementptr i64, ptr %36, i64 %128
  %144 = load i64, ptr %143, align 8, !tbaa !3
  %145 = load ptr, ptr %1, align 8, !tbaa !7
  %146 = load i64, ptr %16, align 8, !tbaa !7
  %147 = mul i64 %146, %131
  %148 = getelementptr i8, ptr %145, i64 %147
  store i64 %144, ptr %148, align 8, !tbaa !3
  br label %149

149:                                              ; preds = %134, %142
  %.1112 = phi i64 [ %.0111126, %134 ], [ %128, %142 ]
  %.1 = phi i64 [ %141, %134 ], [ %.0127, %142 ]
  %150 = add nuw i64 %124, 1
  %exitcond133.not = icmp eq i64 %124, %8
  br i1 %exitcond133.not, label %._crit_edge129, label %.lr.ph128

._crit_edge129:                                   ; preds = %149, %.preheader
  tail call void @free(ptr %35)
  tail call void @free(ptr %36)
  br label %151

151:                                              ; preds = %._crit_edge129, %2
  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 ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

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 = { nounwind }
attributes #4 = { 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}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !10}
