; LLVM IR from ahampriyanshu/algo-ds-101 :: Data-Structures/LinkedList/Singly_Linked_List/Remove duplicates in a Linked List.l_a71fa51e (Z9deleteNumv)

; 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.Node = type { i32, ptr }

@head = external dso_local global ptr, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z9deleteNumv() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load ptr, ptr @head, align 8, !tbaa !5
  store ptr %4, ptr %1, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %35, %0
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %39

8:                                                ; preds = %5
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = getelementptr inbounds %class.Node, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %2, align 8, !tbaa !5
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %12, ptr %3, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %30, %8
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %35

16:                                               ; preds = %13
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.Node, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !12
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.Node, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %23 = icmp eq i32 %19, %22
  br i1 %23, label %24, label %30

24:                                               ; preds = %16
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.Node, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.Node, ptr %28, i32 0, i32 1
  store ptr %27, ptr %29, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %24, %16
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %31, ptr %3, align 8, !tbaa !5
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.Node, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  store ptr %34, ptr %2, align 8, !tbaa !5
  br label %13, !llvm.loop !13

35:                                               ; preds = %13
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  %37 = getelementptr inbounds %class.Node, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  store ptr %38, ptr %1, align 8, !tbaa !5
  br label %5, !llvm.loop !15

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

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 = { 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 8}
!10 = !{!"_ZTS4Node", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@head = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_Z9deleteNumv() local_unnamed_addr #0 {
  %.01218 = load ptr, ptr @head, align 8, !tbaa !5
  %.not19 = icmp eq ptr %.01218, null
  br i1 %.not19, label %._crit_edge, label %.lr.ph21

.loopexit:                                        ; preds = %._crit_edge22
  %.012.pre = load ptr, ptr %1, align 8, !tbaa !5
  %.not = icmp eq ptr %.012.pre, null
  br i1 %.not, label %._crit_edge, label %.lr.ph21, !llvm.loop !9

.lr.ph21:                                         ; preds = %0, %.loopexit
  %.01220 = phi ptr [ %.012.pre, %.loopexit ], [ %.01218, %0 ]
  %1 = getelementptr inbounds i8, ptr %.01220, i64 8
  %.01114 = load ptr, ptr %1, align 8, !tbaa !5
  %.not1315 = icmp eq ptr %.01114, null
  br i1 %.not1315, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph21
  %2 = load i32, ptr %.01220, align 8, !tbaa !11
  br label %3

3:                                                ; preds = %.lr.ph, %._crit_edge22
  %.01117 = phi ptr [ %.01114, %.lr.ph ], [ %7, %._crit_edge22 ]
  %.016 = phi ptr [ %.01220, %.lr.ph ], [ %.01117, %._crit_edge22 ]
  %4 = load i32, ptr %.01117, align 8, !tbaa !11
  %5 = icmp eq i32 %2, %4
  %6 = getelementptr inbounds i8, ptr %.01117, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  br i1 %5, label %8, label %._crit_edge22

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %.016, i64 8
  store ptr %7, ptr %9, align 8, !tbaa !14
  br label %._crit_edge22

._crit_edge22:                                    ; preds = %3, %8
  %.not13 = icmp eq ptr %7, null
  br i1 %.not13, label %.loopexit, label %3, !llvm.loop !15

._crit_edge:                                      ; preds = %.loopexit, %.lr.ph21, %0
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS4Node", !13, i64 0, !6, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass