program name
    implicit none
    integer(4):: n,i,maxh, li, ans
    integer(4),allocatable:: h(:)

    read*, n
    allocate(h(n))
    read*, h(:)

    maxh = maxval(h)
    ans = 0
    do while(maxh > 0)

        do i=1,n
            if (h(i) == maxh) then
                li = i
                exit
            end if
        end do

        do i=1,n
            if (h(i) == maxh) then
                if (li+1 /= i) ans=ans+1
                li = i
                h(i) = h(i) - 1
            end if
        end do
        maxh = maxval(h)
    end do

    print*, ans
end program name
; 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"

@_QFEh.0 = internal unnamed_addr global ptr null
@_QFEh.8 = internal unnamed_addr global i64 0
@_QQcl.c287f537c0834ea765372c8023316a10 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5085/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

define void @_QQmain() local_unnamed_addr {
  %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.c287f537c0834ea765372c8023316a10, 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 @_QFEh.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEh.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.c287f537c0834ea765372c8023316a10, i32 8)
  %.unpack = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %.unpack266.unpack.unpack268 = load i64, ptr @_QFEh.8, align 8, !tbaa !7
  %12 = call i64 @llvm.smax.i64(i64 %.unpack266.unpack.unpack268, i64 0)
  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 %12, 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 %11, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %.unpack271 = load ptr, ptr @_QFEh.0, align 8, !tbaa !7
  %.unpack278.unpack.unpack280 = load i64, ptr @_QFEh.8, align 8, !tbaa !7
  %15 = icmp sgt i64 %.unpack278.unpack.unpack280, 0
  br i1 %15, label %.lr.ph.i.preheader, label %._crit_edge361

.lr.ph.i.preheader:                               ; preds = %0
  %min.iters.check = icmp ult i64 %.unpack278.unpack.unpack280, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader404, label %vector.ph

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

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %19, %vector.body ]
  %vec.phi379 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph ], [ %20, %vector.body ]
  %16 = shl i64 %index, 2
  %17 = getelementptr i8, ptr %.unpack271, i64 %16
  %wide.load = load <4 x i32>, ptr %17, align 4, !tbaa !3
  %18 = getelementptr i32, ptr %17, i64 4
  %wide.load380 = load <4 x i32>, ptr %18, align 4, !tbaa !3
  %19 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load, <4 x i32> %vec.phi)
  %20 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load380, <4 x i32> %vec.phi379)
  %index.next = add nuw i64 %index, 8
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %19, <4 x i32> %20)
  %22 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %cmp.n = icmp eq i64 %.unpack278.unpack.unpack280, %n.vec
  br i1 %cmp.n, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader404

.lr.ph.i.preheader404:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph405 = phi i32 [ -2147483648, %.lr.ph.i.preheader ], [ %22, %middle.block ]
  %.ph406 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader404, %.lr.ph.i
  %23 = phi i32 [ %28, %.lr.ph.i ], [ %.ph405, %.lr.ph.i.preheader404 ]
  %24 = phi i64 [ %29, %.lr.ph.i ], [ %.ph406, %.lr.ph.i.preheader404 ]
  %25 = shl i64 %24, 2
  %26 = getelementptr i8, ptr %.unpack271, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !3
  %28 = call i32 @llvm.smax.i32(i32 %27, i32 %23)
  %29 = add nuw nsw i64 %24, 1
  %exitcond.not.i = icmp eq i64 %29, %.unpack278.unpack.unpack280
  br i1 %exitcond.not.i, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranAMaxvalInteger4x1_contract_simplified.exit: ; preds = %.lr.ph.i, %middle.block
  %.lcssa378 = phi i32 [ %22, %middle.block ], [ %28, %.lr.ph.i ]
  %30 = icmp sgt i32 %.lcssa378, 0
  br i1 %30, label %.lr.ph360, label %._crit_edge361

.lr.ph360:                                        ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit
  br i1 %15, label %.lr.ph360.split.us.preheader, label %.lr.ph360.split

.lr.ph360.split.us.preheader:                     ; preds = %.lr.ph360
  %min.iters.check383 = icmp ult i64 %.unpack278.unpack.unpack280, 8
  %n.vec386 = and i64 %.unpack278.unpack.unpack280, -8
  %cmp.n388 = icmp eq i64 %.unpack278.unpack.unpack280, %n.vec386
  br label %.lr.ph360.split.us

.lr.ph360.split.us:                               ; preds = %.lr.ph360.split.us.preheader, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us
  %.0359.us = phi i32 [ %.lcssa, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us ], [ %.lcssa378, %.lr.ph360.split.us.preheader ]
  %.0243358.us = phi i32 [ %.2.lcssa.us, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us ], [ undef, %.lr.ph360.split.us.preheader ]
  %.0245357.us = phi i32 [ %.1246.lcssa.us, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us ], [ 0, %.lr.ph360.split.us.preheader ]
  %31 = load i32, ptr %2, align 4, !tbaa !3
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph.us, label %.lr.ph.i331.preheader.us

.lr.ph.us:                                        ; preds = %.lr.ph360.split.us, %38
  %.0244347.us = phi i32 [ %39, %38 ], [ 1, %.lr.ph360.split.us ]
  %33 = sext i32 %.0244347.us to i64
  %34 = add nsw i64 %33, -1
  %35 = getelementptr i32, ptr %.unpack271, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !3
  %37 = icmp eq i32 %36, %.0359.us
  br i1 %37, label %._crit_edge.us, label %38

38:                                               ; preds = %.lr.ph.us
  %39 = add nuw i32 %.0244347.us, 1
  %exitcond367.not = icmp eq i32 %.0244347.us, %31
  br i1 %exitcond367.not, label %._crit_edge.us, label %.lr.ph.us

._crit_edge.us:                                   ; preds = %38, %.lr.ph.us
  %.1.us = phi i32 [ %.0243358.us, %38 ], [ %.0244347.us, %.lr.ph.us ]
  br i1 %32, label %.lr.ph353.us.preheader, label %.lr.ph.i331.preheader.us

.lr.ph353.us.preheader:                           ; preds = %._crit_edge.us
  %40 = zext i32 %31 to i64
  %41 = add i32 %.0359.us, -1
  %xtraiter411 = and i64 %40, 1
  %42 = icmp eq i32 %31, 1
  br i1 %42, label %.lr.ph.i331.preheader.us.loopexit.unr-lcssa, label %.lr.ph353.us.preheader.new

.lr.ph353.us.preheader.new:                       ; preds = %.lr.ph353.us.preheader
  %unroll_iter415 = and i64 %40, 4294967294
  br label %.lr.ph353.us

.lr.ph.i331.preheader.us.loopexit.unr-lcssa:      ; preds = %83, %.lr.ph353.us.preheader
  %.3248.us.lcssa.ph = phi i32 [ undef, %.lr.ph353.us.preheader ], [ %.3248.us.1, %83 ]
  %.3.us.lcssa.ph = phi i32 [ undef, %.lr.ph353.us.preheader ], [ %.3.us.1, %83 ]
  %indvars.iv368.unr = phi i64 [ 1, %.lr.ph353.us.preheader ], [ %indvars.iv.next369.1, %83 ]
  %.2351.us.unr = phi i32 [ %.1.us, %.lr.ph353.us.preheader ], [ %.3.us.1, %83 ]
  %.1246350.us.unr = phi i32 [ %.0245357.us, %.lr.ph353.us.preheader ], [ %.3248.us.1, %83 ]
  %lcmp.mod412.not = icmp eq i64 %xtraiter411, 0
  br i1 %lcmp.mod412.not, label %.lr.ph.i331.preheader.us, label %.lr.ph353.us.epil

.lr.ph353.us.epil:                                ; preds = %.lr.ph.i331.preheader.us.loopexit.unr-lcssa
  %43 = add nsw i64 %indvars.iv368.unr, -1
  %44 = getelementptr i32, ptr %.unpack271, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !3
  %46 = icmp eq i32 %45, %.0359.us
  br i1 %46, label %47, label %.lr.ph.i331.preheader.us

47:                                               ; preds = %.lr.ph353.us.epil
  %48 = add i32 %.2351.us.unr, 1
  %49 = zext i32 %48 to i64
  %.not.us.epil = icmp ne i64 %indvars.iv368.unr, %49
  %50 = zext i1 %.not.us.epil to i32
  %spec.select.us.epil = add i32 %.1246350.us.unr, %50
  store i32 %41, ptr %44, align 4, !tbaa !3
  %51 = trunc i64 %indvars.iv368.unr to i32
  br label %.lr.ph.i331.preheader.us

.lr.ph.i331.preheader.us:                         ; preds = %.lr.ph.i331.preheader.us.loopexit.unr-lcssa, %47, %.lr.ph353.us.epil, %.lr.ph360.split.us, %._crit_edge.us
  %.1246.lcssa.us = phi i32 [ %.0245357.us, %._crit_edge.us ], [ %.0245357.us, %.lr.ph360.split.us ], [ %.3248.us.lcssa.ph, %.lr.ph.i331.preheader.us.loopexit.unr-lcssa ], [ %spec.select.us.epil, %47 ], [ %.1246350.us.unr, %.lr.ph353.us.epil ]
  %.2.lcssa.us = phi i32 [ %.1.us, %._crit_edge.us ], [ %.0243358.us, %.lr.ph360.split.us ], [ %.3.us.lcssa.ph, %.lr.ph.i331.preheader.us.loopexit.unr-lcssa ], [ %51, %47 ], [ %.2351.us.unr, %.lr.ph353.us.epil ]
  br i1 %min.iters.check383, label %.lr.ph.i331.us.preheader, label %vector.body389

vector.body389:                                   ; preds = %.lr.ph.i331.preheader.us, %vector.body389
  %index390 = phi i64 [ %index.next395, %vector.body389 ], [ 0, %.lr.ph.i331.preheader.us ]
  %vec.phi391 = phi <4 x i32> [ %55, %vector.body389 ], [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %.lr.ph.i331.preheader.us ]
  %vec.phi392 = phi <4 x i32> [ %56, %vector.body389 ], [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %.lr.ph.i331.preheader.us ]
  %52 = shl i64 %index390, 2
  %53 = getelementptr i8, ptr %.unpack271, i64 %52
  %wide.load393 = load <4 x i32>, ptr %53, align 4, !tbaa !3
  %54 = getelementptr i32, ptr %53, i64 4
  %wide.load394 = load <4 x i32>, ptr %54, align 4, !tbaa !3
  %55 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load393, <4 x i32> %vec.phi391)
  %56 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load394, <4 x i32> %vec.phi392)
  %index.next395 = add nuw i64 %index390, 8
  %57 = icmp eq i64 %index.next395, %n.vec386
  br i1 %57, label %middle.block381, label %vector.body389, !llvm.loop !13

middle.block381:                                  ; preds = %vector.body389
  %rdx.minmax.select397 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %55, <4 x i32> %56)
  %58 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select397)
  br i1 %cmp.n388, label %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us, label %.lr.ph.i331.us.preheader

.lr.ph.i331.us.preheader:                         ; preds = %.lr.ph.i331.preheader.us, %middle.block381
  %.ph = phi i32 [ -2147483648, %.lr.ph.i331.preheader.us ], [ %58, %middle.block381 ]
  %.ph399 = phi i64 [ 0, %.lr.ph.i331.preheader.us ], [ %n.vec386, %middle.block381 ]
  br label %.lr.ph.i331.us

.lr.ph.i331.us:                                   ; preds = %.lr.ph.i331.us.preheader, %.lr.ph.i331.us
  %59 = phi i32 [ %64, %.lr.ph.i331.us ], [ %.ph, %.lr.ph.i331.us.preheader ]
  %60 = phi i64 [ %65, %.lr.ph.i331.us ], [ %.ph399, %.lr.ph.i331.us.preheader ]
  %61 = shl i64 %60, 2
  %62 = getelementptr i8, ptr %.unpack271, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !3
  %64 = call i32 @llvm.smax.i32(i32 %63, i32 %59)
  %65 = add nuw nsw i64 %60, 1
  %exitcond.not.i332.us = icmp eq i64 %65, %.unpack278.unpack.unpack280
  br i1 %exitcond.not.i332.us, label %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us, label %.lr.ph.i331.us, !llvm.loop !14

.lr.ph353.us:                                     ; preds = %83, %.lr.ph353.us.preheader.new
  %indvars.iv368 = phi i64 [ 1, %.lr.ph353.us.preheader.new ], [ %indvars.iv.next369.1, %83 ]
  %.2351.us = phi i32 [ %.1.us, %.lr.ph353.us.preheader.new ], [ %.3.us.1, %83 ]
  %.1246350.us = phi i32 [ %.0245357.us, %.lr.ph353.us.preheader.new ], [ %.3248.us.1, %83 ]
  %niter416 = phi i64 [ 0, %.lr.ph353.us.preheader.new ], [ %niter416.next.1, %83 ]
  %66 = add nsw i64 %indvars.iv368, -1
  %67 = getelementptr i32, ptr %.unpack271, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !3
  %69 = icmp eq i32 %68, %.0359.us
  br i1 %69, label %70, label %.lr.ph353.us.1

70:                                               ; preds = %.lr.ph353.us
  %71 = add i32 %.2351.us, 1
  %72 = zext i32 %71 to i64
  %.not.us = icmp ne i64 %indvars.iv368, %72
  %73 = zext i1 %.not.us to i32
  %spec.select.us = add i32 %.1246350.us, %73
  store i32 %41, ptr %67, align 4, !tbaa !3
  %74 = trunc i64 %indvars.iv368 to i32
  br label %.lr.ph353.us.1

.lr.ph353.us.1:                                   ; preds = %70, %.lr.ph353.us
  %.3248.us = phi i32 [ %spec.select.us, %70 ], [ %.1246350.us, %.lr.ph353.us ]
  %.3.us = phi i32 [ %74, %70 ], [ %.2351.us, %.lr.ph353.us ]
  %75 = getelementptr i32, ptr %.unpack271, i64 %indvars.iv368
  %76 = load i32, ptr %75, align 4, !tbaa !3
  %77 = icmp eq i32 %76, %.0359.us
  br i1 %77, label %78, label %83

78:                                               ; preds = %.lr.ph353.us.1
  %indvars.iv.next369 = add nuw nsw i64 %indvars.iv368, 1
  %79 = add i32 %.3.us, 1
  %80 = zext i32 %79 to i64
  %.not.us.1 = icmp ne i64 %indvars.iv.next369, %80
  %81 = zext i1 %.not.us.1 to i32
  %spec.select.us.1 = add i32 %.3248.us, %81
  store i32 %41, ptr %75, align 4, !tbaa !3
  %82 = trunc i64 %indvars.iv.next369 to i32
  br label %83

83:                                               ; preds = %78, %.lr.ph353.us.1
  %.3248.us.1 = phi i32 [ %spec.select.us.1, %78 ], [ %.3248.us, %.lr.ph353.us.1 ]
  %.3.us.1 = phi i32 [ %82, %78 ], [ %.3.us, %.lr.ph353.us.1 ]
  %indvars.iv.next369.1 = add nuw nsw i64 %indvars.iv368, 2
  %niter416.next.1 = add i64 %niter416, 2
  %niter416.ncmp.1 = icmp eq i64 %niter416.next.1, %unroll_iter415
  br i1 %niter416.ncmp.1, label %.lr.ph.i331.preheader.us.loopexit.unr-lcssa, label %.lr.ph353.us

_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us: ; preds = %.lr.ph.i331.us, %middle.block381
  %.lcssa = phi i32 [ %58, %middle.block381 ], [ %64, %.lr.ph.i331.us ]
  %84 = icmp sgt i32 %.lcssa, 0
  br i1 %84, label %.lr.ph360.split.us, label %._crit_edge361

.lr.ph360.split:                                  ; preds = %.lr.ph360
  %85 = load i32, ptr %2, align 4, !tbaa !3
  %86 = icmp sgt i32 %85, 0
  br i1 %86, label %.lr.ph, label %._crit_edge361

.lr.ph:                                           ; preds = %.lr.ph360.split, %.lr.ph
  %.0244347 = phi i32 [ %92, %.lr.ph ], [ 1, %.lr.ph360.split ]
  %87 = sext i32 %.0244347 to i64
  %88 = add nsw i64 %87, -1
  %89 = getelementptr i32, ptr %.unpack271, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !3
  %91 = icmp eq i32 %90, %.lcssa378
  %92 = add nuw i32 %.0244347, 1
  %exitcond.not = icmp eq i32 %.0244347, %85
  %or.cond = select i1 %91, i1 true, i1 %exitcond.not
  br i1 %or.cond, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  br i1 %86, label %.lr.ph353.preheader, label %._crit_edge361

.lr.ph353.preheader:                              ; preds = %._crit_edge
  %93 = zext i32 %85 to i64
  %94 = add i32 %.lcssa378, -1
  %xtraiter = and i64 %93, 1
  %95 = icmp eq i32 %85, 1
  br i1 %95, label %._crit_edge361.loopexit403.unr-lcssa, label %.lr.ph353.preheader.new

.lr.ph353.preheader.new:                          ; preds = %.lr.ph353.preheader
  %unroll_iter = and i64 %93, 4294967294
  br label %.lr.ph353

.lr.ph353:                                        ; preds = %113, %.lr.ph353.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph353.preheader.new ], [ %indvars.iv.next.1, %113 ]
  %.2351 = phi i32 [ %.0244347, %.lr.ph353.preheader.new ], [ %.3.1, %113 ]
  %.1246350 = phi i32 [ 0, %.lr.ph353.preheader.new ], [ %.3248.1, %113 ]
  %niter = phi i64 [ 0, %.lr.ph353.preheader.new ], [ %niter.next.1, %113 ]
  %96 = add nsw i64 %indvars.iv, -1
  %97 = getelementptr i32, ptr %.unpack271, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !3
  %99 = icmp eq i32 %98, %.lcssa378
  br i1 %99, label %100, label %.lr.ph353.1

100:                                              ; preds = %.lr.ph353
  %101 = add i32 %.2351, 1
  %102 = zext i32 %101 to i64
  %.not = icmp ne i64 %indvars.iv, %102
  %103 = zext i1 %.not to i32
  %spec.select = add i32 %.1246350, %103
  store i32 %94, ptr %97, align 4, !tbaa !3
  %104 = trunc i64 %indvars.iv to i32
  br label %.lr.ph353.1

.lr.ph353.1:                                      ; preds = %100, %.lr.ph353
  %.3248 = phi i32 [ %spec.select, %100 ], [ %.1246350, %.lr.ph353 ]
  %.3 = phi i32 [ %104, %100 ], [ %.2351, %.lr.ph353 ]
  %105 = getelementptr i32, ptr %.unpack271, i64 %indvars.iv
  %106 = load i32, ptr %105, align 4, !tbaa !3
  %107 = icmp eq i32 %106, %.lcssa378
  br i1 %107, label %108, label %113

108:                                              ; preds = %.lr.ph353.1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %109 = add i32 %.3, 1
  %110 = zext i32 %109 to i64
  %.not.1 = icmp ne i64 %indvars.iv.next, %110
  %111 = zext i1 %.not.1 to i32
  %spec.select.1 = add i32 %.3248, %111
  store i32 %94, ptr %105, align 4, !tbaa !3
  %112 = trunc i64 %indvars.iv.next to i32
  br label %113

113:                                              ; preds = %108, %.lr.ph353.1
  %.3248.1 = phi i32 [ %spec.select.1, %108 ], [ %.3248, %.lr.ph353.1 ]
  %.3.1 = phi i32 [ %112, %108 ], [ %.3, %.lr.ph353.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge361.loopexit403.unr-lcssa, label %.lr.ph353

._crit_edge361.loopexit403.unr-lcssa:             ; preds = %113, %.lr.ph353.preheader
  %.3248.lcssa.ph = phi i32 [ undef, %.lr.ph353.preheader ], [ %.3248.1, %113 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph353.preheader ], [ %indvars.iv.next.1, %113 ]
  %.2351.unr = phi i32 [ %.0244347, %.lr.ph353.preheader ], [ %.3.1, %113 ]
  %.1246350.unr = phi i32 [ 0, %.lr.ph353.preheader ], [ %.3248.1, %113 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge361, label %.lr.ph353.epil

.lr.ph353.epil:                                   ; preds = %._crit_edge361.loopexit403.unr-lcssa
  %114 = add nsw i64 %indvars.iv.unr, -1
  %115 = getelementptr i32, ptr %.unpack271, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !3
  %117 = icmp eq i32 %116, %.lcssa378
  br i1 %117, label %118, label %._crit_edge361

118:                                              ; preds = %.lr.ph353.epil
  %119 = add i32 %.2351.unr, 1
  %120 = zext i32 %119 to i64
  %.not.epil = icmp ne i64 %indvars.iv.unr, %120
  %121 = zext i1 %.not.epil to i32
  %spec.select.epil = add i32 %.1246350.unr, %121
  store i32 %94, ptr %115, align 4, !tbaa !3
  br label %._crit_edge361

._crit_edge361:                                   ; preds = %._crit_edge361.loopexit403.unr-lcssa, %118, %.lr.ph353.epil, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us, %.lr.ph360.split, %0, %._crit_edge, %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %.0245.lcssa = phi i32 [ 0, %_FortranAMaxvalInteger4x1_contract_simplified.exit ], [ 0, %._crit_edge ], [ 0, %0 ], [ 0, %.lr.ph360.split ], [ %.1246.lcssa.us, %_FortranAMaxvalInteger4x1_contract_simplified.exit334.loopexit.us ], [ %.3248.lcssa.ph, %._crit_edge361.loopexit403.unr-lcssa ], [ %spec.select.epil, %118 ], [ %.1246350.unr, %.lr.ph353.epil ]
  %122 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.c287f537c0834ea765372c8023316a10, i32 31)
  %123 = call i1 @_FortranAioOutputInteger32(ptr %122, i32 %.0245.lcssa)
  %124 = call i32 @_FortranAioEndIoStatement(ptr %122)
  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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind 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, !11, !10}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
