; LLVM IR from Tunghohin/Competitive_Coding :: Codeforces/cf1691_D.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"

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

@a = external dso_local global [200010 x i64], align 16
@L = external dso_local global [200010 x i64], align 16
@R = external dso_local global [200010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildxxx(i64 noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5queryxxx(ptr dead_on_unwind noalias writable sret(%struct.Node) align 8, i64 noundef, i64 noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca %"class.std::stack", align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.Node, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store i64 1, ptr %2, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %21, %0
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = load i64, ptr %1, align 8, !tbaa !5
  %15 = icmp sle i64 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  br label %24

17:                                               ; preds = %12
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %18
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %19)
  br label %21

21:                                               ; preds = %17
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = add nsw i64 %22, 1
  store i64 %23, ptr %2, align 8, !tbaa !5
  br label %12, !llvm.loop !9

24:                                               ; preds = %16
  %25 = load i64, ptr %1, align 8, !tbaa !5
  call void @_Z5buildxxx(i64 noundef 1, i64 noundef 1, i64 noundef %25)
  call void @llvm.lifetime.start.p0(i64 80, ptr %3) #5
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 1, ptr %4, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %68, %24
  %27 = load i64, ptr %4, align 8, !tbaa !5
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = icmp sle i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %71

31:                                               ; preds = %26
  br label %32

32:                                               ; preds = %48, %31
  %33 = invoke noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %34 unwind label %49

34:                                               ; preds = %32
  br i1 %33, label %45, label %35

35:                                               ; preds = %34
  %36 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %37 unwind label %49

37:                                               ; preds = %35
  %38 = load i64, ptr %36, align 8, !tbaa !5
  %39 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !5
  %41 = load i64, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !5
  %44 = icmp slt i64 %40, %43
  br label %45

45:                                               ; preds = %37, %34
  %46 = phi i1 [ false, %34 ], [ %44, %37 ]
  br i1 %46, label %47, label %53

47:                                               ; preds = %45
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %48 unwind label %49

48:                                               ; preds = %47
  br label %32, !llvm.loop !11

49:                                               ; preds = %66, %56, %53, %47, %35, %32
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %5, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %173

53:                                               ; preds = %45
  %54 = invoke noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %55 unwind label %49

55:                                               ; preds = %53
  br i1 %54, label %63, label %56

56:                                               ; preds = %55
  %57 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %58 unwind label %49

58:                                               ; preds = %56
  %59 = load i64, ptr %57, align 8, !tbaa !5
  %60 = add nsw i64 %59, 1
  %61 = load i64, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds [200010 x i64], ptr @L, i64 0, i64 %61
  store i64 %60, ptr %62, align 8, !tbaa !5
  br label %66

63:                                               ; preds = %55
  %64 = load i64, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds [200010 x i64], ptr @L, i64 0, i64 %64
  store i64 1, ptr %65, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %63, %58
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %67 unwind label %49

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  %69 = load i64, ptr %4, align 8, !tbaa !5
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %4, align 8, !tbaa !5
  br label %26, !llvm.loop !12

71:                                               ; preds = %30
  br label %72

72:                                               ; preds = %77, %71
  %73 = invoke noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %74 unwind label %78

74:                                               ; preds = %72
  %75 = xor i1 %73, true
  br i1 %75, label %76, label %82

76:                                               ; preds = %74
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %77 unwind label %78

77:                                               ; preds = %76
  br label %72, !llvm.loop !13

78:                                               ; preds = %167, %76, %72
  %79 = landingpad { ptr, i32 }
          cleanup
  %80 = extractvalue { ptr, i32 } %79, 0
  store ptr %80, ptr %5, align 8
  %81 = extractvalue { ptr, i32 } %79, 1
  store i32 %81, ptr %6, align 4
  br label %173

82:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %83 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %83, ptr %7, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %126, %82
  %85 = load i64, ptr %7, align 8, !tbaa !5
  %86 = icmp sge i64 %85, 1
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %129

88:                                               ; preds = %84
  br label %89

89:                                               ; preds = %105, %88
  %90 = invoke noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %91 unwind label %106

91:                                               ; preds = %89
  br i1 %90, label %102, label %92

92:                                               ; preds = %91
  %93 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %94 unwind label %106

94:                                               ; preds = %92
  %95 = load i64, ptr %93, align 8, !tbaa !5
  %96 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !5
  %98 = load i64, ptr %7, align 8, !tbaa !5
  %99 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !5
  %101 = icmp sle i64 %97, %100
  br label %102

102:                                              ; preds = %94, %91
  %103 = phi i1 [ false, %91 ], [ %101, %94 ]
  br i1 %103, label %104, label %110

104:                                              ; preds = %102
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %105 unwind label %106

105:                                              ; preds = %104
  br label %89, !llvm.loop !14

106:                                              ; preds = %124, %113, %110, %104, %92, %89
  %107 = landingpad { ptr, i32 }
          cleanup
  %108 = extractvalue { ptr, i32 } %107, 0
  store ptr %108, ptr %5, align 8
  %109 = extractvalue { ptr, i32 } %107, 1
  store i32 %109, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %173

110:                                              ; preds = %102
  %111 = invoke noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %112 unwind label %106

112:                                              ; preds = %110
  br i1 %111, label %120, label %113

113:                                              ; preds = %112
  %114 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %3)
          to label %115 unwind label %106

115:                                              ; preds = %113
  %116 = load i64, ptr %114, align 8, !tbaa !5
  %117 = sub nsw i64 %116, 1
  %118 = load i64, ptr %7, align 8, !tbaa !5
  %119 = getelementptr inbounds [200010 x i64], ptr @R, i64 0, i64 %118
  store i64 %117, ptr %119, align 8, !tbaa !5
  br label %124

120:                                              ; preds = %112
  %121 = load i64, ptr %1, align 8, !tbaa !5
  %122 = load i64, ptr %7, align 8, !tbaa !5
  %123 = getelementptr inbounds [200010 x i64], ptr @R, i64 0, i64 %122
  store i64 %121, ptr %123, align 8, !tbaa !5
  br label %124

124:                                              ; preds = %120, %115
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %3, ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %125 unwind label %106

125:                                              ; preds = %124
  br label %126

126:                                              ; preds = %125
  %127 = load i64, ptr %7, align 8, !tbaa !5
  %128 = add nsw i64 %127, -1
  store i64 %128, ptr %7, align 8, !tbaa !5
  br label %84, !llvm.loop !15

129:                                              ; preds = %87
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 1, ptr %8, align 8, !tbaa !5
  br label %130

130:                                              ; preds = %161, %129
  %131 = load i64, ptr %8, align 8, !tbaa !5
  %132 = load i64, ptr %1, align 8, !tbaa !5
  %133 = icmp sle i64 %131, %132
  br i1 %133, label %135, label %134

134:                                              ; preds = %130
  store i32 17, ptr %9, align 4
  br label %164

135:                                              ; preds = %130
  %136 = load i64, ptr %8, align 8, !tbaa !5
  %137 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %136
  %138 = load i64, ptr %137, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %10) #5
  %139 = load i64, ptr %8, align 8, !tbaa !5
  %140 = getelementptr inbounds [200010 x i64], ptr @L, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !5
  %142 = load i64, ptr %8, align 8, !tbaa !5
  %143 = getelementptr inbounds [200010 x i64], ptr @R, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !5
  invoke void @_Z5queryxxx(ptr dead_on_unwind writable sret(%struct.Node) align 8 %10, i64 noundef 1, i64 noundef %141, i64 noundef %144)
          to label %145 unwind label %152

145:                                              ; preds = %135
  %146 = getelementptr inbounds %struct.Node, ptr %10, i32 0, i32 5
  %147 = load i64, ptr %146, align 8, !tbaa !16
  %148 = icmp slt i64 %138, %147
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #5
  br i1 %148, label %149, label %160

149:                                              ; preds = %145
  %150 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
          to label %151 unwind label %156

151:                                              ; preds = %149
  store i32 1, ptr %9, align 4
  br label %164

152:                                              ; preds = %135
  %153 = landingpad { ptr, i32 }
          cleanup
  %154 = extractvalue { ptr, i32 } %153, 0
  store ptr %154, ptr %5, align 8
  %155 = extractvalue { ptr, i32 } %153, 1
  store i32 %155, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #5
  br label %166

156:                                              ; preds = %149
  %157 = landingpad { ptr, i32 }
          cleanup
  %158 = extractvalue { ptr, i32 } %157, 0
  store ptr %158, ptr %5, align 8
  %159 = extractvalue { ptr, i32 } %157, 1
  store i32 %159, ptr %6, align 4
  br label %166

160:                                              ; preds = %145
  br label %161

161:                                              ; preds = %160
  %162 = load i64, ptr %8, align 8, !tbaa !5
  %163 = add nsw i64 %162, 1
  store i64 %163, ptr %8, align 8, !tbaa !5
  br label %130, !llvm.loop !18

164:                                              ; preds = %151, %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %165 = load i32, ptr %9, align 4
  switch i32 %165, label %170 [
    i32 17, label %167
  ]

166:                                              ; preds = %156, %152
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %173

167:                                              ; preds = %164
  %168 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.1)
          to label %169 unwind label %78

169:                                              ; preds = %167
  store i32 0, ptr %9, align 4
  br label %170

170:                                              ; preds = %169, %164
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  %171 = load i32, ptr %9, align 4
  switch i32 %171, label %179 [
    i32 0, label %172
    i32 1, label %172
  ]

172:                                              ; preds = %170, %170
  ret void

173:                                              ; preds = %166, %106, %78, %49
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  br label %174

174:                                              ; preds = %173
  %175 = load ptr, ptr %5, align 8
  %176 = load i32, ptr %6, align 4
  %177 = insertvalue { ptr, i32 } poison, ptr %175, 0
  %178 = insertvalue { ptr, i32 } %177, i32 %176, 1
  resume { ptr, i32 } %178

179:                                              ; preds = %170
  unreachable
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !6, i64 40}
!17 = !{!"_ZTS4Node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!18 = distinct !{!18, !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"

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

@a = external dso_local global [200010 x i64], align 16
@L = external dso_local local_unnamed_addr global [200010 x i64], align 16
@R = external dso_local local_unnamed_addr global [200010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; 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 uwtable
declare dso_local void @_Z5buildxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5queryxxx(ptr dead_on_unwind noalias writable sret(%struct.Node) align 8, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca i64, align 8
  %2 = alloca %"class.std::stack", align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %struct.Node, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  %6 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %7 = load i64, ptr %1, align 8, !tbaa !5
  %.not28 = icmp slt i64 %7, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i64 [ %7, %0 ], [ %12, %.lr.ph ]
  call void @_Z5buildxxx(i64 noundef 1, i64 noundef 1, i64 noundef %.lcssa)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #5
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store i64 1, ptr %3, align 8, !tbaa !5
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %.not1832 = icmp slt i64 %8, 1
  br i1 %.not1832, label %._crit_edge33, label %.preheader27

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01629 = phi i64 [ %11, %.lr.ph ], [ 1, %0 ]
  %9 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %.01629
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %11 = add nuw nsw i64 %.01629, 1
  %12 = load i64, ptr %1, align 8, !tbaa !5
  %.not.not = icmp slt i64 %.01629, %12
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.preheader27:                                     ; preds = %._crit_edge, %34
  %13 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %13, label %.critedge, label %.lr.ph30

._crit_edge33:                                    ; preds = %34, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %14 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %14, label %._crit_edge36, label %.lr.ph35

.lr.ph30:                                         ; preds = %.preheader27, %23
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = icmp slt i64 %18, %21
  br i1 %22, label %23, label %.critedge

23:                                               ; preds = %.lr.ph30
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %24 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %24, label %.critedge, label %.lr.ph30, !llvm.loop !11

25:                                               ; preds = %32
  %26 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %91

.critedge:                                        ; preds = %.lr.ph30, %23, %.preheader27
  %27 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %27, label %32, label %28

28:                                               ; preds = %.critedge
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %30 = load i64, ptr %29, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  br label %32

32:                                               ; preds = %.critedge, %28
  %.sink = phi i64 [ %31, %28 ], [ 1, %.critedge ]
  %.sink48 = load i64, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds [200010 x i64], ptr @L, i64 0, i64 %.sink48
  store i64 %.sink, ptr %33, align 8, !tbaa !5
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %34 unwind label %25

34:                                               ; preds = %32
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = add nsw i64 %35, 1
  store i64 %36, ptr %3, align 8, !tbaa !5
  %37 = load i64, ptr %1, align 8, !tbaa !5
  %.not18.not = icmp slt i64 %35, %37
  br i1 %.not18.not, label %.preheader27, label %._crit_edge33, !llvm.loop !12

.lr.ph35:                                         ; preds = %._crit_edge33, %.lr.ph35
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %38 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %38, label %._crit_edge36, label %.lr.ph35, !llvm.loop !13

39:                                               ; preds = %.critedge26
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %91

._crit_edge36:                                    ; preds = %.lr.ph35, %._crit_edge33
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %41 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %41, ptr %4, align 8, !tbaa !5
  %42 = icmp sgt i64 %41, 0
  br i1 %42, label %.preheader, label %._crit_edge39.thread

._crit_edge39.thread:                             ; preds = %._crit_edge36
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %.critedge26

.preheader:                                       ; preds = %._crit_edge36, %66
  %43 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %43, label %.critedge2, label %.lr.ph37

._crit_edge39:                                    ; preds = %66
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  %44 = icmp slt i64 %.pre, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br i1 %44, label %.critedge26, label %.lr.ph43

.lr.ph43:                                         ; preds = %._crit_edge39
  %45 = getelementptr inbounds i8, ptr %5, i64 40
  br label %73

.lr.ph37:                                         ; preds = %.preheader, %53
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %47 = load i64, ptr %46, align 8, !tbaa !5
  %48 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !5
  %50 = load i64, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !5
  %.not22 = icmp sgt i64 %49, %52
  br i1 %.not22, label %.critedge2, label %53

53:                                               ; preds = %.lr.ph37
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %54 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %54, label %.critedge2, label %.lr.ph37, !llvm.loop !14

55:                                               ; preds = %64
  %56 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %91

.critedge2:                                       ; preds = %.lr.ph37, %53, %.preheader
  %57 = call noundef zeroext i1 @_ZNKSt5stackIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %57, label %62, label %58

58:                                               ; preds = %.critedge2
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5stackIxSt5dequeIxSaIxEEE3topEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = add nsw i64 %60, -1
  br label %64

62:                                               ; preds = %.critedge2
  %63 = load i64, ptr %1, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %62, %58
  %.sink49 = phi i64 [ %63, %62 ], [ %61, %58 ]
  %.sink51 = load i64, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds [200010 x i64], ptr @R, i64 0, i64 %.sink51
  store i64 %.sink49, ptr %65, align 8, !tbaa !5
  invoke void @_ZNSt5stackIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %66 unwind label %55

66:                                               ; preds = %64
  %67 = load i64, ptr %4, align 8, !tbaa !5
  %68 = add nsw i64 %67, -1
  store i64 %68, ptr %4, align 8, !tbaa !5
  %69 = icmp sgt i64 %67, 1
  br i1 %69, label %.preheader, label %._crit_edge39, !llvm.loop !15

70:                                               ; preds = %80
  %71 = add nuw nsw i64 %.01241, 1
  %72 = load i64, ptr %1, align 8, !tbaa !5
  %.not20.not = icmp slt i64 %.01241, %72
  br i1 %.not20.not, label %73, label %.critedge26, !llvm.loop !16

73:                                               ; preds = %.lr.ph43, %70
  %.01241 = phi i64 [ 1, %.lr.ph43 ], [ %71, %70 ]
  %74 = getelementptr inbounds [200010 x i64], ptr @a, i64 0, i64 %.01241
  %75 = load i64, ptr %74, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %5) #5
  %76 = getelementptr inbounds [200010 x i64], ptr @L, i64 0, i64 %.01241
  %77 = load i64, ptr %76, align 8, !tbaa !5
  %78 = getelementptr inbounds [200010 x i64], ptr @R, i64 0, i64 %.01241
  %79 = load i64, ptr %78, align 8, !tbaa !5
  invoke void @_Z5queryxxx(ptr dead_on_unwind nonnull writable sret(%struct.Node) align 8 %5, i64 noundef 1, i64 noundef %77, i64 noundef %79)
          to label %80 unwind label %85

80:                                               ; preds = %73
  %81 = load i64, ptr %45, align 8, !tbaa !17
  %82 = icmp slt i64 %75, %81
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #5
  br i1 %82, label %83, label %70

83:                                               ; preds = %80
  %84 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
          to label %90 unwind label %87

85:                                               ; preds = %73
  %86 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %5) #5
  br label %91

87:                                               ; preds = %83
  %88 = landingpad { ptr, i32 }
          cleanup
  br label %91

.critedge26:                                      ; preds = %70, %._crit_edge39.thread, %._crit_edge39
  %89 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.1)
          to label %90 unwind label %39

90:                                               ; preds = %83, %.critedge26
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  ret void

91:                                               ; preds = %85, %87, %55, %39, %25
  %.pn23 = phi { ptr, i32 } [ %26, %25 ], [ %56, %55 ], [ %40, %39 ], [ %88, %87 ], [ %86, %85 ]
  call void @_ZNSt5stackIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  resume { ptr, i32 } %.pn23
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = !{!18, !6, i64 40}
!18 = !{!"_ZTS4Node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}


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