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

; 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.LineSegment = type { double, double, i32, double, double, double, double, i32, i32, i32 }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z27ComputeAngleBetweenTwoLinesP11LineSegmentS0_Pd(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.LineSegment, ptr %18, i32 0, i32 5
  %20 = load double, ptr %19, align 8, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.LineSegment, ptr %21, i32 0, i32 3
  %23 = load double, ptr %22, align 8, !tbaa !13
  %24 = fsub double %20, %23
  store double %24, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.LineSegment, ptr %25, i32 0, i32 6
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.LineSegment, ptr %28, i32 0, i32 4
  %30 = load double, ptr %29, align 8, !tbaa !16
  %31 = fsub double %27, %30
  store double %31, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %32 = load double, ptr %7, align 8, !tbaa !14
  %33 = load double, ptr %7, align 8, !tbaa !14
  %34 = load double, ptr %8, align 8, !tbaa !14
  %35 = load double, ptr %8, align 8, !tbaa !14
  %36 = fmul double %34, %35
  %37 = call double @llvm.fmuladd.f64(double %32, double %33, double %36)
  %38 = call double @sqrt(double noundef %37) #4
  store double %38, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LineSegment, ptr %39, i32 0, i32 5
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.LineSegment, ptr %42, i32 0, i32 3
  %44 = load double, ptr %43, align 8, !tbaa !13
  %45 = fsub double %41, %44
  store double %45, ptr %10, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.LineSegment, ptr %46, i32 0, i32 6
  %48 = load double, ptr %47, align 8, !tbaa !15
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.LineSegment, ptr %49, i32 0, i32 4
  %51 = load double, ptr %50, align 8, !tbaa !16
  %52 = fsub double %48, %51
  store double %52, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %53 = load double, ptr %10, align 8, !tbaa !14
  %54 = load double, ptr %10, align 8, !tbaa !14
  %55 = load double, ptr %11, align 8, !tbaa !14
  %56 = load double, ptr %11, align 8, !tbaa !14
  %57 = fmul double %55, %56
  %58 = call double @llvm.fmuladd.f64(double %53, double %54, double %57)
  %59 = call double @sqrt(double noundef %58) #4
  store double %59, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %60 = load double, ptr %7, align 8, !tbaa !14
  %61 = load double, ptr %10, align 8, !tbaa !14
  %62 = load double, ptr %8, align 8, !tbaa !14
  %63 = load double, ptr %11, align 8, !tbaa !14
  %64 = fmul double %62, %63
  %65 = call double @llvm.fmuladd.f64(double %60, double %61, double %64)
  store double %65, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %66 = load double, ptr %13, align 8, !tbaa !14
  %67 = load double, ptr %9, align 8, !tbaa !14
  %68 = load double, ptr %12, align 8, !tbaa !14
  %69 = fmul double %67, %68
  %70 = fdiv double %66, %69
  store double %70, ptr %14, align 8, !tbaa !14
  %71 = load double, ptr %14, align 8, !tbaa !14
  %72 = fcmp olt double %71, -1.000000e+00
  br i1 %72, label %73, label %74

73:                                               ; preds = %3
  store double -1.000000e+00, ptr %14, align 8, !tbaa !14
  br label %79

74:                                               ; preds = %3
  %75 = load double, ptr %14, align 8, !tbaa !14
  %76 = fcmp ogt double %75, 1.000000e+00
  br i1 %76, label %77, label %78

77:                                               ; preds = %74
  store double 1.000000e+00, ptr %14, align 8, !tbaa !14
  br label %78

78:                                               ; preds = %77, %74
  br label %79

79:                                               ; preds = %78, %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %80 = load double, ptr %14, align 8, !tbaa !14
  %81 = call double @acos(double noundef %80) #4
  store double %81, ptr %15, align 8, !tbaa !14
  %82 = load double, ptr %15, align 8, !tbaa !14
  %83 = fdiv double %82, 3.141590e+00
  %84 = fmul double %83, 1.800000e+02
  store double %84, ptr %15, align 8, !tbaa !14
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %110

87:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.LineSegment, ptr %88, i32 0, i32 5
  %90 = load double, ptr %89, align 8, !tbaa !9
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.LineSegment, ptr %91, i32 0, i32 3
  %93 = load double, ptr %92, align 8, !tbaa !13
  %94 = fsub double %90, %93
  store double %94, ptr %16, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.LineSegment, ptr %95, i32 0, i32 6
  %97 = load double, ptr %96, align 8, !tbaa !15
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.LineSegment, ptr %98, i32 0, i32 4
  %100 = load double, ptr %99, align 8, !tbaa !16
  %101 = fsub double %97, %100
  store double %101, ptr %17, align 8, !tbaa !14
  %102 = load double, ptr %16, align 8, !tbaa !14
  %103 = load double, ptr %16, align 8, !tbaa !14
  %104 = load double, ptr %17, align 8, !tbaa !14
  %105 = load double, ptr %17, align 8, !tbaa !14
  %106 = fmul double %104, %105
  %107 = call double @llvm.fmuladd.f64(double %102, double %103, double %106)
  %108 = call double @sqrt(double noundef %107) #4
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  store double %108, ptr %109, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br label %110

110:                                              ; preds = %87, %79
  %111 = load double, ptr %15, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #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
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %111
}

; Function Attrs: nounwind
declare double @acos(double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 40}
!10 = !{!"_ZTS11LineSegment", !11, i64 0, !11, i64 8, !12, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !12, i64 56, !12, i64 60, !12, i64 64}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 24}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 48}
!16 = !{!10, !11, i64 32}


; 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 nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_Z27ComputeAngleBetweenTwoLinesP11LineSegmentS0_Pd(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load double, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load double, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = load double, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %1, i64 40
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %1, i64 48
  %17 = load double, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %1, i64 32
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = insertelement <2 x double> poison, double %5, i64 0
  %21 = insertelement <2 x double> %20, double %13, i64 1
  %22 = insertelement <2 x double> poison, double %7, i64 0
  %23 = insertelement <2 x double> %22, double %15, i64 1
  %24 = fsub <2 x double> %21, %23
  %25 = insertelement <2 x double> poison, double %9, i64 0
  %26 = insertelement <2 x double> %25, double %17, i64 1
  %27 = insertelement <2 x double> poison, double %11, i64 0
  %28 = insertelement <2 x double> %27, double %19, i64 1
  %29 = fsub <2 x double> %26, %28
  %30 = fmul <2 x double> %29, %29
  %31 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %24, <2 x double> %24, <2 x double> %30)
  %32 = tail call <2 x double> @llvm.sqrt.v2f64(<2 x double> %31)
  %shift = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %33 = fmul <2 x double> %29, %shift
  %34 = extractelement <2 x double> %33, i64 0
  %35 = extractelement <2 x double> %24, i64 0
  %36 = extractelement <2 x double> %24, i64 1
  %37 = tail call double @llvm.fmuladd.f64(double %35, double %36, double %34)
  %shift42 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %38 = fmul <2 x double> %32, %shift42
  %39 = extractelement <2 x double> %38, i64 0
  %40 = fdiv double %37, %39
  %41 = fcmp olt double %40, -1.000000e+00
  br i1 %41, label %45, label %42

42:                                               ; preds = %3
  %43 = fcmp ogt double %40, 1.000000e+00
  br i1 %43, label %44, label %45

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %3, %42, %44
  %.0 = phi double [ 1.000000e+00, %44 ], [ %40, %42 ], [ -1.000000e+00, %3 ]
  %46 = tail call double @acos(double noundef %.0) #4
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %56, label %47

47:                                               ; preds = %45
  %48 = load double, ptr %4, align 8, !tbaa !5
  %49 = load double, ptr %14, align 8, !tbaa !11
  %50 = fsub double %48, %49
  %51 = load double, ptr %8, align 8, !tbaa !12
  %52 = load double, ptr %18, align 8, !tbaa !13
  %53 = fsub double %51, %52
  %54 = fmul double %53, %53
  %55 = tail call double @llvm.fmuladd.f64(double %50, double %50, double %54)
  %sqrt41 = tail call double @llvm.sqrt.f64(double %55)
  store double %sqrt41, ptr %2, align 8, !tbaa !14
  br label %56

56:                                               ; preds = %47, %45
  %57 = fdiv double %46, 3.141590e+00
  %58 = fmul double %57, 1.800000e+02
  ret double %58
}

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

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

; 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>) #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 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 = { 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, !7, i64 40}
!6 = !{!"_ZTS11LineSegment", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 48}
!13 = !{!6, !7, i64 32}
!14 = !{!7, !7, i64 0}


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