; LLVM IR from xyzxqs/XLowPoly :: xlowpoly/src/main/jni (dedup)

; 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 { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @dedup(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  call void @qsort(ptr noundef %10, i64 noundef %13, i64 noundef 8, ptr noundef @qsorter)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %71, %2
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = add nsw i32 %15, 1
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %14
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %74

21:                                               ; preds = %14
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %struct.Point, ptr %22, i64 %24
  store ptr %25, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %9, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %66, %21
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = icmp slt i32 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 5, ptr %8, align 4
  br label %69

35:                                               ; preds = %28
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.Point, ptr %36, i64 %38
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Point, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Point, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 4, !tbaa !11
  %46 = icmp eq i32 %42, %45
  br i1 %46, label %47, label %64

47:                                               ; preds = %35
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Point, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.Point, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !13
  %54 = icmp eq i32 %50, %53
  br i1 %54, label %55, label %62

55:                                               ; preds = %47
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = call zeroext i1 @point_remove(ptr noundef %56, ptr noundef %57, i32 noundef %58)
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = add nsw i32 %60, -1
  store i32 %61, ptr %9, align 4, !tbaa !9
  br label %63

62:                                               ; preds = %47
  store i32 5, ptr %8, align 4
  br label %69

63:                                               ; preds = %55
  br label %65

64:                                               ; preds = %35
  store i32 5, ptr %8, align 4
  br label %69

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %9, align 4, !tbaa !9
  br label %28, !llvm.loop !14

69:                                               ; preds = %64, %62, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %7, align 4, !tbaa !9
  br label %14, !llvm.loop !16

74:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @qsorter(ptr noundef, ptr noundef) #0

declare zeroext i1 @point_remove(ptr noundef, ptr noundef, i32 noundef) #2

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

attributes #0 = { 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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !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.Point = type { i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @dedup(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  tail call void @qsort(ptr noundef %0, i64 noundef %4, i64 noundef 8, ptr noundef nonnull @qsorter) #3
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 1
  br i1 %6, label %.lr.ph26, label %._crit_edge27

._crit_edge27:                                    ; preds = %._crit_edge, %2
  ret void

.lr.ph26:                                         ; preds = %2, %._crit_edge
  %7 = phi i32 [ %33, %._crit_edge ], [ %5, %2 ]
  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %._crit_edge ], [ 0, %2 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %._crit_edge ], [ 1, %2 ]
  %8 = getelementptr inbounds %struct.Point, ptr %0, i64 %indvars.iv28
  %9 = getelementptr inbounds %struct.Point, ptr %0, i64 %indvars.iv
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = add nuw nsw i64 %indvars.iv28, 2
  %12 = sext i32 %7 to i64
  %13 = icmp slt i64 %11, %12
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph26
  %14 = getelementptr inbounds i8, ptr %8, i64 4
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %.lr.ph33, label %._crit_edge.loopexit

19:                                               ; preds = %27
  %20 = load i32, ptr %9, align 4, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = icmp eq i32 %20, %21
  br i1 %22, label %.lr.ph33, label %._crit_edge.loopexit, !llvm.loop !11

.lr.ph33:                                         ; preds = %.lr.ph, %19
  %23 = phi i32 [ %29, %19 ], [ %7, %.lr.ph ]
  %24 = load i32, ptr %10, align 4, !tbaa !13
  %25 = load i32, ptr %14, align 4, !tbaa !13
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %._crit_edge.loopexit

27:                                               ; preds = %.lr.ph33
  %28 = tail call zeroext i1 @point_remove(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %15) #3
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %11, %30
  br i1 %31, label %19, label %._crit_edge.loopexit, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %27, %.lr.ph33, %19, %.lr.ph
  %32 = phi i32 [ %7, %.lr.ph ], [ %29, %27 ], [ %23, %.lr.ph33 ], [ %29, %19 ]
  %.pre = sext i32 %32 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph26
  %.pre-phi = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %12, %.lr.ph26 ]
  %33 = phi i32 [ %32, %._crit_edge.loopexit ], [ %7, %.lr.ph26 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = icmp slt i64 %indvars.iv.next, %.pre-phi
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  br i1 %34, label %.lr.ph26, label %._crit_edge27, !llvm.loop !14
}

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @qsorter(ptr noundef, ptr noundef) #0

declare zeroext i1 @point_remove(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 = { nofree "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" }
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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!10, !6, i64 4}
!14 = distinct !{!14, !12}


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