; LLVM IR from NishkarshRaj/Computer-Graphics :: Logistics/Clipping Algorithms/Sutherland Hodgeman (Sutherland_Net)

; 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.point2D = type { float, float }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @_Z12intersection7point2DS_S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) #1 {
  %5 = alloca %struct.point2D, align 4
  %6 = alloca %struct.point2D, align 4
  %7 = alloca %struct.point2D, align 4
  %8 = alloca %struct.point2D, align 4
  %9 = alloca %struct.point2D, align 4
  %10 = alloca %struct.point2D, align 4
  %11 = alloca %struct.point2D, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  store <2 x float> %0, ptr %6, align 4
  store <2 x float> %1, ptr %7, align 4
  store <2 x float> %2, ptr %8, align 4
  store <2 x float> %3, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %15 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 0
  %16 = getelementptr inbounds %struct.point2D, ptr %6, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = getelementptr inbounds %struct.point2D, ptr %7, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fsub float %17, %19
  store float %20, ptr %15, align 4, !tbaa !5
  %21 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 1
  %22 = getelementptr inbounds %struct.point2D, ptr %6, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !10
  %24 = getelementptr inbounds %struct.point2D, ptr %7, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !10
  %26 = fsub float %23, %25
  store float %26, ptr %21, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %27 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 0
  %28 = getelementptr inbounds %struct.point2D, ptr %8, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = getelementptr inbounds %struct.point2D, ptr %9, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = fsub float %29, %31
  store float %32, ptr %27, align 4, !tbaa !5
  %33 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 1
  %34 = getelementptr inbounds %struct.point2D, ptr %8, i32 0, i32 1
  %35 = load float, ptr %34, align 4, !tbaa !10
  %36 = getelementptr inbounds %struct.point2D, ptr %9, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !10
  %38 = fsub float %35, %37
  store float %38, ptr %33, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %39 = getelementptr inbounds %struct.point2D, ptr %6, i32 0, i32 0
  %40 = load float, ptr %39, align 4, !tbaa !5
  %41 = getelementptr inbounds %struct.point2D, ptr %7, i32 0, i32 1
  %42 = load float, ptr %41, align 4, !tbaa !10
  %43 = getelementptr inbounds %struct.point2D, ptr %6, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !10
  %45 = getelementptr inbounds %struct.point2D, ptr %7, i32 0, i32 0
  %46 = load float, ptr %45, align 4, !tbaa !5
  %47 = fmul float %44, %46
  %48 = fneg float %47
  %49 = call float @llvm.fmuladd.f32(float %40, float %42, float %48)
  store float %49, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %50 = getelementptr inbounds %struct.point2D, ptr %8, i32 0, i32 0
  %51 = load float, ptr %50, align 4, !tbaa !5
  %52 = getelementptr inbounds %struct.point2D, ptr %9, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !10
  %54 = getelementptr inbounds %struct.point2D, ptr %8, i32 0, i32 1
  %55 = load float, ptr %54, align 4, !tbaa !10
  %56 = getelementptr inbounds %struct.point2D, ptr %9, i32 0, i32 0
  %57 = load float, ptr %56, align 4, !tbaa !5
  %58 = fmul float %55, %57
  %59 = fneg float %58
  %60 = call float @llvm.fmuladd.f32(float %51, float %53, float %59)
  store float %60, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %61 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !5
  %63 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !10
  %65 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 1
  %66 = load float, ptr %65, align 4, !tbaa !10
  %67 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 0
  %68 = load float, ptr %67, align 4, !tbaa !5
  %69 = fmul float %66, %68
  %70 = fneg float %69
  %71 = call float @llvm.fmuladd.f32(float %62, float %64, float %70)
  %72 = fpext float %71 to double
  %73 = fdiv double 1.000000e+00, %72
  %74 = fptrunc double %73 to float
  store float %74, ptr %14, align 4, !tbaa !11
  %75 = getelementptr inbounds %struct.point2D, ptr %5, i32 0, i32 0
  %76 = load float, ptr %12, align 4, !tbaa !11
  %77 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 0
  %78 = load float, ptr %77, align 4, !tbaa !5
  %79 = load float, ptr %13, align 4, !tbaa !11
  %80 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 0
  %81 = load float, ptr %80, align 4, !tbaa !5
  %82 = fmul float %79, %81
  %83 = fneg float %82
  %84 = call float @llvm.fmuladd.f32(float %76, float %78, float %83)
  %85 = load float, ptr %14, align 4, !tbaa !11
  %86 = fmul float %84, %85
  store float %86, ptr %75, align 4, !tbaa !5
  %87 = getelementptr inbounds %struct.point2D, ptr %5, i32 0, i32 1
  %88 = load float, ptr %12, align 4, !tbaa !11
  %89 = getelementptr inbounds %struct.point2D, ptr %11, i32 0, i32 1
  %90 = load float, ptr %89, align 4, !tbaa !10
  %91 = load float, ptr %13, align 4, !tbaa !11
  %92 = getelementptr inbounds %struct.point2D, ptr %10, i32 0, i32 1
  %93 = load float, ptr %92, align 4, !tbaa !10
  %94 = fmul float %91, %93
  %95 = fneg float %94
  %96 = call float @llvm.fmuladd.f32(float %88, float %90, float %95)
  %97 = load float, ptr %14, align 4, !tbaa !11
  %98 = fmul float %96, %97
  store float %98, ptr %87, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %99 = load <2 x float>, ptr %5, align 4
  ret <2 x float> %99
}

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

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"_ZTS7point2D", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!7, !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 float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local <2 x float> @_Z12intersection7point2DS_S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #1 {
  %5 = extractelement <2 x float> %1, i64 1
  %6 = extractelement <2 x float> %1, i64 0
  %7 = extractelement <2 x float> %0, i64 1
  %8 = extractelement <2 x float> %0, i64 0
  %9 = extractelement <2 x float> %3, i64 1
  %10 = extractelement <2 x float> %3, i64 0
  %11 = extractelement <2 x float> %2, i64 1
  %12 = extractelement <2 x float> %2, i64 0
  %13 = fneg float %7
  %14 = fmul float %6, %13
  %15 = tail call float @llvm.fmuladd.f32(float %8, float %5, float %14)
  %16 = fneg float %11
  %17 = fmul float %10, %16
  %18 = tail call float @llvm.fmuladd.f32(float %12, float %9, float %17)
  %19 = fneg float %18
  %20 = fsub <2 x float> %0, %1
  %21 = fsub <2 x float> %2, %3
  %22 = extractelement <2 x float> %20, i64 1
  %23 = fneg float %22
  %24 = extractelement <2 x float> %21, i64 0
  %25 = fmul float %24, %23
  %26 = extractelement <2 x float> %21, i64 1
  %27 = extractelement <2 x float> %20, i64 0
  %28 = tail call float @llvm.fmuladd.f32(float %27, float %26, float %25)
  %29 = fdiv float 1.000000e+00, %28
  %30 = insertelement <2 x float> poison, float %19, i64 0
  %31 = shufflevector <2 x float> %30, <2 x float> poison, <2 x i32> zeroinitializer
  %32 = fmul <2 x float> %20, %31
  %33 = insertelement <2 x float> poison, float %15, i64 0
  %34 = shufflevector <2 x float> %33, <2 x float> poison, <2 x i32> zeroinitializer
  %35 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %34, <2 x float> %21, <2 x float> %32)
  %36 = insertelement <2 x float> poison, float %29, i64 0
  %37 = shufflevector <2 x float> %36, <2 x float> poison, <2 x i32> zeroinitializer
  %38 = fmul <2 x float> %35, %37
  ret <2 x float> %38
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable "min-legal-vector-width"="64" "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) }

!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)"}


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