; LLVM IR from tangjz/acm-icpc :: codeforces (312B)

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

@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@ans = external dso_local global double, align 8
@tmp1 = external dso_local global double, align 8
@tmp2 = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %36, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @b, ptr noundef @c, ptr noundef @d)
  %4 = icmp ne i32 %3, -1
  br i1 %4, label %5, label %39

5:                                                ; preds = %2
  store double 0.000000e+00, ptr @ans, align 8, !tbaa !5
  %6 = load i32, ptr @a, align 4, !tbaa !9
  %7 = sitofp i32 %6 to double
  %8 = load i32, ptr @b, align 4, !tbaa !9
  %9 = sitofp i32 %8 to double
  %10 = fdiv double %7, %9
  store double %10, ptr @tmp1, align 8, !tbaa !5
  %11 = load i32, ptr @b, align 4, !tbaa !9
  %12 = load i32, ptr @a, align 4, !tbaa !9
  %13 = sub nsw i32 %11, %12
  %14 = sitofp i32 %13 to double
  %15 = load i32, ptr @b, align 4, !tbaa !9
  %16 = sitofp i32 %15 to double
  %17 = fdiv double %14, %16
  %18 = load i32, ptr @d, align 4, !tbaa !9
  %19 = load i32, ptr @c, align 4, !tbaa !9
  %20 = sub nsw i32 %18, %19
  %21 = sitofp i32 %20 to double
  %22 = fmul double %17, %21
  %23 = load i32, ptr @d, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %22, %24
  store double %25, ptr @tmp2, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %29, %5
  %27 = load double, ptr @tmp1, align 8, !tbaa !5
  %28 = fcmp ogt double %27, 0x3BC79CA10C924223
  br i1 %28, label %29, label %36

29:                                               ; preds = %26
  %30 = load double, ptr @tmp1, align 8, !tbaa !5
  %31 = load double, ptr @ans, align 8, !tbaa !5
  %32 = fadd double %31, %30
  store double %32, ptr @ans, align 8, !tbaa !5
  %33 = load double, ptr @tmp2, align 8, !tbaa !5
  %34 = load double, ptr @tmp1, align 8, !tbaa !5
  %35 = fmul double %34, %33
  store double %35, ptr @tmp1, align 8, !tbaa !5
  br label %26, !llvm.loop !11

36:                                               ; preds = %26
  %37 = load double, ptr @ans, align 8, !tbaa !5
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %37)
  br label %2, !llvm.loop !13

39:                                               ; preds = %2
  ret i32 0
}

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

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

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global double, align 8
@tmp1 = external dso_local local_unnamed_addr global double, align 8
@tmp2 = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind 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 @a, ptr noundef nonnull @b, ptr noundef nonnull @c, ptr noundef nonnull @d)
  %.not2 = icmp eq i32 %1, -1
  br i1 %.not2, label %._crit_edge5, label %.lr.ph4

.lr.ph4:                                          ; preds = %0, %23
  store double 0.000000e+00, ptr @ans, align 8, !tbaa !5
  %2 = load i32, ptr @a, align 4, !tbaa !9
  %3 = sitofp i32 %2 to double
  %4 = load i32, ptr @b, align 4, !tbaa !9
  %5 = sitofp i32 %4 to double
  %6 = fdiv double %3, %5
  store double %6, ptr @tmp1, align 8, !tbaa !5
  %7 = sub nsw i32 %4, %2
  %8 = sitofp i32 %7 to double
  %9 = fdiv double %8, %5
  %10 = load i32, ptr @d, align 4, !tbaa !9
  %11 = load i32, ptr @c, align 4, !tbaa !9
  %12 = sub nsw i32 %10, %11
  %13 = sitofp i32 %12 to double
  %14 = fmul double %9, %13
  %15 = sitofp i32 %10 to double
  %16 = fdiv double %14, %15
  store double %16, ptr @tmp2, align 8, !tbaa !5
  %17 = fcmp ogt double %6, 0x3BC79CA10C924223
  br i1 %17, label %.lr.ph, label %23

.lr.ph:                                           ; preds = %.lr.ph4, %.lr.ph
  %18 = phi double [ %21, %.lr.ph ], [ %6, %.lr.ph4 ]
  %19 = phi double [ %20, %.lr.ph ], [ 0.000000e+00, %.lr.ph4 ]
  %20 = fadd double %18, %19
  %21 = fmul double %16, %18
  %22 = fcmp ogt double %21, 0x3BC79CA10C924223
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  store double %20, ptr @ans, align 8, !tbaa !5
  store double %21, ptr @tmp1, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %._crit_edge, %.lr.ph4
  %24 = phi double [ %20, %._crit_edge ], [ 0.000000e+00, %.lr.ph4 ]
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %24)
  %26 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b, ptr noundef nonnull @c, ptr noundef nonnull @d)
  %.not = icmp eq i32 %26, -1
  br i1 %.not, label %._crit_edge5, label %.lr.ph4, !llvm.loop !13

._crit_edge5:                                     ; preds = %23, %0
  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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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" }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass