; LLVM IR from eyangch/competitive-programming :: Codeforces/1746 (b)

; 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" }
%"class.std::queue" = 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 }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [200000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.std::queue", align 8
  %6 = alloca %"class.std::queue", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %14 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %15 = getelementptr i8, ptr %14, i64 -24
  %16 = load i64, ptr %15, align 8
  %17 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %16
  %18 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %17, ptr noundef null)
  %19 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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) @T)
  br label %21

21:                                               ; preds = %148, %146, %0
  %22 = load i64, ptr @T, align 8, !tbaa !8
  %23 = add nsw i64 %22, -1
  store i64 %23, ptr @T, align 8, !tbaa !8
  %24 = icmp ne i64 %22, 0
  br i1 %24, label %25, label %152

25:                                               ; preds = %21
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #7
  store i8 0, ptr %2, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %27

27:                                               ; preds = %42, %25
  %28 = load i64, ptr %3, align 8, !tbaa !8
  %29 = load i64, ptr @N, align 8, !tbaa !8
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  br label %45

32:                                               ; preds = %27
  %33 = load i64, ptr %3, align 8, !tbaa !8
  %34 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %33
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %34)
  %36 = load i64, ptr %3, align 8, !tbaa !8
  %37 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !8
  %39 = icmp eq i64 %38, 1
  br i1 %39, label %40, label %41

40:                                               ; preds = %32
  store i8 1, ptr %2, align 1, !tbaa !11
  br label %41

41:                                               ; preds = %40, %32
  br label %42

42:                                               ; preds = %41
  %43 = load i64, ptr %3, align 8, !tbaa !8
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %3, align 8, !tbaa !8
  br label %27, !llvm.loop !13

45:                                               ; preds = %31
  %46 = load i8, ptr %2, align 1, !tbaa !11, !range !15, !noundef !16
  %47 = trunc i8 %46 to i1
  br i1 %47, label %51, label %48

48:                                               ; preds = %45
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  %50 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %49, i8 noundef signext 10)
  store i32 2, ptr %4, align 4
  br label %146, !llvm.loop !17

51:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
  call void @llvm.lifetime.start.p0(i64 80, ptr %6) #7
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
          to label %52 unwind label %59

52:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %53 = load i64, ptr @N, align 8, !tbaa !8
  %54 = sub nsw i64 %53, 1
  store i64 %54, ptr %9, align 8, !tbaa !8
  br label %55

55:                                               ; preds = %75, %52
  %56 = load i64, ptr %9, align 8, !tbaa !8
  %57 = icmp sge i64 %56, 0
  br i1 %57, label %63, label %58

58:                                               ; preds = %55
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %78

59:                                               ; preds = %51
  %60 = landingpad { ptr, i32 }
          cleanup
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %7, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %8, align 4
  br label %151

63:                                               ; preds = %55
  %64 = load i64, ptr %9, align 8, !tbaa !8
  %65 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = icmp eq i64 %66, 0
  br i1 %67, label %68, label %74

68:                                               ; preds = %63
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %5, ptr noundef nonnull align 8 dereferenceable(8) %9)
          to label %69 unwind label %70

69:                                               ; preds = %68
  br label %74

70:                                               ; preds = %68
  %71 = landingpad { ptr, i32 }
          cleanup
  %72 = extractvalue { ptr, i32 } %71, 0
  store ptr %72, ptr %7, align 8
  %73 = extractvalue { ptr, i32 } %71, 1
  store i32 %73, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %150

74:                                               ; preds = %69, %63
  br label %75

75:                                               ; preds = %74
  %76 = load i64, ptr %9, align 8, !tbaa !8
  %77 = add nsw i64 %76, -1
  store i64 %77, ptr %9, align 8, !tbaa !8
  br label %55, !llvm.loop !18

78:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !8
  br label %79

79:                                               ; preds = %96, %78
  %80 = load i64, ptr %10, align 8, !tbaa !8
  %81 = load i64, ptr @N, align 8, !tbaa !8
  %82 = icmp slt i64 %80, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %79
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %99

84:                                               ; preds = %79
  %85 = load i64, ptr %10, align 8, !tbaa !8
  %86 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !8
  %88 = icmp eq i64 %87, 1
  br i1 %88, label %89, label %95

89:                                               ; preds = %84
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %6, ptr noundef nonnull align 8 dereferenceable(8) %10)
          to label %90 unwind label %91

90:                                               ; preds = %89
  br label %95

91:                                               ; preds = %89
  %92 = landingpad { ptr, i32 }
          cleanup
  %93 = extractvalue { ptr, i32 } %92, 0
  store ptr %93, ptr %7, align 8
  %94 = extractvalue { ptr, i32 } %92, 1
  store i32 %94, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %150

95:                                               ; preds = %90, %84
  br label %96

96:                                               ; preds = %95
  %97 = load i64, ptr %10, align 8, !tbaa !8
  %98 = add nsw i64 %97, 1
  store i64 %98, ptr %10, align 8, !tbaa !8
  br label %79, !llvm.loop !19

99:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 0, ptr %11, align 8, !tbaa !8
  br label %100

100:                                              ; preds = %138, %99
  br label %101

101:                                              ; preds = %100
  %102 = invoke noundef zeroext i1 @_ZNKSt5queueIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %103 unwind label %108

103:                                              ; preds = %101
  br i1 %102, label %107, label %104

104:                                              ; preds = %103
  %105 = invoke noundef zeroext i1 @_ZNKSt5queueIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
          to label %106 unwind label %108

106:                                              ; preds = %104
  br i1 %105, label %107, label %112

107:                                              ; preds = %106, %103
  br label %140

108:                                              ; preds = %143, %140, %104, %101
  %109 = landingpad { ptr, i32 }
          cleanup
  %110 = extractvalue { ptr, i32 } %109, 0
  store ptr %110, ptr %7, align 8
  %111 = extractvalue { ptr, i32 } %109, 1
  store i32 %111, ptr %8, align 4
  br label %149

112:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %113 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIxSt5dequeIxSaIxEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %114 unwind label %123

114:                                              ; preds = %112
  %115 = load i64, ptr %113, align 8, !tbaa !8
  store i64 %115, ptr %12, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %116 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIxSt5dequeIxSaIxEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
          to label %117 unwind label %127

117:                                              ; preds = %114
  %118 = load i64, ptr %116, align 8, !tbaa !8
  store i64 %118, ptr %13, align 8, !tbaa !8
  %119 = load i64, ptr %13, align 8, !tbaa !8
  %120 = load i64, ptr %12, align 8, !tbaa !8
  %121 = icmp sgt i64 %119, %120
  br i1 %121, label %122, label %131

122:                                              ; preds = %117
  store i32 14, ptr %4, align 4
  br label %136

123:                                              ; preds = %112
  %124 = landingpad { ptr, i32 }
          cleanup
  %125 = extractvalue { ptr, i32 } %124, 0
  store ptr %125, ptr %7, align 8
  %126 = extractvalue { ptr, i32 } %124, 1
  store i32 %126, ptr %8, align 4
  br label %139

127:                                              ; preds = %132, %131, %114
  %128 = landingpad { ptr, i32 }
          cleanup
  %129 = extractvalue { ptr, i32 } %128, 0
  store ptr %129, ptr %7, align 8
  %130 = extractvalue { ptr, i32 } %128, 1
  store i32 %130, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %139

131:                                              ; preds = %117
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %5)
          to label %132 unwind label %127

132:                                              ; preds = %131
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %6)
          to label %133 unwind label %127

133:                                              ; preds = %132
  %134 = load i64, ptr %11, align 8, !tbaa !8
  %135 = add nsw i64 %134, 1
  store i64 %135, ptr %11, align 8, !tbaa !8
  store i32 0, ptr %4, align 4
  br label %136

136:                                              ; preds = %133, %122
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %137 = load i32, ptr %4, align 4
  switch i32 %137, label %159 [
    i32 0, label %138
    i32 14, label %140
  ]

138:                                              ; preds = %136
  br label %100, !llvm.loop !20

139:                                              ; preds = %127, %123
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %149

140:                                              ; preds = %136, %107
  %141 = load i64, ptr %11, align 8, !tbaa !8
  %142 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %141)
          to label %143 unwind label %108

143:                                              ; preds = %140
  %144 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %142, i8 noundef signext 10)
          to label %145 unwind label %108

145:                                              ; preds = %143
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %6) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %6) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #7
  store i32 0, ptr %4, align 4
  br label %146

146:                                              ; preds = %145, %48
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #7
  %147 = load i32, ptr %4, align 4
  switch i32 %147, label %159 [
    i32 0, label %148
    i32 2, label %21
  ]

148:                                              ; preds = %146
  br label %21, !llvm.loop !17

149:                                              ; preds = %139, %108
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %150

150:                                              ; preds = %149, %91, %70
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %6) #7
  br label %151

151:                                              ; preds = %150, %59
  call void @llvm.lifetime.end.p0(i64 80, ptr %6) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %5) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #7
  br label %154

152:                                              ; preds = %21
  %153 = load i32, ptr %1, align 4
  ret i32 %153

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

159:                                              ; preds = %146, %136
  unreachable
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #2

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

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

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

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

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


; 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" }
%"class.std::queue" = 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 }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [200000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::queue", align 8
  %2 = alloca %"class.std::queue", align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  %12 = load i64, ptr @T, align 8, !tbaa !8
  %13 = add nsw i64 %12, -1
  store i64 %13, ptr @T, align 8, !tbaa !8
  %.not48 = icmp eq i64 %12, 0
  br i1 %.not48, label %._crit_edge51, label %.lr.ph50

.lr.ph50:                                         ; preds = %0, %69
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %15 = load i64, ptr @N, align 8, !tbaa !8
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %.lr.ph, label %.critedge

._crit_edge:                                      ; preds = %.lr.ph
  br i1 %spec.select, label %26, label %.critedge

.lr.ph:                                           ; preds = %.lr.ph50, %.lr.ph
  %.029 = phi i1 [ %spec.select, %.lr.ph ], [ false, %.lr.ph50 ]
  %.01228 = phi i64 [ %21, %.lr.ph ], [ 0, %.lr.ph50 ]
  %17 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %.01228
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %19 = load i64, ptr %17, align 8, !tbaa !8
  %20 = icmp eq i64 %19, 1
  %spec.select = select i1 %20, i1 true, i1 %.029
  %21 = add nuw nsw i64 %.01228, 1
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.critedge:                                        ; preds = %.lr.ph50, %._crit_edge
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef 0)
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %24, i8 noundef signext 10)
  br label %69, !llvm.loop !13

26:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %2) #7
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEEC2IS2_vEEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
          to label %27 unwind label %30

27:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %storemerge.in30 = load i64, ptr @N, align 8, !tbaa !8
  %storemerge31 = add nsw i64 %storemerge.in30, -1
  store i64 %storemerge31, ptr %3, align 8, !tbaa !8
  %28 = icmp sgt i64 %storemerge.in30, 0
  br i1 %28, label %.lr.ph34, label %._crit_edge35.thread

._crit_edge35.thread:                             ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  br label %._crit_edge39

._crit_edge35:                                    ; preds = %38
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  %29 = icmp sgt i64 %.pre, 0
  br i1 %29, label %.lr.ph38, label %._crit_edge39

30:                                               ; preds = %26
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %73

.lr.ph34:                                         ; preds = %27, %38
  %storemerge32 = phi i64 [ %storemerge, %38 ], [ %storemerge31, %27 ]
  %32 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %storemerge32
  %33 = load i64, ptr %32, align 8, !tbaa !8
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %.lr.ph34
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %1, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %._crit_edge52 unwind label %36

._crit_edge52:                                    ; preds = %35
  %storemerge.in.pre = load i64, ptr %3, align 8, !tbaa !8
  br label %38

36:                                               ; preds = %35
  %37 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %72

38:                                               ; preds = %._crit_edge52, %.lr.ph34
  %storemerge.in = phi i64 [ %storemerge.in.pre, %._crit_edge52 ], [ %storemerge32, %.lr.ph34 ]
  %storemerge = add nsw i64 %storemerge.in, -1
  store i64 %storemerge, ptr %3, align 8, !tbaa !8
  %39 = icmp sgt i64 %storemerge.in, 0
  br i1 %39, label %.lr.ph34, label %._crit_edge35, !llvm.loop !14

._crit_edge39:                                    ; preds = %48, %._crit_edge35.thread, %._crit_edge35
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %40 = call noundef zeroext i1 @_ZNKSt5queueIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %40, label %.thread, label %.lr.ph42

.lr.ph38:                                         ; preds = %._crit_edge35, %48
  %41 = phi i64 [ %49, %48 ], [ %.pre, %._crit_edge35 ]
  %storemerge2236 = phi i64 [ %51, %48 ], [ 0, %._crit_edge35 ]
  %42 = getelementptr inbounds [200000 x i64], ptr @A, i64 0, i64 %storemerge2236
  %43 = load i64, ptr %42, align 8, !tbaa !8
  %44 = icmp eq i64 %43, 1
  br i1 %44, label %45, label %48

45:                                               ; preds = %.lr.ph38
  invoke void @_ZNSt5queueIxSt5dequeIxSaIxEEE4pushERKx(ptr noundef nonnull align 8 dereferenceable(80) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %._crit_edge54 unwind label %46

._crit_edge54:                                    ; preds = %45
  %.pre55 = load i64, ptr %4, align 8, !tbaa !8
  %.pre56 = load i64, ptr @N, align 8, !tbaa !8
  br label %48

46:                                               ; preds = %45
  %47 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %72

48:                                               ; preds = %._crit_edge54, %.lr.ph38
  %49 = phi i64 [ %.pre56, %._crit_edge54 ], [ %41, %.lr.ph38 ]
  %50 = phi i64 [ %.pre55, %._crit_edge54 ], [ %storemerge2236, %.lr.ph38 ]
  %51 = add nsw i64 %50, 1
  store i64 %51, ptr %4, align 8, !tbaa !8
  %52 = icmp slt i64 %51, %49
  br i1 %52, label %.lr.ph38, label %._crit_edge39, !llvm.loop !15

.lr.ph42:                                         ; preds = %._crit_edge39, %62
  %.01340 = phi i64 [ %63, %62 ], [ 0, %._crit_edge39 ]
  %53 = call noundef zeroext i1 @_ZNKSt5queueIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  br i1 %53, label %.thread, label %56

54:                                               ; preds = %66, %.thread
  %55 = landingpad { ptr, i32 }
          cleanup
  br label %72

56:                                               ; preds = %.lr.ph42
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIxSt5dequeIxSaIxEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  %58 = load i64, ptr %57, align 8, !tbaa !8
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5queueIxSt5dequeIxSaIxEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %60 = load i64, ptr %59, align 8, !tbaa !8
  %61 = icmp sgt i64 %60, %58
  br i1 %61, label %.thread, label %62

62:                                               ; preds = %56
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %63 = add nuw nsw i64 %.01340, 1
  %64 = call noundef zeroext i1 @_ZNKSt5queueIxSt5dequeIxSaIxEEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %1)
  br i1 %64, label %.thread, label %.lr.ph42

.thread:                                          ; preds = %.lr.ph42, %62, %56, %._crit_edge39
  %.013.lcssa = phi i64 [ 0, %._crit_edge39 ], [ %.01340, %56 ], [ %63, %62 ], [ %.01340, %.lr.ph42 ]
  %65 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.013.lcssa)
          to label %66 unwind label %54

66:                                               ; preds = %.thread
  %67 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %65, i8 noundef signext 10)
          to label %68 unwind label %54

68:                                               ; preds = %66
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #7
  br label %69

69:                                               ; preds = %68, %.critedge
  %70 = load i64, ptr @T, align 8, !tbaa !8
  %71 = add nsw i64 %70, -1
  store i64 %71, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %70, 0
  br i1 %.not, label %._crit_edge51, label %.lr.ph50

72:                                               ; preds = %54, %46, %36
  %.pn = phi { ptr, i32 } [ %37, %36 ], [ %47, %46 ], [ %55, %54 ]
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %2) #7
  br label %73

73:                                               ; preds = %72, %30
  %.pn.pn = phi { ptr, i32 } [ %.pn, %72 ], [ %31, %30 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %2) #7
  call void @_ZNSt5queueIxSt5dequeIxSaIxEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %1) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #7
  resume { ptr, i32 } %.pn.pn

._crit_edge51:                                    ; preds = %69, %0
  ret i32 0
}

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #2

; 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 #3 align 2

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

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

; 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 #5

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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass