; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/172 Division 2/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"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@tmp = external dso_local global double, align 8
@f1 = external dso_local global double, align 8
@f2 = external dso_local global double, align 8
@f3 = external dso_local global double, align 8
@mn = external dso_local global double, align 8
@eps = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = 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
  store i32 0, ptr %1, align 4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x, ptr noundef @y, ptr noundef @n)
  %4 = load i32, ptr @x, align 4, !tbaa !5
  %5 = sitofp i32 %4 to double
  %6 = load i32, ptr @y, align 4, !tbaa !5
  %7 = sitofp i32 %6 to double
  %8 = fdiv double %5, %7
  store double %8, ptr @f1, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %86, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = icmp sle i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %89

14:                                               ; preds = %9
  %15 = load i32, ptr @x, align 4, !tbaa !5
  %16 = sitofp i32 %15 to double
  %17 = load i32, ptr @y, align 4, !tbaa !5
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %16, %18
  store double %19, ptr @tmp, align 8, !tbaa !9
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sitofp i32 %20 to double
  %22 = load double, ptr @tmp, align 8, !tbaa !9
  %23 = fmul double %22, %21
  store double %23, ptr @tmp, align 8, !tbaa !9
  %24 = load double, ptr @tmp, align 8, !tbaa !9
  %25 = call double @llvm.ceil.f64(double %24)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sitofp i32 %26 to double
  %28 = fdiv double %25, %27
  store double %28, ptr @f2, align 8, !tbaa !9
  %29 = load double, ptr @tmp, align 8, !tbaa !9
  %30 = call double @llvm.floor.f64(double %29)
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fdiv double %30, %32
  store double %33, ptr @f3, align 8, !tbaa !9
  %34 = load double, ptr @f1, align 8, !tbaa !9
  %35 = load double, ptr @f3, align 8, !tbaa !9
  %36 = fsub double %34, %35
  %37 = call double @llvm.fabs.f64(double %36)
  %38 = load double, ptr @mn, align 8, !tbaa !9
  %39 = fcmp olt double %37, %38
  br i1 %39, label %40, label %59

40:                                               ; preds = %14
  %41 = load double, ptr @f1, align 8, !tbaa !9
  %42 = load double, ptr @f3, align 8, !tbaa !9
  %43 = fsub double %41, %42
  %44 = call double @llvm.fabs.f64(double %43)
  %45 = load double, ptr @mn, align 8, !tbaa !9
  %46 = fsub double %44, %45
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = load double, ptr @eps, align 8, !tbaa !9
  %49 = fcmp ogt double %47, %48
  br i1 %49, label %50, label %59

50:                                               ; preds = %40
  %51 = load double, ptr @f1, align 8, !tbaa !9
  %52 = load double, ptr @f3, align 8, !tbaa !9
  %53 = fsub double %51, %52
  %54 = call double @llvm.fabs.f64(double %53)
  store double %54, ptr @mn, align 8, !tbaa !9
  %55 = load double, ptr @tmp, align 8, !tbaa !9
  %56 = call double @llvm.floor.f64(double %55)
  %57 = fptosi double %56 to i32
  store i32 %57, ptr @a, align 4, !tbaa !5
  %58 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %58, ptr @b, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %50, %40, %14
  %60 = load double, ptr @f1, align 8, !tbaa !9
  %61 = load double, ptr @f2, align 8, !tbaa !9
  %62 = fsub double %60, %61
  %63 = call double @llvm.fabs.f64(double %62)
  %64 = load double, ptr @mn, align 8, !tbaa !9
  %65 = fcmp olt double %63, %64
  br i1 %65, label %66, label %85

66:                                               ; preds = %59
  %67 = load double, ptr @f1, align 8, !tbaa !9
  %68 = load double, ptr @f2, align 8, !tbaa !9
  %69 = fsub double %67, %68
  %70 = call double @llvm.fabs.f64(double %69)
  %71 = load double, ptr @mn, align 8, !tbaa !9
  %72 = fsub double %70, %71
  %73 = call double @llvm.fabs.f64(double %72)
  %74 = load double, ptr @eps, align 8, !tbaa !9
  %75 = fcmp ogt double %73, %74
  br i1 %75, label %76, label %85

76:                                               ; preds = %66
  %77 = load double, ptr @f1, align 8, !tbaa !9
  %78 = load double, ptr @f2, align 8, !tbaa !9
  %79 = fsub double %77, %78
  %80 = call double @llvm.fabs.f64(double %79)
  store double %80, ptr @mn, align 8, !tbaa !9
  %81 = load double, ptr @tmp, align 8, !tbaa !9
  %82 = call double @llvm.ceil.f64(double %81)
  %83 = fptosi double %82 to i32
  store i32 %83, ptr @a, align 4, !tbaa !5
  %84 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %84, ptr @b, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %76, %66, %59
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !11

89:                                               ; preds = %13
  %90 = load i32, ptr @a, align 4, !tbaa !5
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %90)
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %91, ptr noundef @.str.1)
  %93 = load i32, ptr @b, align 4, !tbaa !5
  %94 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %92, i32 noundef %93)
  %95 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %94, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare i32 @__isoc99_scanf(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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint mustprogress 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 #5 = { mustprogress 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 #6 = { 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"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@a = external dso_local local_unnamed_addr global i32, align 4
@b = external dso_local local_unnamed_addr global i32, align 4
@tmp = external dso_local local_unnamed_addr global double, align 8
@f1 = external dso_local local_unnamed_addr global double, align 8
@f2 = external dso_local local_unnamed_addr global double, align 8
@f3 = external dso_local local_unnamed_addr global double, align 8
@mn = external dso_local local_unnamed_addr global double, align 8
@eps = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x, ptr noundef nonnull @y, ptr noundef nonnull @n)
  %2 = load i32, ptr @x, align 4, !tbaa !5
  %3 = sitofp i32 %2 to double
  %4 = load i32, ptr @y, align 4, !tbaa !5
  %5 = sitofp i32 %4 to double
  %6 = fdiv double %3, %5
  store double %6, ptr @f1, align 8, !tbaa !9
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %.not11 = icmp slt i32 %7, 1
  br i1 %.not11, label %9, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %mn.promoted = load double, ptr @mn, align 8, !tbaa !9
  %8 = load double, ptr @eps, align 8
  br label %16

._crit_edge:                                      ; preds = %44
  store double %19, ptr @tmp, align 8, !tbaa !9
  store double %21, ptr @f2, align 8, !tbaa !9
  store double %23, ptr @f3, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %._crit_edge, %0
  %10 = load i32, ptr @a, align 4, !tbaa !5
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %10)
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull @.str.1)
  %13 = load i32, ptr @b, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef %13)
  %15 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

16:                                               ; preds = %.lr.ph, %44
  %.012 = phi i32 [ 1, %.lr.ph ], [ %46, %44 ]
  %17 = phi double [ %mn.promoted, %.lr.ph ], [ %45, %44 ]
  %18 = uitofp nneg i32 %.012 to double
  %19 = fmul double %6, %18
  %20 = tail call double @llvm.ceil.f64(double %19)
  %21 = fdiv double %20, %18
  %22 = tail call double @llvm.floor.f64(double %19)
  %23 = fdiv double %22, %18
  %24 = fsub double %6, %23
  %25 = tail call double @llvm.fabs.f64(double %24)
  %26 = fcmp olt double %25, %17
  br i1 %26, label %27, label %33

27:                                               ; preds = %16
  %28 = fsub double %25, %17
  %29 = tail call double @llvm.fabs.f64(double %28)
  %30 = fcmp ogt double %29, %8
  br i1 %30, label %31, label %33

31:                                               ; preds = %27
  store double %25, ptr @mn, align 8, !tbaa !9
  %32 = fptosi double %22 to i32
  store i32 %32, ptr @a, align 4, !tbaa !5
  store i32 %.012, ptr @b, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %31, %27, %16
  %34 = phi double [ %25, %31 ], [ %17, %27 ], [ %17, %16 ]
  %35 = fsub double %6, %21
  %36 = tail call double @llvm.fabs.f64(double %35)
  %37 = fcmp olt double %36, %34
  br i1 %37, label %38, label %44

38:                                               ; preds = %33
  %39 = fsub double %36, %34
  %40 = tail call double @llvm.fabs.f64(double %39)
  %41 = fcmp ogt double %40, %8
  br i1 %41, label %42, label %44

42:                                               ; preds = %38
  store double %36, ptr @mn, align 8, !tbaa !9
  %43 = fptosi double %20 to i32
  store i32 %43, ptr @a, align 4, !tbaa !5
  store i32 %.012, ptr @b, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %33, %38, %42
  %45 = phi double [ %34, %33 ], [ %34, %38 ], [ %36, %42 ]
  %46 = add nuw i32 %.012, 1
  %exitcond.not = icmp eq i32 %.012, %7
  br i1 %exitcond.not, label %._crit_edge, label %16, !llvm.loop !11
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.ceil.f64(double) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { 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 speculatable willreturn memory(none) }
attributes #3 = { inlinehint mustprogress 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 = { "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 #5 = { mustprogress 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" }

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


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