; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/树算法/动态维护树中白色结点的最长距离.ll (Z6updatei)

; 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.heap = type { %"class.std::priority_queue", %"class.std::priority_queue" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@pa = external dso_local global [101000 x i32], align 16
@state = external dso_local global [101000 x i32], align 16
@res = external dso_local global [101000 x i32], align 16
@head = external dso_local global [101000 x %class.heap], align 16
@Q = external dso_local global [101000 x %class.heap], align 16
@answer = external dso_local global %class.heap, 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
declare dso_local noundef i32 @_Z4distii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4heapIiE4top2Ev(ptr noundef nonnull align 8 dereferenceable(64)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE7emplaceIJRiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updatei(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %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 i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = xor i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 -1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %18 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %18, ptr %4, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %144, %1
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = icmp sge i32 %20, 1
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %150

23:                                               ; preds = %19
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = icmp eq i32 %24, -1
  br i1 %25, label %26, label %41

26:                                               ; preds = %23
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %26
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64) %35, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %40

36:                                               ; preds = %26
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %39, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %40

40:                                               ; preds = %36, %32
  br label %81

41:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [101000 x %class.heap], ptr @Q, i64 0, i64 %43
  store ptr %44, ptr %7, align 8, !tbaa !9
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %45)
  %47 = icmp ne i64 %46, 0
  br i1 %47, label %48, label %54

48:                                               ; preds = %41
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %52)
  store i32 %53, ptr %8, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %51, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %54

54:                                               ; preds = %48, %41
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %65

60:                                               ; preds = %54
  %61 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = call noundef i32 @_Z4distii(i32 noundef %62, i32 noundef %63)
  store i32 %64, ptr %9, align 4, !tbaa !5
  call void @_ZN4heapIiE7emplaceIJiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64) %61, ptr noundef nonnull align 4 dereferenceable(4) %9)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %70

65:                                               ; preds = %54
  %66 = load ptr, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = call noundef i32 @_Z4distii(i32 noundef %67, i32 noundef %68)
  store i32 %69, ptr %10, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %66, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %70

70:                                               ; preds = %65, %60
  %71 = load ptr, ptr %7, align 8, !tbaa !9
  %72 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %71)
  %73 = icmp ne i64 %72, 0
  br i1 %73, label %74, label %80

74:                                               ; preds = %70
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %78 = load ptr, ptr %7, align 8, !tbaa !9
  %79 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %78)
  store i32 %79, ptr %11, align 4, !tbaa !5
  call void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64) %77, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %80

80:                                               ; preds = %74, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %81

81:                                               ; preds = %80, %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !5
  store i32 %85, ptr %12, align 4, !tbaa !5
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %87
  %89 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %88)
  %90 = icmp uge i64 %89, 2
  br i1 %90, label %91, label %104

91:                                               ; preds = %81
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %93
  %95 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %94)
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %97
  %99 = call noundef i32 @_ZN4heapIiE4top2Ev(ptr noundef nonnull align 8 dereferenceable(64) %98)
  %100 = add nsw i32 %95, %99
  %101 = load i32, ptr %4, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %102
  store i32 %100, ptr %103, align 4, !tbaa !5
  br label %132

104:                                              ; preds = %81
  %105 = load i32, ptr %4, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %106
  %108 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %107)
  %109 = icmp uge i64 %108, 1
  br i1 %109, label %110, label %127

110:                                              ; preds = %104
  %111 = load i32, ptr %4, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = icmp eq i32 %114, 0
  br i1 %115, label %116, label %121

116:                                              ; preds = %110
  %117 = load i32, ptr %4, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %118
  %120 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %119)
  br label %122

121:                                              ; preds = %110
  br label %122

122:                                              ; preds = %121, %116
  %123 = phi i32 [ %120, %116 ], [ 0, %121 ]
  %124 = load i32, ptr %4, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %125
  store i32 %123, ptr %126, align 4, !tbaa !5
  br label %131

127:                                              ; preds = %104
  %128 = load i32, ptr %4, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %129
  store i32 -1, ptr %130, align 4, !tbaa !5
  br label %131

131:                                              ; preds = %127, %122
  br label %132

132:                                              ; preds = %131, %91
  %133 = load i32, ptr %12, align 4, !tbaa !5
  %134 = load i32, ptr %4, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %135
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = icmp ne i32 %133, %137
  br i1 %138, label %139, label %143

139:                                              ; preds = %132
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) @answer, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %140 = load i32, ptr %4, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %141
  call void @_ZN4heapIiE7emplaceIJRiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64) @answer, ptr noundef nonnull align 4 dereferenceable(4) %142)
  br label %143

143:                                              ; preds = %139, %132
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %145, ptr %3, align 4, !tbaa !5
  %146 = load i32, ptr %3, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [101000 x i32], ptr @pa, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  store i32 %149, ptr %4, align 4, !tbaa !5
  br label %19, !llvm.loop !11

150:                                              ; preds = %22
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE7emplaceIJiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

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 = { 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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.heap = type { %"class.std::priority_queue", %"class.std::priority_queue" }
%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@pa = external dso_local local_unnamed_addr global [101000 x i32], align 16
@state = external dso_local local_unnamed_addr global [101000 x i32], align 16
@res = external dso_local global [101000 x i32], align 16
@head = external dso_local global [101000 x %class.heap], align 16
@Q = external dso_local global [101000 x %class.heap], align 16
@answer = external dso_local global %class.heap, align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4distii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN4heapIiE4top2Ev(ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE7emplaceIJRiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updatei(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = sext i32 %0 to i64
  %10 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = xor i32 %11, 1
  store i32 %12, ptr %10, align 4, !tbaa !5
  %13 = icmp sgt i32 %0, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %14 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %9
  br label %15

._crit_edge:                                      ; preds = %65, %1
  ret void

15:                                               ; preds = %.lr.ph, %65
  %.039 = phi i32 [ -1, %.lr.ph ], [ %.03438, %65 ]
  %.03438 = phi i32 [ %0, %.lr.ph ], [ %67, %65 ]
  %16 = icmp eq i32 %.039, -1
  br i1 %16, label %17, label %22

17:                                               ; preds = %15
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64) %14, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %43

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %14, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %43

22:                                               ; preds = %15
  %23 = zext nneg i32 %.039 to i64
  %24 = getelementptr inbounds [101000 x %class.heap], ptr @Q, i64 0, i64 %23
  %25 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %24)
  %.not = icmp eq i64 %25, 0
  br i1 %.not, label %30, label %26

26:                                               ; preds = %22
  %27 = zext nneg i32 %.03438 to i64
  %28 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %27
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %29 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %24)
  store i32 %29, ptr %4, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %28, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br label %30

30:                                               ; preds = %26, %22
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  %34 = call noundef i32 @_Z4distii(i32 noundef %0, i32 noundef %.03438)
  store i32 %34, ptr %5, align 4, !tbaa !5
  call void @_ZN4heapIiE7emplaceIJiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64) %24, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br label %37

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %36 = call noundef i32 @_Z4distii(i32 noundef %0, i32 noundef %.03438)
  store i32 %36, ptr %6, align 4, !tbaa !5
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) %24, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %37

37:                                               ; preds = %35, %33
  %38 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %24)
  %.not35 = icmp eq i64 %38, 0
  br i1 %.not35, label %43, label %39

39:                                               ; preds = %37
  %40 = zext nneg i32 %.03438 to i64
  %41 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %40
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %42 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %24)
  store i32 %42, ptr %7, align 4, !tbaa !5
  call void @_ZN4heapIiE4pushERKi(ptr noundef nonnull align 8 dereferenceable(64) %41, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  br label %43

43:                                               ; preds = %37, %39, %20, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %44 = zext nneg i32 %.03438 to i64
  %45 = getelementptr inbounds [101000 x i32], ptr @res, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  store i32 %46, ptr %8, align 4, !tbaa !5
  %47 = getelementptr inbounds [101000 x %class.heap], ptr @head, i64 0, i64 %44
  %48 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %47)
  %49 = icmp ugt i64 %48, 1
  br i1 %49, label %50, label %54

50:                                               ; preds = %43
  %51 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %47)
  %52 = call noundef i32 @_ZN4heapIiE4top2Ev(ptr noundef nonnull align 8 dereferenceable(64) %47)
  %53 = add nsw i32 %52, %51
  br label %62

54:                                               ; preds = %43
  %55 = call noundef i64 @_ZNK4heapIiE4sizeEv(ptr noundef nonnull align 8 dereferenceable(64) %47)
  %.not36 = icmp eq i64 %55, 0
  br i1 %.not36, label %62, label %56

56:                                               ; preds = %54
  %57 = getelementptr inbounds [101000 x i32], ptr @state, i64 0, i64 %44
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %62

60:                                               ; preds = %56
  %61 = call noundef i32 @_ZN4heapIiE3topEv(ptr noundef nonnull align 8 dereferenceable(64) %47)
  br label %62

62:                                               ; preds = %54, %60, %56, %50
  %.sink = phi i32 [ %53, %50 ], [ %61, %60 ], [ 0, %56 ], [ -1, %54 ]
  store i32 %.sink, ptr %45, align 4, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %.not37 = icmp eq i32 %63, %.sink
  br i1 %.not37, label %65, label %64

64:                                               ; preds = %62
  call void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64) @answer, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @_ZN4heapIiE7emplaceIJRiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64) @answer, ptr noundef nonnull align 4 dereferenceable(4) %45)
  br label %65

65:                                               ; preds = %64, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  %66 = getelementptr inbounds [101000 x i32], ptr @pa, i64 0, i64 %44
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 0
  br i1 %68, label %15, label %._crit_edge, !llvm.loop !9
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE5eraseERKi(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4heapIiE7emplaceIJiEEEvDpOT_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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