program kadai
implicit none
integer(8)  ::  l,r
integer  ::  i,j,k
integer,allocatable  ::  ans(:)
integer  ::  mn


read(*,*) l,r

if (r/2019-l/2019>0) then
    write(*,*) 0
    stop
end if

l=mod(l,2019)
r=mod(r,2019)

allocate(ans(r*r))
ans=2020
k=1
if (l<r) then
do i=l,r
    do j=i+1,r
        ans(k)=mod(i*j,2019)
        k=k+1
    end do
end do
end if

if (l==r) then
    write(*,*) mod(l*r,2019)
    stop
end if

mn=minval(ans)
!write(*,*) ans
write(*,*) mn!,l,r

stop

end program kadai

; 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"

@_QFEans.0 = internal unnamed_addr global ptr null
@_QFEans.7 = internal unnamed_addr global i64 1
@_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3824/source.f\00"
@_QQcl.16373402fa3425c6e46827601abb88fa = linkonce constant [76 x i8] c"array left hand side must be allocated when the right hand side is a scalar\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: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %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.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 9)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 8)
  %7 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %8 = load i64, ptr %3, align 8, !tbaa !3
  %9 = sdiv i64 %8, 2019
  %10 = srem i64 %8, 2019
  %11 = load i64, ptr %2, align 8, !tbaa !3
  %.neg = sdiv i64 %11, -2019
  %12 = add nsw i64 %.neg, %9
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %14, label %19

14:                                               ; preds = %0
  %15 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 12)
  %16 = call i1 @_FortranAioOutputInteger32(ptr %15, i32 0)
  %17 = call i32 @_FortranAioEndIoStatement(ptr %15)
  %18 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

19:                                               ; preds = %0
  %20 = srem i64 %11, 2019
  store i64 %20, ptr %2, align 8, !tbaa !3
  store i64 %10, ptr %3, align 8, !tbaa !3
  %21 = mul nsw i64 %10, %10
  %22 = shl nsw i64 %21, 2
  %23 = call ptr @malloc(i64 %22)
  store ptr %23, ptr @_QFEans.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEans.7, align 8, !tbaa !7
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %34, label %.preheader

.preheader:                                       ; preds = %19
  %.not241 = icmp eq i64 %10, 0
  br i1 %.not241, label %.loopexit235, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %24 = call i64 @llvm.smax.i64(i64 %21, i64 1)
  %min.iters.check = icmp ult i64 %24, 8
  br i1 %min.iters.check, label %.lr.ph.preheader266, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %24, 9223372036854775800
  %ind.end = sub nsw i64 %21, %n.vec
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %25 = getelementptr i32, ptr %23, i64 %index
  store <4 x i32> <i32 2020, i32 2020, i32 2020, i32 2020>, ptr %25, align 4, !tbaa !3
  %26 = getelementptr i32, ptr %25, i64 4
  store <4 x i32> <i32 2020, i32 2020, i32 2020, i32 2020>, ptr %26, align 4, !tbaa !3
  %index.next = add nuw i64 %index, 8
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %24, %n.vec
  br i1 %cmp.n, label %.loopexit235, label %.lr.ph.preheader266

.lr.ph.preheader266:                              ; preds = %.lr.ph.preheader, %middle.block
  %.ph267 = phi i64 [ %21, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.ph268 = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader266, %.lr.ph
  %28 = phi i64 [ %32, %.lr.ph ], [ %.ph267, %.lr.ph.preheader266 ]
  %29 = phi i64 [ %30, %.lr.ph ], [ %.ph268, %.lr.ph.preheader266 ]
  %30 = add nuw nsw i64 %29, 1
  %31 = getelementptr i32, ptr %23, i64 %29
  store i32 2020, ptr %31, align 4, !tbaa !3
  %32 = add nsw i64 %28, -1
  %33 = icmp sgt i64 %28, 1
  br i1 %33, label %.lr.ph, label %.loopexit235, !llvm.loop !12

34:                                               ; preds = %19
  %35 = call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 20)
  %.unpack219.unpack.unpack = load i64, ptr @_QFEans.7, align 8, !tbaa !7
  %36 = icmp eq i64 %10, 0
  %37 = select i1 %36, i64 1, i64 %.unpack219.unpack.unpack
  store i64 %37, ptr @_QFEans.7, align 8, !tbaa !7
  %.pre = load i64, ptr %2, align 8, !tbaa !3
  %.pre242 = load i64, ptr %3, align 8, !tbaa !3
  br label %.loopexit235

.loopexit235:                                     ; preds = %.lr.ph, %middle.block, %.preheader, %34
  %.unpack195.unpack.unpack = phi i64 [ 1, %.preheader ], [ %37, %34 ], [ 1, %middle.block ], [ 1, %.lr.ph ]
  %38 = phi i64 [ 0, %.preheader ], [ %.pre242, %34 ], [ %10, %middle.block ], [ %10, %.lr.ph ]
  %39 = phi i64 [ %20, %.preheader ], [ %.pre, %34 ], [ %20, %middle.block ], [ %20, %.lr.ph ]
  %40 = icmp sgt i64 %38, %39
  br i1 %40, label %41, label %.loopexit

41:                                               ; preds = %.loopexit235
  %42 = sub i64 1, %39
  %43 = add i64 %42, %38
  %44 = icmp sgt i64 %43, 0
  br i1 %44, label %.lr.ph240, label %.loopexit

.lr.ph240:                                        ; preds = %41
  %45 = trunc i64 %39 to i32
  %46 = add i32 %45, 1
  %47 = add i64 %38, 1
  br label %48

48:                                               ; preds = %.lr.ph240, %._crit_edge
  %indvar = phi i32 [ 0, %.lr.ph240 ], [ %indvar.next, %._crit_edge ]
  %49 = phi i64 [ %43, %.lr.ph240 ], [ %84, %._crit_edge ]
  %50 = phi i32 [ %45, %.lr.ph240 ], [ %57, %._crit_edge ]
  %.0238 = phi i32 [ 1, %.lr.ph240 ], [ %.1.lcssa, %._crit_edge ]
  %51 = add i32 %46, %indvar
  %52 = sext i32 %51 to i64
  %53 = sub i64 %47, %52
  %54 = add i32 %46, %indvar
  %55 = sext i32 %54 to i64
  %56 = sub i64 %38, %55
  %57 = add i32 %50, 1
  %58 = sext i32 %57 to i64
  %59 = sub nsw i64 1, %58
  %60 = add i64 %59, %38
  %61 = icmp sgt i64 %60, 0
  br i1 %61, label %.lr.ph237.preheader, label %._crit_edge

.lr.ph237.preheader:                              ; preds = %48
  %min.iters.check248 = icmp ult i64 %53, 4
  br i1 %min.iters.check248, label %.lr.ph237.preheader264, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph237.preheader
  %62 = trunc i64 %56 to i32
  %63 = add i32 %.0238, %62
  %64 = icmp slt i32 %63, %.0238
  %65 = icmp ugt i64 %56, 4294967295
  %66 = or i1 %64, %65
  br i1 %66, label %.lr.ph237.preheader264, label %vector.ph249

vector.ph249:                                     ; preds = %vector.scevcheck
  %n.vec251 = and i64 %53, -4
  %ind.end252 = sub i64 %60, %n.vec251
  %.cast = trunc i64 %n.vec251 to i32
  %ind.end254 = add i32 %57, %.cast
  %.cast256 = trunc i64 %n.vec251 to i32
  %ind.end257 = add i32 %.0238, %.cast256
  %.splatinsert = insertelement <4 x i32> poison, i32 %57, i64 0
  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %induction = add <4 x i32> %.splat, <i32 0, i32 1, i32 2, i32 3>
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %50, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body260

vector.body260:                                   ; preds = %vector.body260, %vector.ph249
  %index261 = phi i64 [ 0, %vector.ph249 ], [ %index.next263, %vector.body260 ]
  %vec.ind = phi <4 x i32> [ %induction, %vector.ph249 ], [ %vec.ind.next, %vector.body260 ]
  %.cast262 = trunc i64 %index261 to i32
  %offset.idx = add i32 %.0238, %.cast262
  %67 = mul <4 x i32> %vec.ind, %broadcast.splat
  %68 = srem <4 x i32> %67, <i32 2019, i32 2019, i32 2019, i32 2019>
  %69 = sext i32 %offset.idx to i64
  %70 = sub i64 %69, %.unpack195.unpack.unpack
  %71 = getelementptr i32, ptr %23, i64 %70
  store <4 x i32> %68, ptr %71, align 4, !tbaa !3
  %index.next263 = add nuw i64 %index261, 4
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %72 = icmp eq i64 %index.next263, %n.vec251
  br i1 %72, label %middle.block246, label %vector.body260, !llvm.loop !13

middle.block246:                                  ; preds = %vector.body260
  %cmp.n259 = icmp eq i64 %53, %n.vec251
  br i1 %cmp.n259, label %._crit_edge, label %.lr.ph237.preheader264

.lr.ph237.preheader264:                           ; preds = %vector.scevcheck, %.lr.ph237.preheader, %middle.block246
  %.ph = phi i64 [ %60, %vector.scevcheck ], [ %60, %.lr.ph237.preheader ], [ %ind.end252, %middle.block246 ]
  %.ph265 = phi i32 [ %57, %vector.scevcheck ], [ %57, %.lr.ph237.preheader ], [ %ind.end254, %middle.block246 ]
  %.1236.ph = phi i32 [ %.0238, %vector.scevcheck ], [ %.0238, %.lr.ph237.preheader ], [ %ind.end257, %middle.block246 ]
  br label %.lr.ph237

.lr.ph237:                                        ; preds = %.lr.ph237.preheader264, %.lr.ph237
  %73 = phi i64 [ %82, %.lr.ph237 ], [ %.ph, %.lr.ph237.preheader264 ]
  %74 = phi i32 [ %81, %.lr.ph237 ], [ %.ph265, %.lr.ph237.preheader264 ]
  %.1236 = phi i32 [ %80, %.lr.ph237 ], [ %.1236.ph, %.lr.ph237.preheader264 ]
  %75 = mul i32 %74, %50
  %76 = srem i32 %75, 2019
  %77 = sext i32 %.1236 to i64
  %78 = sub i64 %77, %.unpack195.unpack.unpack
  %79 = getelementptr i32, ptr %23, i64 %78
  store i32 %76, ptr %79, align 4, !tbaa !3
  %80 = add i32 %.1236, 1
  %81 = add i32 %74, 1
  %82 = add nsw i64 %73, -1
  %83 = icmp ugt i64 %73, 1
  br i1 %83, label %.lr.ph237, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph237, %middle.block246, %48
  %.1.lcssa = phi i32 [ %.0238, %48 ], [ %ind.end257, %middle.block246 ], [ %80, %.lr.ph237 ]
  %84 = add i64 %49, -1
  %85 = icmp sgt i64 %84, 0
  %indvar.next = add i32 %indvar, 1
  br i1 %85, label %48, label %.loopexit

.loopexit:                                        ; preds = %._crit_edge, %41, %.loopexit235
  %86 = icmp eq i64 %39, %38
  br i1 %86, label %87, label %96

87:                                               ; preds = %.loopexit
  %88 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 32)
  %89 = load i64, ptr %2, align 8, !tbaa !3
  %90 = load i64, ptr %3, align 8, !tbaa !3
  %91 = mul i64 %90, %89
  %92 = srem i64 %91, 2019
  %93 = call i1 @_FortranAioOutputInteger64(ptr %88, i64 %92)
  %94 = call i32 @_FortranAioEndIoStatement(ptr %88)
  %95 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

96:                                               ; preds = %.loopexit
  %97 = icmp eq i64 %10, 0
  %98 = select i1 %97, i64 1, i64 %.unpack195.unpack.unpack
  store ptr %23, 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 %98, 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 %21, 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
  %99 = call i32 @_FortranAMinvalInteger4(ptr nonnull %1, ptr nonnull @_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 36, i32 0, ptr null)
  %100 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.8371d0d24fc6c8b0e4a44cdf6a4a70c8, i32 38)
  %101 = call i1 @_FortranAioOutputInteger32(ptr %100, i32 %99)
  %102 = call i32 @_FortranAioEndIoStatement(ptr %100)
  %103 = 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 ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

declare {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
attributes #2 = { 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, !10}
