; LLVM IR from HarshCasper/NeoAlgo :: C-Plus-Plus/cp/Lee_Algorithm.ll (Z3bfsPA10_iiiii)

; 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.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl" }
%"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl" = type { %"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl_data" }
%"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.Node = type { i32, i32, i32 }

@direction = external dso_local global [4 x [2 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3bfsPA10_iiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 personality ptr @__gxx_personality_v0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %"class.std::queue", align 8
  %13 = alloca [10 x [10 x i8]], align 16
  %14 = alloca %struct.Node, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %struct.Node, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca %struct.Node, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 80, ptr %12) #6
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %12)
  call void @llvm.lifetime.start.p0(i64 100, ptr %13) #6
  %25 = getelementptr inbounds [10 x [10 x i8]], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %25, i8 0, i64 100, i1 false)
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10 x [10 x i8]], ptr %13, i64 0, i64 %27
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [10 x i8], ptr %28, i64 0, i64 %30
  store i8 1, ptr %31, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #6
  %32 = getelementptr inbounds %struct.Node, ptr %14, i32 0, i32 0
  %33 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %33, ptr %32, align 4, !tbaa !13
  %34 = getelementptr inbounds %struct.Node, ptr %14, i32 0, i32 1
  %35 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %35, ptr %34, align 4, !tbaa !15
  %36 = getelementptr inbounds %struct.Node, ptr %14, i32 0, i32 2
  store i32 0, ptr %36, align 4, !tbaa !16
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %12, ptr noundef nonnull align 4 dereferenceable(12) %14)
          to label %37 unwind label %62

37:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 2147483647, ptr %17, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %147, %37
  %39 = invoke noundef zeroext i1 @_ZNKSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %12)
          to label %40 unwind label %66

40:                                               ; preds = %38
  %41 = xor i1 %39, true
  br i1 %41, label %42, label %149

42:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 12, ptr %18) #6
  %43 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %12)
          to label %44 unwind label %70

44:                                               ; preds = %42
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %43, i64 12, i1 false), !tbaa.struct !17
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %12)
          to label %45 unwind label %70

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %46 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 0
  %47 = load i32, ptr %46, align 4, !tbaa !13
  store i32 %47, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %48 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 1
  %49 = load i32, ptr %48, align 4, !tbaa !15
  store i32 %49, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %50 = getelementptr inbounds %struct.Node, ptr %18, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !16
  store i32 %51, ptr %21, align 4, !tbaa !9
  %52 = load i32, ptr %19, align 4, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = icmp eq i32 %52, %53
  br i1 %54, label %55, label %74

55:                                               ; preds = %45
  %56 = load i32, ptr %20, align 4, !tbaa !9
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = icmp eq i32 %56, %57
  br i1 %58, label %59, label %74

59:                                               ; preds = %55
  %60 = load i32, ptr %21, align 4, !tbaa !9
  store i32 %60, ptr %17, align 4, !tbaa !9
  %61 = load i32, ptr %17, align 4, !tbaa !9
  store i32 %61, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %145

62:                                               ; preds = %5
  %63 = landingpad { ptr, i32 }
          cleanup
  %64 = extractvalue { ptr, i32 } %63, 0
  store ptr %64, ptr %15, align 8
  %65 = extractvalue { ptr, i32 } %63, 1
  store i32 %65, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #6
  br label %153

66:                                               ; preds = %38
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %15, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %16, align 4
  br label %152

70:                                               ; preds = %44, %42
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %15, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %16, align 4
  br label %148

74:                                               ; preds = %55, %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  store i32 0, ptr %23, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %141, %74
  %76 = load i32, ptr %23, align 4, !tbaa !9
  %77 = icmp slt i32 %76, 4
  br i1 %77, label %79, label %78

78:                                               ; preds = %75
  store i32 4, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  br label %144

79:                                               ; preds = %75
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds [10 x [10 x i8]], ptr %13, i64 0, i64 0
  %82 = load i32, ptr %19, align 4, !tbaa !9
  %83 = load i32, ptr %23, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %84
  %86 = getelementptr inbounds [2 x i32], ptr %85, i64 0, i64 0
  %87 = load i32, ptr %86, align 8, !tbaa !9
  %88 = add nsw i32 %82, %87
  %89 = load i32, ptr %20, align 4, !tbaa !9
  %90 = load i32, ptr %23, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %91
  %93 = getelementptr inbounds [2 x i32], ptr %92, i64 0, i64 1
  %94 = load i32, ptr %93, align 4, !tbaa !9
  %95 = add nsw i32 %89, %94
  %96 = call noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef %80, ptr noundef %81, i32 noundef %88, i32 noundef %95)
  br i1 %96, label %97, label %140

97:                                               ; preds = %79
  %98 = load i32, ptr %19, align 4, !tbaa !9
  %99 = load i32, ptr %23, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %100
  %102 = getelementptr inbounds [2 x i32], ptr %101, i64 0, i64 0
  %103 = load i32, ptr %102, align 8, !tbaa !9
  %104 = add nsw i32 %98, %103
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [10 x [10 x i8]], ptr %13, i64 0, i64 %105
  %107 = load i32, ptr %20, align 4, !tbaa !9
  %108 = load i32, ptr %23, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %109
  %111 = getelementptr inbounds [2 x i32], ptr %110, i64 0, i64 1
  %112 = load i32, ptr %111, align 4, !tbaa !9
  %113 = add nsw i32 %107, %112
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [10 x i8], ptr %106, i64 0, i64 %114
  store i8 1, ptr %115, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 12, ptr %24) #6
  %116 = getelementptr inbounds %struct.Node, ptr %24, i32 0, i32 0
  %117 = load i32, ptr %19, align 4, !tbaa !9
  %118 = load i32, ptr %23, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %119
  %121 = getelementptr inbounds [2 x i32], ptr %120, i64 0, i64 0
  %122 = load i32, ptr %121, align 8, !tbaa !9
  %123 = add nsw i32 %117, %122
  store i32 %123, ptr %116, align 4, !tbaa !13
  %124 = getelementptr inbounds %struct.Node, ptr %24, i32 0, i32 1
  %125 = load i32, ptr %20, align 4, !tbaa !9
  %126 = load i32, ptr %23, align 4, !tbaa !9
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [4 x [2 x i32]], ptr @direction, i64 0, i64 %127
  %129 = getelementptr inbounds [2 x i32], ptr %128, i64 0, i64 1
  %130 = load i32, ptr %129, align 4, !tbaa !9
  %131 = add nsw i32 %125, %130
  store i32 %131, ptr %124, align 4, !tbaa !15
  %132 = getelementptr inbounds %struct.Node, ptr %24, i32 0, i32 2
  %133 = load i32, ptr %21, align 4, !tbaa !9
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %132, align 4, !tbaa !16
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %12, ptr noundef nonnull align 4 dereferenceable(12) %24)
          to label %135 unwind label %136

135:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 12, ptr %24) #6
  br label %140

136:                                              ; preds = %97
  %137 = landingpad { ptr, i32 }
          cleanup
  %138 = extractvalue { ptr, i32 } %137, 0
  store ptr %138, ptr %15, align 8
  %139 = extractvalue { ptr, i32 } %137, 1
  store i32 %139, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 12, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %148

140:                                              ; preds = %135, %79
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %23, align 4, !tbaa !9
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %23, align 4, !tbaa !9
  br label %75, !llvm.loop !18

144:                                              ; preds = %78
  store i32 0, ptr %22, align 4
  br label %145

145:                                              ; preds = %144, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #6
  %146 = load i32, ptr %22, align 4
  switch i32 %146, label %150 [
    i32 0, label %147
  ]

147:                                              ; preds = %145
  br label %38, !llvm.loop !20

148:                                              ; preds = %136, %70
  call void @llvm.lifetime.end.p0(i64 12, ptr %18) #6
  br label %152

149:                                              ; preds = %40
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %150

150:                                              ; preds = %149, %145
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 100, ptr %13) #6
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %12) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %12) #6
  %151 = load i32, ptr %6, align 4
  ret i32 %151

152:                                              ; preds = %148, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %153

153:                                              ; preds = %152, %62
  call void @llvm.lifetime.end.p0(i64 100, ptr %13) #6
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %12) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %12) #6
  br label %154

154:                                              ; preds = %153
  %155 = load ptr, ptr %15, align 8
  %156 = load i32, ptr %16, align 4
  %157 = insertvalue { ptr, i32 } poison, ptr %155, 0
  %158 = insertvalue { ptr, i32 } %157, i32 %156, 1
  resume { ptr, i32 } %158
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #5 align 2

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


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

%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl" }
%"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl" = type { %"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl_data" }
%"struct.std::_Deque_base<Node, std::allocator<Node>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%struct.Node = type { i32, i32, i32 }

@direction = external dso_local local_unnamed_addr global [4 x [2 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3bfsPA10_iiiii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.std::queue", align 8
  %7 = alloca [10 x [10 x i8]], align 16
  %8 = alloca %struct.Node, align 4
  %9 = alloca %struct.Node, align 4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %6) #5
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %7) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) %7, i8 0, i64 100, i1 false)
  %10 = sext i32 %1 to i64
  %11 = sext i32 %2 to i64
  %12 = getelementptr inbounds [10 x [10 x i8]], ptr %7, i64 0, i64 %10, i64 %11
  store i8 1, ptr %12, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #5
  store i32 %1, ptr %8, align 4, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %2, ptr %13, align 4, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %8, i64 8
  store i32 0, ptr %14, align 4, !tbaa !13
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 4 dereferenceable(12) %8)
          to label %15 unwind label %29

15:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  %16 = call noundef zeroext i1 @_ZNKSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  br i1 %16, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %15
  %17 = getelementptr inbounds i8, ptr %9, i64 4
  %18 = getelementptr inbounds i8, ptr %9, i64 8
  br label %19

19:                                               ; preds = %.lr.ph, %.loopexit
  %20 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  %.sroa.0.0.copyload = load i32, ptr %20, align 4, !tbaa !14
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %20, i64 4
  %.sroa.5.0.copyload = load i32, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !14
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %20, i64 8
  %.sroa.6.0.copyload = load i32, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !14
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  %21 = icmp eq i32 %.sroa.0.0.copyload, %3
  %22 = icmp eq i32 %.sroa.5.0.copyload, %4
  %or.cond = select i1 %21, i1 %22, i1 false
  br i1 %or.cond, label %.thread, label %.preheader

.preheader:                                       ; preds = %19
  %23 = add nsw i32 %.sroa.6.0.copyload, 1
  %24 = load i32, ptr @direction, align 16, !tbaa !14
  %25 = add nsw i32 %24, %.sroa.0.0.copyload
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 4), align 4, !tbaa !14
  %27 = add nsw i32 %26, %.sroa.5.0.copyload
  %28 = call noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef %0, ptr noundef nonnull %7, i32 noundef %25, i32 noundef %27)
  br i1 %28, label %31, label %42

29:                                               ; preds = %5
  %30 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  br label %88

31:                                               ; preds = %.preheader
  %32 = load i32, ptr @direction, align 16, !tbaa !14
  %33 = add nsw i32 %32, %.sroa.0.0.copyload
  %34 = sext i32 %33 to i64
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 4), align 4, !tbaa !14
  %36 = add nsw i32 %35, %.sroa.5.0.copyload
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [10 x [10 x i8]], ptr %7, i64 0, i64 %34, i64 %37
  store i8 1, ptr %38, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  store i32 %33, ptr %9, align 4, !tbaa !9
  store i32 %36, ptr %17, align 4, !tbaa !12
  store i32 %23, ptr %18, align 4, !tbaa !13
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %39 unwind label %40

39:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %42

40:                                               ; preds = %78, %63, %48, %31
  %41 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %88

42:                                               ; preds = %.preheader, %39
  %43 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 8), align 8, !tbaa !14
  %44 = add nsw i32 %43, %.sroa.0.0.copyload
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 12), align 4, !tbaa !14
  %46 = add nsw i32 %45, %.sroa.5.0.copyload
  %47 = call noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef %0, ptr noundef nonnull %7, i32 noundef %44, i32 noundef %46)
  br i1 %47, label %48, label %57

48:                                               ; preds = %42
  %49 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 8), align 8, !tbaa !14
  %50 = add nsw i32 %49, %.sroa.0.0.copyload
  %51 = sext i32 %50 to i64
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 12), align 4, !tbaa !14
  %53 = add nsw i32 %52, %.sroa.5.0.copyload
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [10 x [10 x i8]], ptr %7, i64 0, i64 %51, i64 %54
  store i8 1, ptr %55, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  store i32 %50, ptr %9, align 4, !tbaa !9
  store i32 %53, ptr %17, align 4, !tbaa !12
  store i32 %23, ptr %18, align 4, !tbaa !13
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %56 unwind label %40

56:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %57

57:                                               ; preds = %56, %42
  %58 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 16), align 16, !tbaa !14
  %59 = add nsw i32 %58, %.sroa.0.0.copyload
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 20), align 4, !tbaa !14
  %61 = add nsw i32 %60, %.sroa.5.0.copyload
  %62 = call noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef %0, ptr noundef nonnull %7, i32 noundef %59, i32 noundef %61)
  br i1 %62, label %63, label %72

63:                                               ; preds = %57
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 16), align 16, !tbaa !14
  %65 = add nsw i32 %64, %.sroa.0.0.copyload
  %66 = sext i32 %65 to i64
  %67 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 20), align 4, !tbaa !14
  %68 = add nsw i32 %67, %.sroa.5.0.copyload
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [10 x [10 x i8]], ptr %7, i64 0, i64 %66, i64 %69
  store i8 1, ptr %70, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  store i32 %65, ptr %9, align 4, !tbaa !9
  store i32 %68, ptr %17, align 4, !tbaa !12
  store i32 %23, ptr %18, align 4, !tbaa !13
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %71 unwind label %40

71:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %72

72:                                               ; preds = %71, %57
  %73 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 24), align 8, !tbaa !14
  %74 = add nsw i32 %73, %.sroa.0.0.copyload
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 28), align 4, !tbaa !14
  %76 = add nsw i32 %75, %.sroa.5.0.copyload
  %77 = call noundef zeroext i1 @_Z5checkPA10_iPA10_bii(ptr noundef %0, ptr noundef nonnull %7, i32 noundef %74, i32 noundef %76)
  br i1 %77, label %78, label %.loopexit

78:                                               ; preds = %72
  %79 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 24), align 8, !tbaa !14
  %80 = add nsw i32 %79, %.sroa.0.0.copyload
  %81 = sext i32 %80 to i64
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @direction, i64 28), align 4, !tbaa !14
  %83 = add nsw i32 %82, %.sroa.5.0.copyload
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [10 x [10 x i8]], ptr %7, i64 0, i64 %81, i64 %84
  store i8 1, ptr %85, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  store i32 %80, ptr %9, align 4, !tbaa !9
  store i32 %83, ptr %17, align 4, !tbaa !12
  store i32 %23, ptr %18, align 4, !tbaa !13
  invoke void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 4 dereferenceable(12) %9)
          to label %86 unwind label %40

86:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %.loopexit

.loopexit:                                        ; preds = %86, %72
  %87 = call noundef zeroext i1 @_ZNKSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
  br i1 %87, label %.thread, label %19, !llvm.loop !15

.thread:                                          ; preds = %.loopexit, %19, %15
  %.2 = phi i32 [ -1, %15 ], [ %.sroa.6.0.copyload, %19 ], [ -1, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %7) #5
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %6) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %6) #5
  ret i32 %.2

88:                                               ; preds = %40, %29
  %.pn = phi { ptr, i32 } [ %41, %40 ], [ %30, %29 ]
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %7) #5
  call void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %6) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %6) #5
  resume { ptr, i32 } %.pn
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEEC2IS3_vEEv(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEE3popEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt5queueI4NodeSt5dequeIS0_SaIS0_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(80)) unnamed_addr #4 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { inlinehint 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 #5 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS4Node", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass