; LLVM IR from ShahjalalShohag/code-library :: Data Structures/MOs with DSU.ll (Z5solvev)

; 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.query = type { i32, i32, i32 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.persistent_dsu = type { i32, [200009 x i32], [200009 x i32], %"class.std::stack" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl" }
%"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl" = type { %"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl_data" }
%"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@ed = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global [200009 x %struct.query], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@rt = external dso_local global i32, align 4
@cnt_q = external dso_local global i32, align 4
@d = external dso_local global %struct.persistent_dsu, align 8
@answer = external dso_local global [200009 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

; 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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp5queryS_(i64, i32, i64, i32) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addi(i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #4 {
  %1 = alloca i32, align 4
  %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 %struct.query, align 4
  %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
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = load i32, ptr @n, align 4, !tbaa !5
  call void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160) @d, i32 noundef %16)
  call void @_ZN14persistent_dsu8snapshotEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  %17 = load i32, ptr @ed, align 4, !tbaa !5
  %18 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %17)
  %19 = fptosi double %18 to i32
  store i32 %19, ptr @rt, align 4, !tbaa !5
  store i32 0, ptr @cnt_q, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #7
  %20 = load i32, ptr @m, align 4, !tbaa !5
  store i32 %20, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %63, %0
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = load i32, ptr @m, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

25:                                               ; preds = %21
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %66

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sub nsw i32 %29, %30
  %32 = add nsw i32 %31, 1
  %33 = load i32, ptr @rt, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %35, label %52

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %36 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %36, ptr %6, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %44, %35
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = icmp sle i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %47

42:                                               ; preds = %37
  %43 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z3addi(i32 noundef %43)
  br label %44

44:                                               ; preds = %42
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %6, align 4, !tbaa !5
  br label %37, !llvm.loop !9

47:                                               ; preds = %41
  %48 = load i32, ptr @d, align 8, !tbaa !11
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %50
  store i32 %48, ptr %51, align 4, !tbaa !5
  call void @_ZN14persistent_dsu8rollbackEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  store i32 4, ptr %3, align 4
  br label %60

52:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #7
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN5queryC2Eiii(ptr noundef nonnull align 4 dereferenceable(12) %7, i32 noundef %53, i32 noundef %54, i32 noundef %55)
  %56 = load i32, ptr @cnt_q, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr @cnt_q, align 4, !tbaa !5
  %58 = sext i32 %56 to i64
  %59 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %58
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 4 %7, i64 12, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #7
  store i32 0, ptr %3, align 4
  br label %60

60:                                               ; preds = %52, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %61 = load i32, ptr %3, align 4
  switch i32 %61, label %162 [
    i32 0, label %62
    i32 4, label %63
  ]

62:                                               ; preds = %60
  br label %63

63:                                               ; preds = %62, %60
  %64 = load i32, ptr %2, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %2, align 4, !tbaa !5
  br label %21, !llvm.loop !22

66:                                               ; preds = %25
  %67 = load i32, ptr @cnt_q, align 4, !tbaa !5
  store i32 %67, ptr @m, align 4, !tbaa !5
  %68 = load i32, ptr @m, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.query, ptr @q, i64 %69
  call void @_ZSt4sortIP5queryPFbS0_S0_EEvT_S4_T0_(ptr noundef @q, ptr noundef %70, ptr noundef @_Z3cmp5queryS_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 -1, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %142, %66
  %72 = load i32, ptr %12, align 4, !tbaa !5
  %73 = load i32, ptr @m, align 4, !tbaa !5
  %74 = icmp slt i32 %72, %73
  br i1 %74, label %76, label %75

75:                                               ; preds = %71
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %145

76:                                               ; preds = %71
  %77 = load i32, ptr %12, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %78
  %80 = getelementptr inbounds %struct.query, ptr %79, i32 0, i32 0
  %81 = load i32, ptr %80, align 4, !tbaa !23
  %82 = load i32, ptr @rt, align 4, !tbaa !5
  %83 = sdiv i32 %81, %82
  store i32 %83, ptr %11, align 4, !tbaa !5
  %84 = load i32, ptr %10, align 4, !tbaa !5
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = icmp ne i32 %84, %85
  br i1 %86, label %87, label %94

87:                                               ; preds = %76
  %88 = load i32, ptr @n, align 4, !tbaa !5
  call void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160) @d, i32 noundef %88)
  %89 = load i32, ptr @rt, align 4, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  %92 = mul nsw i32 %89, %91
  store i32 %92, ptr %9, align 4, !tbaa !5
  %93 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %93, ptr %8, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %87, %76
  %95 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %95, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %13, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %109, %94
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = load i32, ptr %12, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.query, ptr %102, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !25
  %105 = icmp sle i32 %99, %104
  br i1 %105, label %107, label %106

106:                                              ; preds = %98
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %112

107:                                              ; preds = %98
  %108 = load i32, ptr %13, align 4, !tbaa !5
  call void @_Z3addi(i32 noundef %108)
  br label %109

109:                                              ; preds = %107
  %110 = load i32, ptr %13, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %13, align 4, !tbaa !5
  br label %98, !llvm.loop !26

112:                                              ; preds = %106
  call void @_ZN14persistent_dsu8snapshotEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  %113 = load i32, ptr %12, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.query, ptr %115, i32 0, i32 0
  %117 = load i32, ptr %116, align 4, !tbaa !23
  store i32 %117, ptr %14, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %125, %112
  %119 = load i32, ptr %14, align 4, !tbaa !5
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = icmp sle i32 %119, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %118
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %128

123:                                              ; preds = %118
  %124 = load i32, ptr %14, align 4, !tbaa !5
  call void @_Z3addi(i32 noundef %124)
  br label %125

125:                                              ; preds = %123
  %126 = load i32, ptr %14, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %14, align 4, !tbaa !5
  br label %118, !llvm.loop !27

128:                                              ; preds = %122
  %129 = load i32, ptr @d, align 8, !tbaa !11
  %130 = load i32, ptr %12, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %131
  %133 = getelementptr inbounds %struct.query, ptr %132, i32 0, i32 2
  %134 = load i32, ptr %133, align 4, !tbaa !28
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %135
  store i32 %129, ptr %136, align 4, !tbaa !5
  call void @_ZN14persistent_dsu8rollbackEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  %137 = load i32, ptr %12, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %138
  %140 = getelementptr inbounds %struct.query, ptr %139, i32 0, i32 1
  %141 = load i32, ptr %140, align 4, !tbaa !25
  store i32 %141, ptr %8, align 4, !tbaa !5
  br label %142

142:                                              ; preds = %128
  %143 = load i32, ptr %12, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %12, align 4, !tbaa !5
  br label %71, !llvm.loop !29

145:                                              ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %158, %145
  %147 = load i32, ptr %15, align 4, !tbaa !5
  %148 = load i32, ptr %1, align 4, !tbaa !5
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %146
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %161

151:                                              ; preds = %146
  %152 = load i32, ptr %15, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %155)
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %156, i8 noundef signext 10)
  br label %158

158:                                              ; preds = %151
  %159 = load i32, ptr %15, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %15, align 4, !tbaa !5
  br label %146, !llvm.loop !30

161:                                              ; preds = %150
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  ret void

162:                                              ; preds = %60
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160), i32 noundef) #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5queryC2Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5queryPFbS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #0

attributes #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #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 = { inlinehint 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 #7 = { 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"}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS14persistent_dsu", !6, i64 0, !7, i64 4, !7, i64 800040, !13, i64 1600080}
!13 = !{!"_ZTSSt5stackIN14persistent_dsu5stateESt5dequeIS1_SaIS1_EEE", !14, i64 0}
!14 = !{!"_ZTSSt5dequeIN14persistent_dsu5stateESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE16_Deque_impl_dataE", !18, i64 0, !19, i64 8, !20, i64 16, !20, i64 48}
!18 = !{!"any pointer", !7, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTSSt15_Deque_iteratorIN14persistent_dsu5stateERS1_PS1_E", !18, i64 0, !18, i64 8, !18, i64 16, !18, i64 24}
!21 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!22 = distinct !{!22, !10}
!23 = !{!24, !6, i64 0}
!24 = !{!"_ZTS5query", !6, i64 0, !6, i64 4, !6, i64 8}
!25 = !{!24, !6, i64 4}
!26 = distinct !{!26, !10}
!27 = distinct !{!27, !10}
!28 = !{!24, !6, i64 8}
!29 = distinct !{!29, !10}
!30 = distinct !{!30, !10}


; 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.query = type { i32, i32, i32 }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%struct.persistent_dsu = type { i32, [200009 x i32], [200009 x i32], %"class.std::stack" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl" }
%"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl" = type { %"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl_data" }
%"struct.std::_Deque_base<persistent_dsu::state, std::allocator<persistent_dsu::state>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local local_unnamed_addr global i32, align 4
@ed = external dso_local local_unnamed_addr global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@q = external dso_local global [200009 x %struct.query], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@rt = external dso_local local_unnamed_addr global i32, align 4
@cnt_q = external dso_local local_unnamed_addr global i32, align 4
@d = external dso_local global %struct.persistent_dsu, align 8
@answer = external dso_local local_unnamed_addr global [200009 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmp5queryS_(i64, i32, i64, i32) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3addi(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca %struct.query, align 4
  %4 = load i32, ptr @n, align 4, !tbaa !5
  tail call void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160) @d, i32 noundef %4)
  tail call void @_ZN14persistent_dsu8snapshotEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  %5 = load i32, ptr @ed, align 4, !tbaa !5
  %6 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %5)
  %7 = fptosi double %6 to i32
  store i32 %7, ptr @rt, align 4, !tbaa !5
  store i32 0, ptr @cnt_q, align 4, !tbaa !5
  %8 = load i32, ptr @m, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph50, label %._crit_edge51

._crit_edge51.loopexit:                           ; preds = %31
  %.pre = load i32, ptr @cnt_q, align 4, !tbaa !5
  br label %._crit_edge51

._crit_edge51:                                    ; preds = %._crit_edge51.loopexit, %0
  %10 = phi i32 [ %.pre, %._crit_edge51.loopexit ], [ 0, %0 ]
  store i32 %10, ptr @m, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds %struct.query, ptr @q, i64 %11
  call void @_ZSt4sortIP5queryPFbS0_S0_EEvT_S4_T0_(ptr noundef nonnull @q, ptr noundef nonnull %12, ptr noundef nonnull @_Z3cmp5queryS_)
  %13 = load i32, ptr @m, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph67, label %.preheader

.lr.ph50:                                         ; preds = %0, %31
  %indvars.iv = phi i64 [ %indvars.iv.next, %31 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sub nsw i32 %17, %18
  %20 = load i32, ptr @rt, align 4, !tbaa !5
  %.not43.not = icmp slt i32 %19, %20
  br i1 %.not43.not, label %.preheader45, label %25

.preheader45:                                     ; preds = %.lr.ph50
  %.not4446 = icmp sgt i32 %18, %17
  br i1 %.not4446, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.preheader45
  %21 = load i32, ptr @d, align 8, !tbaa !9
  %22 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %indvars.iv
  store i32 %21, ptr %22, align 4, !tbaa !5
  call void @_ZN14persistent_dsu8rollbackEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  br label %31

.lr.ph:                                           ; preds = %.preheader45, %.lr.ph
  %.03947 = phi i32 [ %23, %.lr.ph ], [ %18, %.preheader45 ]
  call void @_Z3addi(i32 noundef %.03947)
  %23 = add nsw i32 %.03947, 1
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %.not44.not = icmp slt i32 %.03947, %24
  br i1 %.not44.not, label %.lr.ph, label %._crit_edge, !llvm.loop !19

25:                                               ; preds = %.lr.ph50
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #7
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_ZN5queryC2Eiii(ptr noundef nonnull align 4 dereferenceable(12) %3, i32 noundef %18, i32 noundef %17, i32 noundef %26)
  %27 = load i32, ptr @cnt_q, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr @cnt_q, align 4, !tbaa !5
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %30, ptr noundef nonnull align 4 dereferenceable(12) %3, i64 12, i1 false), !tbaa.struct !21
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #7
  br label %31

31:                                               ; preds = %25, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = icmp slt i64 %indvars.iv.next, %33
  br i1 %34, label %.lr.ph50, label %._crit_edge51.loopexit, !llvm.loop !22

.preheader:                                       ; preds = %._crit_edge61, %._crit_edge51
  br i1 %9, label %.lr.ph69.preheader, label %._crit_edge70

.lr.ph69.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %8 to i64
  br label %.lr.ph69

.lr.ph67:                                         ; preds = %._crit_edge51, %._crit_edge61
  %indvars.iv72 = phi i64 [ %indvars.iv.next73, %._crit_edge61 ], [ 0, %._crit_edge51 ]
  %.03564 = phi i32 [ %38, %._crit_edge61 ], [ -1, %._crit_edge51 ]
  %.03663 = phi i32 [ %.1, %._crit_edge61 ], [ undef, %._crit_edge51 ]
  %.03762 = phi i32 [ %54, %._crit_edge61 ], [ undef, %._crit_edge51 ]
  %35 = getelementptr inbounds [200009 x %struct.query], ptr @q, i64 0, i64 %indvars.iv72
  %36 = load i32, ptr %35, align 4, !tbaa !23
  %37 = load i32, ptr @rt, align 4, !tbaa !5
  %38 = sdiv i32 %36, %37
  %.not = icmp eq i32 %.03564, %38
  br i1 %.not, label %44, label %39

39:                                               ; preds = %.lr.ph67
  %40 = load i32, ptr @n, align 4, !tbaa !5
  call void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160) @d, i32 noundef %40)
  %41 = load i32, ptr @rt, align 4, !tbaa !5
  %42 = add nsw i32 %38, 1
  %43 = mul nsw i32 %41, %42
  br label %44

44:                                               ; preds = %39, %.lr.ph67
  %.138 = phi i32 [ %43, %39 ], [ %.03762, %.lr.ph67 ]
  %.1 = phi i32 [ %43, %39 ], [ %.03663, %.lr.ph67 ]
  %45 = getelementptr inbounds i8, ptr %35, i64 4
  %46 = load i32, ptr %45, align 4, !tbaa !25
  %.not41.not52 = icmp slt i32 %.138, %46
  br i1 %.not41.not52, label %.lr.ph55, label %._crit_edge56

._crit_edge56:                                    ; preds = %.lr.ph55, %44
  call void @_ZN14persistent_dsu8snapshotEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  %47 = load i32, ptr %35, align 4, !tbaa !23
  %.not4257 = icmp sgt i32 %47, %.1
  br i1 %.not4257, label %._crit_edge61, label %.lr.ph60

.lr.ph55:                                         ; preds = %44, %.lr.ph55
  %.032.in53 = phi i32 [ %.032, %.lr.ph55 ], [ %.138, %44 ]
  %.032 = add nsw i32 %.032.in53, 1
  call void @_Z3addi(i32 noundef %.032)
  %48 = load i32, ptr %45, align 4, !tbaa !25
  %.not41.not = icmp slt i32 %.032, %48
  br i1 %.not41.not, label %.lr.ph55, label %._crit_edge56, !llvm.loop !26

._crit_edge61:                                    ; preds = %.lr.ph60, %._crit_edge56
  %49 = load i32, ptr @d, align 8, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %35, i64 8
  %51 = load i32, ptr %50, align 4, !tbaa !27
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %52
  store i32 %49, ptr %53, align 4, !tbaa !5
  call void @_ZN14persistent_dsu8rollbackEv(ptr noundef nonnull align 8 dereferenceable(1600160) @d)
  %54 = load i32, ptr %45, align 4, !tbaa !25
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %55 = load i32, ptr @m, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next73, %56
  br i1 %57, label %.lr.ph67, label %.preheader, !llvm.loop !28

.lr.ph60:                                         ; preds = %._crit_edge56, %.lr.ph60
  %.03158 = phi i32 [ %58, %.lr.ph60 ], [ %47, %._crit_edge56 ]
  call void @_Z3addi(i32 noundef %.03158)
  %58 = add i32 %.03158, 1
  %exitcond.not = icmp eq i32 %.03158, %.1
  br i1 %exitcond.not, label %._crit_edge61, label %.lr.ph60, !llvm.loop !29

._crit_edge70:                                    ; preds = %.lr.ph69, %.preheader
  ret void

.lr.ph69:                                         ; preds = %.lr.ph69.preheader, %.lr.ph69
  %indvars.iv75 = phi i64 [ 0, %.lr.ph69.preheader ], [ %indvars.iv.next76, %.lr.ph69 ]
  %59 = getelementptr inbounds [200009 x i32], ptr @answer, i64 0, i64 %indvars.iv75
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %60)
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %61, i8 noundef signext 10)
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond78.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count
  br i1 %exitcond78.not, label %._crit_edge70, label %.lr.ph69, !llvm.loop !30
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14persistent_dsu4initEi(ptr noundef nonnull align 8 dereferenceable(1600160), i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5queryC2Eiii(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, i32 noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5queryPFbS0_S0_EEvT_S4_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #0

attributes #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #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 = { inlinehint 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 #7 = { 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, !6, i64 0}
!10 = !{!"_ZTS14persistent_dsu", !6, i64 0, !7, i64 4, !7, i64 800040, !11, i64 1600080}
!11 = !{!"_ZTSSt5stackIN14persistent_dsu5stateESt5dequeIS1_SaIS1_EEE", !12, i64 0}
!12 = !{!"_ZTSSt5dequeIN14persistent_dsu5stateESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE11_Deque_implE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIN14persistent_dsu5stateESaIS1_EE16_Deque_impl_dataE", !16, i64 0, !17, i64 8, !18, i64 16, !18, i64 48}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSSt15_Deque_iteratorIN14persistent_dsu5stateERS1_PS1_E", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!22 = distinct !{!22, !20}
!23 = !{!24, !6, i64 0}
!24 = !{!"_ZTS5query", !6, i64 0, !6, i64 4, !6, i64 8}
!25 = !{!24, !6, i64 4}
!26 = distinct !{!26, !20}
!27 = !{!24, !6, i64 8}
!28 = distinct !{!28, !20}
!29 = distinct !{!29, !20}
!30 = distinct !{!30, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass