program ABC064B
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)
    print'(i0)',maxval(A)-minval(A)
end program ABC064B
; 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.ead54ae2fb929a79c8509bf62d3360ef = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7211/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 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.ead54ae2fb929a79c8509bf62d3360ef, i32 5)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i64, ptr %2, align 8, !tbaa !3
  %7 = call i64 @llvm.smax.i64(i64 %6, i64 0)
  %8 = shl i64 %7, 3
  %9 = call ptr @malloc(i64 %8)
  store ptr %9, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %7, ptr @_QFEa.8, align 8, !tbaa !7
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.ead54ae2fb929a79c8509bf62d3360ef, i32 7)
  %11 = load i64, ptr %2, align 8, !tbaa !3
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %13 = phi i64 [ %17, %.lr.ph ], [ 1, %0 ]
  %.unpack150 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %14 = add i64 %13, -1
  %15 = getelementptr i64, ptr %.unpack150, i64 %14
  %16 = call i1 @_FortranAioInputInteger(ptr %10, ptr %15, i32 8)
  %17 = add nuw i64 %13, 1
  %exitcond.not = icmp eq i64 %13, %11
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %18 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %19 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.ead54ae2fb929a79c8509bf62d3360ef, i32 8)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack133.unpack.unpack135 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %20 = icmp sgt i64 %.unpack133.unpack.unpack135, 0
  br i1 %20, label %.lr.ph.i.preheader, label %_FortranAMaxvalInteger8x1_contract_simplified.exit

.lr.ph.i.preheader:                               ; preds = %._crit_edge
  %min.iters.check = icmp ult i64 %.unpack133.unpack.unpack135, 4
  br i1 %min.iters.check, label %.lr.ph.i.preheader164, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i.preheader
  %n.vec = and i64 %.unpack133.unpack.unpack135, -4
  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 -9223372036854775808, i64 -9223372036854775808>, %vector.ph ], [ %24, %vector.body ]
  %vec.phi162 = phi <2 x i64> [ <i64 -9223372036854775808, i64 -9223372036854775808>, %vector.ph ], [ %25, %vector.body ]
  %21 = shl i64 %index, 3
  %22 = getelementptr i8, ptr %.unpack, i64 %21
  %wide.load = load <2 x i64>, ptr %22, align 8, !tbaa !3
  %23 = getelementptr i64, ptr %22, i64 2
  %wide.load163 = load <2 x i64>, ptr %23, align 8, !tbaa !3
  %24 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %wide.load, <2 x i64> %vec.phi)
  %25 = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %wide.load163, <2 x i64> %vec.phi162)
  %index.next = add nuw i64 %index, 4
  %26 = icmp eq i64 %index.next, %n.vec
  br i1 %26, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %rdx.minmax.select = call <2 x i64> @llvm.smax.v2i64(<2 x i64> %24, <2 x i64> %25)
  %27 = call i64 @llvm.vector.reduce.smax.v2i64(<2 x i64> %rdx.minmax.select)
  %cmp.n = icmp eq i64 %.unpack133.unpack.unpack135, %n.vec
  br i1 %cmp.n, label %_FortranAMaxvalInteger8x1_contract_simplified.exit, label %.lr.ph.i.preheader164

.lr.ph.i.preheader164:                            ; preds = %.lr.ph.i.preheader, %middle.block
  %.ph = phi i64 [ -9223372036854775808, %.lr.ph.i.preheader ], [ %27, %middle.block ]
  %.ph165 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader164, %.lr.ph.i
  %28 = phi i64 [ %33, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader164 ]
  %29 = phi i64 [ %34, %.lr.ph.i ], [ %.ph165, %.lr.ph.i.preheader164 ]
  %30 = shl i64 %29, 3
  %31 = getelementptr i8, ptr %.unpack, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !3
  %33 = call i64 @llvm.smax.i64(i64 %32, i64 %28)
  %34 = add nuw nsw i64 %29, 1
  %exitcond.not.i = icmp eq i64 %34, %.unpack133.unpack.unpack135
  br i1 %exitcond.not.i, label %_FortranAMaxvalInteger8x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranAMaxvalInteger8x1_contract_simplified.exit: ; preds = %.lr.ph.i, %middle.block, %._crit_edge
  %.lcssa.i = phi i64 [ -9223372036854775808, %._crit_edge ], [ %27, %middle.block ], [ %33, %.lr.ph.i ]
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep71 = 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.gep71, align 8, !tbaa !7
  %.fca.2.gep73 = 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.gep73, align 8, !tbaa !7
  %.fca.3.gep75 = 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.gep75, align 4, !tbaa !7
  %.fca.4.gep77 = 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.gep77, align 1, !tbaa !7
  %.fca.5.gep79 = 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.gep79, align 2, !tbaa !7
  %.fca.6.gep81 = 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.gep81, align 1, !tbaa !7
  %.fca.7.0.0.gep83 = 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.gep83, align 8, !tbaa !7
  %.fca.7.0.1.gep85 = 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 %.unpack133.unpack.unpack135, ptr %.fca.7.0.1.gep85, align 8, !tbaa !7
  %.fca.7.0.2.gep87 = 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.gep87, align 8, !tbaa !7
  %35 = call i64 @_FortranAMinvalInteger8(ptr nonnull %1, ptr nonnull @_QQcl.ead54ae2fb929a79c8509bf62d3360ef, i32 8, i32 0, ptr null)
  %36 = sub i64 %.lcssa.i, %35
  %37 = call i1 @_FortranAioOutputInteger64(ptr %19, i64 %36)
  %38 = call i32 @_FortranAioEndIoStatement(ptr %19)
  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 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

declare i64 @_FortranAMinvalInteger8(ptr, ptr, i32, i32, ptr) local_unnamed_addr

; Function Attrs: mustprogress 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 <2 x i64> @llvm.smax.v2i64(<2 x i64>, <2 x i64>) #2

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

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) }
attributes #3 = { 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}
