program prob3
    implicit none
    real(8)::tmp
    integer::n, i, j
    integer, allocatable::x(:,:)
    read*, n
    tmp = dble(0)
    allocate(x(n,2))
    do i = 1, n
        read(*,*) x(i,1), x(i,2)
    end do
    do i = 2, n
        do j = 1, i-1
            tmp = tmp + sqrt(dble(x(i,1) - x(j,1))**2 + dble(x(i,2) - x(j,2))**2)
        end do
    end do
    tmp = tmp * dble(2) / dble(n)
    write(*,*) tmp
    stop
end program
; 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.e80a14c4428a733dc39eaa7565ca12ff = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2996/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: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e80a14c4428a733dc39eaa7565ca12ff, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = call i32 @llvm.smax.i32(i32 %5, i32 0)
  %7 = zext i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 3
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEx.0, align 8, !tbaa !7
  store i64 %7, ptr @_QFEx.8, align 8, !tbaa !7
  %10 = icmp sgt i32 %5, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge167

.lr.ph.preheader:                                 ; preds = %0
  %11 = zext i32 %5 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e80a14c4428a733dc39eaa7565ca12ff, i32 10)
  %.unpack128 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %13 = add nsw i64 %indvars.iv, -1
  %14 = getelementptr i32, ptr %.unpack128, i64 %13
  %15 = call i1 @_FortranAioInputInteger(ptr %12, ptr %14, i32 4)
  %.unpack144 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %.unpack151.unpack.unpack154 = load i64, ptr @_QFEx.8, align 8, !tbaa !7
  %16 = add nsw i64 %indvars.iv, -1
  %17 = add i64 %16, %.unpack151.unpack.unpack154
  %18 = getelementptr i32, ptr %.unpack144, i64 %17
  %19 = call i1 @_FortranAioInputInteger(ptr %12, ptr %18, i32 4)
  %20 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %11
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.pre = load i32, ptr %1, align 4, !tbaa !3
  %21 = icmp sgt i32 %.pre, 1
  br i1 %21, label %.lr.ph166, label %._crit_edge167

.lr.ph166:                                        ; preds = %._crit_edge
  %22 = zext i32 %.pre to i64
  %.unpack = load ptr, ptr @_QFEx.0, align 8
  %.unpack119.unpack.unpack122 = load i64, ptr @_QFEx.8, align 8
  br label %.lr.ph162

.lr.ph162:                                        ; preds = %._crit_edge163, %.lr.ph166
  %indvars.iv173 = phi i64 [ 2, %.lr.ph166 ], [ %indvars.iv.next174, %._crit_edge163 ]
  %.0164 = phi double [ 0.000000e+00, %.lr.ph166 ], [ %44, %._crit_edge163 ]
  %23 = add nsw i64 %indvars.iv173, -1
  %24 = getelementptr i32, ptr %.unpack, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !3
  %26 = add i64 %.unpack119.unpack.unpack122, %23
  %27 = getelementptr i32, ptr %.unpack, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !3
  br label %29

29:                                               ; preds = %.lr.ph162, %29
  %indvars.iv170 = phi i64 [ 1, %.lr.ph162 ], [ %indvars.iv.next171, %29 ]
  %.1160 = phi double [ %.0164, %.lr.ph162 ], [ %44, %29 ]
  %30 = add nsw i64 %indvars.iv170, -1
  %31 = getelementptr i32, ptr %.unpack, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !3
  %33 = sub i32 %25, %32
  %34 = sitofp i32 %33 to double
  %35 = fmul double %34, %34
  %36 = add i64 %.unpack119.unpack.unpack122, %30
  %37 = getelementptr i32, ptr %.unpack, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !3
  %39 = sub i32 %28, %38
  %40 = sitofp i32 %39 to double
  %41 = fmul double %40, %40
  %42 = fadd contract double %35, %41
  %43 = call contract double @llvm.sqrt.f64(double %42)
  %44 = fadd contract double %.1160, %43
  %indvars.iv.next171 = add nuw nsw i64 %indvars.iv170, 1
  %exitcond175.not = icmp eq i64 %indvars.iv.next171, %indvars.iv173
  br i1 %exitcond175.not, label %._crit_edge163, label %29

._crit_edge163:                                   ; preds = %29
  %indvars.iv.next174 = add nuw nsw i64 %indvars.iv173, 1
  %exitcond177.not = icmp eq i64 %indvars.iv173, %22
  br i1 %exitcond177.not, label %._crit_edge167.loopexit, label %.lr.ph162

._crit_edge167.loopexit:                          ; preds = %._crit_edge163
  %45 = fmul contract double %44, 2.000000e+00
  br label %._crit_edge167

._crit_edge167:                                   ; preds = %0, %._crit_edge167.loopexit, %._crit_edge
  %46 = phi i32 [ %.pre, %._crit_edge ], [ %.pre, %._crit_edge167.loopexit ], [ %5, %0 ]
  %.0.lcssa = phi double [ 0.000000e+00, %._crit_edge ], [ %45, %._crit_edge167.loopexit ], [ 0.000000e+00, %0 ]
  %47 = sitofp i32 %46 to double
  %48 = fdiv contract double %.0.lcssa, %47
  %49 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.e80a14c4428a733dc39eaa7565ca12ff, i32 18)
  %50 = call i1 @_FortranAioOutputReal64(ptr %49, double %48)
  %51 = call i32 @_FortranAioEndIoStatement(ptr %49)
  %52 = 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 ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #2

; 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 = { noreturn }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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}
