program ABC143B
    implicit none
    integer:: N,i,j
    integer:: result=0
    integer,allocatable,dimension(:):: D
    read *, N
    allocate(D(N))
    read*, (D(i),i=1,N)

    do i=1,N-1
        do j=i+1,N
            result=result+D(i)*D(j)
        end do
    end do

    print '(i0)',result
end program ABC143B
; 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"

@_QFEd.0 = internal unnamed_addr global ptr null
@_QFEresult = internal unnamed_addr global i32 0
@_QQcl.eb3dc77b3b65fea3a261ee270450c9f5 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3113/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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.eb3dc77b3b65fea3a261ee270450c9f5, 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, 2
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEd.0, align 8, !tbaa !7
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.eb3dc77b3b65fea3a261ee270450c9f5, i32 8)
  %11 = load i32, ptr %1, align 4, !tbaa !3
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph.preheader, label %._crit_edge

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %14 = phi i64 [ %19, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %.unpack75 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %sext = shl i64 %14, 32
  %15 = ashr exact i64 %sext, 32
  %16 = add nsw i64 %15, -1
  %17 = getelementptr i32, ptr %.unpack75, i64 %16
  %18 = call i1 @_FortranAioInputInteger(ptr %10, ptr %17, i32 4)
  %19 = add nuw nsw i64 %14, 1
  %exitcond.not = icmp eq i64 %14, %13
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %20 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %21 = load i32, ptr %1, align 4, !tbaa !3
  %22 = add i32 %21, -1
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph95, label %._crit_edge96

.lr.ph95:                                         ; preds = %._crit_edge
  %24 = zext i32 %22 to i64
  %_QFEresult.promoted90 = load i32, ptr @_QFEresult, align 4, !tbaa !3
  %25 = sext i32 %21 to i64
  %26 = add nsw i64 %25, 1
  %.unpack = load ptr, ptr @_QFEd.0, align 8
  %27 = add nsw i64 %25, 1
  br label %28

28:                                               ; preds = %.lr.ph95, %70
  %indvar = phi i32 [ 0, %.lr.ph95 ], [ %indvar.next, %70 ]
  %indvars.iv = phi i64 [ 1, %.lr.ph95 ], [ %indvars.iv.next, %70 ]
  %.lcssa9293 = phi i32 [ %_QFEresult.promoted90, %.lr.ph95 ], [ %.lcssa91, %70 ]
  %29 = add i32 %indvar, 2
  %30 = sext i32 %29 to i64
  %31 = sub nsw i64 %27, %30
  %32 = add i32 %indvar, 2
  %33 = sext i32 %32 to i64
  %34 = sub nsw i64 %25, %33
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext99 = shl i64 %indvars.iv.next, 32
  %35 = ashr exact i64 %sext99, 32
  %36 = sub nsw i64 %26, %35
  %37 = icmp sgt i64 %36, 0
  br i1 %37, label %.lr.ph88, label %70

.lr.ph88:                                         ; preds = %28
  %38 = trunc i64 %indvars.iv.next to i32
  %39 = add nsw i64 %indvars.iv, -1
  %40 = getelementptr i32, ptr %.unpack, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !3
  %min.iters.check = icmp ult i64 %31, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph88
  %42 = trunc i64 %34 to i32
  %43 = add i32 %32, %42
  %44 = icmp slt i32 %43, %32
  %45 = icmp ugt i64 %34, 4294967295
  %46 = or i1 %44, %45
  br i1 %46, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %n.vec = and i64 %31, -8
  %ind.end = sub nsw i64 %36, %n.vec
  %.cast = trunc i64 %n.vec to i32
  %ind.end100 = add i32 %38, %.cast
  %47 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.lcssa9293, i64 0
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %41, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert105 = insertelement <4 x i32> poison, i32 %41, i64 0
  %broadcast.splat106 = shufflevector <4 x i32> %broadcast.splatinsert105, <4 x i32> poison, <4 x i32> zeroinitializer
  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> [ %47, %vector.ph ], [ %54, %vector.body ]
  %vec.phi102 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %55, %vector.body ]
  %offset.idx = add i64 %indvars.iv.next, %index
  %sext107 = shl i64 %offset.idx, 32
  %48 = ashr exact i64 %sext107, 32
  %49 = add nsw i64 %48, -1
  %50 = getelementptr i32, ptr %.unpack, i64 %49
  %wide.load = load <4 x i32>, ptr %50, align 4, !tbaa !3
  %51 = getelementptr i32, ptr %50, i64 4
  %wide.load104 = load <4 x i32>, ptr %51, align 4, !tbaa !3
  %52 = mul <4 x i32> %wide.load, %broadcast.splat
  %53 = mul <4 x i32> %wide.load104, %broadcast.splat106
  %54 = add <4 x i32> %52, %vec.phi
  %55 = add <4 x i32> %53, %vec.phi102
  %index.next = add nuw i64 %index, 8
  %56 = icmp eq i64 %index.next, %n.vec
  br i1 %56, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %55, %54
  %57 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %31, %n.vec
  br i1 %cmp.n, label %._crit_edge89, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.scevcheck, %.lr.ph88, %middle.block
  %.ph = phi i64 [ %36, %vector.scevcheck ], [ %36, %.lr.ph88 ], [ %ind.end, %middle.block ]
  %.ph108 = phi i32 [ %38, %vector.scevcheck ], [ %38, %.lr.ph88 ], [ %ind.end100, %middle.block ]
  %.ph109 = phi i32 [ %.lcssa9293, %vector.scevcheck ], [ %.lcssa9293, %.lr.ph88 ], [ %57, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %58 = phi i64 [ %68, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %59 = phi i32 [ %67, %scalar.ph ], [ %.ph108, %scalar.ph.preheader ]
  %60 = phi i32 [ %66, %scalar.ph ], [ %.ph109, %scalar.ph.preheader ]
  %61 = sext i32 %59 to i64
  %62 = add nsw i64 %61, -1
  %63 = getelementptr i32, ptr %.unpack, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !3
  %65 = mul i32 %64, %41
  %66 = add i32 %65, %60
  %67 = add i32 %59, 1
  %68 = add nsw i64 %58, -1
  %69 = icmp ugt i64 %58, 1
  br i1 %69, label %scalar.ph, label %._crit_edge89, !llvm.loop !12

._crit_edge89:                                    ; preds = %scalar.ph, %middle.block
  %.lcssa = phi i32 [ %57, %middle.block ], [ %66, %scalar.ph ]
  store i32 %.lcssa, ptr @_QFEresult, align 4, !tbaa !3
  br label %70

70:                                               ; preds = %._crit_edge89, %28
  %.lcssa91 = phi i32 [ %.lcssa, %._crit_edge89 ], [ %.lcssa9293, %28 ]
  %exitcond98.not = icmp eq i64 %indvars.iv, %24
  %indvar.next = add i32 %indvar, 1
  br i1 %exitcond98.not, label %._crit_edge96, label %28

._crit_edge96:                                    ; preds = %70, %._crit_edge
  %71 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.eb3dc77b3b65fea3a261ee270450c9f5, i32 16)
  %72 = load i32, ptr @_QFEresult, align 4, !tbaa !3
  %73 = call i1 @_FortranAioOutputInteger32(ptr %71, i32 %72)
  %74 = call i32 @_FortranAioEndIoStatement(ptr %71)
  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 ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

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

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