; LLVM IR from tangjz/acm-icpc :: codeforces/complete (5D)

; 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 double, align 8
@v = external dso_local global double, align 8
@l = external dso_local global double, align 8
@d = external dso_local global double, align 8
@w = external dso_local global double, align 8
@s1 = external dso_local global double, align 8
@s2 = external dso_local global double, align 8
@ans = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 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
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @v, ptr noundef @l, ptr noundef @d, ptr noundef @w)
  %3 = load double, ptr @v, align 8, !tbaa !5
  %4 = load double, ptr @w, align 8, !tbaa !5
  %5 = fcmp olt double %3, %4
  br i1 %5, label %6, label %8

6:                                                ; preds = %0
  %7 = load double, ptr @v, align 8, !tbaa !5
  store double %7, ptr @w, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %0
  %9 = load double, ptr @v, align 8, !tbaa !5
  %10 = load double, ptr @v, align 8, !tbaa !5
  %11 = fmul double %9, %10
  %12 = load double, ptr @a, align 8, !tbaa !5
  %13 = fdiv double %11, %12
  %14 = fdiv double %13, 2.000000e+00
  store double %14, ptr @s1, align 8, !tbaa !5
  %15 = load double, ptr @w, align 8, !tbaa !5
  %16 = load double, ptr @w, align 8, !tbaa !5
  %17 = fmul double %15, %16
  %18 = load double, ptr @a, align 8, !tbaa !5
  %19 = fdiv double %17, %18
  %20 = fdiv double %19, 2.000000e+00
  store double %20, ptr @s2, align 8, !tbaa !5
  %21 = load double, ptr @d, align 8, !tbaa !5
  %22 = load double, ptr @s2, align 8, !tbaa !5
  %23 = fcmp ole double %21, %22
  br i1 %23, label %24, label %35

24:                                               ; preds = %8
  %25 = load double, ptr @a, align 8, !tbaa !5
  %26 = fmul double 2.000000e+00, %25
  %27 = load double, ptr @d, align 8, !tbaa !5
  %28 = fmul double %26, %27
  %29 = call double @sqrt(double noundef %28) #4
  store double %29, ptr @w, align 8, !tbaa !5
  %30 = load double, ptr @w, align 8, !tbaa !5
  %31 = load double, ptr @a, align 8, !tbaa !5
  %32 = fdiv double %30, %31
  %33 = load double, ptr @ans, align 8, !tbaa !5
  %34 = fadd double %33, %32
  store double %34, ptr @ans, align 8, !tbaa !5
  br label %74

35:                                               ; preds = %8
  %36 = load double, ptr @d, align 8, !tbaa !5
  %37 = load double, ptr @s2, align 8, !tbaa !5
  %38 = fadd double %36, %37
  %39 = load double, ptr @s1, align 8, !tbaa !5
  %40 = fmul double 2.000000e+00, %39
  %41 = fcmp olt double %38, %40
  br i1 %41, label %42, label %56

42:                                               ; preds = %35
  %43 = load double, ptr @a, align 8, !tbaa !5
  %44 = load double, ptr @d, align 8, !tbaa !5
  %45 = load double, ptr @s2, align 8, !tbaa !5
  %46 = fadd double %44, %45
  %47 = fmul double %43, %46
  %48 = call double @sqrt(double noundef %47) #4
  %49 = load double, ptr @w, align 8, !tbaa !5
  %50 = fneg double %49
  %51 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %48, double %50)
  %52 = load double, ptr @a, align 8, !tbaa !5
  %53 = fdiv double %51, %52
  %54 = load double, ptr @ans, align 8, !tbaa !5
  %55 = fadd double %54, %53
  store double %55, ptr @ans, align 8, !tbaa !5
  br label %73

56:                                               ; preds = %35
  %57 = load double, ptr @v, align 8, !tbaa !5
  %58 = load double, ptr @w, align 8, !tbaa !5
  %59 = fneg double %58
  %60 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %57, double %59)
  %61 = load double, ptr @a, align 8, !tbaa !5
  %62 = fdiv double %60, %61
  %63 = load double, ptr @d, align 8, !tbaa !5
  %64 = load double, ptr @s2, align 8, !tbaa !5
  %65 = fadd double %63, %64
  %66 = load double, ptr @s1, align 8, !tbaa !5
  %67 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %66, double %65)
  %68 = load double, ptr @v, align 8, !tbaa !5
  %69 = fdiv double %67, %68
  %70 = fadd double %62, %69
  %71 = load double, ptr @ans, align 8, !tbaa !5
  %72 = fadd double %71, %70
  store double %72, ptr @ans, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %56, %42
  br label %74

74:                                               ; preds = %73, %24
  %75 = load double, ptr @w, align 8, !tbaa !5
  %76 = load double, ptr @w, align 8, !tbaa !5
  %77 = fmul double %75, %76
  %78 = load double, ptr @a, align 8, !tbaa !5
  %79 = fdiv double %77, %78
  %80 = fdiv double %79, 2.000000e+00
  %81 = load double, ptr @s1, align 8, !tbaa !5
  %82 = fsub double %81, %80
  store double %82, ptr @s1, align 8, !tbaa !5
  %83 = load double, ptr @l, align 8, !tbaa !5
  %84 = load double, ptr @d, align 8, !tbaa !5
  %85 = fsub double %83, %84
  %86 = load double, ptr @s1, align 8, !tbaa !5
  %87 = fcmp ogt double %85, %86
  br i1 %87, label %88, label %104

88:                                               ; preds = %74
  %89 = load double, ptr @v, align 8, !tbaa !5
  %90 = load double, ptr @w, align 8, !tbaa !5
  %91 = fsub double %89, %90
  %92 = load double, ptr @a, align 8, !tbaa !5
  %93 = fdiv double %91, %92
  %94 = load double, ptr @l, align 8, !tbaa !5
  %95 = load double, ptr @d, align 8, !tbaa !5
  %96 = fsub double %94, %95
  %97 = load double, ptr @s1, align 8, !tbaa !5
  %98 = fsub double %96, %97
  %99 = load double, ptr @v, align 8, !tbaa !5
  %100 = fdiv double %98, %99
  %101 = fadd double %93, %100
  %102 = load double, ptr @ans, align 8, !tbaa !5
  %103 = fadd double %102, %101
  store double %103, ptr @ans, align 8, !tbaa !5
  br label %121

104:                                              ; preds = %74
  %105 = load double, ptr @a, align 8, !tbaa !5
  %106 = fmul double 2.000000e+00, %105
  %107 = load double, ptr @l, align 8, !tbaa !5
  %108 = load double, ptr @d, align 8, !tbaa !5
  %109 = fsub double %107, %108
  %110 = load double, ptr @w, align 8, !tbaa !5
  %111 = load double, ptr @w, align 8, !tbaa !5
  %112 = fmul double %110, %111
  %113 = call double @llvm.fmuladd.f64(double %106, double %109, double %112)
  %114 = call double @sqrt(double noundef %113) #4
  %115 = load double, ptr @w, align 8, !tbaa !5
  %116 = fsub double %114, %115
  %117 = load double, ptr @a, align 8, !tbaa !5
  %118 = fdiv double %116, %117
  %119 = load double, ptr @ans, align 8, !tbaa !5
  %120 = fadd double %119, %118
  store double %120, ptr @ans, align 8, !tbaa !5
  br label %121

121:                                              ; preds = %104, %88
  %122 = load double, ptr @ans, align 8, !tbaa !5
  %123 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %122)
  ret i32 0
}

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

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

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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; 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 double, align 8
@v = external dso_local global double, align 8
@l = external dso_local global double, align 8
@d = external dso_local global double, align 8
@w = external dso_local global double, align 8
@s1 = external dso_local local_unnamed_addr global double, align 8
@s2 = external dso_local local_unnamed_addr global double, align 8
@ans = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 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 @v, ptr noundef nonnull @l, ptr noundef nonnull @d, ptr noundef nonnull @w)
  %2 = load double, ptr @v, align 8, !tbaa !5
  %3 = load double, ptr @w, align 8, !tbaa !5
  %4 = fcmp olt double %2, %3
  br i1 %4, label %5, label %6

5:                                                ; preds = %0
  store double %2, ptr @w, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %5, %0
  %7 = phi double [ %2, %5 ], [ %3, %0 ]
  %8 = insertelement <2 x double> poison, double %2, i64 1
  %9 = insertelement <2 x double> %8, double %7, i64 0
  %10 = fmul <2 x double> %9, %9
  %11 = load double, ptr @a, align 8, !tbaa !5
  %12 = insertelement <2 x double> poison, double %11, i64 0
  %13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
  %14 = fdiv <2 x double> %10, %13
  %15 = fmul <2 x double> %14, <double 5.000000e-01, double 5.000000e-01>
  %16 = extractelement <2 x double> %15, i64 1
  store double %16, ptr @s1, align 8, !tbaa !5
  %17 = extractelement <2 x double> %15, i64 0
  store double %17, ptr @s2, align 8, !tbaa !5
  %18 = load double, ptr @d, align 8, !tbaa !5
  %19 = fcmp ugt double %18, %17
  br i1 %19, label %28, label %20

20:                                               ; preds = %6
  %21 = fmul double %11, 2.000000e+00
  %22 = fmul double %21, %18
  %23 = tail call double @sqrt(double noundef %22) #5
  store double %23, ptr @w, align 8, !tbaa !5
  %24 = load double, ptr @a, align 8, !tbaa !5
  %25 = fdiv double %23, %24
  %26 = load double, ptr @ans, align 8, !tbaa !5
  %27 = fadd double %26, %25
  br label %57

28:                                               ; preds = %6
  %29 = insertelement <2 x double> poison, double %18, i64 0
  %30 = fadd <2 x double> %29, %15
  %31 = extractelement <2 x double> %30, i64 0
  %32 = extractelement <2 x double> %15, i64 1
  %33 = fmul double %32, 2.000000e+00
  %34 = fcmp olt double %31, %33
  br i1 %34, label %35, label %45

35:                                               ; preds = %28
  %36 = fmul double %11, %31
  %37 = tail call double @sqrt(double noundef %36) #5
  %38 = load double, ptr @w, align 8, !tbaa !5
  %39 = fneg double %38
  %40 = tail call double @llvm.fmuladd.f64(double %37, double 2.000000e+00, double %39)
  %41 = load double, ptr @a, align 8, !tbaa !5
  %42 = fdiv double %40, %41
  %43 = load double, ptr @ans, align 8, !tbaa !5
  %44 = fadd double %43, %42
  br label %57

45:                                               ; preds = %28
  %46 = fneg double %7
  %47 = insertelement <2 x double> %15, double %2, i64 0
  %48 = insertelement <2 x double> poison, double %46, i64 0
  %49 = shufflevector <2 x double> %48, <2 x double> %30, <2 x i32> <i32 0, i32 2>
  %50 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %47, <2 x double> <double 2.000000e+00, double -2.000000e+00>, <2 x double> %49)
  %51 = insertelement <2 x double> %8, double %11, i64 0
  %52 = fdiv <2 x double> %50, %51
  %shift = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %53 = fadd <2 x double> %52, %shift
  %54 = extractelement <2 x double> %53, i64 0
  %55 = load double, ptr @ans, align 8, !tbaa !5
  %56 = fadd double %54, %55
  br label %57

57:                                               ; preds = %35, %45, %20
  %.sink = phi double [ %44, %35 ], [ %56, %45 ], [ %27, %20 ]
  %58 = phi double [ %41, %35 ], [ %11, %45 ], [ %24, %20 ]
  %59 = phi double [ %38, %35 ], [ %7, %45 ], [ %23, %20 ]
  store double %.sink, ptr @ans, align 8, !tbaa !5
  %60 = fmul double %59, %59
  %61 = fdiv double %60, %58
  %62 = fmul double %61, 5.000000e-01
  %63 = load double, ptr @s1, align 8, !tbaa !5
  %64 = fsub double %63, %62
  store double %64, ptr @s1, align 8, !tbaa !5
  %65 = load double, ptr @l, align 8, !tbaa !5
  %66 = load double, ptr @d, align 8, !tbaa !5
  %67 = fsub double %65, %66
  %68 = fcmp ogt double %67, %64
  br i1 %68, label %69, label %82

69:                                               ; preds = %57
  %70 = load double, ptr @v, align 8, !tbaa !5
  %71 = insertelement <2 x double> poison, double %67, i64 0
  %72 = insertelement <2 x double> %71, double %70, i64 1
  %73 = insertelement <2 x double> poison, double %64, i64 0
  %74 = insertelement <2 x double> %73, double %59, i64 1
  %75 = fsub <2 x double> %72, %74
  %76 = insertelement <2 x double> poison, double %70, i64 0
  %77 = insertelement <2 x double> %76, double %58, i64 1
  %78 = fdiv <2 x double> %75, %77
  %shift8 = shufflevector <2 x double> %78, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %79 = fadd <2 x double> %78, %shift8
  %80 = extractelement <2 x double> %79, i64 0
  %81 = fadd double %.sink, %80
  br label %92

82:                                               ; preds = %57
  %83 = fmul double %58, 2.000000e+00
  %84 = tail call double @llvm.fmuladd.f64(double %83, double %67, double %60)
  %85 = tail call double @sqrt(double noundef %84) #5
  %86 = load double, ptr @w, align 8, !tbaa !5
  %87 = fsub double %85, %86
  %88 = load double, ptr @a, align 8, !tbaa !5
  %89 = fdiv double %87, %88
  %90 = load double, ptr @ans, align 8, !tbaa !5
  %91 = fadd double %90, %89
  br label %92

92:                                               ; preds = %82, %69
  %storemerge = phi double [ %91, %82 ], [ %81, %69 ]
  store double %storemerge, ptr @ans, align 8, !tbaa !5
  %93 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %storemerge)
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #2

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

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" }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass