; LLVM IR from yourtion/LearningMasteringAlgorithms-C :: source (bfs)

; 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.List_ = type { i32, ptr, ptr, ptr, ptr }
%struct.Graph_ = type { i32, i32, ptr, ptr, %struct.List_ }
%struct.ListElmt_ = type { ptr, ptr }
%struct.AdjList_ = type { ptr, %struct.List_ }
%struct.BfsVertex_ = type { ptr, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @bfs(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.List_, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Graph_, ptr %16, i32 0, i32 4
  %18 = getelementptr inbounds %struct.List_, ptr %17, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %13, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %47, %3
  %21 = load ptr, ptr %13, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %51

23:                                               ; preds = %20
  %24 = load ptr, ptr %13, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ListElmt_, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.AdjList_, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  store ptr %28, ptr %11, align 8, !tbaa !5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Graph_, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call i32 %31(ptr noundef %32, ptr noundef %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %23
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.BfsVertex_, ptr %37, i32 0, i32 1
  store i32 1, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.BfsVertex_, ptr %39, i32 0, i32 2
  store i32 0, ptr %40, align 4, !tbaa !20
  br label %46

41:                                               ; preds = %23
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.BfsVertex_, ptr %42, i32 0, i32 1
  store i32 0, ptr %43, align 8, !tbaa !18
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.BfsVertex_, ptr %44, i32 0, i32 2
  store i32 -1, ptr %45, align 4, !tbaa !20
  br label %46

46:                                               ; preds = %41, %36
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ListElmt_, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  store ptr %50, ptr %13, align 8, !tbaa !5
  br label %20, !llvm.loop !22

51:                                               ; preds = %20
  call void @list_init(ptr noundef %8, ptr noundef null)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = call i32 @graph_adjlist(ptr noundef %52, ptr noundef %53, ptr noundef %10)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %51
  call void @list_destroy(ptr noundef %8)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

57:                                               ; preds = %51
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = call i32 @queue_enqueue(ptr noundef %8, ptr noundef %58)
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %57
  call void @list_destroy(ptr noundef %8)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

62:                                               ; preds = %57
  br label %63

63:                                               ; preds = %133, %62
  %64 = getelementptr inbounds %struct.List_, ptr %8, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !24
  %66 = icmp sgt i32 %65, 0
  br i1 %66, label %67, label %134

67:                                               ; preds = %63
  %68 = getelementptr inbounds %struct.List_, ptr %8, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !25
  %70 = icmp eq ptr %69, null
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  br label %77

72:                                               ; preds = %67
  %73 = getelementptr inbounds %struct.List_, ptr %8, i32 0, i32 3
  %74 = load ptr, ptr %73, align 8, !tbaa !25
  %75 = getelementptr inbounds %struct.ListElmt_, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  br label %77

77:                                               ; preds = %72, %71
  %78 = phi ptr [ null, %71 ], [ %76, %72 ]
  store ptr %78, ptr %9, align 8, !tbaa !5
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.AdjList_, ptr %79, i32 0, i32 1
  %81 = getelementptr inbounds %struct.List_, ptr %80, i32 0, i32 3
  %82 = load ptr, ptr %81, align 8, !tbaa !26
  store ptr %82, ptr %14, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %120, %77
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = icmp ne ptr %84, null
  br i1 %85, label %86, label %124

86:                                               ; preds = %83
  %87 = load ptr, ptr %14, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.ListElmt_, ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !13
  store ptr %89, ptr %12, align 8, !tbaa !5
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = call i32 @graph_adjlist(ptr noundef %90, ptr noundef %91, ptr noundef %10)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %86
  call void @list_destroy(ptr noundef %8)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

95:                                               ; preds = %86
  %96 = load ptr, ptr %10, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.AdjList_, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !15
  store ptr %98, ptr %11, align 8, !tbaa !5
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.BfsVertex_, ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 8, !tbaa !18
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %119

103:                                              ; preds = %95
  %104 = load ptr, ptr %11, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.BfsVertex_, ptr %104, i32 0, i32 1
  store i32 1, ptr %105, align 8, !tbaa !18
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.AdjList_, ptr %106, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8, !tbaa !15
  %109 = getelementptr inbounds %struct.BfsVertex_, ptr %108, i32 0, i32 2
  %110 = load i32, ptr %109, align 4, !tbaa !20
  %111 = add nsw i32 %110, 1
  %112 = load ptr, ptr %11, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.BfsVertex_, ptr %112, i32 0, i32 2
  store i32 %111, ptr %113, align 4, !tbaa !20
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = call i32 @queue_enqueue(ptr noundef %8, ptr noundef %114)
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %118

117:                                              ; preds = %103
  call void @list_destroy(ptr noundef %8)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

118:                                              ; preds = %103
  br label %119

119:                                              ; preds = %118, %95
  br label %120

120:                                              ; preds = %119
  %121 = load ptr, ptr %14, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.ListElmt_, ptr %121, i32 0, i32 1
  %123 = load ptr, ptr %122, align 8, !tbaa !21
  store ptr %123, ptr %14, align 8, !tbaa !5
  br label %83, !llvm.loop !27

124:                                              ; preds = %83
  %125 = call i32 @queue_dequeue(ptr noundef %8, ptr noundef %9)
  %126 = icmp eq i32 %125, 0
  br i1 %126, label %127, label %132

127:                                              ; preds = %124
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.AdjList_, ptr %128, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8, !tbaa !15
  %131 = getelementptr inbounds %struct.BfsVertex_, ptr %130, i32 0, i32 1
  store i32 2, ptr %131, align 8, !tbaa !18
  br label %133

132:                                              ; preds = %124
  call void @list_destroy(ptr noundef %8)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

133:                                              ; preds = %127
  br label %63, !llvm.loop !28

134:                                              ; preds = %63
  call void @list_destroy(ptr noundef %8)
  %135 = load ptr, ptr %7, align 8, !tbaa !5
  call void @list_init(ptr noundef %135, ptr noundef null)
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.Graph_, ptr %136, i32 0, i32 4
  %138 = getelementptr inbounds %struct.List_, ptr %137, i32 0, i32 3
  %139 = load ptr, ptr %138, align 8, !tbaa !9
  store ptr %139, ptr %13, align 8, !tbaa !5
  br label %140

140:                                              ; preds = %165, %134
  %141 = load ptr, ptr %13, align 8, !tbaa !5
  %142 = icmp ne ptr %141, null
  br i1 %142, label %143, label %169

143:                                              ; preds = %140
  %144 = load ptr, ptr %13, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.ListElmt_, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !13
  %147 = getelementptr inbounds %struct.AdjList_, ptr %146, i32 0, i32 0
  %148 = load ptr, ptr %147, align 8, !tbaa !15
  store ptr %148, ptr %11, align 8, !tbaa !5
  %149 = load ptr, ptr %11, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.BfsVertex_, ptr %149, i32 0, i32 2
  %151 = load i32, ptr %150, align 4, !tbaa !20
  %152 = icmp ne i32 %151, -1
  br i1 %152, label %153, label %164

153:                                              ; preds = %143
  %154 = load ptr, ptr %7, align 8, !tbaa !5
  %155 = load ptr, ptr %7, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.List_, ptr %155, i32 0, i32 4
  %157 = load ptr, ptr %156, align 8, !tbaa !29
  %158 = load ptr, ptr %11, align 8, !tbaa !5
  %159 = call i32 @list_ins_next(ptr noundef %154, ptr noundef %157, ptr noundef %158)
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %161, label %163

161:                                              ; preds = %153
  %162 = load ptr, ptr %7, align 8, !tbaa !5
  call void @list_destroy(ptr noundef %162)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

163:                                              ; preds = %153
  br label %164

164:                                              ; preds = %163, %143
  br label %165

165:                                              ; preds = %164
  %166 = load ptr, ptr %13, align 8, !tbaa !5
  %167 = getelementptr inbounds %struct.ListElmt_, ptr %166, i32 0, i32 1
  %168 = load ptr, ptr %167, align 8, !tbaa !21
  store ptr %168, ptr %13, align 8, !tbaa !5
  br label %140, !llvm.loop !30

169:                                              ; preds = %140
  store i32 0, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %170

170:                                              ; preds = %169, %161, %132, %117, %94, %61, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #3
  %171 = load i32, ptr %4, align 4
  ret i32 %171
}

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

declare void @list_init(ptr noundef, ptr noundef) #2

declare i32 @graph_adjlist(ptr noundef, ptr noundef, ptr noundef) #2

declare void @list_destroy(ptr noundef) #2

declare i32 @queue_enqueue(ptr noundef, ptr noundef) #2

declare i32 @queue_dequeue(ptr noundef, ptr noundef) #2

declare i32 @list_ins_next(ptr noundef, ptr noundef, ptr noundef) #2

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"Graph_", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !12, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!"List_", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!14, !6, i64 0}
!14 = !{!"ListElmt_", !6, i64 0, !6, i64 8}
!15 = !{!16, !6, i64 0}
!16 = !{!"AdjList_", !6, i64 0, !12, i64 8}
!17 = !{!10, !6, i64 8}
!18 = !{!19, !11, i64 8}
!19 = !{!"BfsVertex_", !6, i64 0, !11, i64 8, !11, i64 12}
!20 = !{!19, !11, i64 12}
!21 = !{!14, !6, i64 8}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !11, i64 0}
!25 = !{!12, !6, i64 24}
!26 = !{!16, !6, i64 32}
!27 = distinct !{!27, !23}
!28 = distinct !{!28, !23}
!29 = !{!12, !6, i64 32}
!30 = distinct !{!30, !23}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @bfs(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.List_, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %.03143 = load ptr, ptr %7, align 8, !tbaa !5
  %.not44 = icmp eq ptr %.03143, null
  br i1 %.not44, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %.03145 = phi ptr [ %.03143, %.lr.ph ], [ %.031, %9 ]
  %10 = load ptr, ptr %.03145, align 8, !tbaa !9
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %8, align 8, !tbaa !15
  %13 = tail call i32 %12(ptr noundef %11, ptr noundef %1) #3
  %.not42 = icmp ne i32 %13, 0
  %spec.select = zext i1 %.not42 to i32
  %not..not42 = xor i1 %.not42, true
  %spec.select60 = sext i1 %not..not42 to i32
  %14 = getelementptr inbounds i8, ptr %11, i64 8
  store i32 %spec.select, ptr %14, align 8
  %15 = getelementptr inbounds i8, ptr %11, i64 12
  store i32 %spec.select60, ptr %15, align 4
  %16 = getelementptr inbounds i8, ptr %.03145, i64 8
  %.031 = load ptr, ptr %16, align 8, !tbaa !5
  %.not = icmp eq ptr %.031, null
  br i1 %.not, label %._crit_edge, label %9, !llvm.loop !17

._crit_edge:                                      ; preds = %9, %3
  call void @list_init(ptr noundef nonnull %4, ptr noundef null) #3
  %17 = call i32 @graph_adjlist(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull %6) #3
  %.not34 = icmp eq i32 %17, 0
  br i1 %.not34, label %18, label %.loopexit.sink.split

18:                                               ; preds = %._crit_edge
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i32 @queue_enqueue(ptr noundef nonnull %4, ptr noundef %19) #3
  %.not35 = icmp eq i32 %20, 0
  br i1 %.not35, label %.preheader, label %.loopexit.sink.split

.preheader:                                       ; preds = %18
  %21 = load i32, ptr %4, align 8, !tbaa !19
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph52, label %._crit_edge53

.lr.ph52:                                         ; preds = %.preheader
  %23 = getelementptr inbounds i8, ptr %4, i64 24
  br label %24

24:                                               ; preds = %.lr.ph52, %48
  %25 = load ptr, ptr %23, align 8, !tbaa !20, !nonnull !21, !noundef !21
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  store ptr %26, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 32
  %.046 = load ptr, ptr %27, align 8, !tbaa !5
  %.not3947 = icmp eq ptr %.046, null
  br i1 %.not3947, label %._crit_edge51, label %.lr.ph50

.lr.ph50:                                         ; preds = %24, %44
  %.048 = phi ptr [ %.0, %44 ], [ %.046, %24 ]
  %28 = load ptr, ptr %.048, align 8, !tbaa !9
  %29 = call i32 @graph_adjlist(ptr noundef %0, ptr noundef %28, ptr noundef nonnull %6) #3
  %.not40 = icmp eq i32 %29, 0
  br i1 %.not40, label %30, label %.loopexit.sink.split

30:                                               ; preds = %.lr.ph50
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %32, i64 8
  %34 = load i32, ptr %33, align 8, !tbaa !22
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %44

36:                                               ; preds = %30
  store i32 1, ptr %33, align 8, !tbaa !22
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds i8, ptr %38, i64 12
  %40 = load i32, ptr %39, align 4, !tbaa !24
  %41 = add nsw i32 %40, 1
  %42 = getelementptr inbounds i8, ptr %32, i64 12
  store i32 %41, ptr %42, align 4, !tbaa !24
  %43 = call i32 @queue_enqueue(ptr noundef nonnull %4, ptr noundef nonnull %31) #3
  %.not41 = icmp eq i32 %43, 0
  br i1 %.not41, label %44, label %.loopexit.sink.split

44:                                               ; preds = %30, %36
  %45 = getelementptr inbounds i8, ptr %.048, i64 8
  %.0 = load ptr, ptr %45, align 8, !tbaa !5
  %.not39 = icmp eq ptr %.0, null
  br i1 %.not39, label %._crit_edge51, label %.lr.ph50, !llvm.loop !25

._crit_edge51:                                    ; preds = %44, %24
  %46 = call i32 @queue_dequeue(ptr noundef nonnull %4, ptr noundef nonnull %5) #3
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %.loopexit.sink.split

48:                                               ; preds = %._crit_edge51
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = getelementptr inbounds i8, ptr %50, i64 8
  store i32 2, ptr %51, align 8, !tbaa !22
  %52 = load i32, ptr %4, align 8, !tbaa !19
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %24, label %._crit_edge53, !llvm.loop !26

._crit_edge53:                                    ; preds = %48, %.preheader
  call void @list_destroy(ptr noundef nonnull %4) #3
  call void @list_init(ptr noundef %2, ptr noundef null) #3
  %.154 = load ptr, ptr %7, align 8, !tbaa !5
  %.not3655 = icmp eq ptr %.154, null
  br i1 %.not3655, label %.loopexit, label %.lr.ph58

.lr.ph58:                                         ; preds = %._crit_edge53
  %54 = getelementptr inbounds i8, ptr %2, i64 32
  br label %55

55:                                               ; preds = %.lr.ph58, %63
  %.156 = phi ptr [ %.154, %.lr.ph58 ], [ %.1, %63 ]
  %56 = load ptr, ptr %.156, align 8, !tbaa !9
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds i8, ptr %57, i64 12
  %59 = load i32, ptr %58, align 4, !tbaa !24
  %.not37 = icmp eq i32 %59, -1
  br i1 %.not37, label %63, label %60

60:                                               ; preds = %55
  %61 = load ptr, ptr %54, align 8, !tbaa !27
  %62 = call i32 @list_ins_next(ptr noundef %2, ptr noundef %61, ptr noundef nonnull %57) #3
  %.not38 = icmp eq i32 %62, 0
  br i1 %.not38, label %63, label %.loopexit.sink.split

63:                                               ; preds = %55, %60
  %64 = getelementptr inbounds i8, ptr %.156, i64 8
  %.1 = load ptr, ptr %64, align 8, !tbaa !5
  %.not36 = icmp eq ptr %.1, null
  br i1 %.not36, label %.loopexit, label %55, !llvm.loop !28

.loopexit.sink.split:                             ; preds = %._crit_edge51, %36, %.lr.ph50, %60, %18, %._crit_edge
  %.sink = phi ptr [ %4, %._crit_edge ], [ %4, %18 ], [ %2, %60 ], [ %4, %.lr.ph50 ], [ %4, %36 ], [ %4, %._crit_edge51 ]
  call void @list_destroy(ptr noundef nonnull %.sink) #3
  br label %.loopexit

.loopexit:                                        ; preds = %63, %.loopexit.sink.split, %._crit_edge53
  %.032 = phi i32 [ 0, %._crit_edge53 ], [ -1, %.loopexit.sink.split ], [ 0, %63 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #3
  ret i32 %.032
}

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

declare void @list_init(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @graph_adjlist(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @list_destroy(ptr noundef) local_unnamed_addr #2

declare i32 @queue_enqueue(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @queue_dequeue(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @list_ins_next(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"ListElmt_", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 0}
!12 = !{!"AdjList_", !6, i64 0, !13, i64 8}
!13 = !{!"List_", !14, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"Graph_", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 16, !13, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!13, !14, i64 0}
!20 = !{!13, !6, i64 24}
!21 = !{}
!22 = !{!23, !14, i64 8}
!23 = !{!"BfsVertex_", !6, i64 0, !14, i64 8, !14, i64 12}
!24 = !{!23, !14, i64 12}
!25 = distinct !{!25, !18}
!26 = distinct !{!26, !18}
!27 = !{!13, !6, i64 32}
!28 = distinct !{!28, !18}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass