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

; 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._Z16inside_convex_v25pointiPS_.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 @_Z16inside_convex_v25pointiPS_(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._Z16inside_convex_v25pointiPS_.s, i64 12, i1 false)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %94, %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 %33

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

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

33:                                               ; preds = %26, %22, %18
  %34 = phi i1 [ false, %22 ], [ false, %18 ], [ %32, %26 ]
  br i1 %34, label %35, label %97

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

61:                                               ; preds = %35
  br label %90

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

90:                                               ; preds = %62, %61
  %91 = phi i32 [ 1, %61 ], [ %89, %62 ]
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 %92
  store i32 0, ptr %93, align 4, !tbaa !5
  br label %94

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

97:                                               ; preds = %33
  %98 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 0
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %108

101:                                              ; preds = %97
  %102 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 2
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = or i32 %103, %105
  %107 = icmp ne i32 %106, 0
  br label %108

108:                                              ; preds = %101, %97
  %109 = phi i1 [ false, %97 ], [ %107, %101 ]
  %110 = zext i1 %109 to i32
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  ret i32 %110
}

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._Z16inside_convex_v25pointiPS_.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 range(i32 0, 2) i32 @_Z16inside_convex_v25pointiPS_(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._Z16inside_convex_v25pointiPS_.s, i64 12, i1 false)
  %6 = getelementptr inbounds i8, ptr %5, i64 4
  %7 = icmp sgt i32 %2, 0
  %8 = load i32, ptr %5, align 4
  %9 = icmp ne i32 %8, 0
  %or.cond26 = select i1 %7, i1 %9, i1 false
  br i1 %or.cond26, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %4
  %10 = getelementptr inbounds i8, ptr %5, i64 8
  %11 = zext nneg i32 %2 to i64
  br label %12

12:                                               ; preds = %.lr.ph, %28
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %28 ]
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %10, align 4, !tbaa !5
  %15 = or i32 %14, %13
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %.critedge, label %16

16:                                               ; preds = %12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = trunc nuw nsw i64 %indvars.iv.next to i32
  %18 = urem i32 %17, %2
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds %struct.point, ptr %3, i64 %19
  %.sroa.011.0.copyload = load double, ptr %20, align 8, !tbaa !9
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %20, i64 8
  %.sroa.212.0.copyload = load double, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.point, ptr %3, i64 %indvars.iv
  %.sroa.07.0.copyload = load double, ptr %21, align 8, !tbaa !9
  %.sroa.28.0..sroa_idx = getelementptr inbounds i8, ptr %21, i64 8
  %.sroa.28.0.copyload = load double, ptr %.sroa.28.0..sroa_idx, align 8, !tbaa !9
  %22 = tail call noundef double @_Z5xmult5pointS_S_(double %.sroa.011.0.copyload, double %.sroa.212.0.copyload, double %0, double %1, double %.sroa.07.0.copyload, double %.sroa.28.0.copyload)
  %23 = fcmp ogt double %22, 1.000000e-08
  br i1 %23, label %28, label %24

24:                                               ; preds = %16
  %.sroa.05.0.copyload = load double, ptr %20, align 8, !tbaa !9
  %.sroa.26.0.copyload = load double, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !9
  %.sroa.0.0.copyload = load double, ptr %21, align 8, !tbaa !9
  %.sroa.2.0.copyload = load double, ptr %.sroa.28.0..sroa_idx, align 8, !tbaa !9
  %25 = tail call noundef double @_Z5xmult5pointS_S_(double %.sroa.05.0.copyload, double %.sroa.26.0.copyload, double %0, double %1, double %.sroa.0.0.copyload, double %.sroa.2.0.copyload)
  %26 = fcmp olt double %25, -1.000000e-08
  %27 = select i1 %26, i64 2, i64 0
  br label %28

28:                                               ; preds = %16, %24
  %29 = phi i64 [ %27, %24 ], [ 1, %16 ]
  %30 = getelementptr inbounds [3 x i32], ptr %5, i64 0, i64 %29
  store i32 0, ptr %30, align 4, !tbaa !5
  %31 = icmp ult i64 %indvars.iv.next, %11
  %32 = load i32, ptr %5, align 4
  %33 = icmp ne i32 %32, 0
  %or.cond = select i1 %31, i1 %33, i1 false
  br i1 %or.cond, label %12, label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %12, %28, %4
  %.lcssa = phi i1 [ %9, %4 ], [ %33, %28 ], [ true, %12 ]
  %34 = load i32, ptr %6, align 4
  %35 = getelementptr inbounds i8, ptr %5, i64 8
  %36 = load i32, ptr %35, align 4
  %37 = or i32 %36, %34
  %38 = icmp ne i32 %37, 0
  %39 = select i1 %.lcssa, i1 %38, i1 false
  %40 = zext i1 %39 to i32
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #3
  ret i32 %40
}

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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