; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/259 Division 2/Problem C (C)

; 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_istream" = type { ptr, i64, %"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 }

@ans = external dso_local global x86_fp80, align 16
@n = external dso_local global x86_fp80, align 16
@m = external dso_local global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_Z4powwei(x86_fp80 noundef, i32 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 x86_fp80, align 16
  store i32 0, ptr %1, align 4
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) @m)
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 16 dereferenceable(16) @n)
  %5 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %6 = fdiv x86_fp80 0xK3FFF8000000000000000, %5
  %7 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %8 = fptosi x86_fp80 %7 to i32
  %9 = call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %6, i32 noundef %8)
  store x86_fp80 %9, ptr @ans, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #6
  store x86_fp80 0xK40008000000000000000, ptr %2, align 16, !tbaa !5
  br label %10

10:                                               ; preds = %33, %0
  %11 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %12 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %13 = fcmp ole x86_fp80 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #6
  br label %36

15:                                               ; preds = %10
  %16 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %17 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %18 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %19 = fdiv x86_fp80 %17, %18
  %20 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %21 = fptosi x86_fp80 %20 to i32
  %22 = call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %19, i32 noundef %21)
  %23 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %24 = fsub x86_fp80 %23, 0xK3FFF8000000000000000
  %25 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %26 = fdiv x86_fp80 %24, %25
  %27 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %28 = fptosi x86_fp80 %27 to i32
  %29 = call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %26, i32 noundef %28)
  %30 = fsub x86_fp80 %22, %29
  %31 = load x86_fp80, ptr @ans, align 16, !tbaa !5
  %32 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %16, x86_fp80 %30, x86_fp80 %31)
  store x86_fp80 %32, ptr @ans, align 16, !tbaa !5
  br label %33

33:                                               ; preds = %15
  %34 = load x86_fp80, ptr %2, align 16, !tbaa !5
  %35 = fadd x86_fp80 %34, 0xK3FFF8000000000000000
  store x86_fp80 %35, ptr %2, align 16, !tbaa !5
  br label %10, !llvm.loop !9

36:                                               ; preds = %14
  %37 = load x86_fp80, ptr @ans, align 16, !tbaa !5
  %38 = fptrunc x86_fp80 %37 to double
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %38)
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 16 dereferenceable(16)) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #4

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

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { "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 = !{!"long double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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_istream" = type { ptr, i64, %"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 }

@ans = external dso_local local_unnamed_addr global x86_fp80, align 16
@n = external dso_local global x86_fp80, align 16
@m = external dso_local global x86_fp80, align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_Z4powwei(x86_fp80 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 16 dereferenceable(16) @m)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERe(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 16 dereferenceable(16) @n)
  %3 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %4 = fdiv x86_fp80 0xK3FFF8000000000000000, %3
  %5 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %6 = fptosi x86_fp80 %5 to i32
  %7 = tail call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %4, i32 noundef %6)
  store x86_fp80 %7, ptr @ans, align 16, !tbaa !5
  %8 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %9 = fcmp ult x86_fp80 %8, 0xK40008000000000000000
  br i1 %9, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %10 = phi x86_fp80 [ %7, %0 ], [ %26, %.lr.ph ]
  %11 = fptrunc x86_fp80 %10 to double
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %11)
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %13 = phi x86_fp80 [ %28, %.lr.ph ], [ %8, %0 ]
  %.06 = phi x86_fp80 [ %27, %.lr.ph ], [ 0xK40008000000000000000, %0 ]
  %14 = fdiv x86_fp80 %.06, %13
  %15 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %16 = fptosi x86_fp80 %15 to i32
  %17 = tail call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %14, i32 noundef %16)
  %18 = fadd x86_fp80 %.06, 0xKBFFF8000000000000000
  %19 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %20 = fdiv x86_fp80 %18, %19
  %21 = load x86_fp80, ptr @n, align 16, !tbaa !5
  %22 = fptosi x86_fp80 %21 to i32
  %23 = tail call noundef x86_fp80 @_Z4powwei(x86_fp80 noundef %20, i32 noundef %22)
  %24 = fsub x86_fp80 %17, %23
  %25 = load x86_fp80, ptr @ans, align 16, !tbaa !5
  %26 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %.06, x86_fp80 %24, x86_fp80 %25)
  store x86_fp80 %26, ptr @ans, align 16, !tbaa !5
  %27 = fadd x86_fp80 %.06, 0xK3FFF8000000000000000
  %28 = load x86_fp80, ptr @m, align 16, !tbaa !5
  %29 = fcmp ugt x86_fp80 %27, %28
  br i1 %29, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare x86_fp80 @llvm.fmuladd.f80(x86_fp80, x86_fp80, x86_fp80) #3

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

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 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 = { 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"long double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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