; LLVM IR from smv1999/CompetitiveProgrammingQuestionBank :: Data Structures/Graphs/Representation (Adjacency_List)

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

@.str = external hidden unnamed_addr constant [26 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: mustprogress uwtable
define dso_local void @_Z17delete_from_graphP13AdjacencyListi(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.AdjacencyList, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %104

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.AdjacencyList, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.AdjacencyList, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !13
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = icmp eq i32 %19, %20
  br i1 %21, label %22, label %28

22:                                               ; preds = %13
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.AdjacencyList, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.AdjacencyList, ptr %26, i32 0, i32 1
  store ptr %25, ptr %27, align 8, !tbaa !11
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %60

28:                                               ; preds = %13
  br label %29

29:                                               ; preds = %42, %28
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.AdjacencyList, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %40

34:                                               ; preds = %29
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.AdjacencyList, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br label %40

40:                                               ; preds = %34, %29
  %41 = phi i1 [ false, %29 ], [ %39, %34 ]
  br i1 %41, label %42, label %47

42:                                               ; preds = %40
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %43, ptr %7, align 8, !tbaa !5
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.AdjacencyList, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  store ptr %46, ptr %6, align 8, !tbaa !5
  br label %29, !llvm.loop !15

47:                                               ; preds = %40
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.AdjacencyList, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = load i32, ptr %4, align 4, !tbaa !9
  %52 = icmp eq i32 %50, %51
  br i1 %52, label %53, label %59

53:                                               ; preds = %47
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.AdjacencyList, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.AdjacencyList, ptr %57, i32 0, i32 2
  store ptr %56, ptr %58, align 8, !tbaa !14
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %53, %47
  br label %60

60:                                               ; preds = %59, %22
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.AdjacencyList, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  store ptr %63, ptr %6, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %99, %60
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %103

67:                                               ; preds = %64
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %68, ptr %7, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %82, %67
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.AdjacencyList, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %80

74:                                               ; preds = %69
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.AdjacencyList, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !13
  %78 = load i32, ptr %4, align 4, !tbaa !9
  %79 = icmp ne i32 %77, %78
  br label %80

80:                                               ; preds = %74, %69
  %81 = phi i1 [ false, %69 ], [ %79, %74 ]
  br i1 %81, label %82, label %87

82:                                               ; preds = %80
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %83, ptr %8, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.AdjacencyList, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !11
  store ptr %86, ptr %7, align 8, !tbaa !5
  br label %69, !llvm.loop !17

87:                                               ; preds = %80
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.AdjacencyList, ptr %88, i32 0, i32 0
  %90 = load i32, ptr %89, align 8, !tbaa !13
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = icmp eq i32 %90, %91
  br i1 %92, label %93, label %99

93:                                               ; preds = %87
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.AdjacencyList, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.AdjacencyList, ptr %97, i32 0, i32 1
  store ptr %96, ptr %98, align 8, !tbaa !11
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %99

99:                                               ; preds = %93, %87
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.AdjacencyList, ptr %100, i32 0, i32 2
  %102 = load ptr, ptr %101, align 8, !tbaa !14
  store ptr %102, ptr %6, align 8, !tbaa !5
  br label %64, !llvm.loop !18

103:                                              ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %104

104:                                              ; preds = %103, %2
  %105 = load i32, ptr %5, align 4, !tbaa !9
  %106 = icmp eq i32 %105, 0
  br i1 %106, label %107, label %110

107:                                              ; preds = %104
  %108 = load i32, ptr %4, align 4, !tbaa !9
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %108)
  br label %110

110:                                              ; preds = %107, %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!12, !6, i64 8}
!12 = !{!"_ZTS13AdjacencyList", !10, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 0}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; 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 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local void @_Z17delete_from_graphP13AdjacencyListi(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.critedge46, label %5

5:                                                ; preds = %2
  %6 = load i32, ptr %4, align 8, !tbaa !9
  %7 = icmp eq i32 %6, %1
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  br i1 %7, label %11, label %.preheader47

.preheader47:                                     ; preds = %5
  %.not4049 = icmp eq ptr %9, null
  br i1 %.not4049, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader47
  %10 = load i32, ptr %4, align 8, !tbaa !9
  %.not4189 = icmp ne i32 %10, %1
  tail call void @llvm.assume(i1 %.not4189)
  br label %.lr.ph91

11:                                               ; preds = %5
  store ptr %9, ptr %3, align 8, !tbaa !13
  br label %18

.lr.ph91:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0335090 = phi ptr [ %12, %.lr.ph ], [ %4, %.lr.ph.preheader ]
  %12 = phi ptr [ %14, %.lr.ph ], [ %9, %.lr.ph.preheader ]
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %.not40 = icmp eq ptr %14, null
  %.pre.pre = load i32, ptr %12, align 8, !tbaa !9
  br i1 %.not40, label %.critedge, label %.lr.ph, !llvm.loop !14

.lr.ph:                                           ; preds = %.lr.ph91
  %.not41 = icmp eq i32 %.pre.pre, %1
  br i1 %.not41, label %.critedge.thread, label %.lr.ph91, !llvm.loop !14

.critedge:                                        ; preds = %.lr.ph91, %.preheader47
  %15 = phi i32 [ %6, %.preheader47 ], [ %.pre.pre, %.lr.ph91 ]
  %.031.lcssa = phi ptr [ undef, %.preheader47 ], [ %.0335090, %.lr.ph91 ]
  %16 = icmp eq i32 %15, %1
  br i1 %16, label %.critedge.thread, label %18

.critedge.thread:                                 ; preds = %.lr.ph, %.critedge
  %.lcssa4880 = phi ptr [ null, %.critedge ], [ %14, %.lr.ph ]
  %.031.lcssa79 = phi ptr [ %.031.lcssa, %.critedge ], [ %.0335090, %.lr.ph ]
  %17 = getelementptr inbounds i8, ptr %.031.lcssa79, i64 16
  store ptr %.lcssa4880, ptr %17, align 8, !tbaa !12
  %.13469.pre = load ptr, ptr %3, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %.critedge, %.critedge.thread, %11
  %.13469 = phi ptr [ %9, %11 ], [ %.13469.pre, %.critedge.thread ], [ %4, %.critedge ]
  %.035 = phi i32 [ 1, %11 ], [ 1, %.critedge.thread ], [ 0, %.critedge ]
  %.not4270 = icmp eq ptr %.13469, null
  br i1 %.not4270, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %18, %30
  %.13473 = phi ptr [ %.134, %30 ], [ %.13469, %18 ]
  %.072 = phi ptr [ %.1.lcssa, %30 ], [ undef, %18 ]
  %.13671 = phi i32 [ %.2, %30 ], [ %.035, %18 ]
  %19 = getelementptr inbounds i8, ptr %.13473, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %.not4358 = icmp eq ptr %20, null
  br i1 %.not4358, label %.critedge2, label %.lr.ph61.preheader

.lr.ph61.preheader:                               ; preds = %.preheader
  %21 = load i32, ptr %.13473, align 8, !tbaa !9
  %.not4493 = icmp eq i32 %21, %1
  br i1 %.not4493, label %.critedge2, label %.lr.ph95, !llvm.loop !16

.lr.ph95:                                         ; preds = %.lr.ph61.preheader, %.lr.ph61
  %.1325994 = phi ptr [ %22, %.lr.ph61 ], [ %.13473, %.lr.ph61.preheader ]
  %22 = phi ptr [ %24, %.lr.ph61 ], [ %20, %.lr.ph61.preheader ]
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %.not43 = icmp eq ptr %24, null
  br i1 %.not43, label %.critedge2, label %.lr.ph61, !llvm.loop !16

.lr.ph61:                                         ; preds = %.lr.ph95
  %25 = load i32, ptr %22, align 8, !tbaa !9
  %.not44 = icmp eq i32 %25, %1
  br i1 %.not44, label %.critedge2, label %.lr.ph95, !llvm.loop !16

.critedge2:                                       ; preds = %.lr.ph95, %.lr.ph61, %.lr.ph61.preheader, %.preheader
  %.132.lcssa = phi ptr [ %.13473, %.preheader ], [ %.13473, %.lr.ph61.preheader ], [ %22, %.lr.ph61 ], [ %22, %.lr.ph95 ]
  %.1.lcssa = phi ptr [ %.072, %.preheader ], [ %.072, %.lr.ph61.preheader ], [ %.1325994, %.lr.ph61 ], [ %.1325994, %.lr.ph95 ]
  %.lcssa = phi ptr [ null, %.preheader ], [ %20, %.lr.ph61.preheader ], [ %24, %.lr.ph61 ], [ null, %.lr.ph95 ]
  %26 = load i32, ptr %.132.lcssa, align 8, !tbaa !9
  %27 = icmp eq i32 %26, %1
  br i1 %27, label %28, label %30

28:                                               ; preds = %.critedge2
  %29 = getelementptr inbounds i8, ptr %.1.lcssa, i64 8
  store ptr %.lcssa, ptr %29, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %28, %.critedge2
  %.2 = phi i32 [ 1, %28 ], [ %.13671, %.critedge2 ]
  %31 = getelementptr inbounds i8, ptr %.13473, i64 16
  %.134 = load ptr, ptr %31, align 8, !tbaa !5
  %.not42 = icmp eq ptr %.134, null
  br i1 %.not42, label %._crit_edge, label %.preheader, !llvm.loop !17

._crit_edge:                                      ; preds = %30, %18
  %.136.lcssa = phi i32 [ %.035, %18 ], [ %.2, %30 ]
  %32 = icmp eq i32 %.136.lcssa, 0
  br i1 %32, label %.critedge46, label %34

.critedge46:                                      ; preds = %2, %._crit_edge
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %1)
  br label %34

34:                                               ; preds = %.critedge46, %._crit_edge
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #2

attributes #0 = { mustprogress nofree 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 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 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }

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


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass