integer N
integer(8),allocatable,dimension(:)::A
integer(8) Yotei
read*,N
allocate(A(0:N+1))
A(0)=0
read*,A(1:N)
A(N+1)=0
do i=1,N+1
  Yotei=Yotei+abs(A(i)-A(i-1))
end do
do i=1,N
  print"(i0)",Yotei-(abs(A(i)-A(i-1))+abs(A(i+1)-A(i)))+abs(A(i-1)-A(i+1))
end do
end
; 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.7 = internal unnamed_addr global i64 1
@_QQcl.6bc61a504843424d87411a5051cf5368 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6144/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 i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6bc61a504843424d87411a5051cf5368, i32 4)
  %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 = add i32 %6, 1
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 -1)
  %9 = sext i32 %8 to i64
  %10 = add nsw i64 %9, 1
  %11 = shl nuw nsw i64 %10, 3
  %12 = call ptr @malloc(i64 %11)
  %13 = icmp eq i64 %10, 0
  %.neg = sext i1 %13 to i64
  %14 = zext i1 %13 to i64
  store ptr %12, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %14, ptr @_QFEa.7, align 8, !tbaa !7
  %15 = getelementptr i64, ptr %12, i64 %.neg
  store i64 0, ptr %15, align 8, !tbaa !3
  %16 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6bc61a504843424d87411a5051cf5368, i32 7)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack170.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %17 = load i32, ptr %2, align 4, !tbaa !3
  %18 = sub i64 1, %.unpack170.unpack.unpack
  %19 = call i32 @llvm.smax.i32(i32 %17, i32 0)
  %20 = zext i32 %19 to i64
  %21 = getelementptr i64, ptr %.unpack, i64 %18
  store ptr %21, 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 %20, 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
  %22 = call i1 @_FortranAioInputDescriptor(ptr %16, ptr nonnull %1)
  %23 = call i32 @_FortranAioEndIoStatement(ptr %16)
  %.unpack175 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack182.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %24 = load i32, ptr %2, align 4, !tbaa !3
  %25 = add i32 %24, 1
  %26 = sext i32 %25 to i64
  %27 = sub i64 %26, %.unpack182.unpack.unpack
  %28 = getelementptr i64, ptr %.unpack175, i64 %27
  store i64 0, ptr %28, align 8, !tbaa !3
  %29 = icmp ult i32 %24, 2147483647
  br i1 %29, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %30 = xor i64 %.unpack182.unpack.unpack, -1
  %31 = call i64 @llvm.smax.i64(i64 %26, i64 1)
  %min.iters.check = icmp ult i64 %31, 4
  br i1 %min.iters.check, label %.lr.ph.preheader228, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %31, 9223372036854775804
  %ind.end = or i64 %n.vec, 1
  %ind.end222 = sub i64 %26, %n.vec
  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> [ <i64 undef, i64 0>, %vector.ph ], [ %42, %vector.body ]
  %vec.phi224 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %43, %vector.body ]
  %offset.idx = or i64 %index, 1
  %32 = sub i64 %offset.idx, %.unpack182.unpack.unpack
  %33 = getelementptr i64, ptr %.unpack175, i64 %32
  %wide.load = load <2 x i64>, ptr %33, align 8, !tbaa !3
  %34 = getelementptr i64, ptr %33, i64 2
  %wide.load225 = load <2 x i64>, ptr %34, align 8, !tbaa !3
  %35 = add i64 %offset.idx, %30
  %36 = getelementptr i64, ptr %.unpack175, i64 %35
  %wide.load226 = load <2 x i64>, ptr %36, align 8, !tbaa !3
  %37 = getelementptr i64, ptr %36, i64 2
  %wide.load227 = load <2 x i64>, ptr %37, align 8, !tbaa !3
  %38 = sub <2 x i64> %wide.load, %wide.load226
  %39 = sub <2 x i64> %wide.load225, %wide.load227
  %40 = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %38, i1 false)
  %41 = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %39, i1 false)
  %42 = add <2 x i64> %40, %vec.phi
  %43 = add <2 x i64> %41, %vec.phi224
  %index.next = add nuw i64 %index, 4
  %44 = icmp eq i64 %index.next, %n.vec
  br i1 %44, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %43, %42
  %45 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %31, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader228

.lr.ph.preheader228:                              ; preds = %.lr.ph.preheader, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.ph = phi i64 [ %26, %.lr.ph.preheader ], [ %ind.end222, %middle.block ]
  %.0214.ph = phi i64 [ undef, %.lr.ph.preheader ], [ %45, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader228, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader228 ]
  %46 = phi i64 [ %56, %.lr.ph ], [ %.ph, %.lr.ph.preheader228 ]
  %.0214 = phi i64 [ %55, %.lr.ph ], [ %.0214.ph, %.lr.ph.preheader228 ]
  %47 = sub i64 %indvars.iv, %.unpack182.unpack.unpack
  %48 = getelementptr i64, ptr %.unpack175, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !3
  %50 = add i64 %indvars.iv, %30
  %51 = getelementptr i64, ptr %.unpack175, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !3
  %53 = sub i64 %49, %52
  %54 = call i64 @llvm.abs.i64(i64 %53, i1 false)
  %55 = add i64 %54, %.0214
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %56 = add nsw i64 %46, -1
  %57 = icmp sgt i64 %46, 1
  br i1 %57, label %.lr.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %0
  %.0.lcssa = phi i64 [ undef, %0 ], [ %45, %middle.block ], [ %55, %.lr.ph ]
  %58 = icmp sgt i32 %24, 0
  br i1 %58, label %.lr.ph216.preheader, label %._crit_edge217

.lr.ph216.preheader:                              ; preds = %._crit_edge
  %59 = zext i32 %24 to i64
  br label %.lr.ph216

.lr.ph216:                                        ; preds = %.lr.ph216.preheader, %.lr.ph216
  %indvars.iv219 = phi i64 [ 1, %.lr.ph216.preheader ], [ %indvars.iv.next220, %.lr.ph216 ]
  %60 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.6bc61a504843424d87411a5051cf5368, i32 13)
  %.unpack187 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack194.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %61 = sub i64 %indvars.iv219, %.unpack194.unpack.unpack
  %62 = getelementptr i64, ptr %.unpack187, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !3
  %64 = xor i64 %.unpack194.unpack.unpack, -1
  %65 = add i64 %indvars.iv219, %64
  %66 = getelementptr i64, ptr %.unpack187, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !3
  %68 = sub i64 %63, %67
  %69 = call i64 @llvm.abs.i64(i64 %68, i1 false)
  %indvars.iv.next220 = add nuw nsw i64 %indvars.iv219, 1
  %sext = shl i64 %indvars.iv.next220, 32
  %70 = ashr exact i64 %sext, 32
  %71 = sub i64 %70, %.unpack194.unpack.unpack
  %72 = getelementptr i64, ptr %.unpack187, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !3
  %74 = sub i64 %73, %63
  %75 = call i64 @llvm.abs.i64(i64 %74, i1 false)
  %76 = sub i64 %67, %73
  %77 = call i64 @llvm.abs.i64(i64 %76, i1 false)
  %78 = add i64 %69, %75
  %79 = sub i64 %.0.lcssa, %78
  %80 = add i64 %79, %77
  %81 = call i1 @_FortranAioOutputInteger64(ptr %60, i64 %80)
  %82 = call i32 @_FortranAioEndIoStatement(ptr %60)
  %exitcond.not = icmp eq i64 %indvars.iv219, %59
  br i1 %exitcond.not, label %._crit_edge217, label %.lr.ph216

._crit_edge217:                                   ; preds = %.lr.ph216, %._crit_edge
  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 @_FortranAioOutputInteger64(ptr, i64) 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 speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1 immarg) #1

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

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

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}
