; LLVM IR from tangjz/acm-icpc :: codeforces/complete (700A)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@v1 = external dso_local global i32, align 4
@v2 = external dso_local global i32, align 4
@kk = external dso_local global i32, align 4
@cs = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3band(double noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m, ptr noundef @v1, ptr noundef @v2, ptr noundef @kk)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sub nsw i32 %7, 1
  %9 = load i32, ptr @kk, align 4, !tbaa !5
  %10 = sdiv i32 %8, %9
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr @cs, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store double 0.000000e+00, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = sitofp i32 %12 to double
  %14 = load i32, ptr @v1, align 4, !tbaa !5
  %15 = sitofp i32 %14 to double
  %16 = fdiv double %13, %15
  store double %16, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %33, %0
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 100
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %36

21:                                               ; preds = %17
  %22 = load double, ptr %2, align 8, !tbaa !9
  %23 = load double, ptr %3, align 8, !tbaa !9
  %24 = fadd double %22, %23
  %25 = fdiv double %24, 2.000000e+00
  store double %25, ptr %4, align 8, !tbaa !9
  %26 = load double, ptr %4, align 8, !tbaa !9
  %27 = call noundef zeroext i1 @_Z3band(double noundef %26)
  br i1 %27, label %28, label %30

28:                                               ; preds = %21
  %29 = load double, ptr %4, align 8, !tbaa !9
  store double %29, ptr %2, align 8, !tbaa !9
  br label %32

30:                                               ; preds = %21
  %31 = load double, ptr %4, align 8, !tbaa !9
  store double %31, ptr %3, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %30, %28
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %5, align 4, !tbaa !5
  br label %17, !llvm.loop !11

36:                                               ; preds = %20
  %37 = load double, ptr %2, align 8, !tbaa !9
  %38 = load double, ptr %3, align 8, !tbaa !9
  %39 = fadd double %37, %38
  %40 = fdiv double %39, 2.000000e+00
  store double %40, ptr %4, align 8, !tbaa !9
  %41 = load double, ptr %4, align 8, !tbaa !9
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %41)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

declare i32 @printf(ptr noundef, ...) #3

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@v1 = external dso_local global i32, align 4
@v2 = external dso_local global i32, align 4
@kk = external dso_local global i32, align 4
@cs = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3band(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @v1, ptr noundef nonnull @v2, ptr noundef nonnull @kk)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  %4 = load i32, ptr @kk, align 4, !tbaa !5
  %5 = sdiv i32 %3, %4
  %6 = add nsw i32 %5, 1
  store i32 %6, ptr @cs, align 4, !tbaa !5
  %7 = load i32, ptr @m, align 4, !tbaa !5
  %8 = sitofp i32 %7 to double
  %9 = load i32, ptr @v1, align 4, !tbaa !5
  %10 = sitofp i32 %9 to double
  %11 = fdiv double %8, %10
  br label %16

12:                                               ; preds = %16
  %13 = fadd double %..010, %.09.
  %14 = fmul double %13, 5.000000e-01
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %14)
  ret i32 0

16:                                               ; preds = %0, %16
  %.014 = phi i32 [ 0, %0 ], [ %20, %16 ]
  %.0913 = phi double [ %11, %0 ], [ %.09., %16 ]
  %.01012 = phi double [ 0.000000e+00, %0 ], [ %..010, %16 ]
  %17 = fadd double %.01012, %.0913
  %18 = fmul double %17, 5.000000e-01
  %19 = tail call noundef zeroext i1 @_Z3band(double noundef %18)
  %..010 = select i1 %19, double %18, double %.01012
  %.09. = select i1 %19, double %.0913, double %18
  %20 = add nuw nsw i32 %.014, 1
  %exitcond.not = icmp eq i32 %20, 100
  br i1 %exitcond.not, label %12, label %16, !llvm.loop !9
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass