; LLVM IR from lzyrapx/Competitive-Programming :: hihocoder/1040(计算几何).ll (Z10judgePointP4line)

; 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.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<point, point, std::_Identity<point>, std::less<point>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<point, point, std::_Identity<point>, std::less<point>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }
%struct.line = type { %struct.point, %struct.point }
%struct.point = type { i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10judgePointP4line(ptr noundef %0) #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::set", align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"struct.std::pair", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %3) #3
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %36, %1
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 4
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %43

13:                                               ; preds = %9
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %struct.line, ptr %14, i64 %16
  %18 = getelementptr inbounds %struct.line, ptr %17, i32 0, i32 0
  %19 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 4 dereferenceable(8) %18)
          to label %20 unwind label %39

20:                                               ; preds = %13
  %21 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 0
  %22 = extractvalue { ptr, i8 } %19, 0
  store ptr %22, ptr %21, align 8
  %23 = getelementptr inbounds { ptr, i8 }, ptr %7, i32 0, i32 1
  %24 = extractvalue { ptr, i8 } %19, 1
  store i8 %24, ptr %23, align 8
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds %struct.line, ptr %25, i64 %27
  %29 = getelementptr inbounds %struct.line, ptr %28, i32 0, i32 1
  %30 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 4 dereferenceable(8) %29)
          to label %31 unwind label %39

31:                                               ; preds = %20
  %32 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %33 = extractvalue { ptr, i8 } %30, 0
  store ptr %33, ptr %32, align 8
  %34 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %35 = extractvalue { ptr, i8 } %30, 1
  store i8 %35, ptr %34, align 8
  br label %36

36:                                               ; preds = %31
  %37 = load i32, ptr %4, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !11

39:                                               ; preds = %20, %13
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %5, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #3
  br label %47

43:                                               ; preds = %12
  %44 = call noundef i64 @_ZNKSt3setI5pointSt4lessIS0_ESaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  %45 = icmp eq i64 %44, 4
  %46 = zext i1 %45 to i32
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %3) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %3) #3
  ret i32 %46

47:                                               ; preds = %39
  %48 = load ptr, ptr %5, align 8
  %49 = load i32, ptr %6, align 4
  %50 = insertvalue { ptr, i32 } poison, ptr %48, 0
  %51 = insertvalue { ptr, i32 } %50, i32 %49, 1
  resume { ptr, i32 } %51
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

declare i32 @__gxx_personality_v0(...)

; 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
declare dso_local noundef i64 @_ZNKSt3setI5pointSt4lessIS0_ESaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = distinct !{!11, !12}
!12 = !{!"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"

%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<point, point, std::_Identity<point>, std::less<point>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<point, point, std::_Identity<point>, std::less<point>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z10judgePointP4line(ptr noundef %0) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.std::set", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #3
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #3
  %3 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %0)
          to label %4 unwind label %29

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %5)
          to label %7 unwind label %29

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %8)
          to label %10 unwind label %29

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %11)
          to label %13 unwind label %29

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %14)
          to label %16 unwind label %29

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %17)
          to label %19 unwind label %29

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 48
  %21 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %20)
          to label %22 unwind label %29

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %0, i64 56
  %24 = invoke { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 4 dereferenceable(8) %23)
          to label %25 unwind label %29

25:                                               ; preds = %22
  %26 = call noundef i64 @_ZNKSt3setI5pointSt4lessIS0_ESaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %2) #3
  %27 = icmp eq i64 %26, 4
  %28 = zext i1 %27 to i32
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #3
  ret i32 %28

29:                                               ; preds = %22, %19, %16, %13, %10, %7, %4, %1
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %2) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #3
  resume { ptr, i32 } %30
}

; 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 nounwind uwtable
declare dso_local void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EE6insertERKS0_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; 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
declare dso_local noundef i64 @_ZNKSt3setI5pointSt4lessIS0_ESaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setI5pointSt4lessIS0_ESaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2 align 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass