; LLVM IR from ShahjalalShohag/code-library :: Geometry/Delaunay Triangulation.ll (Z9make_edge2PTS_)

; 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.PT = type { i64, i64 }
%struct.Quad = type { i8, ptr, ptr, %struct.PT }

@arb = external dso_local global %struct.PT, align 8

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9make_edge2PTS_(ptr noundef %0, ptr noundef %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [4 x ptr], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = 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 32, ptr %5) #5
  %9 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %10 = getelementptr inbounds %struct.Quad, ptr %9, i32 0, i32 0
  store i8 0, ptr %10, align 16, !tbaa !9
  %11 = getelementptr inbounds %struct.Quad, ptr %9, i32 0, i32 1
  store ptr null, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds %struct.Quad, ptr %9, i32 0, i32 2
  store ptr null, ptr %12, align 16, !tbaa !15
  %13 = getelementptr inbounds %struct.Quad, ptr %9, i32 0, i32 3
  invoke void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %0)
          to label %14 unwind label %40

14:                                               ; preds = %2
  store ptr %9, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds ptr, ptr %5, i64 1
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %17 = getelementptr inbounds %struct.Quad, ptr %16, i32 0, i32 0
  store i8 0, ptr %17, align 16, !tbaa !9
  %18 = getelementptr inbounds %struct.Quad, ptr %16, i32 0, i32 1
  store ptr null, ptr %18, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.Quad, ptr %16, i32 0, i32 2
  store ptr null, ptr %19, align 16, !tbaa !15
  %20 = getelementptr inbounds %struct.Quad, ptr %16, i32 0, i32 3
  invoke void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) @arb)
          to label %21 unwind label %44

21:                                               ; preds = %14
  store ptr %16, ptr %15, align 8, !tbaa !5
  %22 = getelementptr inbounds ptr, ptr %5, i64 2
  %23 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %24 = getelementptr inbounds %struct.Quad, ptr %23, i32 0, i32 0
  store i8 0, ptr %24, align 16, !tbaa !9
  %25 = getelementptr inbounds %struct.Quad, ptr %23, i32 0, i32 1
  store ptr null, ptr %25, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.Quad, ptr %23, i32 0, i32 2
  store ptr null, ptr %26, align 16, !tbaa !15
  %27 = getelementptr inbounds %struct.Quad, ptr %23, i32 0, i32 3
  invoke void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 8 dereferenceable(16) %1)
          to label %28 unwind label %48

28:                                               ; preds = %21
  store ptr %23, ptr %22, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %5, i64 3
  %30 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 40) #6
  %31 = getelementptr inbounds %struct.Quad, ptr %30, i32 0, i32 0
  store i8 0, ptr %31, align 16, !tbaa !9
  %32 = getelementptr inbounds %struct.Quad, ptr %30, i32 0, i32 1
  store ptr null, ptr %32, align 8, !tbaa !14
  %33 = getelementptr inbounds %struct.Quad, ptr %30, i32 0, i32 2
  store ptr null, ptr %33, align 16, !tbaa !15
  %34 = getelementptr inbounds %struct.Quad, ptr %30, i32 0, i32 3
  invoke void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(16) @arb)
          to label %35 unwind label %52

35:                                               ; preds = %28
  store ptr %30, ptr %29, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !16
  br label %36

36:                                               ; preds = %79, %35
  %37 = load i32, ptr %8, align 4, !tbaa !16
  %38 = icmp slt i32 %37, 4
  br i1 %38, label %56, label %39

39:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %82

40:                                               ; preds = %2
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %6, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %9, i64 noundef 40) #7
  br label %85

44:                                               ; preds = %14
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %6, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 40) #7
  br label %85

48:                                               ; preds = %21
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %6, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %23, i64 noundef 40) #7
  br label %85

52:                                               ; preds = %28
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %6, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %30, i64 noundef 40) #7
  br label %85

56:                                               ; preds = %36
  %57 = load i32, ptr %8, align 4, !tbaa !16
  %58 = sub nsw i32 0, %57
  %59 = and i32 %58, 3
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !16
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Quad, ptr %66, i32 0, i32 1
  store ptr %62, ptr %67, align 8, !tbaa !14
  %68 = load i32, ptr %8, align 4, !tbaa !16
  %69 = add nsw i32 %68, 1
  %70 = and i32 %69, 3
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !16
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 %75
  %77 = load ptr, ptr %76, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Quad, ptr %77, i32 0, i32 2
  store ptr %73, ptr %78, align 8, !tbaa !15
  br label %79

79:                                               ; preds = %56
  %80 = load i32, ptr %8, align 4, !tbaa !16
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %8, align 4, !tbaa !16
  br label %36, !llvm.loop !18

82:                                               ; preds = %39
  %83 = getelementptr inbounds [4 x ptr], ptr %5, i64 0, i64 0
  %84 = load ptr, ptr %83, align 16, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  ret ptr %84

85:                                               ; preds = %52, %48, %44, %40
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  br label %86

86:                                               ; preds = %85
  %87 = load ptr, ptr %6, align 8
  %88 = load i32, ptr %7, align 4
  %89 = insertvalue { ptr, i32 } poison, ptr %87, 0
  %90 = insertvalue { ptr, i32 } %89, i32 %88, 1
  resume { ptr, i32 } %90
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { nobuiltin allocsize(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 #4 = { nobuiltin nounwind "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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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, !11, i64 0}
!10 = !{!"_ZTS4Quad", !11, i64 0, !6, i64 8, !6, i64 16, !12, i64 24}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTS2PT", !13, i64 0, !13, i64 8}
!13 = !{!"long long", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !6, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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.PT = type { i64, i64 }

@arb = external dso_local global %struct.PT, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_Z9make_edge2PTS_(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  store i8 0, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = getelementptr inbounds i8, ptr %3, i64 16
  %6 = getelementptr inbounds i8, ptr %3, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  tail call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %7 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  store i8 0, ptr %7, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = getelementptr inbounds i8, ptr %7, i64 16
  %10 = getelementptr inbounds i8, ptr %7, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  tail call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) @arb)
  %11 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  store i8 0, ptr %11, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = getelementptr inbounds i8, ptr %11, i64 16
  %14 = getelementptr inbounds i8, ptr %11, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %12, i8 0, i64 16, i1 false)
  tail call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %15 = tail call noalias noundef nonnull dereferenceable(40) ptr @_Znwm(i64 noundef 40) #4
  store i8 0, ptr %15, align 16, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = getelementptr inbounds i8, ptr %15, i64 16
  %18 = getelementptr inbounds i8, ptr %15, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %16, i8 0, i64 16, i1 false)
  tail call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %18, ptr noundef nonnull align 8 dereferenceable(16) @arb)
  store ptr %3, ptr %4, align 8, !tbaa !13
  store ptr %7, ptr %5, align 8, !tbaa !14
  store ptr %15, ptr %8, align 8, !tbaa !13
  store ptr %11, ptr %9, align 8, !tbaa !14
  store ptr %11, ptr %12, align 8, !tbaa !13
  store ptr %15, ptr %13, align 8, !tbaa !14
  store ptr %7, ptr %16, align 8, !tbaa !13
  store ptr %3, ptr %17, align 8, !tbaa !14
  ret ptr %3
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 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 = { nobuiltin allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { builtin allocsize(0) }

!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, !7, i64 0}
!6 = !{!"_ZTS4Quad", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS2PT", !12, i64 0, !12, i64 8}
!12 = !{!"long long", !8, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}


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