; LLVM IR from NavInfoNC/nc-geo :: test/polygon_merger_unittest.ll (Z14isPolygonEqualP13StaticPolygonPK5Pointi)

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

%"class.testing::AssertionResult" = type { i8, %"class.testing::internal::scoped_ptr" }
%"class.testing::internal::scoped_ptr" = type { ptr }
%struct.Point = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14isPolygonEqualP13StaticPolygonPK5Pointi(ptr dead_on_unwind noalias writable sret(%"class.testing::AssertionResult") align 8 %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.Point, align 4
  %14 = alloca %struct.Point, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noundef ptr @_ZN13StaticPolygon6pointsEv(ptr noundef nonnull align 8 dereferenceable(40) %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef i32 @_ZN13StaticPolygon11pointNumberEv(ptr noundef nonnull align 8 dereferenceable(40) %19)
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp ne i32 %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %4
  call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  store i32 1, ptr %11, align 4
  br label %100

25:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 -1, ptr %12, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %42, %25
  %27 = load i32, ptr %12, align 4, !tbaa !9
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %45

30:                                               ; preds = %26
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.Point, ptr %31, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %34, i64 8, i1 false), !tbaa.struct !11
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Point, ptr %35, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %36, i64 8, i1 false), !tbaa.struct !11
  %37 = load i64, ptr %13, align 4
  %38 = load i64, ptr %14, align 4
  %39 = call noundef zeroext i1 @_Zeq5PointS_(i64 %37, i64 %38)
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  br label %45

41:                                               ; preds = %30
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %12, align 4, !tbaa !9
  br label %26, !llvm.loop !12

45:                                               ; preds = %40, %26
  %46 = load i32, ptr %12, align 4, !tbaa !9
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %49

48:                                               ; preds = %45
  call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  store i32 1, ptr %11, align 4
  br label %99

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %93, %49
  %51 = load i32, ptr %15, align 4, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 5, ptr %11, align 4
  br label %96

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %56 = load i32, ptr %12, align 4, !tbaa !9
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = add nsw i32 %56, %57
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = srem i32 %58, %59
  store i32 %60, ptr %16, align 4, !tbaa !9
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = load i32, ptr %15, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds %struct.Point, ptr %61, i64 %63
  %65 = getelementptr inbounds %struct.Point, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !14
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load i32, ptr %16, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.Point, ptr %67, i64 %69
  %71 = getelementptr inbounds %struct.Point, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 4, !tbaa !14
  %73 = icmp ne i32 %66, %72
  br i1 %73, label %88, label %74

74:                                               ; preds = %55
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load i32, ptr %15, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.Point, ptr %75, i64 %77
  %79 = getelementptr inbounds %struct.Point, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !16
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load i32, ptr %16, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds %struct.Point, ptr %81, i64 %83
  %85 = getelementptr inbounds %struct.Point, ptr %84, i32 0, i32 1
  %86 = load i32, ptr %85, align 4, !tbaa !16
  %87 = icmp ne i32 %80, %86
  br i1 %87, label %88, label %89

88:                                               ; preds = %74, %55
  call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  store i32 1, ptr %11, align 4
  br label %90

89:                                               ; preds = %74
  store i32 0, ptr %11, align 4
  br label %90

90:                                               ; preds = %89, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  %91 = load i32, ptr %11, align 4
  switch i32 %91, label %96 [
    i32 0, label %92
  ]

92:                                               ; preds = %90
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %15, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %15, align 4, !tbaa !9
  br label %50, !llvm.loop !17

96:                                               ; preds = %90, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %97 = load i32, ptr %11, align 4
  switch i32 %97, label %99 [
    i32 5, label %98
  ]

98:                                               ; preds = %96
  call void @_ZN7testing16AssertionSuccessEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  store i32 1, ptr %11, align 4
  br label %99

99:                                               ; preds = %98, %96, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %100

100:                                              ; preds = %99, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret void
}

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN13StaticPolygon6pointsEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN13StaticPolygon11pointNumberEv(ptr noundef nonnull align 8 dereferenceable(40)) #2 align 2

declare void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8) #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Zeq5PointS_(i64, i64) #2

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

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

declare void @_ZN7testing16AssertionSuccessEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8) #3

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


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

%"class.testing::AssertionResult" = type { i8, %"class.testing::internal::scoped_ptr" }
%"class.testing::internal::scoped_ptr" = type { ptr }
%struct.Point = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14isPolygonEqualP13StaticPolygonPK5Pointi(ptr dead_on_unwind noalias writable sret(%"class.testing::AssertionResult") align 8 %0, ptr noundef nonnull %1, ptr nocapture noundef readonly %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = tail call noundef ptr @_ZN13StaticPolygon6pointsEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
  %6 = tail call noundef i32 @_ZN13StaticPolygon11pointNumberEv(ptr noundef nonnull align 8 dereferenceable(40) %1)
  %.not = icmp eq i32 %6, %3
  br i1 %.not, label %.preheader36, label %8

.preheader36:                                     ; preds = %4
  %7 = icmp sgt i32 %3, -1
  br i1 %7, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %.preheader36
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.lr.ph

8:                                                ; preds = %4
  tail call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  br label %28

.lr.ph:                                           ; preds = %.lr.ph.preheader, %11
  %indvars.iv = phi i64 [ -1, %.lr.ph.preheader ], [ %indvars.iv.next, %11 ]
  %9 = getelementptr inbounds %struct.Point, ptr %5, i64 %indvars.iv
  %.sroa.08.0.copyload = load i64, ptr %9, align 4
  %.sroa.0.0.copyload = load i64, ptr %2, align 4
  %10 = tail call noundef zeroext i1 @_Zeq5PointS_(i64 %.sroa.08.0.copyload, i64 %.sroa.0.0.copyload)
  br i1 %10, label %._crit_edge.split.loop.exit50, label %11

11:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge.split.loop.exit50:                    ; preds = %.lr.ph
  %12 = trunc nsw i64 %indvars.iv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %11, %._crit_edge.split.loop.exit50
  %.029.lcssa = phi i32 [ %12, %._crit_edge.split.loop.exit50 ], [ %3, %11 ]
  %13 = icmp eq i32 %.029.lcssa, -1
  br i1 %13, label %._crit_edge.thread, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %.not3340.not = icmp eq i32 %3, 0
  br i1 %.not3340.not, label %.critedge35, label %.lr.ph42.preheader

.lr.ph42.preheader:                               ; preds = %.preheader
  %wide.trip.count47 = zext nneg i32 %3 to i64
  br label %.lr.ph42

._crit_edge.thread:                               ; preds = %.preheader36, %._crit_edge
  tail call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  br label %28

14:                                               ; preds = %23
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
  br i1 %exitcond48.not, label %.critedge35, label %.lr.ph42, !llvm.loop !7

.lr.ph42:                                         ; preds = %.lr.ph42.preheader, %14
  %indvars.iv44 = phi i64 [ 0, %.lr.ph42.preheader ], [ %indvars.iv.next45, %14 ]
  %15 = trunc i64 %indvars.iv44 to i32
  %16 = add i32 %.029.lcssa, %15
  %17 = srem i32 %16, %3
  %18 = getelementptr inbounds %struct.Point, ptr %2, i64 %indvars.iv44
  %19 = load i32, ptr %18, align 4, !tbaa !8
  %20 = sext i32 %17 to i64
  %21 = getelementptr inbounds %struct.Point, ptr %5, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !8
  %.not31 = icmp eq i32 %19, %22
  br i1 %.not31, label %23, label %.critedge

23:                                               ; preds = %.lr.ph42
  %24 = getelementptr inbounds i8, ptr %18, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %21, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %.not32 = icmp eq i32 %25, %27
  br i1 %.not32, label %14, label %.critedge

.critedge:                                        ; preds = %23, %.lr.ph42
  tail call void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  br label %28

.critedge35:                                      ; preds = %14, %.preheader
  tail call void @_ZN7testing16AssertionSuccessEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8 %0)
  br label %28

28:                                               ; preds = %.critedge, %._crit_edge.thread, %.critedge35, %8
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN13StaticPolygon6pointsEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN13StaticPolygon11pointNumberEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

declare void @_ZN7testing16AssertionFailureEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8) local_unnamed_addr #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Zeq5PointS_(i64, i64) local_unnamed_addr #1

declare void @_ZN7testing16AssertionSuccessEv(ptr dead_on_unwind writable sret(%"class.testing::AssertionResult") align 8) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { alwaysinline 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 #2 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !10, i64 0}
!9 = !{!"_ZTS5Point", !10, i64 0, !10, i64 4}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!9, !10, i64 4}


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