      PROGRAM takoFes
      IMPLICIT NONE
      INTEGER :: N
      INTEGER,ALLOCATABLE :: d(:)
      INTEGER(8) :: ans
      
      INTEGER :: a,piyo
      READ*,N
      ALLOCATE( d(N) )
      read*,d(:)
      
      ans = 0
      DO a = 1,N-1
        piyo = sum(d(a+1:N))
        ans = ans + d(a)*piyo
      END DO
      
      print*,ans
      
      
      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"

@_QFEd.0 = internal unnamed_addr global ptr null
@_QFEd.8 = internal unnamed_addr global i64 0
@_QQcl.ba70e5fa9a9efaffad1b30be45e10474 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3114/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 { 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.ba70e5fa9a9efaffad1b30be45e10474, i32 8)
  %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 @_QFEd.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEd.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ba70e5fa9a9efaffad1b30be45e10474, i32 10)
  %.unpack = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %.unpack139.unpack.unpack141 = load i64, ptr @_QFEd.8, align 8, !tbaa !7
  %12 = call i64 @llvm.smax.i64(i64 %.unpack139.unpack.unpack141, 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 = load i32, ptr %2, align 4, !tbaa !3
  %16 = add i32 %15, -1
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %18 = zext i32 %16 to i64
  %.unpack144 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %19 = sext i32 %15 to i64
  br label %20

20:                                               ; preds = %.lr.ph, %_FortranASumInteger4x1_contract_simplified.exit
  %indvar = phi i32 [ 0, %.lr.ph ], [ %indvar.next, %_FortranASumInteger4x1_contract_simplified.exit ]
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %_FortranASumInteger4x1_contract_simplified.exit ]
  %.0168 = phi i64 [ 0, %.lr.ph ], [ %49, %_FortranASumInteger4x1_contract_simplified.exit ]
  %21 = add i32 %indvar, 2
  %22 = sext i32 %21 to i64
  %23 = sub nsw i64 %19, %22
  %smax = call i64 @llvm.smax.i64(i64 %23, i64 -1)
  %24 = add nsw i64 %smax, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %25 = ashr exact i64 %sext, 32
  %26 = add nsw i64 %25, -1
  %27 = sub nsw i64 %19, %25
  %28 = call i64 @llvm.smax.i64(i64 %27, i64 -1)
  %29 = getelementptr i32, ptr %.unpack144, i64 %26
  %.not = icmp slt i64 %27, 0
  br i1 %.not, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %20
  %min.iters.check = icmp ult i64 %24, 8
  br i1 %min.iters.check, label %.lr.ph.i.preheader175, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %24, -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 ], [ %33, %vector.body ]
  %vec.phi173 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %34, %vector.body ]
  %30 = shl i64 %index, 2
  %31 = getelementptr i8, ptr %29, i64 %30
  %wide.load = load <4 x i32>, ptr %31, align 4, !tbaa !3
  %32 = getelementptr i32, ptr %31, i64 4
  %wide.load174 = load <4 x i32>, ptr %32, align 4, !tbaa !3
  %33 = add <4 x i32> %wide.load, %vec.phi
  %34 = add <4 x i32> %wide.load174, %vec.phi173
  %index.next = add nuw i64 %index, 8
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %34, %33
  %36 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %24, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader175

.lr.ph.i.preheader175:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i32 [ 0, %.lr.ph.i.preheader ], [ %36, %middle.block ]
  %.ph176 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader175, %.lr.ph.i
  %37 = phi i32 [ %42, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader175 ]
  %38 = phi i64 [ %43, %.lr.ph.i ], [ %.ph176, %.lr.ph.i.preheader175 ]
  %39 = shl i64 %38, 2
  %40 = getelementptr i8, ptr %29, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !3
  %42 = add i32 %41, %37
  %43 = add nuw nsw i64 %38, 1
  %exitcond.not.i = icmp eq i64 %38, %28
  br i1 %exitcond.not.i, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranASumInteger4x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block, %20
  %.lcssa.i = phi i32 [ 0, %20 ], [ %36, %middle.block ], [ %42, %.lr.ph.i ]
  %44 = add nsw i64 %indvars.iv, -1
  %45 = getelementptr i32, ptr %.unpack144, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = mul i32 %46, %.lcssa.i
  %48 = sext i32 %47 to i64
  %49 = add i64 %.0168, %48
  %exitcond.not = icmp eq i64 %indvars.iv, %18
  %indvar.next = add i32 %indvar, 1
  br i1 %exitcond.not, label %._crit_edge, label %20

._crit_edge:                                      ; preds = %_FortranASumInteger4x1_contract_simplified.exit, %0
  %.0.lcssa = phi i64 [ 0, %0 ], [ %49, %_FortranASumInteger4x1_contract_simplified.exit ]
  %50 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.ba70e5fa9a9efaffad1b30be45e10474, i32 18)
  %51 = call i1 @_FortranAioOutputInteger64(ptr %50, i64 %.0.lcssa)
  %52 = call i32 @_FortranAioEndIoStatement(ptr %50)
  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 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: 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) #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, !11, !10}
