; LLVM IR from Lodour/ACM-CheatSheet :: src/6_计算几何/3_多边形/5_小结.ll (Z12intersection4lineS_)

; 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.line = type { %struct.point, %struct.point }
%struct.point = type { double, double }

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

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTS4line", !12, i64 0, !12, i64 16}
!12 = !{!"_ZTS5point", !7, i64 0, !7, i64 8}
!13 = !{!11, !7, i64 8}
!14 = !{!11, !7, i64 24}
!15 = !{!11, !7, i64 16}
!16 = !{!12, !7, i64 0}
!17 = !{!12, !7, i64 8}


; 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.line = type { %struct.point, %struct.point }
%struct.point = type { double, double }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local { double, double } @_Z12intersection4lineS_(ptr nocapture noundef readonly byval(%struct.line) align 8 %0, ptr nocapture noundef readonly byval(%struct.line) align 8 %1) local_unnamed_addr #0 {
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load double, ptr %7, align 8, !tbaa !12
  %9 = fsub double %5, %8
  %10 = load double, ptr %6, align 8, !tbaa !13
  %11 = fsub double %3, %10
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load <2 x double>, ptr %0, align 8, !tbaa !14
  %14 = load <2 x double>, ptr %12, align 8, !tbaa !14
  %15 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
  %16 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> <i32 poison, i32 0>
  %17 = insertelement <2 x double> %16, double %3, i64 0
  %18 = fsub <2 x double> %15, %17
  %19 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> <i32 1, i32 1>
  %20 = insertelement <2 x double> %14, double %5, i64 0
  %21 = fsub <2 x double> %19, %20
  %22 = fneg <2 x double> %21
  %23 = insertelement <2 x double> poison, double %11, i64 0
  %24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
  %25 = fmul <2 x double> %24, %22
  %26 = insertelement <2 x double> poison, double %9, i64 0
  %27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %28 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %27, <2 x double> %25)
  %29 = extractelement <2 x double> %28, i64 0
  %30 = extractelement <2 x double> %28, i64 1
  %31 = fdiv double %29, %30
  %32 = fsub <2 x double> %14, %13
  %33 = insertelement <2 x double> poison, double %31, i64 0
  %34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %34, <2 x double> %13)
  %36 = extractelement <2 x double> %35, i64 0
  %.fca.0.insert = insertvalue { double, double } poison, double %36, 0
  %37 = extractelement <2 x double> %35, i64 1
  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %37, 1
  ret { double, double } %.fca.1.insert
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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, !8, i64 0}
!6 = !{!"_ZTS4line", !7, i64 0, !7, i64 16}
!7 = !{!"_ZTS5point", !8, i64 0, !8, i64 8}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!6, !8, i64 24}
!13 = !{!6, !8, i64 16}
!14 = !{!8, !8, i64 0}


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