program ccc
implicit none

integer :: n, k, i, j
integer,allocatable,dimension(:) :: m
real(8) :: res

read*, n, k
allocate(m(n))
m=0

do i=1,n
 j=i
 do while(j<k)
 j=j*2
 m(i)=m(i)+1
 end do
end do

res=0

do i=1,n
res=res+0.5D0**m(i)
end do

res=res*(1/dble(n))

write(*,*) res

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

@_QFEm.0 = internal unnamed_addr global ptr null
@_QFEm.7 = internal unnamed_addr global i64 1
@_QQcl.b8b615fb6c331effe3f4d8afe44863ad = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4284/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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.b8b615fb6c331effe3f4d8afe44863ad, i32 8)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 2
  %11 = call ptr @malloc(i64 %10)
  store ptr %11, ptr @_QFEm.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEm.7, align 8, !tbaa !7
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %.loopexit, label %.preheader196

.preheader196:                                    ; preds = %0
  %.not206 = icmp slt i32 %7, 1
  br i1 %.not206, label %._crit_edge205, label %.loopexit.thread

.loopexit.thread:                                 ; preds = %.preheader196
  %12 = call i64 @llvm.smax.i64(i64 %9, i64 1)
  %13 = shl nuw nsw i64 %12, 2
  call void @llvm.memset.p0.i64(ptr nonnull align 4 %11, i8 0, i64 %13, i1 false), !tbaa !3
  br label %.preheader.lr.ph

.loopexit:                                        ; preds = %0
  %14 = call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.b8b615fb6c331effe3f4d8afe44863ad, i32 10)
  %.unpack182.unpack.unpack = load i64, ptr @_QFEm.7, align 8, !tbaa !7
  %15 = icmp slt i32 %7, 1
  %16 = select i1 %15, i64 1, i64 %.unpack182.unpack.unpack
  store i64 %16, ptr @_QFEm.7, align 8, !tbaa !7
  %.pre = load i32, ptr %2, align 4, !tbaa !3
  %17 = icmp sgt i32 %.pre, 0
  br i1 %17, label %.preheader.lr.ph, label %._crit_edge205

.preheader.lr.ph:                                 ; preds = %.loopexit.thread, %.loopexit
  %18 = phi i32 [ %7, %.loopexit.thread ], [ %.pre, %.loopexit ]
  %.unpack158.unpack.unpack215 = phi i64 [ 1, %.loopexit.thread ], [ %16, %.loopexit ]
  %.pre211 = load i32, ptr %1, align 4, !tbaa !3
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.0139200 = phi i32 [ 1, %.preheader.lr.ph ], [ %28, %._crit_edge ]
  %19 = icmp slt i32 %.0139200, %.pre211
  br i1 %19, label %.lr.ph198, label %._crit_edge

.lr.ph198:                                        ; preds = %.preheader
  %20 = sext i32 %.0139200 to i64
  %21 = sub i64 %20, %.unpack158.unpack.unpack215
  %22 = getelementptr i32, ptr %11, i64 %21
  %.pre212 = load i32, ptr %22, align 4, !tbaa !3
  br label %23

23:                                               ; preds = %.lr.ph198, %23
  %24 = phi i32 [ %.pre212, %.lr.ph198 ], [ %26, %23 ]
  %.0138197 = phi i32 [ %.0139200, %.lr.ph198 ], [ %25, %23 ]
  %25 = shl i32 %.0138197, 1
  %26 = add i32 %24, 1
  %27 = icmp slt i32 %25, %.pre211
  br i1 %27, label %23, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %23
  store i32 %26, ptr %22, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %28 = add nuw i32 %.0139200, 1
  %exitcond.not = icmp eq i32 %.0139200, %18
  br i1 %exitcond.not, label %.lr.ph204, label %.preheader

.lr.ph204:                                        ; preds = %._crit_edge
  %29 = sext i32 %18 to i64
  %30 = add nsw i64 %29, -1
  %xtraiter = and i64 %29, 3
  %31 = icmp ult i64 %30, 3
  br i1 %31, label %._crit_edge205.loopexit.unr-lcssa, label %.lr.ph204.new

.lr.ph204.new:                                    ; preds = %.lr.ph204
  %unroll_iter = and i64 %29, -4
  br label %32

32:                                               ; preds = %32, %.lr.ph204.new
  %indvars.iv = phi i64 [ 1, %.lr.ph204.new ], [ %indvars.iv.next.3, %32 ]
  %.0202 = phi double [ 0.000000e+00, %.lr.ph204.new ], [ %52, %32 ]
  %niter = phi i64 [ 0, %.lr.ph204.new ], [ %niter.next.3, %32 ]
  %33 = sub i64 %indvars.iv, %.unpack158.unpack.unpack215
  %34 = getelementptr i32, ptr %11, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !3
  %36 = call contract double @llvm.powi.f64.i32(double 5.000000e-01, i32 %35)
  %37 = fadd contract double %.0202, %36
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = sub i64 %indvars.iv.next, %.unpack158.unpack.unpack215
  %39 = getelementptr i32, ptr %11, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !3
  %41 = call contract double @llvm.powi.f64.i32(double 5.000000e-01, i32 %40)
  %42 = fadd contract double %37, %41
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %43 = sub i64 %indvars.iv.next.1, %.unpack158.unpack.unpack215
  %44 = getelementptr i32, ptr %11, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !3
  %46 = call contract double @llvm.powi.f64.i32(double 5.000000e-01, i32 %45)
  %47 = fadd contract double %42, %46
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %48 = sub i64 %indvars.iv.next.2, %.unpack158.unpack.unpack215
  %49 = getelementptr i32, ptr %11, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !3
  %51 = call contract double @llvm.powi.f64.i32(double 5.000000e-01, i32 %50)
  %52 = fadd contract double %47, %51
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge205.loopexit.unr-lcssa, label %32

._crit_edge205.loopexit.unr-lcssa:                ; preds = %32, %.lr.ph204
  %.lcssa.ph = phi double [ undef, %.lr.ph204 ], [ %52, %32 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph204 ], [ %indvars.iv.next.3, %32 ]
  %.0202.unr = phi double [ 0.000000e+00, %.lr.ph204 ], [ %52, %32 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge205, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge205.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.epil.preheader ], [ %indvars.iv.unr, %._crit_edge205.loopexit.unr-lcssa ]
  %.0202.epil = phi double [ %57, %.epil.preheader ], [ %.0202.unr, %._crit_edge205.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge205.loopexit.unr-lcssa ]
  %53 = sub i64 %indvars.iv.epil, %.unpack158.unpack.unpack215
  %54 = getelementptr i32, ptr %11, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !3
  %56 = call contract double @llvm.powi.f64.i32(double 5.000000e-01, i32 %55)
  %57 = fadd contract double %.0202.epil, %56
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge205, label %.epil.preheader, !llvm.loop !9

._crit_edge205:                                   ; preds = %._crit_edge205.loopexit.unr-lcssa, %.epil.preheader, %.loopexit, %.preheader196
  %58 = phi i32 [ %7, %.preheader196 ], [ %.pre, %.loopexit ], [ %18, %.epil.preheader ], [ %18, %._crit_edge205.loopexit.unr-lcssa ]
  %.0.lcssa = phi double [ 0.000000e+00, %.preheader196 ], [ 0.000000e+00, %.loopexit ], [ %.lcssa.ph, %._crit_edge205.loopexit.unr-lcssa ], [ %57, %.epil.preheader ]
  %59 = sitofp i32 %58 to double
  %60 = fdiv contract double 1.000000e+00, %59
  %61 = fmul contract double %60, %.0.lcssa
  %62 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.b8b615fb6c331effe3f4d8afe44863ad, i32 28)
  %63 = call i1 @_FortranAioOutputReal64(ptr %62, double %61)
  %64 = call i32 @_FortranAioEndIoStatement(ptr %62)
  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 {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

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

declare i1 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.powi.f64.i32(double, i32) #1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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}
!10 = !{!"llvm.loop.unroll.disable"}
