program sample
	implicit none
    integer :: x,y,i,sum1,maxval1,minval1
    integer, allocatable :: a(:)
    
    read(*,*) x,y
    
    allocate(a(x))
    
    do i=1,x
       a(i)=y+i-1
    end do
    
    sum1=sum(a)
    maxval1=maxval(a)
	minval1=minval(a)
    
    if (maxval1 >=0 .and. minval1<=0) then
    	write(*,*) sum1
    else if (minval1>0) then
    	write(*,*) sum1-minval1
    else
    	write(*,*) sum1-maxval1
    end if
    
    deallocate(a)
    
    stop
end program sample
; 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
@_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3940/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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #2 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2, i32 6)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 4)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i32, ptr %2, align 4, !tbaa !3
  %9 = call i32 @llvm.smax.i32(i32 %8, i32 0)
  %10 = zext i32 %9 to i64
  %11 = shl nuw nsw i64 %10, 2
  %12 = call ptr @malloc(i64 %11)
  store ptr %12, ptr @_QFEa.0, align 8, !tbaa !7
  %13 = icmp sgt i32 %8, 0
  br i1 %13, label %.lr.ph, label %_FortranAMaxvalInteger4x1_contract_simplified.exit

.lr.ph:                                           ; preds = %0
  %14 = zext i32 %8 to i64
  %15 = load i32, ptr %3, align 4, !tbaa !3
  %min.iters.check = icmp ult i32 %8, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %14, 4294967288
  %ind.end = or i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %15, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert337 = insertelement <4 x i32> poison, i32 %15, i64 0
  %broadcast.splat338 = shufflevector <4 x i32> %broadcast.splatinsert337, <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 ]
  %16 = or i64 %index, 1
  %17 = or i64 %index, 2
  %18 = or i64 %index, 3
  %19 = insertelement <4 x i64> poison, i64 %index, i64 0
  %20 = insertelement <4 x i64> %19, i64 %16, i64 1
  %21 = insertelement <4 x i64> %20, i64 %17, i64 2
  %22 = insertelement <4 x i64> %21, i64 %18, i64 3
  %23 = or i64 %index, 4
  %24 = or i64 %index, 5
  %25 = or i64 %index, 6
  %26 = or i64 %index, 7
  %27 = insertelement <4 x i64> poison, i64 %23, i64 0
  %28 = insertelement <4 x i64> %27, i64 %24, i64 1
  %29 = insertelement <4 x i64> %28, i64 %25, i64 2
  %30 = insertelement <4 x i64> %29, i64 %26, i64 3
  %31 = trunc <4 x i64> %22 to <4 x i32>
  %32 = trunc <4 x i64> %30 to <4 x i32>
  %33 = add <4 x i32> %broadcast.splat, %31
  %34 = add <4 x i32> %broadcast.splat338, %32
  %35 = getelementptr i32, ptr %12, i64 %index
  store <4 x i32> %33, ptr %35, align 4, !tbaa !3
  %36 = getelementptr i32, ptr %35, i64 4
  store <4 x i32> %34, ptr %36, align 4, !tbaa !3
  %index.next = add nuw i64 %index, 8
  %37 = icmp eq i64 %index.next, %n.vec
  br i1 %37, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %14
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %38 = add nsw i64 %indvars.iv, -1
  %39 = trunc i64 %38 to i32
  %40 = add i32 %15, %39
  %41 = getelementptr i32, ptr %12, i64 %38
  store i32 %40, ptr %41, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %14
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %.not = icmp slt i32 %8, 1
  br i1 %.not, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %._crit_edge
  %min.iters.check341 = icmp ult i32 %9, 8
  br i1 %min.iters.check341, label %.lr.ph.i.preheader372, label %vector.ph342

vector.ph342:                                     ; preds = %.lr.ph.i.preheader
  %n.vec344 = and i64 %10, 2147483640
  br label %vector.body347

vector.body347:                                   ; preds = %vector.body347, %vector.ph342
  %index348 = phi i64 [ 0, %vector.ph342 ], [ %index.next351, %vector.body347 ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph342 ], [ %45, %vector.body347 ]
  %vec.phi349 = phi <4 x i32> [ zeroinitializer, %vector.ph342 ], [ %46, %vector.body347 ]
  %42 = shl i64 %index348, 2
  %43 = getelementptr i8, ptr %12, i64 %42
  %wide.load = load <4 x i32>, ptr %43, align 4, !tbaa !3
  %44 = getelementptr i32, ptr %43, i64 4
  %wide.load350 = load <4 x i32>, ptr %44, align 4, !tbaa !3
  %45 = add <4 x i32> %wide.load, %vec.phi
  %46 = add <4 x i32> %wide.load350, %vec.phi349
  %index.next351 = add nuw i64 %index348, 8
  %47 = icmp eq i64 %index.next351, %n.vec344
  br i1 %47, label %middle.block339, label %vector.body347, !llvm.loop !13

middle.block339:                                  ; preds = %vector.body347
  %bin.rdx = add <4 x i32> %46, %45
  %48 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n346 = icmp eq i64 %n.vec344, %10
  br i1 %cmp.n346, label %.lr.ph.i315.preheader, label %.lr.ph.i.preheader372

.lr.ph.i.preheader372:                            ; preds = %.lr.ph.i.preheader, %middle.block339
  %.ph373 = phi i32 [ 0, %.lr.ph.i.preheader ], [ %48, %middle.block339 ]
  %.ph374 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec344, %middle.block339 ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader372, %.lr.ph.i
  %49 = phi i32 [ %54, %.lr.ph.i ], [ %.ph373, %.lr.ph.i.preheader372 ]
  %50 = phi i64 [ %55, %.lr.ph.i ], [ %.ph374, %.lr.ph.i.preheader372 ]
  %51 = shl i64 %50, 2
  %52 = getelementptr i8, ptr %12, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !3
  %54 = add i32 %53, %49
  %55 = add nuw nsw i64 %50, 1
  %exitcond.not.i = icmp eq i64 %55, %10
  br i1 %exitcond.not.i, label %.lr.ph.i315.preheader, label %.lr.ph.i, !llvm.loop !14

.lr.ph.i315.preheader:                            ; preds = %.lr.ph.i, %middle.block339
  %.lcssa336 = phi i32 [ %48, %middle.block339 ], [ %54, %.lr.ph.i ]
  %min.iters.check354 = icmp ult i32 %9, 8
  br i1 %min.iters.check354, label %.lr.ph.i315.preheader368, label %vector.ph355

vector.ph355:                                     ; preds = %.lr.ph.i315.preheader
  %n.vec357 = and i64 %10, 2147483640
  br label %vector.body360

vector.body360:                                   ; preds = %vector.body360, %vector.ph355
  %index361 = phi i64 [ 0, %vector.ph355 ], [ %index.next366, %vector.body360 ]
  %vec.phi362 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph355 ], [ %59, %vector.body360 ]
  %vec.phi363 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph355 ], [ %60, %vector.body360 ]
  %56 = shl i64 %index361, 2
  %57 = getelementptr i8, ptr %12, i64 %56
  %wide.load364 = load <4 x i32>, ptr %57, align 4, !tbaa !3
  %58 = getelementptr i32, ptr %57, i64 4
  %wide.load365 = load <4 x i32>, ptr %58, align 4, !tbaa !3
  %59 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load364, <4 x i32> %vec.phi362)
  %60 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load365, <4 x i32> %vec.phi363)
  %index.next366 = add nuw i64 %index361, 8
  %61 = icmp eq i64 %index.next366, %n.vec357
  br i1 %61, label %middle.block352, label %vector.body360, !llvm.loop !15

middle.block352:                                  ; preds = %vector.body360
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %59, <4 x i32> %60)
  %62 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %cmp.n359 = icmp eq i64 %n.vec357, %10
  br i1 %cmp.n359, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i315.preheader368

.lr.ph.i315.preheader368:                         ; preds = %.lr.ph.i315.preheader, %middle.block352
  %.ph = phi i32 [ -2147483648, %.lr.ph.i315.preheader ], [ %62, %middle.block352 ]
  %.ph369 = phi i64 [ 0, %.lr.ph.i315.preheader ], [ %n.vec357, %middle.block352 ]
  br label %.lr.ph.i315

.lr.ph.i315:                                      ; preds = %.lr.ph.i315.preheader368, %.lr.ph.i315
  %63 = phi i32 [ %68, %.lr.ph.i315 ], [ %.ph, %.lr.ph.i315.preheader368 ]
  %64 = phi i64 [ %69, %.lr.ph.i315 ], [ %.ph369, %.lr.ph.i315.preheader368 ]
  %65 = shl i64 %64, 2
  %66 = getelementptr i8, ptr %12, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !3
  %68 = call i32 @llvm.smax.i32(i32 %67, i32 %63)
  %69 = add nuw nsw i64 %64, 1
  %exitcond.not.i316 = icmp eq i64 %69, %10
  br i1 %exitcond.not.i316, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i315, !llvm.loop !16

_FortranAMaxvalInteger4x1_contract_simplified.exit: ; preds = %.lr.ph.i315, %middle.block352, %0, %._crit_edge
  %.lcssa.i329 = phi i32 [ 0, %._crit_edge ], [ 0, %0 ], [ %.lcssa336, %middle.block352 ], [ %.lcssa336, %.lr.ph.i315 ]
  %.lcssa.i317 = phi i32 [ -2147483648, %._crit_edge ], [ -2147483648, %0 ], [ %62, %middle.block352 ], [ %68, %.lr.ph.i315 ]
  store ptr %12, ptr %1, align 8, !tbaa !7
  %.fca.1.gep130 = 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.gep130, align 8, !tbaa !7
  %.fca.2.gep132 = 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.gep132, align 8, !tbaa !7
  %.fca.3.gep134 = 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.gep134, align 4, !tbaa !7
  %.fca.4.gep136 = 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.gep136, align 1, !tbaa !7
  %.fca.5.gep138 = 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.gep138, align 2, !tbaa !7
  %.fca.6.gep140 = 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.gep140, align 1, !tbaa !7
  %.fca.7.0.0.gep142 = 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.gep142, align 8, !tbaa !7
  %.fca.7.0.1.gep144 = 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 %10, ptr %.fca.7.0.1.gep144, align 8, !tbaa !7
  %.fca.7.0.2.gep146 = 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.gep146, align 8, !tbaa !7
  %70 = call i32 @_FortranAMinvalInteger4(ptr nonnull %1, ptr nonnull @_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2, i32 16, i32 0, ptr null)
  %71 = icmp sgt i32 %.lcssa.i317, -1
  %72 = icmp slt i32 %70, 1
  %73 = and i1 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %75 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2, i32 19)
  br label %84

76:                                               ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %77 = icmp sgt i32 %70, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %76
  %79 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2, i32 21)
  %80 = sub i32 %.lcssa.i329, %70
  br label %84

81:                                               ; preds = %76
  %82 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7210e0e81134cd5cdaeb8cb83f34f0f2, i32 23)
  %83 = sub i32 %.lcssa.i329, %.lcssa.i317
  br label %84

84:                                               ; preds = %74, %78, %81
  %.lcssa.i329.sink = phi i32 [ %.lcssa.i329, %74 ], [ %80, %78 ], [ %83, %81 ]
  %.sink335 = phi ptr [ %75, %74 ], [ %79, %78 ], [ %82, %81 ]
  %85 = call i1 @_FortranAioOutputInteger32(ptr %.sink335, i32 %.lcssa.i329.sink)
  %86 = call i32 @_FortranAioEndIoStatement(ptr %.sink335)
  %.unpack291 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  call void @free(ptr %.unpack291)
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  %87 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 i32 @_FortranAMinvalInteger4(ptr, ptr, i32, i32, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #5

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { noreturn }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #5 = { nocallback nofree nosync nounwind speculatable 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}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
!15 = distinct !{!15, !10, !11}
!16 = distinct !{!16, !11, !10}
