; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/76 Beta Division 1/Problem B (B)

; 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
@w = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca x86_fp80, align 16
  %4 = alloca x86_fp80, align 16
  %5 = alloca x86_fp80, align 16
  %6 = alloca i32, align 4
  %7 = alloca x86_fp80, align 16
  %8 = alloca x86_fp80, align 16
  %9 = alloca x86_fp80, align 16
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @w, ptr noundef @m)
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = load i32, ptr @m, align 4, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %23

14:                                               ; preds = %0
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = sub nsw i32 %16, %17
  %19 = srem i32 %15, %18
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %14
  %22 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  br label %75

23:                                               ; preds = %14, %0
  %24 = call i32 @puts(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #4
  %25 = load i32, ptr @n, align 4, !tbaa !5
  %26 = sitofp i32 %25 to x86_fp80
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = sitofp i32 %27 to x86_fp80
  %29 = fdiv x86_fp80 %26, %28
  store x86_fp80 %29, ptr %3, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  store x86_fp80 0xK3FFF8000000000000000, ptr %4, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  store x86_fp80 0xK3FE189705F4136B4A800, ptr %5, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %71, %23
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %74

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  store x86_fp80 0xK00000000000000000000, ptr %7, align 16, !tbaa !9
  br label %36

36:                                               ; preds = %68, %35
  %37 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %38 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %39 = fsub x86_fp80 %37, %38
  %40 = call noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef %39)
  %41 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %42 = fcmp ogt x86_fp80 %40, %41
  br i1 %42, label %43, label %69

43:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %44 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %45 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %46 = fsub x86_fp80 %44, %45
  store x86_fp80 %46, ptr %9, align 16, !tbaa !9
  %47 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16) %9, ptr noundef nonnull align 16 dereferenceable(16) %4)
  %48 = load x86_fp80, ptr %47, align 16, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  store x86_fp80 %48, ptr %8, align 16, !tbaa !9
  %49 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %50 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %51 = fsub x86_fp80 %50, %49
  store x86_fp80 %51, ptr %4, align 16, !tbaa !9
  %52 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %53 = load x86_fp80, ptr %7, align 16, !tbaa !9
  %54 = fadd x86_fp80 %53, %52
  store x86_fp80 %54, ptr %7, align 16, !tbaa !9
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = load x86_fp80, ptr %8, align 16, !tbaa !9
  %57 = fptrunc x86_fp80 %56 to double
  %58 = load i32, ptr @w, align 4, !tbaa !5
  %59 = sitofp i32 %58 to double
  %60 = fmul double %57, %59
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %55, double noundef %60)
  %62 = load x86_fp80, ptr %4, align 16, !tbaa !9
  %63 = load x86_fp80, ptr %5, align 16, !tbaa !9
  %64 = fcmp olt x86_fp80 %62, %63
  br i1 %64, label %65, label %68

65:                                               ; preds = %43
  store x86_fp80 0xK3FFF8000000000000000, ptr %4, align 16, !tbaa !9
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %2, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %65, %43
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %36, !llvm.loop !11

69:                                               ; preds = %36
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  br label %71

71:                                               ; preds = %69
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %6, align 4, !tbaa !5
  br label %30, !llvm.loop !13

74:                                               ; preds = %34
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %75

75:                                               ; preds = %74, %21
  %76 = load i32, ptr %1, align 4
  ret i32 %76
}

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

declare i32 @puts(ptr noundef) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #3

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

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

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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
@w = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca x86_fp80, align 16
  %2 = alloca x86_fp80, align 16
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @w, ptr noundef nonnull @m)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = icmp slt i32 %4, %5
  br i1 %6, label %7, label %13

7:                                                ; preds = %0
  %8 = sub nsw i32 %4, %5
  %9 = srem i32 %4, %8
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %7
  %12 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %45

13:                                               ; preds = %7, %0
  %14 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = sitofp i32 %15 to x86_fp80
  %17 = load i32, ptr @m, align 4, !tbaa !5
  %18 = sitofp i32 %17 to x86_fp80
  %19 = fdiv x86_fp80 %16, %18
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #4
  store x86_fp80 0xK3FFF8000000000000000, ptr %1, align 16, !tbaa !9
  %.not21 = icmp slt i32 %17, 1
  br i1 %.not21, label %._crit_edge24, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %13
  %20 = fsub x86_fp80 0xK00000000000000000000, %19
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.01523 = phi i32 [ 1, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %.01722 = phi i32 [ 1, %.preheader.lr.ph ], [ %43, %._crit_edge ]
  %21 = call noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef %20)
  %22 = fcmp ogt x86_fp80 %21, 0xK3FE189705F4136B4A800
  br i1 %22, label %.lr.ph, label %._crit_edge

._crit_edge24:                                    ; preds = %._crit_edge, %13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #4
  br label %45

.lr.ph:                                           ; preds = %.preheader, %38
  %.120 = phi i32 [ %.2, %38 ], [ %.01523, %.preheader ]
  %.01619 = phi x86_fp80 [ %28, %38 ], [ 0xK00000000000000000000, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  %23 = fsub x86_fp80 %19, %.01619
  store x86_fp80 %23, ptr %2, align 16, !tbaa !9
  %24 = call noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16) %2, ptr noundef nonnull align 16 dereferenceable(16) %1)
  %25 = load x86_fp80, ptr %24, align 16, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  %26 = load x86_fp80, ptr %1, align 16, !tbaa !9
  %27 = fsub x86_fp80 %26, %25
  store x86_fp80 %27, ptr %1, align 16, !tbaa !9
  %28 = fadd x86_fp80 %.01619, %25
  %29 = fptrunc x86_fp80 %25 to double
  %30 = load i32, ptr @w, align 4, !tbaa !5
  %31 = sitofp i32 %30 to double
  %32 = fmul double %29, %31
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.120, double noundef %32)
  %34 = load x86_fp80, ptr %1, align 16, !tbaa !9
  %35 = fcmp olt x86_fp80 %34, 0xK3FE189705F4136B4A800
  br i1 %35, label %36, label %38

36:                                               ; preds = %.lr.ph
  store x86_fp80 0xK3FFF8000000000000000, ptr %1, align 16, !tbaa !9
  %37 = add nsw i32 %.120, 1
  br label %38

38:                                               ; preds = %36, %.lr.ph
  %.2 = phi i32 [ %37, %36 ], [ %.120, %.lr.ph ]
  %39 = fsub x86_fp80 %28, %19
  %40 = call noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef %39)
  %41 = fcmp ogt x86_fp80 %40, 0xK3FE189705F4136B4A800
  br i1 %41, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %38, %.preheader
  %.1.lcssa = phi i32 [ %.01523, %.preheader ], [ %.2, %38 ]
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %43 = add nuw nsw i32 %.01722, 1
  %44 = load i32, ptr @m, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.01722, %44
  br i1 %.not.not, label %.preheader, label %._crit_edge24, !llvm.loop !13

45:                                               ; preds = %._crit_edge24, %11
  ret i32 0
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZSt3abse(x86_fp80 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(16) ptr @_ZSt3minIeERKT_S2_S2_(ptr noundef nonnull align 16 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) local_unnamed_addr #3

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

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

attributes #0 = { 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 #1 = { 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" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = !{!"long double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass