; LLVM IR from bqi343/cp-notebook :: Implementations/content/graphs (12)/Advanced/LCTtest.ll (Z6delNexP5snode)

; 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.snode = type { ptr, [2 x ptr], ptr, i8, i32, i32, i32, i32, i64, i64 }

@.str.3 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@__PRETTY_FUNCTION__._Z6delNexP5snode = external hidden unnamed_addr constant [16 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9connectedP5snodeS0_(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4linkP5snodeS0_b(ptr noundef, ptr noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6delNexP5snode(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = call noundef ptr @_ZN5snode7getRootEv(ptr noundef nonnull align 8 dereferenceable(72) %5)
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = icmp eq ptr %7, %8
  br i1 %9, label %10, label %13

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.snode, ptr %11, i32 0, i32 2
  store ptr null, ptr %12, align 8, !tbaa !9
  store i32 1, ptr %4, align 4
  br label %36

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z3cutP5snode(ptr noundef %14)
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.snode, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %13
  br label %22

20:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 324, ptr noundef @__PRETTY_FUNCTION__._Z6delNexP5snode) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.snode, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = call noundef zeroext i1 @_Z9connectedP5snodeS0_(ptr noundef %23, ptr noundef %26)
  br i1 %27, label %35, label %28

28:                                               ; preds = %22
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.snode, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_Z4linkP5snodeS0_b(ptr noundef %31, ptr noundef %32, i1 noundef zeroext false)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.snode, ptr %33, i32 0, i32 2
  store ptr null, ptr %34, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %28, %22
  store i32 0, ptr %4, align 4
  br label %36

36:                                               ; preds = %35, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %37 = load i32, ptr %4, align 4
  switch i32 %37, label %39 [
    i32 0, label %38
    i32 1, label %38
  ]

38:                                               ; preds = %36, %36
  ret void

39:                                               ; preds = %36
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5snode7getRootEv(ptr noundef nonnull align 8 dereferenceable(72)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3cutP5snode(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { nounwind }
attributes #4 = { noreturn 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, !6, i64 24}
!10 = !{!"_ZTS5snode", !6, i64 0, !7, i64 8, !6, i64 24, !11, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !13, i64 56, !13, i64 64}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long long", !7, i64 0}


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

@.str.3 = external hidden unnamed_addr constant [109 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@__PRETTY_FUNCTION__._Z6delNexP5snode = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9connectedP5snodeS0_(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4linkP5snodeS0_b(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6delNexP5snode(ptr noundef nonnull %0) local_unnamed_addr #1 {
  %2 = tail call noundef ptr @_ZN5snode7getRootEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %3 = icmp eq ptr %2, %0
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %2, i64 24
  br label %.sink.split

6:                                                ; preds = %1
  tail call void @_Z3cutP5snode(ptr noundef nonnull %0)
  %7 = getelementptr inbounds i8, ptr %2, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 324, ptr noundef nonnull @__PRETTY_FUNCTION__._Z6delNexP5snode) #2
  unreachable

10:                                               ; preds = %6
  %11 = tail call noundef zeroext i1 @_Z9connectedP5snodeS0_(ptr noundef nonnull %2, ptr noundef nonnull %8)
  br i1 %11, label %14, label %12

12:                                               ; preds = %10
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @_Z4linkP5snodeS0_b(ptr noundef %13, ptr noundef nonnull %2, i1 noundef zeroext false)
  br label %.sink.split

.sink.split:                                      ; preds = %4, %12
  %.sink = phi ptr [ %7, %12 ], [ %5, %4 ]
  store ptr null, ptr %.sink, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %.sink.split, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN5snode7getRootEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3cutP5snode(ptr noundef) local_unnamed_addr #1

attributes #0 = { noreturn 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 #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 = { noreturn 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, !7, i64 24}
!6 = !{!"_ZTS5snode", !7, i64 0, !8, i64 8, !7, i64 24, !10, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !12, i64 56, !12, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long long", !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass