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

; 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._Z12is_convex_v2iP5point.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 @_Z12is_convex_v2iP5point(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [3 x i32], align 4
  %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.point, align 8
  %12 = alloca %struct.point, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const._Z12is_convex_v2iP5point.s, i64 12, i1 false)
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %103, %2
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %17, label %28

17:                                               ; preds = %13
  %18 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %28

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

28:                                               ; preds = %21, %17, %13
  %29 = phi i1 [ false, %17 ], [ false, %13 ], [ %27, %21 ]
  br i1 %29, label %30, label %106

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

63:                                               ; preds = %30
  br label %99

64:                                               ; preds = %30
  %65 = load ptr, ptr %4, align 8, !tbaa !9
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = srem i32 %67, %68
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %struct.point, ptr %65, i64 %70
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %71, i64 16, i1 false), !tbaa.struct !11
  %72 = load ptr, ptr %4, align 8, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = add nsw i32 %73, 2
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = srem i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.point, ptr %72, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %78, i64 16, i1 false), !tbaa.struct !11
  %79 = load ptr, ptr %4, align 8, !tbaa !9
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds %struct.point, ptr %79, i64 %81
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %82, i64 16, i1 false), !tbaa.struct !11
  %83 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %84 = load double, ptr %83, align 8
  %85 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %86 = load double, ptr %85, align 8
  %87 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %88 = load double, ptr %87, align 8
  %89 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %90 = load double, ptr %89, align 8
  %91 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %92 = load double, ptr %91, align 8
  %93 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %94 = load double, ptr %93, align 8
  %95 = call noundef double @_Z5xmult5pointS_S_(double %84, double %86, double %88, double %90, double %92, double %94)
  %96 = fcmp olt double %95, -1.000000e-08
  %97 = zext i1 %96 to i64
  %98 = select i1 %96, i32 2, i32 0
  br label %99

99:                                               ; preds = %64, %63
  %100 = phi i32 [ 1, %63 ], [ %98, %64 ]
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 %101
  store i32 0, ptr %102, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %99
  %104 = load i32, ptr %5, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %5, align 4, !tbaa !5
  br label %13, !llvm.loop !14

106:                                              ; preds = %28
  %107 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %117

110:                                              ; preds = %106
  %111 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 1
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 2
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = or i32 %112, %114
  %116 = icmp ne i32 %115, 0
  br label %117

117:                                              ; preds = %110, %106
  %118 = phi i1 [ false, %106 ], [ %116, %110 ]
  %119 = zext i1 %118 to i32
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %119
}

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._Z12is_convex_v2iP5point.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 @_Z12is_convex_v2iP5point(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [3 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) @__const._Z12is_convex_v2iP5point.s, i64 12, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 4
  %5 = icmp sgt i32 %0, 0
  %6 = load i32, ptr %3, align 4
  %7 = icmp ne i32 %6, 0
  %or.cond31 = select i1 %5, i1 %7, i1 false
  br i1 %or.cond31, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = zext nneg i32 %0 to i64
  br label %10

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

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

27:                                               ; preds = %14
  %.sroa.05.0.copyload = load double, ptr %18, align 8, !tbaa !9
  %.sroa.26.0.copyload = load double, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !9
  %.sroa.03.0.copyload = load double, ptr %23, align 8, !tbaa !9
  %.sroa.24.0.copyload = load double, ptr %.sroa.210.0..sroa_idx, align 8, !tbaa !9
  %.sroa.0.0.copyload = load double, ptr %24, align 8, !tbaa !9
  %.sroa.2.0.copyload = load double, ptr %.sroa.28.0..sroa_idx, align 8, !tbaa !9
  %28 = tail call noundef double @_Z5xmult5pointS_S_(double %.sroa.05.0.copyload, double %.sroa.26.0.copyload, double %.sroa.03.0.copyload, double %.sroa.24.0.copyload, double %.sroa.0.0.copyload, double %.sroa.2.0.copyload)
  %29 = fcmp olt double %28, -1.000000e-08
  %30 = select i1 %29, i64 2, i64 0
  br label %31

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

.critedge:                                        ; preds = %10, %31, %2
  %.lcssa = phi i1 [ %7, %2 ], [ %36, %31 ], [ true, %10 ]
  %37 = load i32, ptr %4, align 4
  %38 = getelementptr inbounds i8, ptr %3, i64 8
  %39 = load i32, ptr %38, align 4
  %40 = or i32 %39, %37
  %41 = icmp ne i32 %40, 0
  %42 = select i1 %.lcssa, i1 %41, i1 false
  %43 = zext i1 %42 to i32
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #3
  ret i32 %43
}

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