! 2019.11.16
!
      program answer
      implicit none
      integer :: N
      double precision,allocatable,dimension(:) :: x,y
      integer :: i,j
      double precision :: ans
      intrinsic dsqrt,dble
!
      read(*,*) N
      allocate(x(N),y(N)) 
!
      ans = 0.0d0
!
      do i=1,N
        read(*,*) x(i),y(i)
      end do
!
      do i=1,N-1
        do j=i+1,N
          ans = ans + dsqrt((x(i)-x(j))**2+(y(i)-y(j))**2)
        end do
      end do
!
      ans = ans * 2 / N
      write(*,*) ans
      end program answer

; 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
@_QFEy.0 = internal unnamed_addr global ptr null
@_QQcl.2c7e9e13421a0a949ce49838cec1a621 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3000/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 i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2c7e9e13421a0a949ce49838cec1a621, i32 11)
  %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
  %10 = call ptr @malloc(i64 %8)
  store ptr %10, ptr @_QFEy.0, align 8, !tbaa !7
  %11 = icmp sgt i32 %5, 0
  br i1 %11, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %12 = 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 ]
  %13 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.2c7e9e13421a0a949ce49838cec1a621, i32 17)
  %.unpack181 = load ptr, ptr @_QFEx.0, align 8, !tbaa !7
  %14 = add nsw i64 %indvars.iv, -1
  %15 = getelementptr double, ptr %.unpack181, i64 %14
  %16 = call i1 @_FortranAioInputReal64(ptr %13, ptr %15)
  %.unpack193 = load ptr, ptr @_QFEy.0, align 8, !tbaa !7
  %17 = add nsw i64 %indvars.iv, -1
  %18 = getelementptr double, ptr %.unpack193, i64 %17
  %19 = call i1 @_FortranAioInputReal64(ptr %13, ptr %18)
  %20 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %12
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %1, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %21 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %0 ]
  %22 = add i32 %21, -1
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph211, label %._crit_edge212

.lr.ph211:                                        ; preds = %._crit_edge
  %24 = zext i32 %22 to i64
  %25 = sext i32 %21 to i64
  %26 = add nsw i64 %25, 1
  %.unpack = load ptr, ptr @_QFEx.0, align 8
  %.unpack169 = load ptr, ptr @_QFEy.0, align 8
  br label %27

27:                                               ; preds = %.lr.ph211, %._crit_edge208
  %indvars.iv215 = phi i64 [ 1, %.lr.ph211 ], [ %indvars.iv.next216, %._crit_edge208 ]
  %.0209 = phi double [ 0.000000e+00, %.lr.ph211 ], [ %.1.lcssa, %._crit_edge208 ]
  %indvars.iv.next216 = add nuw nsw i64 %indvars.iv215, 1
  %sext = shl i64 %indvars.iv.next216, 32
  %28 = ashr exact i64 %sext, 32
  %29 = sub nsw i64 %26, %28
  %30 = icmp sgt i64 %29, 0
  br i1 %30, label %.lr.ph207, label %._crit_edge208

.lr.ph207:                                        ; preds = %27
  %31 = trunc i64 %indvars.iv.next216 to i32
  %32 = add nsw i64 %indvars.iv215, -1
  %33 = getelementptr double, ptr %.unpack, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !3
  %35 = add nsw i64 %indvars.iv215, -1
  %36 = getelementptr double, ptr %.unpack169, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !3
  br label %38

38:                                               ; preds = %.lr.ph207, %38
  %39 = phi i64 [ %29, %.lr.ph207 ], [ %56, %38 ]
  %40 = phi i32 [ %31, %.lr.ph207 ], [ %55, %38 ]
  %.1205 = phi double [ %.0209, %.lr.ph207 ], [ %54, %38 ]
  %41 = sext i32 %40 to i64
  %42 = add nsw i64 %41, -1
  %43 = getelementptr double, ptr %.unpack, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !3
  %45 = fsub contract double %34, %44
  %46 = fmul double %45, %45
  %47 = add nsw i64 %41, -1
  %48 = getelementptr double, ptr %.unpack169, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !3
  %50 = fsub contract double %37, %49
  %51 = fmul double %50, %50
  %52 = fadd contract double %46, %51
  %53 = call contract double @llvm.sqrt.f64(double %52)
  %54 = fadd contract double %.1205, %53
  %55 = add i32 %40, 1
  %56 = add nsw i64 %39, -1
  %57 = icmp ugt i64 %39, 1
  br i1 %57, label %38, label %._crit_edge208

._crit_edge208:                                   ; preds = %38, %27
  %.1.lcssa = phi double [ %.0209, %27 ], [ %54, %38 ]
  %exitcond218.not = icmp eq i64 %indvars.iv215, %24
  br i1 %exitcond218.not, label %._crit_edge212, label %27

._crit_edge212:                                   ; preds = %._crit_edge208, %._crit_edge
  %.0.lcssa = phi double [ 0.000000e+00, %._crit_edge ], [ %.1.lcssa, %._crit_edge208 ]
  %58 = fmul contract double %.0.lcssa, 2.000000e+00
  %59 = sitofp i32 %21 to double
  %60 = fdiv contract double %58, %59
  %61 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.2c7e9e13421a0a949ce49838cec1a621, i32 27)
  %62 = call i1 @_FortranAioOutputReal64(ptr %61, double %60)
  %63 = call i32 @_FortranAioEndIoStatement(ptr %61)
  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 @_FortranAioInputReal64(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

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

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

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) }

!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}
