; LLVM IR from bbenligiray/stag :: src/ED/LineSegment.ll (Z11ComputeLineddddPdS_Pi)

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

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

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

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

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

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

28:                                               ; preds = %7
  %29 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %29, align 4, !tbaa !11
  %30 = load double, ptr %16, align 8, !tbaa !5
  %31 = call double @llvm.fabs.f64(double %30)
  %32 = fcmp olt double %31, 1.000000e-03
  br i1 %32, label %33, label %40

33:                                               ; preds = %28
  %34 = load ptr, ptr %13, align 8, !tbaa !9
  store double 0.000000e+00, ptr %34, align 8, !tbaa !5
  %35 = load double, ptr %9, align 8, !tbaa !5
  %36 = load double, ptr %11, align 8, !tbaa !5
  %37 = fadd double %35, %36
  %38 = fdiv double %37, 2.000000e+00
  %39 = load ptr, ptr %12, align 8, !tbaa !9
  store double %38, ptr %39, align 8, !tbaa !5
  br label %52

40:                                               ; preds = %28
  %41 = load double, ptr %16, align 8, !tbaa !5
  %42 = load double, ptr %15, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  %44 = load ptr, ptr %13, align 8, !tbaa !9
  store double %43, ptr %44, align 8, !tbaa !5
  %45 = load double, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %13, align 8, !tbaa !9
  %47 = load double, ptr %46, align 8, !tbaa !5
  %48 = load double, ptr %8, align 8, !tbaa !5
  %49 = fneg double %47
  %50 = call double @llvm.fmuladd.f64(double %49, double %48, double %45)
  %51 = load ptr, ptr %12, align 8, !tbaa !9
  store double %50, ptr %51, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %40, %33
  br label %78

53:                                               ; preds = %7
  %54 = load ptr, ptr %14, align 8, !tbaa !9
  store i32 1, ptr %54, align 4, !tbaa !11
  %55 = load double, ptr %15, align 8, !tbaa !5
  %56 = call double @llvm.fabs.f64(double %55)
  %57 = fcmp olt double %56, 1.000000e-03
  br i1 %57, label %58, label %65

58:                                               ; preds = %53
  %59 = load ptr, ptr %13, align 8, !tbaa !9
  store double 0.000000e+00, ptr %59, align 8, !tbaa !5
  %60 = load double, ptr %8, align 8, !tbaa !5
  %61 = load double, ptr %10, align 8, !tbaa !5
  %62 = fadd double %60, %61
  %63 = fdiv double %62, 2.000000e+00
  %64 = load ptr, ptr %12, align 8, !tbaa !9
  store double %63, ptr %64, align 8, !tbaa !5
  br label %77

65:                                               ; preds = %53
  %66 = load double, ptr %15, align 8, !tbaa !5
  %67 = load double, ptr %16, align 8, !tbaa !5
  %68 = fdiv double %66, %67
  %69 = load ptr, ptr %13, align 8, !tbaa !9
  store double %68, ptr %69, align 8, !tbaa !5
  %70 = load double, ptr %8, align 8, !tbaa !5
  %71 = load ptr, ptr %13, align 8, !tbaa !9
  %72 = load double, ptr %71, align 8, !tbaa !5
  %73 = load double, ptr %9, align 8, !tbaa !5
  %74 = fneg double %72
  %75 = call double @llvm.fmuladd.f64(double %74, double %73, double %70)
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  store double %75, ptr %76, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %65, %58
  br label %78

78:                                               ; preds = %77, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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

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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_Z11ComputeLineddddPdS_Pi(double noundef %0, double noundef %1, double noundef %2, double noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #1 {
  %8 = fsub double %2, %0
  %9 = fsub double %3, %1
  %10 = tail call double @llvm.fabs.f64(double %8)
  %11 = tail call double @llvm.fabs.f64(double %9)
  %12 = fcmp ult double %10, %11
  br i1 %12, label %22, label %13

13:                                               ; preds = %7
  store i32 0, ptr %6, align 4, !tbaa !5
  %14 = fcmp olt double %11, 1.000000e-03
  br i1 %14, label %15, label %18

15:                                               ; preds = %13
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  %16 = fadd double %1, %3
  %17 = fmul double %16, 5.000000e-01
  br label %31

18:                                               ; preds = %13
  %19 = fdiv double %9, %8
  store double %19, ptr %5, align 8, !tbaa !9
  %20 = fneg double %19
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %0, double %1)
  br label %31

22:                                               ; preds = %7
  store i32 1, ptr %6, align 4, !tbaa !5
  %23 = fcmp olt double %10, 1.000000e-03
  br i1 %23, label %24, label %27

24:                                               ; preds = %22
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  %25 = fadd double %0, %2
  %26 = fmul double %25, 5.000000e-01
  br label %31

27:                                               ; preds = %22
  %28 = fdiv double %8, %9
  store double %28, ptr %5, align 8, !tbaa !9
  %29 = fneg double %28
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %1, double %0)
  br label %31

31:                                               ; preds = %24, %27, %15, %18
  %.sink = phi double [ %26, %24 ], [ %30, %27 ], [ %17, %15 ], [ %21, %18 ]
  store double %.sink, ptr %4, align 8, !tbaa !9
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass