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

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

@__const._Z13inside_convex5pointiPS_.s = external hidden unnamed_addr constant [3 x i32], align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5xmult5pointS_S_(double, double, double, 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 noundef i32 @_Z13inside_convex5pointiPS_(double %0, double %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca %struct.point, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [3 x i32], align 4
  %10 = alloca %struct.point, align 8
  %11 = alloca %struct.point, align 8
  %12 = alloca %struct.point, align 8
  %13 = alloca %struct.point, align 8
  %14 = alloca %struct.point, align 8
  %15 = alloca %struct.point, align 8
  %16 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  store double %0, ptr %16, align 8
  %17 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  store double %1, ptr %17, align 8
  store i32 %2, ptr %6, align 4, !tbaa !5
  store ptr %3, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 @__const._Z13inside_convex5pointiPS_.s, i64 12, i1 false)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %90, %4
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %29

22:                                               ; preds = %18
  %23 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 2
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = or i32 %24, %26
  %28 = icmp ne i32 %27, 0
  br label %29

29:                                               ; preds = %22, %18
  %30 = phi i1 [ false, %18 ], [ %28, %22 ]
  br i1 %30, label %31, label %93

31:                                               ; preds = %29
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i32, ptr %8, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = srem i32 %34, %35
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds %struct.point, ptr %32, i64 %37
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %38, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !11
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct.point, ptr %39, i64 %41
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %42, i64 16, i1 false), !tbaa.struct !11
  %43 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %44 = load double, ptr %43, align 8
  %45 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %46 = load double, ptr %45, align 8
  %47 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %48 = load double, ptr %47, align 8
  %49 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %50 = load double, ptr %49, align 8
  %51 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %54 = load double, ptr %53, align 8
  %55 = call noundef double @_Z5xmult5pointS_S_(double %44, double %46, double %48, double %50, double %52, double %54)
  %56 = fcmp ogt double %55, 1.000000e-08
  br i1 %56, label %57, label %58

57:                                               ; preds = %31
  br label %86

58:                                               ; preds = %31
  %59 = load ptr, ptr %7, align 8, !tbaa !9
  %60 = load i32, ptr %8, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = srem i32 %61, %62
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.point, ptr %59, i64 %64
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %65, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !11
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds %struct.point, ptr %66, i64 %68
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %69, i64 16, i1 false), !tbaa.struct !11
  %70 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %71 = load double, ptr %70, align 8
  %72 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %73 = load double, ptr %72, align 8
  %74 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 0
  %75 = load double, ptr %74, align 8
  %76 = getelementptr inbounds { double, double }, ptr %14, i32 0, i32 1
  %77 = load double, ptr %76, align 8
  %78 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 0
  %79 = load double, ptr %78, align 8
  %80 = getelementptr inbounds { double, double }, ptr %15, i32 0, i32 1
  %81 = load double, ptr %80, align 8
  %82 = call noundef double @_Z5xmult5pointS_S_(double %71, double %73, double %75, double %77, double %79, double %81)
  %83 = fcmp olt double %82, -1.000000e-08
  %84 = zext i1 %83 to i64
  %85 = select i1 %83, i32 2, i32 0
  br label %86

86:                                               ; preds = %58, %57
  %87 = phi i32 [ 1, %57 ], [ %85, %58 ]
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 %88
  store i32 0, ptr %89, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %86
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %8, align 4, !tbaa !5
  br label %18, !llvm.loop !14

93:                                               ; preds = %29
  %94 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 2
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = or i32 %95, %97
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  ret i32 %98
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{i64 0, i64 8, !12, i64 8, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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

@__const._Z13inside_convex5pointiPS_.s = external hidden unnamed_addr constant [3 x i32], align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5xmult5pointS_S_(double, double, double, double, double, double) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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: mustprogress 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 noundef i32 @_Z13inside_convex5pointiPS_(double %0, double %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = alloca [3 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) @__const._Z13inside_convex5pointiPS_.s, i64 12, i1 false)
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = icmp sgt i32 %2, 0
  %9 = load i32, ptr %6, align 4
  %10 = load i32, ptr %7, align 4
  %11 = or i32 %10, %9
  %12 = icmp ne i32 %11, 0
  %13 = select i1 %8, i1 %12, i1 false
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %14 = zext nneg i32 %2 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %26 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %15 = trunc nuw nsw i64 %indvars.iv.next to i32
  %16 = urem i32 %15, %2
  %17 = zext nneg i32 %16 to i64
  %18 = getelementptr inbounds %struct.point, ptr %3, i64 %17
  %.sroa.09.0.copyload = load double, ptr %18, align 8, !tbaa !5
  %.sroa.210.0..sroa_idx = getelementptr inbounds i8, ptr %18, i64 8
  %.sroa.210.0.copyload = load double, ptr %.sroa.210.0..sroa_idx, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.point, ptr %3, i64 %indvars.iv
  %.sroa.05.0.copyload = load double, ptr %19, align 8, !tbaa !5
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %19, i64 8
  %.sroa.26.0.copyload = load double, ptr %.sroa.26.0..sroa_idx, align 8, !tbaa !5
  %20 = tail call noundef double @_Z5xmult5pointS_S_(double %.sroa.09.0.copyload, double %.sroa.210.0.copyload, double %0, double %1, double %.sroa.05.0.copyload, double %.sroa.26.0.copyload)
  %21 = fcmp ogt double %20, 1.000000e-08
  br i1 %21, label %26, label %22

22:                                               ; preds = %.lr.ph
  %.sroa.03.0.copyload = load double, ptr %18, align 8, !tbaa !5
  %.sroa.24.0.copyload = load double, ptr %.sroa.210.0..sroa_idx, align 8, !tbaa !5
  %.sroa.0.0.copyload = load double, ptr %19, align 8, !tbaa !5
  %.sroa.2.0.copyload = load double, ptr %.sroa.26.0..sroa_idx, align 8, !tbaa !5
  %23 = tail call noundef double @_Z5xmult5pointS_S_(double %.sroa.03.0.copyload, double %.sroa.24.0.copyload, double %0, double %1, double %.sroa.0.0.copyload, double %.sroa.2.0.copyload)
  %24 = fcmp olt double %23, -1.000000e-08
  %25 = select i1 %24, i64 2, i64 0
  br label %26

26:                                               ; preds = %.lr.ph, %22
  %27 = phi i64 [ %25, %22 ], [ 1, %.lr.ph ]
  %28 = getelementptr inbounds [3 x i32], ptr %5, i64 0, i64 %27
  store i32 0, ptr %28, align 4, !tbaa !9
  %29 = icmp ult i64 %indvars.iv.next, %14
  %30 = load i32, ptr %6, align 4
  %31 = load i32, ptr %7, align 4
  %32 = or i32 %31, %30
  %33 = icmp ne i32 %32, 0
  %34 = select i1 %29, i1 %33, i1 false
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %26, %4
  %.lcssa = phi i32 [ %11, %4 ], [ %32, %26 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #3
  ret i32 %.lcssa
}

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 willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass