module global_variables
end module global_variables
program main
  use global_variables
  implicit none
  integer::i,j,k,n,a,b,res
  read *, n,a,b
  res = 0
  do i=1,n
    j = sum((/(mod(i/(10**k),10),k=0,4)/))
    if (j < a .or. j > b) cycle
    res = res + i
  enddo
  print '(i0)', res
end program main


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

@_QQcl.17b8dfd3eabd08adee8347e8be55c3eb = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6529/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

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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.17b8dfd3eabd08adee8347e8be55c3eb, i32 7)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %1, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %9 = load i32, ptr %3, align 4, !tbaa !3
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %11 = zext i32 %9 to i64
  %12 = load i32, ptr %1, align 4, !tbaa !3
  %13 = load i32, ptr %2, align 4, !tbaa !3
  br label %.lr.ph.i18.preheader

.lr.ph.i18.preheader:                             ; preds = %.lr.ph.preheader, %.lr.ph.i18.preheader
  %14 = phi i64 [ %41, %.lr.ph.i18.preheader ], [ %11, %.lr.ph.preheader ]
  %15 = phi i32 [ %40, %.lr.ph.i18.preheader ], [ 1, %.lr.ph.preheader ]
  %.022 = phi i32 [ %spec.select, %.lr.ph.i18.preheader ], [ 0, %.lr.ph.preheader ]
  %16 = call dereferenceable_or_null(20) ptr @malloc(i64 20)
  %17 = srem i32 %15, 10
  store i32 %17, ptr %16, align 4, !tbaa !3
  %.udiv25 = udiv i32 %15, 10
  %18 = urem i32 %.udiv25, 10
  %19 = getelementptr [5 x i32], ptr %16, i64 0, i64 1
  store i32 %18, ptr %19, align 4, !tbaa !3
  %.udiv26 = udiv i32 %15, 100
  %20 = urem i32 %.udiv26, 10
  %21 = getelementptr [5 x i32], ptr %16, i64 0, i64 2
  store i32 %20, ptr %21, align 4, !tbaa !3
  %.udiv27 = udiv i32 %15, 1000
  %22 = urem i32 %.udiv27, 10
  %23 = getelementptr [5 x i32], ptr %16, i64 0, i64 3
  store i32 %22, ptr %23, align 4, !tbaa !3
  %.udiv28 = udiv i32 %15, 10000
  %24 = urem i32 %.udiv28, 10
  %25 = call dereferenceable_or_null(40) ptr @realloc(ptr nonnull %16, i64 40)
  %26 = load i32, ptr %25, align 4, !tbaa !3
  %27 = getelementptr i32, ptr %25, i64 1
  %28 = load i32, ptr %27, align 4, !tbaa !3
  %29 = getelementptr i32, ptr %25, i64 2
  %30 = load i32, ptr %29, align 4, !tbaa !3
  %31 = getelementptr i32, ptr %25, i64 3
  %32 = load i32, ptr %31, align 4, !tbaa !3
  %33 = add i32 %28, %26
  %34 = add i32 %30, %33
  %35 = add i32 %32, %34
  %36 = add i32 %24, %35
  call void @free(ptr %25)
  %37 = icmp sge i32 %36, %12
  %38 = icmp sle i32 %36, %13
  %.not17 = and i1 %37, %38
  %39 = select i1 %.not17, i32 %15, i32 0
  %spec.select = add i32 %39, %.022
  %40 = add nuw i32 %15, 1
  %41 = add nsw i64 %14, -1
  %42 = icmp ugt i64 %14, 1
  br i1 %42, label %.lr.ph.i18.preheader, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.i18.preheader, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %spec.select, %.lr.ph.i18.preheader ]
  %43 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.17b8dfd3eabd08adee8347e8be55c3eb, i32 14)
  %44 = call i1 @_FortranAioOutputInteger32(ptr %43, i32 %.0.lcssa)
  %45 = call i32 @_FortranAioEndIoStatement(ptr %43)
  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

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture, i64 noundef) local_unnamed_addr #2

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }

!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"}
