program atcoder0328_3
  integer, dimension(:), allocatable:: A,D
  read(5,*)K,N
  allocate(A(N),D(N))
  read(5,*)A
  do I=1,N-1
     D(I)=A(I+1)-A(I)
  end do
  D(N)=K+A(1)-A(N)
  L=maxval(D)
  write(6,*)int(K-L)
end program atcoder0328_3
; 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
@_QFEd.0 = internal unnamed_addr global ptr null
@_QFEd.8 = internal unnamed_addr global i64 0
@_QQcl.5fd203811302d00490ec912aaefb7fd0 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1963/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 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.5fd203811302d00490ec912aaefb7fd0, i32 3)
  %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 %3, 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
  store i64 %10, ptr @_QFEa.8, align 8, !tbaa !7
  %13 = call ptr @malloc(i64 %11)
  store ptr %13, ptr @_QFEd.0, align 8, !tbaa !7
  store i64 %10, ptr @_QFEd.8, align 8, !tbaa !7
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.5fd203811302d00490ec912aaefb7fd0, i32 5)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack274.unpack.unpack276 = 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 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 %.unpack274.unpack.unpack276, 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
  %15 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %1)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %17 = load i32, ptr %3, align 4, !tbaa !3
  %18 = add i32 %17, -1
  %19 = icmp sgt i32 %18, 0
  br i1 %19, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.unpack279.pre = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack291.pre = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  br label %._crit_edge

.lr.ph:                                           ; preds = %0
  %20 = zext i32 %18 to i64
  %.unpack315 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack327 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %min.iters.check = icmp ult i32 %18, 12
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %21 = add nsw i64 %20, -1
  %22 = trunc i64 %21 to i32
  %23 = icmp ugt i32 %22, 2147483645
  %24 = icmp ugt i64 %21, 4294967295
  %25 = or i1 %23, %24
  br i1 %25, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %26 = shl nuw nsw i64 %20, 2
  %uglygep = getelementptr i8, ptr %.unpack327, i64 %26
  %27 = add nuw nsw i64 %26, 4
  %uglygep344 = getelementptr i8, ptr %.unpack315, i64 %27
  %bound0 = icmp ult ptr %.unpack327, %uglygep344
  %bound1 = icmp ult ptr %.unpack315, %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 %20, 4294967288
  %ind.end = or i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %28 = shl i64 %index, 32
  %29 = ashr exact i64 %28, 32
  %30 = or i64 %29, 1
  %31 = getelementptr i32, ptr %.unpack315, i64 %30
  %wide.load = load <4 x i32>, ptr %31, align 4, !tbaa !3, !alias.scope !9
  %32 = getelementptr i32, ptr %31, i64 4
  %wide.load345 = load <4 x i32>, ptr %32, align 4, !tbaa !3, !alias.scope !9
  %33 = getelementptr i32, ptr %.unpack315, i64 %index
  %wide.load346 = load <4 x i32>, ptr %33, align 4, !tbaa !3, !alias.scope !9
  %34 = getelementptr i32, ptr %33, i64 4
  %wide.load347 = load <4 x i32>, ptr %34, align 4, !tbaa !3, !alias.scope !9
  %35 = sub <4 x i32> %wide.load, %wide.load346
  %36 = sub <4 x i32> %wide.load345, %wide.load347
  %37 = getelementptr i32, ptr %.unpack327, i64 %index
  store <4 x i32> %35, ptr %37, align 4, !tbaa !3, !alias.scope !12, !noalias !9
  %38 = getelementptr i32, ptr %37, i64 4
  store <4 x i32> %36, ptr %38, align 4, !tbaa !3, !alias.scope !12, !noalias !9
  %index.next = add nuw i64 %index, 8
  %39 = icmp eq i64 %index.next, %n.vec
  br i1 %39, label %middle.block, label %vector.body, !llvm.loop !14

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

scalar.ph.preheader:                              ; preds = %vector.memcheck, %vector.scevcheck, %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %vector.memcheck ], [ 1, %vector.scevcheck ], [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %xtraiter = and i64 %20, 1
  %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
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  %sext.prol = shl i64 %indvars.iv.next.prol, 32
  %40 = ashr exact i64 %sext.prol, 32
  %41 = add nsw i64 %40, -1
  %42 = getelementptr i32, ptr %.unpack315, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !3
  %44 = add nsw i64 %indvars.iv.ph, -1
  %45 = getelementptr i32, ptr %.unpack315, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = sub i32 %43, %46
  %48 = add nsw i64 %indvars.iv.ph, -1
  %49 = getelementptr i32, ptr %.unpack327, i64 %48
  store i32 %47, ptr %49, align 4, !tbaa !3
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %50 = icmp eq i64 %indvars.iv.ph, %20
  br i1 %50, label %._crit_edge.loopexit, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %51 = ashr exact i64 %sext, 32
  %52 = add nsw i64 %51, -1
  %53 = getelementptr i32, ptr %.unpack315, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !3
  %55 = add i64 %indvars.iv, -1
  %56 = getelementptr i32, ptr %.unpack315, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !3
  %58 = sub i32 %54, %57
  %59 = add i64 %indvars.iv, -1
  %60 = getelementptr i32, ptr %.unpack327, i64 %59
  store i32 %58, ptr %60, align 4, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %sext.1 = shl i64 %indvars.iv.next.1, 32
  %61 = ashr exact i64 %sext.1, 32
  %62 = add nsw i64 %61, -1
  %63 = getelementptr i32, ptr %.unpack315, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !3
  %65 = getelementptr i32, ptr %.unpack315, i64 %indvars.iv
  %66 = load i32, ptr %65, align 4, !tbaa !3
  %67 = sub i32 %64, %66
  %68 = getelementptr i32, ptr %.unpack327, i64 %indvars.iv
  store i32 %67, ptr %68, align 4, !tbaa !3
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next, %20
  br i1 %exitcond.not.1, label %._crit_edge.loopexit, label %scalar.ph, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %.pre = load i32, ptr %3, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %.unpack291 = phi ptr [ %.unpack291.pre, %.._crit_edge_crit_edge ], [ %.unpack327, %._crit_edge.loopexit ]
  %69 = phi i32 [ %17, %.._crit_edge_crit_edge ], [ %.pre, %._crit_edge.loopexit ]
  %.unpack279 = phi ptr [ %.unpack279.pre, %.._crit_edge_crit_edge ], [ %.unpack315, %._crit_edge.loopexit ]
  %70 = load i32, ptr %2, align 4, !tbaa !3
  %71 = load i32, ptr %.unpack279, align 4, !tbaa !3
  %72 = add i32 %71, %70
  %73 = sext i32 %69 to i64
  %74 = add nsw i64 %73, -1
  %75 = getelementptr i32, ptr %.unpack279, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !3
  %77 = sub i32 %72, %76
  %78 = add nsw i64 %73, -1
  %79 = getelementptr i32, ptr %.unpack291, i64 %78
  store i32 %77, ptr %79, align 4, !tbaa !3
  %.unpack310.unpack.unpack312 = load i64, ptr @_QFEd.8, align 8, !tbaa !7
  %80 = icmp sgt i64 %.unpack310.unpack.unpack312, 0
  br i1 %80, label %.lr.ph.i.preheader, label %_FortranAMaxvalInteger4x1_contract_simplified.exit

.lr.ph.i.preheader:                               ; preds = %._crit_edge
  %min.iters.check350 = icmp ult i64 %.unpack310.unpack.unpack312, 8
  br i1 %min.iters.check350, label %.lr.ph.i.preheader362, label %vector.ph351

vector.ph351:                                     ; preds = %.lr.ph.i.preheader
  %n.vec353 = and i64 %.unpack310.unpack.unpack312, -8
  br label %vector.body356

vector.body356:                                   ; preds = %vector.body356, %vector.ph351
  %index357 = phi i64 [ 0, %vector.ph351 ], [ %index.next361, %vector.body356 ]
  %vec.phi = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph351 ], [ %84, %vector.body356 ]
  %vec.phi358 = phi <4 x i32> [ <i32 -2147483648, i32 -2147483648, i32 -2147483648, i32 -2147483648>, %vector.ph351 ], [ %85, %vector.body356 ]
  %81 = shl i64 %index357, 2
  %82 = getelementptr i8, ptr %.unpack291, i64 %81
  %wide.load359 = load <4 x i32>, ptr %82, align 4, !tbaa !3
  %83 = getelementptr i32, ptr %82, i64 4
  %wide.load360 = load <4 x i32>, ptr %83, align 4, !tbaa !3
  %84 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load359, <4 x i32> %vec.phi)
  %85 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %wide.load360, <4 x i32> %vec.phi358)
  %index.next361 = add nuw i64 %index357, 8
  %86 = icmp eq i64 %index.next361, %n.vec353
  br i1 %86, label %middle.block348, label %vector.body356, !llvm.loop !18

middle.block348:                                  ; preds = %vector.body356
  %rdx.minmax.select = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %84, <4 x i32> %85)
  %87 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax.select)
  %cmp.n355 = icmp eq i64 %.unpack310.unpack.unpack312, %n.vec353
  br i1 %cmp.n355, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader362

.lr.ph.i.preheader362:                            ; preds = %.lr.ph.i.preheader, %middle.block348
  %.ph = phi i32 [ -2147483648, %.lr.ph.i.preheader ], [ %87, %middle.block348 ]
  %.ph363 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec353, %middle.block348 ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader362, %.lr.ph.i
  %88 = phi i32 [ %93, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader362 ]
  %89 = phi i64 [ %94, %.lr.ph.i ], [ %.ph363, %.lr.ph.i.preheader362 ]
  %90 = shl i64 %89, 2
  %91 = getelementptr i8, ptr %.unpack291, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !3
  %93 = call i32 @llvm.smax.i32(i32 %92, i32 %88)
  %94 = add nuw nsw i64 %89, 1
  %exitcond.not.i = icmp eq i64 %94, %.unpack310.unpack.unpack312
  br i1 %exitcond.not.i, label %_FortranAMaxvalInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !19

_FortranAMaxvalInteger4x1_contract_simplified.exit: ; preds = %.lr.ph.i, %middle.block348, %._crit_edge
  %.lcssa.i = phi i32 [ -2147483648, %._crit_edge ], [ %87, %middle.block348 ], [ %93, %.lr.ph.i ]
  %95 = call ptr @_FortranAioBeginExternalListOutput(i32 6, ptr nonnull @_QQcl.5fd203811302d00490ec912aaefb7fd0, i32 11)
  %96 = load i32, ptr %2, align 4, !tbaa !3
  %97 = sub i32 %96, %.lcssa.i
  %98 = call i1 @_FortranAioOutputInteger32(ptr %95, i32 %97)
  %99 = call i32 @_FortranAioEndIoStatement(ptr %95)
  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 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.smax.v4i32(<4 x i32>) #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 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15, !16}
!19 = distinct !{!19, !16, !15}
