; LLVM IR from ShahjalalShohag/code-library :: Geometry/Delaunay Triangulation.ll (Z22line_line_intersection3dPTS_S_S_)

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

%struct.dPT = type { double, double }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3dPTC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z22line_line_intersection3dPTS_S_S_(ptr dead_on_unwind noalias writable sret(%struct.dPT) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca %struct.dPT, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca %struct.dPT, align 8
  %19 = alloca double, align 8
  store ptr %0, ptr %6, align 8
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %20 = getelementptr inbounds %struct.dPT, ptr %1, i32 0, i32 1
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.dPT, ptr %2, i32 0, i32 1
  %23 = load double, ptr %22, align 8, !tbaa !9
  %24 = fsub double %21, %23
  store double %24, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %25 = getelementptr inbounds %struct.dPT, ptr %2, i32 0, i32 0
  %26 = load double, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.dPT, ptr %1, i32 0, i32 0
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = fsub double %26, %28
  store double %29, ptr %12, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %30 = call noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef %14)
  store double %30, ptr %13, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %31 = getelementptr inbounds %struct.dPT, ptr %3, i32 0, i32 1
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.dPT, ptr %4, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !9
  %35 = fsub double %32, %34
  store double %35, ptr %15, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %36 = getelementptr inbounds %struct.dPT, ptr %4, i32 0, i32 0
  %37 = load double, ptr %36, align 8, !tbaa !13
  %38 = getelementptr inbounds %struct.dPT, ptr %3, i32 0, i32 0
  %39 = load double, ptr %38, align 8, !tbaa !13
  %40 = fsub double %37, %39
  store double %40, ptr %16, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(16) %4)
  %41 = call noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %18)
  store double %41, ptr %17, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %42 = load double, ptr %11, align 8, !tbaa !12
  %43 = load double, ptr %16, align 8, !tbaa !12
  %44 = load double, ptr %15, align 8, !tbaa !12
  %45 = load double, ptr %12, align 8, !tbaa !12
  %46 = fmul double %44, %45
  %47 = fneg double %46
  %48 = call double @llvm.fmuladd.f64(double %42, double %43, double %47)
  store double %48, ptr %19, align 8, !tbaa !12
  %49 = load double, ptr %12, align 8, !tbaa !12
  %50 = load double, ptr %17, align 8, !tbaa !12
  %51 = load double, ptr %16, align 8, !tbaa !12
  %52 = load double, ptr %13, align 8, !tbaa !12
  %53 = fmul double %51, %52
  %54 = fneg double %53
  %55 = call double @llvm.fmuladd.f64(double %49, double %50, double %54)
  %56 = load double, ptr %19, align 8, !tbaa !12
  %57 = fdiv double %55, %56
  %58 = load double, ptr %13, align 8, !tbaa !12
  %59 = load double, ptr %15, align 8, !tbaa !12
  %60 = load double, ptr %11, align 8, !tbaa !12
  %61 = load double, ptr %17, align 8, !tbaa !12
  %62 = fmul double %60, %61
  %63 = fneg double %62
  %64 = call double @llvm.fmuladd.f64(double %58, double %59, double %63)
  %65 = load double, ptr %19, align 8, !tbaa !12
  %66 = fdiv double %64, %65
  call void @_ZN3dPTC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %57, double noundef %66)
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTS3dPT", !11, i64 0, !11, i64 8}
!11 = !{!"double", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, 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"

%struct.dPT = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3dPTC2Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z22line_line_intersection3dPTS_S_S_(ptr dead_on_unwind noalias writable sret(%struct.dPT) align 8 %0, ptr noundef %1, ptr noundef nonnull %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.dPT, align 8
  %7 = alloca %struct.dPT, align 8
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fsub double %9, %11
  %13 = load double, ptr %2, align 8, !tbaa !10
  %14 = load double, ptr %1, align 8, !tbaa !10
  %15 = fsub double %13, %14
  call void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %16 = call noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull %6)
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %4, i64 8
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fsub double %18, %20
  %22 = load double, ptr %4, align 8, !tbaa !10
  %23 = load double, ptr %3, align 8, !tbaa !10
  %24 = fsub double %22, %23
  call void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %4)
  %25 = call noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull %7)
  %26 = fneg double %21
  %27 = fmul double %15, %26
  %28 = call double @llvm.fmuladd.f64(double %12, double %24, double %27)
  %29 = fneg double %24
  %30 = fmul double %16, %29
  %31 = call double @llvm.fmuladd.f64(double %15, double %25, double %30)
  %32 = fdiv double %31, %28
  %33 = fneg double %12
  %34 = fmul double %25, %33
  %35 = call double @llvm.fmuladd.f64(double %16, double %21, double %34)
  %36 = fdiv double %35, %28
  call void @_ZN3dPTC2Edd(ptr noundef nonnull align 8 dereferenceable(16) %0, double noundef %32, double noundef %36)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3dPT5crossES_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3dPTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 = { 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, !7, i64 8}
!6 = !{!"_ZTS3dPT", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}


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