; LLVM IR from Lodour/ACM-CheatSheet :: src/6_计算几何/3_多边形/5_小结.ll (Z10barycenter5pointS_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.line = type { %struct.point, %struct.point }
%struct.point = 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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 { double, double } @_Z12intersection4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local { double, double } @_Z10barycenter5pointS_S_(double %0, double %1, double %2, double %3, double %4, double %5) #2 {
  %7 = alloca %struct.point, align 8
  %8 = alloca %struct.point, align 8
  %9 = alloca %struct.point, align 8
  %10 = alloca %struct.point, align 8
  %11 = alloca %struct.line, align 8
  %12 = alloca %struct.line, align 8
  %13 = alloca %struct.line, align 8
  %14 = alloca %struct.line, align 8
  %15 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  store double %0, ptr %15, align 8
  %16 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  store double %1, ptr %16, align 8
  %17 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  store double %2, ptr %17, align 8
  %18 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  store double %3, ptr %18, align 8
  %19 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  store double %4, ptr %19, align 8
  %20 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  store double %5, ptr %20, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #3
  %21 = getelementptr inbounds %struct.point, ptr %8, i32 0, i32 0
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.point, ptr %9, i32 0, i32 0
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fadd double %22, %24
  %26 = fdiv double %25, 2.000000e+00
  %27 = getelementptr inbounds %struct.line, ptr %11, i32 0, i32 0
  %28 = getelementptr inbounds %struct.point, ptr %27, i32 0, i32 0
  store double %26, ptr %28, align 8, !tbaa !10
  %29 = getelementptr inbounds %struct.point, ptr %8, i32 0, i32 1
  %30 = load double, ptr %29, align 8, !tbaa !12
  %31 = getelementptr inbounds %struct.point, ptr %9, i32 0, i32 1
  %32 = load double, ptr %31, align 8, !tbaa !12
  %33 = fadd double %30, %32
  %34 = fdiv double %33, 2.000000e+00
  %35 = getelementptr inbounds %struct.line, ptr %11, i32 0, i32 0
  %36 = getelementptr inbounds %struct.point, ptr %35, i32 0, i32 1
  store double %34, ptr %36, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.line, ptr %11, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %37, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !14
  %38 = getelementptr inbounds %struct.point, ptr %8, i32 0, i32 0
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.point, ptr %10, i32 0, i32 0
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = fadd double %39, %41
  %43 = fdiv double %42, 2.000000e+00
  %44 = getelementptr inbounds %struct.line, ptr %12, i32 0, i32 0
  %45 = getelementptr inbounds %struct.point, ptr %44, i32 0, i32 0
  store double %43, ptr %45, align 8, !tbaa !10
  %46 = getelementptr inbounds %struct.point, ptr %8, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !12
  %48 = getelementptr inbounds %struct.point, ptr %10, i32 0, i32 1
  %49 = load double, ptr %48, align 8, !tbaa !12
  %50 = fadd double %47, %49
  %51 = fdiv double %50, 2.000000e+00
  %52 = getelementptr inbounds %struct.line, ptr %12, i32 0, i32 0
  %53 = getelementptr inbounds %struct.point, ptr %52, i32 0, i32 1
  store double %51, ptr %53, align 8, !tbaa !13
  %54 = getelementptr inbounds %struct.line, ptr %12, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %54, ptr align 8 %9, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %11, i64 32, i1 false), !tbaa.struct !16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %12, i64 32, i1 false), !tbaa.struct !16
  %55 = call { double, double } @_Z12intersection4lineS_(ptr noundef byval(%struct.line) align 8 %13, ptr noundef byval(%struct.line) align 8 %14)
  %56 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %57 = extractvalue { double, double } %55, 0
  store double %57, ptr %56, align 8
  %58 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  %59 = extractvalue { double, double } %55, 1
  store double %59, ptr %58, align 8
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #3
  %60 = load { double, double }, ptr %7, align 8
  ret { double, double } %60
}

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


; 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 nounwind uwtable
declare dso_local { double, double } @_Z12intersection4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local { double, double } @_Z10barycenter5pointS_S_(double %0, double %1, double %2, double %3, double %4, double %5) local_unnamed_addr #0 {
  %7 = alloca %struct.line, align 16
  %8 = alloca %struct.line, align 16
  %9 = insertelement <2 x double> poison, double %0, i64 0
  %10 = insertelement <2 x double> %9, double %1, i64 1
  %11 = insertelement <2 x double> poison, double %2, i64 0
  %12 = insertelement <2 x double> %11, double %3, i64 1
  %13 = fadd <2 x double> %10, %12
  %14 = insertelement <2 x double> poison, double %4, i64 0
  %15 = insertelement <2 x double> %14, double %5, i64 1
  %16 = fadd <2 x double> %10, %15
  %17 = fmul <2 x double> %13, <double 5.000000e-01, double 5.000000e-01>
  store <2 x double> %17, ptr %7, align 16, !tbaa !5
  %.sroa.53.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 16
  store double %4, ptr %.sroa.53.0..sroa_idx, align 16, !tbaa !5
  %.sroa.53.sroa.4.0..sroa.53.0..sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %7, i64 24
  store double %5, ptr %.sroa.53.sroa.4.0..sroa.53.0..sroa_idx.sroa_idx, align 8, !tbaa !5
  %18 = fmul <2 x double> %16, <double 5.000000e-01, double 5.000000e-01>
  store <2 x double> %18, ptr %8, align 16, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %8, i64 16
  store double %2, ptr %.sroa.5.0..sroa_idx, align 16, !tbaa !5
  %.sroa.5.sroa.4.0..sroa.5.0..sroa_idx.sroa_idx = getelementptr inbounds i8, ptr %8, i64 24
  store double %3, ptr %.sroa.5.sroa.4.0..sroa.5.0..sroa_idx.sroa_idx, align 8, !tbaa !5
  %19 = tail call { double, double } @_Z12intersection4lineS_(ptr noundef nonnull byval(%struct.line) align 8 %7, ptr noundef nonnull byval(%struct.line) align 8 %8)
  ret { double, double } %19
}

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

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


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