program abc156c
  implicit none
  integer :: n
  integer,allocatable :: x(:)
  read *, n
  allocate(x(n))
  read *, x(:)
  print *, sum((x-nint(real(sum(x))/n))**2)
end program abc156c

; 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
@_QQcl.2e5df3dc68e3dd67dd45a288ef810013 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2332/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

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.2e5df3dc68e3dd67dd45a288ef810013, i32 5)
  %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 @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2e5df3dc68e3dd67dd45a288ef810013, i32 7)
  %.unpack = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack123.unpack.unpack125 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %12 = call i64 @llvm.smax.i64(i64 %.unpack123.unpack.unpack125, 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)
  %15 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.2e5df3dc68e3dd67dd45a288ef810013, i32 8)
  %.unpack128 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack135.unpack.unpack137 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %16 = icmp sgt i64 %.unpack135.unpack.unpack137, 0
  br i1 %16, label %.lr.ph.i.preheader, label %_FortranASumInteger4x1_contract_simplified.exit

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

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %.unpack135.unpack.unpack137, -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> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
  %vec.phi158 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %21, %vector.body ]
  %17 = shl i64 %index, 2
  %18 = getelementptr i8, ptr %.unpack128, i64 %17
  %wide.load = load <4 x i32>, ptr %18, align 4, !tbaa !3
  %19 = getelementptr i32, ptr %18, i64 4
  %wide.load159 = load <4 x i32>, ptr %19, align 4, !tbaa !3
  %20 = add <4 x i32> %wide.load, %vec.phi
  %21 = add <4 x i32> %wide.load159, %vec.phi158
  %index.next = add nuw i64 %index, 8
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %21, %20
  %23 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %.unpack135.unpack.unpack137, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger4x1_contract_simplified.exit.loopexit, label %.lr.ph.i.preheader198

.lr.ph.i.preheader198:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph199 = phi i32 [ 0, %.lr.ph.i.preheader ], [ %23, %middle.block ]
  %.ph200 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader198, %.lr.ph.i
  %24 = phi i32 [ %29, %.lr.ph.i ], [ %.ph199, %.lr.ph.i.preheader198 ]
  %25 = phi i64 [ %30, %.lr.ph.i ], [ %.ph200, %.lr.ph.i.preheader198 ]
  %26 = shl i64 %25, 2
  %27 = getelementptr i8, ptr %.unpack128, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !3
  %29 = add i32 %28, %24
  %30 = add nuw nsw i64 %25, 1
  %exitcond.not.i = icmp eq i64 %30, %.unpack135.unpack.unpack137
  br i1 %exitcond.not.i, label %_FortranASumInteger4x1_contract_simplified.exit.loopexit, label %.lr.ph.i, !llvm.loop !12

_FortranASumInteger4x1_contract_simplified.exit.loopexit: ; preds = %.lr.ph.i, %middle.block
  %.lcssa157 = phi i32 [ %23, %middle.block ], [ %29, %.lr.ph.i ]
  %31 = sitofp i32 %.lcssa157 to float
  br label %_FortranASumInteger4x1_contract_simplified.exit

_FortranASumInteger4x1_contract_simplified.exit:  ; preds = %_FortranASumInteger4x1_contract_simplified.exit.loopexit, %0
  %.lcssa.i = phi float [ 0.000000e+00, %0 ], [ %31, %_FortranASumInteger4x1_contract_simplified.exit.loopexit ]
  %32 = load i32, ptr %2, align 4, !tbaa !3
  %33 = sitofp i32 %32 to float
  %34 = fdiv contract float %.lcssa.i, %33
  %35 = call i32 @llvm.lround.i32.f32(float %34)
  %36 = shl i64 %.unpack135.unpack.unpack137, 2
  %37 = call ptr @malloc(i64 %36)
  br i1 %16, label %.lr.ph.preheader, label %_FortranASumInteger4x1_contract_simplified.exit143

.lr.ph.preheader:                                 ; preds = %_FortranASumInteger4x1_contract_simplified.exit
  %min.iters.check162 = icmp ult i64 %.unpack135.unpack.unpack137, 8
  br i1 %min.iters.check162, label %.lr.ph.preheader196, label %vector.ph163

vector.ph163:                                     ; preds = %.lr.ph.preheader
  %n.vec165 = and i64 %.unpack135.unpack.unpack137, -8
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %35, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert172 = insertelement <4 x i32> poison, i32 %35, i64 0
  %broadcast.splat173 = shufflevector <4 x i32> %broadcast.splatinsert172, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body168

vector.body168:                                   ; preds = %vector.body168, %vector.ph163
  %index169 = phi i64 [ 0, %vector.ph163 ], [ %index.next174, %vector.body168 ]
  %38 = getelementptr i32, ptr %.unpack128, i64 %index169
  %wide.load170 = load <4 x i32>, ptr %38, align 4, !tbaa !3
  %39 = getelementptr i32, ptr %38, i64 4
  %wide.load171 = load <4 x i32>, ptr %39, align 4, !tbaa !3
  %40 = sub <4 x i32> %wide.load170, %broadcast.splat
  %41 = sub <4 x i32> %wide.load171, %broadcast.splat173
  %42 = mul <4 x i32> %40, %40
  %43 = mul <4 x i32> %41, %41
  %44 = getelementptr i32, ptr %37, i64 %index169
  store <4 x i32> %42, ptr %44, align 4, !tbaa !3
  %45 = getelementptr i32, ptr %44, i64 4
  store <4 x i32> %43, ptr %45, align 4, !tbaa !3
  %index.next174 = add nuw i64 %index169, 8
  %46 = icmp eq i64 %index.next174, %n.vec165
  br i1 %46, label %middle.block160, label %vector.body168, !llvm.loop !13

middle.block160:                                  ; preds = %vector.body168
  %cmp.n167 = icmp eq i64 %.unpack135.unpack.unpack137, %n.vec165
  br i1 %cmp.n167, label %._crit_edge, label %.lr.ph.preheader196

.lr.ph.preheader196:                              ; preds = %.lr.ph.preheader, %middle.block160
  %.ph197 = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec165, %middle.block160 ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader196, %.lr.ph
  %47 = phi i64 [ %52, %.lr.ph ], [ %.ph197, %.lr.ph.preheader196 ]
  %48 = getelementptr i32, ptr %.unpack128, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !3
  %50 = sub i32 %49, %35
  %51 = mul i32 %50, %50
  %52 = add nuw nsw i64 %47, 1
  %53 = getelementptr i32, ptr %37, i64 %47
  store i32 %51, ptr %53, align 4, !tbaa !3
  %exitcond.not = icmp eq i64 %52, %.unpack135.unpack.unpack137
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %middle.block160
  br i1 %16, label %.lr.ph.i140.preheader, label %_FortranASumInteger4x1_contract_simplified.exit143

.lr.ph.i140.preheader:                            ; preds = %._crit_edge
  %min.iters.check177 = icmp ult i64 %.unpack135.unpack.unpack137, 8
  br i1 %min.iters.check177, label %.lr.ph.i140.preheader192, label %vector.ph178

vector.ph178:                                     ; preds = %.lr.ph.i140.preheader
  %n.vec180 = and i64 %.unpack135.unpack.unpack137, -8
  br label %vector.body183

vector.body183:                                   ; preds = %vector.body183, %vector.ph178
  %index184 = phi i64 [ 0, %vector.ph178 ], [ %index.next189, %vector.body183 ]
  %vec.phi185 = phi <4 x i32> [ zeroinitializer, %vector.ph178 ], [ %57, %vector.body183 ]
  %vec.phi186 = phi <4 x i32> [ zeroinitializer, %vector.ph178 ], [ %58, %vector.body183 ]
  %54 = shl i64 %index184, 2
  %55 = getelementptr i8, ptr %37, i64 %54
  %wide.load187 = load <4 x i32>, ptr %55, align 4, !tbaa !3
  %56 = getelementptr i32, ptr %55, i64 4
  %wide.load188 = load <4 x i32>, ptr %56, align 4, !tbaa !3
  %57 = add <4 x i32> %wide.load187, %vec.phi185
  %58 = add <4 x i32> %wide.load188, %vec.phi186
  %index.next189 = add nuw i64 %index184, 8
  %59 = icmp eq i64 %index.next189, %n.vec180
  br i1 %59, label %middle.block175, label %vector.body183, !llvm.loop !15

middle.block175:                                  ; preds = %vector.body183
  %bin.rdx190 = add <4 x i32> %58, %57
  %60 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx190)
  %cmp.n182 = icmp eq i64 %.unpack135.unpack.unpack137, %n.vec180
  br i1 %cmp.n182, label %_FortranASumInteger4x1_contract_simplified.exit143, label %.lr.ph.i140.preheader192

.lr.ph.i140.preheader192:                         ; preds = %.lr.ph.i140.preheader, %middle.block175
  %.ph = phi i32 [ 0, %.lr.ph.i140.preheader ], [ %60, %middle.block175 ]
  %.ph193 = phi i64 [ 0, %.lr.ph.i140.preheader ], [ %n.vec180, %middle.block175 ]
  br label %.lr.ph.i140

.lr.ph.i140:                                      ; preds = %.lr.ph.i140.preheader192, %.lr.ph.i140
  %61 = phi i32 [ %66, %.lr.ph.i140 ], [ %.ph, %.lr.ph.i140.preheader192 ]
  %62 = phi i64 [ %67, %.lr.ph.i140 ], [ %.ph193, %.lr.ph.i140.preheader192 ]
  %63 = shl i64 %62, 2
  %64 = getelementptr i8, ptr %37, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !3
  %66 = add i32 %65, %61
  %67 = add nuw nsw i64 %62, 1
  %exitcond.not.i141 = icmp eq i64 %67, %.unpack135.unpack.unpack137
  br i1 %exitcond.not.i141, label %_FortranASumInteger4x1_contract_simplified.exit143, label %.lr.ph.i140, !llvm.loop !16

_FortranASumInteger4x1_contract_simplified.exit143: ; preds = %.lr.ph.i140, %middle.block175, %_FortranASumInteger4x1_contract_simplified.exit, %._crit_edge
  %.lcssa.i142 = phi i32 [ 0, %._crit_edge ], [ 0, %_FortranASumInteger4x1_contract_simplified.exit ], [ %60, %middle.block175 ], [ %66, %.lr.ph.i140 ]
  %68 = call i1 @_FortranAioOutputInteger32(ptr %15, i32 %.lcssa.i142)
  call void @free(ptr %37)
  %69 = call i32 @_FortranAioEndIoStatement(ptr %15)
  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.lround.i32.f32(float) #2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !11, !10}
