program decrease
  implicit none
  integer :: n, i
  integer(8) :: a(50), m, t
  a = 0_8
  read(*,*) n
  read(*,*) a(1:n)
  t = 0_8
  do
    m = maxval(a(1:n))
    if (m.lt.int(n,8)) exit
    m = 0_8
    do i = 1, n
      m = m + a(i)/int(n,8)
    end do
    do i = 1, n
      a(i) = a(i) + m - (a(i)/int(n,8))*int(n+1,8)
    end do
    t = t + m
  end do
  write(*,'(i0)') t
  stop
end program decrease
; 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"

@_QFEa = internal global [50 x i64] undef
@_QQcl.69b508999876bdc7b047a01bd17e4a0f = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7097/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @_QFEa, i8 0, i64 400, i1 false), !tbaa !3
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.69b508999876bdc7b047a01bd17e4a0f, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.69b508999876bdc7b047a01bd17e4a0f, i32 7)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  store ptr @_QFEa, 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 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 %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 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 %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 %9, 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 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %10 = call i1 @_FortranAioInputDescriptor(ptr %6, ptr nonnull %1)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %12 = load i32, ptr %2, align 4, !tbaa !3
  %13 = call i32 @llvm.smax.i32(i32 %12, i32 0)
  %14 = zext i32 %13 to i64
  %.not = icmp slt i32 %12, 1
  br i1 %.not, label %_FortranAMaxvalInteger8x1_contract_simplified.exit.thread, label %.lr.ph.i.preheader.us.preheader

.lr.ph.i.preheader.us.preheader:                  ; preds = %0
  %15 = zext i32 %12 to i64
  %16 = add nuw i32 %12, 1
  %17 = sext i32 %16 to i64
  %18 = add nsw i64 %15, -1
  %min.iters.check = icmp ult i32 %13, 4
  %n.vec = and i64 %14, 2147483644
  %cmp.n = icmp eq i64 %n.vec, %14
  %xtraiter = and i64 %15, 1
  %19 = icmp eq i64 %18, 0
  %unroll_iter = and i64 %15, 4294967294
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %xtraiter103 = and i64 %15, 1
  %20 = icmp eq i64 %18, 0
  %unroll_iter105 = and i64 %15, 4294967294
  %lcmp.mod104.not = icmp eq i64 %xtraiter103, 0
  br label %.lr.ph.i.preheader.us

.lr.ph.i.preheader.us:                            ; preds = %.lr.ph.i.preheader.us.preheader, %._crit_edge.us
  %.039.us = phi i64 [ %70, %._crit_edge.us ], [ 0, %.lr.ph.i.preheader.us.preheader ]
  br i1 %min.iters.check, label %.lr.ph.i.us.preheader, label %vector.body

vector.body:                                      ; preds = %.lr.ph.i.preheader.us, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph.i.preheader.us ]
  %vec.phi = phi <2 x i64> [ %24, %vector.body ], [ <i64 -9223372036854775808, i64 -9223372036854775808>, %.lr.ph.i.preheader.us ]
  %vec.phi95 = phi <2 x i64> [ %25, %vector.body ], [ <i64 -9223372036854775808, i64 -9223372036854775808>, %.lr.ph.i.preheader.us ]
  %21 = shl i64 %index, 3
  %22 = getelementptr i8, ptr @_QFEa, i64 %21
  %wide.load = load <2 x i64>, ptr %22, align 16, !tbaa !3
  %23 = getelementptr i64, ptr %22, i64 2
  %wide.load96 = load <2 x i64>, ptr %23, align 16, !tbaa !3
  %24 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %wide.load, <2 x i64> %vec.phi)
  %25 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %wide.load96, <2 x i64> %vec.phi95)
  %index.next = add nuw i64 %index, 4
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax.select = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %24, <2 x i64> %25)
  %27 = call i64 @llvm.vector.reduce.smax.v2i64(<2 x i64> %rdx.minmax.select)
  br i1 %cmp.n, label %_FortranAMaxvalInteger8x1_contract_simplified.exit.us, label %.lr.ph.i.us.preheader

.lr.ph.i.us.preheader:                            ; preds = %.lr.ph.i.preheader.us, %middle.block
  %.ph = phi i64 [ -9223372036854775808, %.lr.ph.i.preheader.us ], [ %27, %middle.block ]
  %.ph97 = phi i64 [ 0, %.lr.ph.i.preheader.us ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i.us

.lr.ph.i.us:                                      ; preds = %.lr.ph.i.us.preheader, %.lr.ph.i.us
  %28 = phi i64 [ %33, %.lr.ph.i.us ], [ %.ph, %.lr.ph.i.us.preheader ]
  %29 = phi i64 [ %34, %.lr.ph.i.us ], [ %.ph97, %.lr.ph.i.us.preheader ]
  %30 = shl i64 %29, 3
  %31 = getelementptr i8, ptr @_QFEa, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !3
  %33 = call i64 @llvm.smax.i64(i64 %32, i64 %28)
  %34 = add nuw nsw i64 %29, 1
  %exitcond.not.i.us = icmp eq i64 %34, %14
  br i1 %exitcond.not.i.us, label %_FortranAMaxvalInteger8x1_contract_simplified.exit.us, label %.lr.ph.i.us, !llvm.loop !12

_FortranAMaxvalInteger8x1_contract_simplified.exit.us: ; preds = %.lr.ph.i.us, %middle.block
  %.lcssa = phi i64 [ %27, %middle.block ], [ %33, %.lr.ph.i.us ]
  %35 = icmp slt i64 %.lcssa, %15
  br i1 %35, label %_FortranAMaxvalInteger8x1_contract_simplified.exit.thread, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %_FortranAMaxvalInteger8x1_contract_simplified.exit.us
  br i1 %19, label %.preheader.us.preheader.unr-lcssa, label %.lr.ph.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %.preheader.us
  %indvars.iv82 = phi i64 [ %indvars.iv.next83.1, %.preheader.us ], [ 1, %.preheader.us.preheader ]
  %niter106 = phi i64 [ %niter106.next.1, %.preheader.us ], [ 0, %.preheader.us.preheader ]
  %36 = add nsw i64 %indvars.iv82, -1
  %37 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !3
  %39 = add i64 %38, %.lcssa101
  %40 = sdiv i64 %38, %15
  %41 = mul i64 %40, %17
  %42 = sub i64 %39, %41
  store i64 %42, ptr %37, align 8, !tbaa !3
  %43 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %indvars.iv82
  %44 = load i64, ptr %43, align 8, !tbaa !3
  %45 = add i64 %44, %.lcssa101
  %46 = sdiv i64 %44, %15
  %47 = mul i64 %46, %17
  %48 = sub i64 %45, %47
  store i64 %48, ptr %43, align 8, !tbaa !3
  %indvars.iv.next83.1 = add nuw nsw i64 %indvars.iv82, 2
  %niter106.next.1 = add i64 %niter106, 2
  %niter106.ncmp.1 = icmp eq i64 %niter106.next.1, %unroll_iter105
  br i1 %niter106.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.us ], [ 1, %.lr.ph.us.preheader ]
  %.03037.us = phi i64 [ %57, %.lr.ph.us ], [ 0, %.lr.ph.us.preheader ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us ], [ 0, %.lr.ph.us.preheader ]
  %49 = add nsw i64 %indvars.iv, -1
  %50 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !3
  %52 = sdiv i64 %51, %15
  %53 = add i64 %52, %.03037.us
  %54 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %indvars.iv
  %55 = load i64, ptr %54, align 8, !tbaa !3
  %56 = sdiv i64 %55, %15
  %57 = add i64 %56, %53
  %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 %.preheader.us.preheader.unr-lcssa, label %.lr.ph.us

.preheader.us.preheader.unr-lcssa:                ; preds = %.lr.ph.us, %.lr.ph.us.preheader
  %.lcssa101.ph = phi i64 [ undef, %.lr.ph.us.preheader ], [ %57, %.lr.ph.us ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.us.preheader ], [ %indvars.iv.next.1, %.lr.ph.us ]
  %.03037.us.unr = phi i64 [ 0, %.lr.ph.us.preheader ], [ %57, %.lr.ph.us ]
  br i1 %lcmp.mod.not, label %.preheader.us.preheader, label %.lr.ph.us.epil

.lr.ph.us.epil:                                   ; preds = %.preheader.us.preheader.unr-lcssa
  %58 = add nsw i64 %indvars.iv.unr, -1
  %59 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !3
  %61 = sdiv i64 %60, %15
  %62 = add i64 %61, %.03037.us.unr
  br label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.preheader.us.preheader.unr-lcssa, %.lr.ph.us.epil
  %.lcssa101 = phi i64 [ %.lcssa101.ph, %.preheader.us.preheader.unr-lcssa ], [ %62, %.lr.ph.us.epil ]
  br i1 %20, label %._crit_edge.us.unr-lcssa, label %.preheader.us

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us, %.preheader.us.preheader
  %indvars.iv82.unr = phi i64 [ 1, %.preheader.us.preheader ], [ %indvars.iv.next83.1, %.preheader.us ]
  br i1 %lcmp.mod104.not, label %._crit_edge.us, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %._crit_edge.us.unr-lcssa
  %63 = add nsw i64 %indvars.iv82.unr, -1
  %64 = getelementptr [50 x i64], ptr @_QFEa, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !3
  %66 = add i64 %65, %.lcssa101
  %67 = sdiv i64 %65, %15
  %68 = mul i64 %67, %17
  %69 = sub i64 %66, %68
  store i64 %69, ptr %64, align 8, !tbaa !3
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %.preheader.us.epil
  %70 = add i64 %.lcssa101, %.039.us
  br label %.lr.ph.i.preheader.us

_FortranAMaxvalInteger8x1_contract_simplified.exit.thread: ; preds = %_FortranAMaxvalInteger8x1_contract_simplified.exit.us, %0
  %.0.lcssa = phi i64 [ 0, %0 ], [ %.039.us, %_FortranAMaxvalInteger8x1_contract_simplified.exit.us ]
  %71 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.69b508999876bdc7b047a01bd17e4a0f, i32 21)
  %72 = call i1 @_FortranAioOutputInteger64(ptr %71, i64 %.0.lcssa)
  %73 = call i32 @_FortranAioEndIoStatement(ptr %71)
  %74 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

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

attributes #0 = { noreturn }
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 nounwind willreturn memory(argmem: write) }
attributes #4 = { 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}
