program ABC163B
    implicit none
    integer(8)::N,M,i
    integer(8),allocatable,dimension(:)::A
    read*,N,M
    allocate(A(M))
    read*,A
    do i=1,M
        N=N-A(i)
    end do

    if(N<0)then
        print'(i0)',-1
    else
        print'(i0)',N
    end if
end program ABC163B
; 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"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QQcl.c1f8bc03f372dadf8df994080a8c1bec = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1694/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 { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.c1f8bc03f372dadf8df994080a8c1bec, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i64, ptr %2, align 8, !tbaa !3
  %9 = call i64 @llvm.smax.i64(i64 %8, i64 0)
  %10 = shl i64 %9, 3
  %11 = call ptr @malloc(i64 %10)
  store ptr %11, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEa.8, align 8, !tbaa !7
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.c1f8bc03f372dadf8df994080a8c1bec, i32 7)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack84.unpack.unpack86 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  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 8, 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 10, 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 %.unpack84.unpack.unpack86, 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 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %12, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %15 = load i64, ptr %2, align 8, !tbaa !3
  %16 = icmp sgt i64 %15, 0
  %.promoted = load i64, ptr %3, align 8, !tbaa !3
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack89 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %min.iters.check = icmp ult i64 %15, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %uglygep = getelementptr inbounds i8, ptr %3, i64 8
  %17 = shl i64 %15, 3
  %uglygep101 = getelementptr i8, ptr %.unpack89, i64 %17
  %bound0 = icmp ult ptr %3, %uglygep101
  %bound1 = icmp ult ptr %.unpack89, %uglygep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %15, -4
  %ind.end = or i64 %n.vec, 1
  %18 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %.promoted, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ %18, %vector.ph ], [ %21, %vector.body ]
  %vec.phi102 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %22, %vector.body ]
  %19 = getelementptr i64, ptr %.unpack89, i64 %index
  %wide.load = load <2 x i64>, ptr %19, align 8, !tbaa !3, !alias.scope !9
  %20 = getelementptr i64, ptr %19, i64 2
  %wide.load103 = load <2 x i64>, ptr %20, align 8, !tbaa !3, !alias.scope !9
  %21 = sub <2 x i64> %vec.phi, %wide.load
  %22 = sub <2 x i64> %vec.phi102, %wide.load103
  %index.next = add nuw i64 %index, 4
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %22, %21
  %24 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  store i64 %24, ptr %3, align 8, !tbaa !3
  %cmp.n = icmp eq i64 %15, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.memcheck, %.lr.ph, %middle.block
  %.ph = phi i64 [ 1, %vector.memcheck ], [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %.ph104 = phi i64 [ %.promoted, %vector.memcheck ], [ %.promoted, %.lr.ph ], [ %24, %middle.block ]
  %25 = add i64 %15, 1
  %26 = sub i64 %25, %.ph
  %27 = sub i64 %15, %.ph
  %xtraiter = and i64 %26, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %28 = phi i64 [ %34, %scalar.ph.prol ], [ %.ph, %scalar.ph.preheader ]
  %29 = phi i64 [ %33, %scalar.ph.prol ], [ %.ph104, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %30 = add i64 %28, -1
  %31 = getelementptr i64, ptr %.unpack89, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !3
  %33 = sub i64 %29, %32
  store i64 %33, ptr %3, align 8, !tbaa !3
  %34 = add nuw i64 %28, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !15

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.lcssa.unr = phi i64 [ undef, %scalar.ph.preheader ], [ %33, %scalar.ph.prol ]
  %.unr = phi i64 [ %.ph, %scalar.ph.preheader ], [ %34, %scalar.ph.prol ]
  %.unr107 = phi i64 [ %.ph104, %scalar.ph.preheader ], [ %33, %scalar.ph.prol ]
  %35 = icmp ult i64 %27, 3
  br i1 %35, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %36 = phi i64 [ %54, %scalar.ph ], [ %.unr, %scalar.ph.prol.loopexit ]
  %37 = phi i64 [ %53, %scalar.ph ], [ %.unr107, %scalar.ph.prol.loopexit ]
  %38 = add i64 %36, -1
  %39 = getelementptr i64, ptr %.unpack89, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !3
  %41 = sub i64 %37, %40
  store i64 %41, ptr %3, align 8, !tbaa !3
  %42 = add nuw i64 %36, 1
  %43 = getelementptr i64, ptr %.unpack89, i64 %36
  %44 = load i64, ptr %43, align 8, !tbaa !3
  %45 = sub i64 %41, %44
  store i64 %45, ptr %3, align 8, !tbaa !3
  %46 = add nuw i64 %36, 2
  %47 = getelementptr i64, ptr %.unpack89, i64 %42
  %48 = load i64, ptr %47, align 8, !tbaa !3
  %49 = sub i64 %45, %48
  store i64 %49, ptr %3, align 8, !tbaa !3
  %50 = add nuw i64 %36, 3
  %51 = getelementptr i64, ptr %.unpack89, i64 %46
  %52 = load i64, ptr %51, align 8, !tbaa !3
  %53 = sub i64 %49, %52
  store i64 %53, ptr %3, align 8, !tbaa !3
  %54 = add nuw i64 %36, 4
  %exitcond.not.3 = icmp eq i64 %50, %15
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !17

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %0
  %55 = phi i64 [ %.promoted, %0 ], [ %24, %middle.block ], [ %.lcssa.unr, %scalar.ph.prol.loopexit ], [ %53, %scalar.ph ]
  %56 = icmp slt i64 %55, 0
  br i1 %56, label %57, label %60

57:                                               ; preds = %._crit_edge
  %58 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.c1f8bc03f372dadf8df994080a8c1bec, i32 13)
  %59 = call i1 @_FortranAioOutputInteger32(ptr %58, i32 -1)
  br label %64

60:                                               ; preds = %._crit_edge
  %61 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.c1f8bc03f372dadf8df994080a8c1bec, i32 15)
  %62 = load i64, ptr %3, align 8, !tbaa !3
  %63 = call i1 @_FortranAioOutputInteger64(ptr %61, i64 %62)
  br label %64

64:                                               ; preds = %57, %60
  %.sink = phi ptr [ %58, %57 ], [ %61, %60 ]
  %65 = call i32 @_FortranAioEndIoStatement(ptr %.sink)
  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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(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 willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #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 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !13}
