; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/339 Division 1/Problem A/A.ll (Z4distdddd)

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

@eps = external dso_local global double, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z4distdddd(double noundef %0, double noundef %1, double noundef %2, double noundef %3) #0 {
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store double %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !5
  store double %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %14 = load double, ptr %8, align 8, !tbaa !5
  %15 = load double, ptr %6, align 8, !tbaa !5
  %16 = fsub double %14, %15
  %17 = load double, ptr %8, align 8, !tbaa !5
  %18 = load double, ptr %6, align 8, !tbaa !5
  %19 = fsub double %17, %18
  %20 = load double, ptr %9, align 8, !tbaa !5
  %21 = load double, ptr %7, align 8, !tbaa !5
  %22 = fsub double %20, %21
  %23 = load double, ptr %9, align 8, !tbaa !5
  %24 = load double, ptr %7, align 8, !tbaa !5
  %25 = fsub double %23, %24
  %26 = fmul double %22, %25
  %27 = call double @llvm.fmuladd.f64(double %16, double %19, double %26)
  store double %27, ptr %10, align 8, !tbaa !5
  %28 = load double, ptr %10, align 8, !tbaa !5
  %29 = call double @llvm.fabs.f64(double %28)
  %30 = load double, ptr @eps, align 8, !tbaa !5
  %31 = fcmp olt double %29, %30
  br i1 %31, label %32, label %39

32:                                               ; preds = %4
  %33 = load double, ptr %6, align 8, !tbaa !5
  %34 = load double, ptr %6, align 8, !tbaa !5
  %35 = load double, ptr %7, align 8, !tbaa !5
  %36 = load double, ptr %7, align 8, !tbaa !5
  %37 = fmul double %35, %36
  %38 = call double @llvm.fmuladd.f64(double %33, double %34, double %37)
  store double %38, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %92

39:                                               ; preds = %4
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = fneg double %40
  %42 = load double, ptr %8, align 8, !tbaa !5
  %43 = load double, ptr %6, align 8, !tbaa !5
  %44 = fsub double %42, %43
  %45 = load double, ptr %7, align 8, !tbaa !5
  %46 = load double, ptr %9, align 8, !tbaa !5
  %47 = load double, ptr %7, align 8, !tbaa !5
  %48 = fsub double %46, %47
  %49 = fmul double %45, %48
  %50 = fneg double %49
  %51 = call double @llvm.fmuladd.f64(double %41, double %44, double %50)
  %52 = load double, ptr %10, align 8, !tbaa !5
  %53 = fdiv double %51, %52
  store double %53, ptr %10, align 8, !tbaa !5
  %54 = load double, ptr %10, align 8, !tbaa !5
  %55 = fcmp olt double %54, 0.000000e+00
  br i1 %55, label %56, label %63

56:                                               ; preds = %39
  %57 = load double, ptr %6, align 8, !tbaa !5
  %58 = load double, ptr %6, align 8, !tbaa !5
  %59 = load double, ptr %7, align 8, !tbaa !5
  %60 = load double, ptr %7, align 8, !tbaa !5
  %61 = fmul double %59, %60
  %62 = call double @llvm.fmuladd.f64(double %57, double %58, double %61)
  store double %62, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %92

63:                                               ; preds = %39
  %64 = load double, ptr %10, align 8, !tbaa !5
  %65 = fcmp ogt double %64, 1.000000e+00
  br i1 %65, label %66, label %73

66:                                               ; preds = %63
  %67 = load double, ptr %8, align 8, !tbaa !5
  %68 = load double, ptr %8, align 8, !tbaa !5
  %69 = load double, ptr %9, align 8, !tbaa !5
  %70 = load double, ptr %9, align 8, !tbaa !5
  %71 = fmul double %69, %70
  %72 = call double @llvm.fmuladd.f64(double %67, double %68, double %71)
  store double %72, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %92

73:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %74 = load double, ptr %6, align 8, !tbaa !5
  %75 = load double, ptr %8, align 8, !tbaa !5
  %76 = load double, ptr %6, align 8, !tbaa !5
  %77 = fsub double %75, %76
  %78 = load double, ptr %10, align 8, !tbaa !5
  %79 = call double @llvm.fmuladd.f64(double %77, double %78, double %74)
  store double %79, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %80 = load double, ptr %7, align 8, !tbaa !5
  %81 = load double, ptr %9, align 8, !tbaa !5
  %82 = load double, ptr %7, align 8, !tbaa !5
  %83 = fsub double %81, %82
  %84 = load double, ptr %10, align 8, !tbaa !5
  %85 = call double @llvm.fmuladd.f64(double %83, double %84, double %80)
  store double %85, ptr %13, align 8, !tbaa !5
  %86 = load double, ptr %12, align 8, !tbaa !5
  %87 = load double, ptr %12, align 8, !tbaa !5
  %88 = load double, ptr %13, align 8, !tbaa !5
  %89 = load double, ptr %13, align 8, !tbaa !5
  %90 = fmul double %88, %89
  %91 = call double @llvm.fmuladd.f64(double %86, double %87, double %90)
  store double %91, ptr %5, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %92

92:                                               ; preds = %73, %66, %56, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %93 = load double, ptr %5, align 8
  ret double %93
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

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

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

@eps = external dso_local local_unnamed_addr global double, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef double @_Z4distdddd(double noundef %0, double noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #0 {
  %5 = fsub double %2, %0
  %6 = fsub double %3, %1
  %7 = fmul double %6, %6
  %8 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %7)
  %9 = tail call double @llvm.fabs.f64(double %8)
  %10 = load double, ptr @eps, align 8, !tbaa !5
  %11 = fcmp olt double %9, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %4
  %13 = fmul double %1, %1
  %14 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %13)
  br label %35

15:                                               ; preds = %4
  %16 = fneg double %0
  %17 = fneg double %6
  %18 = fmul double %17, %1
  %19 = tail call double @llvm.fmuladd.f64(double %16, double %5, double %18)
  %20 = fdiv double %19, %8
  %21 = fcmp olt double %20, 0.000000e+00
  br i1 %21, label %22, label %25

22:                                               ; preds = %15
  %23 = fmul double %1, %1
  %24 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %23)
  br label %35

25:                                               ; preds = %15
  %26 = fcmp ogt double %20, 1.000000e+00
  br i1 %26, label %27, label %30

27:                                               ; preds = %25
  %28 = fmul double %3, %3
  %29 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %28)
  br label %35

30:                                               ; preds = %25
  %31 = tail call double @llvm.fmuladd.f64(double %5, double %20, double %0)
  %32 = tail call double @llvm.fmuladd.f64(double %6, double %20, double %1)
  %33 = fmul double %32, %32
  %34 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %33)
  br label %35

35:                                               ; preds = %30, %27, %22, %12
  %.0 = phi double [ %14, %12 ], [ %24, %22 ], [ %29, %27 ], [ %34, %30 ]
  ret double %.0
}

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

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass