; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2010-11 (gdisc)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_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" }
%"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 }

@N = external dso_local global i32, align 4
@todo = external dso_local global %"class.std::queue", align 8
@done = external dso_local global [41 x i32], align 16
@ans = external dso_local global [41 x [41 x i8]], align 16
@bridge = external dso_local global [41 x [41 x i8]], align 16
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.10 = external hidden unnamed_addr constant [2 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 noundef i32 @_Z5queryv() #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2io2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %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 i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @_ZN2io2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(80) @todo, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %11

11:                                               ; preds = %148, %146, %0
  %12 = call noundef i64 @_ZNKSt5queueIiSt5dequeIiSaIiEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %13 = trunc i64 %12 to i32
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %149

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %17 = load i32, ptr %16, align 4, !tbaa !5
  store i32 %17, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %41, %15
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr @N, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = icmp slt i32 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %44

24:                                               ; preds = %18
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = icmp ne i32 %25, %26
  br i1 %27, label %28, label %40

28:                                               ; preds = %24
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [41 x i8], ptr %31, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !9, !range !11, !noundef !12
  %36 = trunc i8 %35 to i1
  br i1 %36, label %40, label %37

37:                                               ; preds = %28
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z3remii(i32 noundef %38, i32 noundef %39)
  br label %40

40:                                               ; preds = %37, %28, %24
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !5
  br label %18, !llvm.loop !13

44:                                               ; preds = %23
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 2
  br i1 %49, label %53, label %50

50:                                               ; preds = %44
  %51 = call noundef i32 @_Z5queryv()
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %50, %44
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %55
  store i32 2, ptr %56, align 4, !tbaa !5
  store i32 2, ptr %5, align 4
  br label %146, !llvm.loop !15

57:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 1, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %124, %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr @N, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %127

64:                                               ; preds = %58
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !5
  %67 = icmp ne i32 %65, %66
  br i1 %67, label %68, label %123

68:                                               ; preds = %64
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %123, label %74

74:                                               ; preds = %68
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %76
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [41 x i8], ptr %77, i64 0, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !9, !range !11, !noundef !12
  %82 = trunc i8 %81 to i1
  br i1 %82, label %123, label %83

83:                                               ; preds = %74
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z4undoii(i32 noundef %84, i32 noundef %85)
  %86 = call noundef i32 @_Z5queryv()
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %122

88:                                               ; preds = %83
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !5
  call void @_Z3remii(i32 noundef %89, i32 noundef %90)
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %92
  %94 = load i32, ptr %3, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [41 x i8], ptr %93, i64 0, i64 %95
  store i8 1, ptr %96, align 1, !tbaa !9
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %98
  %100 = load i32, ptr %7, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [41 x i8], ptr %99, i64 0, i64 %101
  store i8 1, ptr %102, align 1, !tbaa !9
  %103 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %104 = trunc i8 %103 to i1
  br i1 %104, label %105, label %121

105:                                              ; preds = %88
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @todo, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %107
  store i32 1, ptr %108, align 4, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %110
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [41 x i8], ptr %111, i64 0, i64 %113
  store i8 1, ptr %114, align 1, !tbaa !9
  %115 = load i32, ptr %3, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %116
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [41 x i8], ptr %117, i64 0, i64 %119
  store i8 1, ptr %120, align 1, !tbaa !9
  store i8 0, ptr %6, align 1, !tbaa !9
  br label %121

121:                                              ; preds = %105, %88
  br label %122

122:                                              ; preds = %121, %83
  br label %123

123:                                              ; preds = %122, %74, %68, %64
  br label %124

124:                                              ; preds = %123
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %7, align 4, !tbaa !5
  br label %58, !llvm.loop !16

127:                                              ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %142, %127
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = load i32, ptr @N, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  %132 = icmp slt i32 %129, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %128
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %145

134:                                              ; preds = %128
  %135 = load i32, ptr %8, align 4, !tbaa !5
  %136 = load i32, ptr %3, align 4, !tbaa !5
  %137 = icmp ne i32 %135, %136
  br i1 %137, label %138, label %141

138:                                              ; preds = %134
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = load i32, ptr %8, align 4, !tbaa !5
  call void @_Z4undoii(i32 noundef %139, i32 noundef %140)
  br label %141

141:                                              ; preds = %138, %134
  br label %142

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

145:                                              ; preds = %133
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  store i32 0, ptr %5, align 4
  br label %146

146:                                              ; preds = %145, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %147 = load i32, ptr %5, align 4
  switch i32 %147, label %183 [
    i32 0, label %148
    i32 2, label %11
  ]

148:                                              ; preds = %146
  br label %11, !llvm.loop !15

149:                                              ; preds = %11
  call void @_ZN2io2prIA2_cEEvRKT_(ptr noundef nonnull align 1 dereferenceable(2) @.str.9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %178, %149
  %151 = load i32, ptr %9, align 4, !tbaa !5
  %152 = load i32, ptr @N, align 4, !tbaa !5
  %153 = add nsw i32 %152, 1
  %154 = icmp slt i32 %151, %153
  br i1 %154, label %156, label %155

155:                                              ; preds = %150
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %181

156:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %173, %156
  %158 = load i32, ptr %10, align 4, !tbaa !5
  %159 = load i32, ptr @N, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  %161 = icmp slt i32 %158, %160
  br i1 %161, label %163, label %162

162:                                              ; preds = %157
  store i32 16, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %176

163:                                              ; preds = %157
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %165
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [41 x i8], ptr %166, i64 0, i64 %168
  %170 = load i8, ptr %169, align 1, !tbaa !9, !range !11, !noundef !12
  %171 = trunc i8 %170 to i1
  %172 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %171)
  br label %173

173:                                              ; preds = %163
  %174 = load i32, ptr %10, align 4, !tbaa !5
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %10, align 4, !tbaa !5
  br label %157, !llvm.loop !18

176:                                              ; preds = %162
  %177 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.10)
  br label %178

178:                                              ; preds = %176
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %9, align 4, !tbaa !5
  br label %150, !llvm.loop !19

181:                                              ; preds = %155
  %182 = load i32, ptr %1, align 4
  ret i32 %182

183:                                              ; preds = %146
  unreachable
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8), i1 noundef zeroext) #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) #4

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 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 #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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !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::queue" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl" = type { %"struct.std::_Deque_base<int, std::allocator<int>>::_Deque_impl_data" }
%"struct.std::_Deque_base<int, std::allocator<int>>::_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" }
%"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 }

@N = external dso_local global i32, align 4
@todo = external dso_local global %"class.std::queue", align 8
@done = external dso_local local_unnamed_addr global [41 x i32], align 16
@ans = external dso_local local_unnamed_addr global [41 x [41 x i8]], align 16
@bridge = external dso_local local_unnamed_addr global [41 x [41 x i8]], align 16
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.10 = external hidden unnamed_addr constant [2 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 noundef i32 @_Z5queryv() local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2io2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  tail call void @_ZN2io2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 1, ptr %1, align 4, !tbaa !5
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushEOi(ptr noundef nonnull align 8 dereferenceable(80) @todo, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %3 = call noundef i64 @_ZNKSt5queueIiSt5dequeIiSaIiEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %4 = and i64 %3, 4294967295
  %.not62 = icmp eq i64 %4, 0
  br i1 %.not62, label %._crit_edge65, label %.lr.ph64

.lr.ph64:                                         ; preds = %0, %.loopexit
  %5 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5queueIiSt5dequeIiSaIiEEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %.not4150 = icmp slt i32 %7, 1
  %.pre82 = sext i32 %6 to i64
  br i1 %.not4150, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph64
  %8 = zext i32 %6 to i64
  br label %12

._crit_edge:                                      ; preds = %20, %.lr.ph64
  %9 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %.pre82
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %25, label %23

12:                                               ; preds = %.lr.ph, %20
  %13 = phi i32 [ %7, %.lr.ph ], [ %21, %20 ]
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %.not49 = icmp eq i64 %indvars.iv, %8
  br i1 %.not49, label %20, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %.pre82, i64 %indvars.iv
  %16 = load i8, ptr %15, align 1, !tbaa !9, !range !11, !noundef !12
  %17 = trunc nuw i8 %16 to i1
  br i1 %17, label %20, label %18

18:                                               ; preds = %14
  %19 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_Z3remii(i32 noundef %6, i32 noundef %19)
  %.pre = load i32, ptr @N, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %12, %14, %18
  %21 = phi i32 [ %13, %12 ], [ %13, %14 ], [ %.pre, %18 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = sext i32 %21 to i64
  %.not41.not = icmp slt i64 %indvars.iv, %22
  br i1 %.not41.not, label %12, label %._crit_edge, !llvm.loop !13

23:                                               ; preds = %._crit_edge
  %24 = call noundef i32 @_Z5queryv()
  %.not42 = icmp eq i32 %24, 0
  br i1 %.not42, label %26, label %25

25:                                               ; preds = %23, %._crit_edge
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE3popEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %.loopexit, !llvm.loop !15

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  %27 = load i32, ptr @N, align 4, !tbaa !5
  %.not4352 = icmp slt i32 %27, 1
  br i1 %.not4352, label %._crit_edge57.thread, label %.lr.ph56

._crit_edge57.thread:                             ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %.loopexit

._crit_edge57:                                    ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %.not4458 = icmp slt i32 %52, 1
  br i1 %.not4458, label %.loopexit, label %.lr.ph61

.lr.ph56:                                         ; preds = %26, %49
  %.03454 = phi i1 [ %.1, %49 ], [ true, %26 ]
  %storemerge53 = phi i32 [ %51, %49 ], [ 1, %26 ]
  %.not46 = icmp eq i32 %storemerge53, %6
  br i1 %.not46, label %49, label %28

28:                                               ; preds = %.lr.ph56
  %29 = sext i32 %storemerge53 to i64
  %30 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %.not47 = icmp eq i32 %31, 0
  br i1 %.not47, label %32, label %49

32:                                               ; preds = %28
  %33 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %.pre82, i64 %29
  %34 = load i8, ptr %33, align 1, !tbaa !9, !range !11, !noundef !12
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %49, label %36

36:                                               ; preds = %32
  call void @_Z4undoii(i32 noundef %6, i32 noundef %storemerge53)
  %37 = call noundef i32 @_Z5queryv()
  %.not48 = icmp eq i32 %37, 0
  %.pre80 = load i32, ptr %2, align 4, !tbaa !5
  br i1 %.not48, label %49, label %38

38:                                               ; preds = %36
  call void @_Z3remii(i32 noundef %6, i32 noundef %.pre80)
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %40, i64 %.pre82
  store i8 1, ptr %41, align 1, !tbaa !9
  %42 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %.pre82, i64 %40
  store i8 1, ptr %42, align 1, !tbaa !9
  br i1 %.03454, label %43, label %49

43:                                               ; preds = %38
  call void @_ZNSt5queueIiSt5dequeIiSaIiEEE4pushERKi(ptr noundef nonnull align 8 dereferenceable(80) @todo, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [41 x i32], ptr @done, i64 0, i64 %45
  store i32 1, ptr %46, align 4, !tbaa !5
  %47 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %45, i64 %.pre82
  store i8 1, ptr %47, align 1, !tbaa !9
  %48 = getelementptr inbounds [41 x [41 x i8]], ptr @bridge, i64 0, i64 %.pre82, i64 %45
  store i8 1, ptr %48, align 1, !tbaa !9
  br label %49

49:                                               ; preds = %.lr.ph56, %28, %32, %38, %43, %36
  %50 = phi i32 [ %storemerge53, %28 ], [ %storemerge53, %32 ], [ %44, %43 ], [ %39, %38 ], [ %.pre80, %36 ], [ %6, %.lr.ph56 ]
  %.1 = phi i1 [ %.03454, %28 ], [ %.03454, %32 ], [ false, %43 ], [ false, %38 ], [ %.03454, %36 ], [ %.03454, %.lr.ph56 ]
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %2, align 4, !tbaa !5
  %52 = load i32, ptr @N, align 4, !tbaa !5
  %.not43.not = icmp slt i32 %50, %52
  br i1 %.not43.not, label %.lr.ph56, label %._crit_edge57, !llvm.loop !16

.lr.ph61:                                         ; preds = %._crit_edge57, %55
  %53 = phi i32 [ %56, %55 ], [ %52, %._crit_edge57 ]
  %.03359 = phi i32 [ %57, %55 ], [ 1, %._crit_edge57 ]
  %.not45 = icmp eq i32 %.03359, %6
  br i1 %.not45, label %55, label %54

54:                                               ; preds = %.lr.ph61
  call void @_Z4undoii(i32 noundef %6, i32 noundef %.03359)
  %.pre81 = load i32, ptr @N, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %.lr.ph61, %54
  %56 = phi i32 [ %53, %.lr.ph61 ], [ %.pre81, %54 ]
  %57 = add nuw nsw i32 %.03359, 1
  %.not44.not = icmp slt i32 %.03359, %56
  br i1 %.not44.not, label %.lr.ph61, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %55, %._crit_edge57.thread, %._crit_edge57, %25
  %58 = call noundef i64 @_ZNKSt5queueIiSt5dequeIiSaIiEEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) @todo)
  %59 = and i64 %58, 4294967295
  %.not = icmp eq i64 %59, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64

._crit_edge65:                                    ; preds = %.loopexit, %0
  call void @_ZN2io2prIA2_cEEvRKT_(ptr noundef nonnull align 1 dereferenceable(2) @.str.9)
  %60 = load i32, ptr @N, align 4, !tbaa !5
  %.not3970 = icmp slt i32 %60, 1
  br i1 %.not3970, label %._crit_edge72, label %.preheader

.preheader:                                       ; preds = %._crit_edge65, %._crit_edge69
  %61 = phi i32 [ %63, %._crit_edge69 ], [ %60, %._crit_edge65 ]
  %indvars.iv77 = phi i64 [ %indvars.iv.next78, %._crit_edge69 ], [ 1, %._crit_edge65 ]
  %.not4066 = icmp slt i32 %61, 1
  br i1 %.not4066, label %._crit_edge69, label %.lr.ph68

._crit_edge72:                                    ; preds = %._crit_edge69, %._crit_edge65
  ret i32 0

._crit_edge69:                                    ; preds = %.lr.ph68, %.preheader
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.10)
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %63 = load i32, ptr @N, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %.not39.not = icmp slt i64 %indvars.iv77, %64
  br i1 %.not39.not, label %.preheader, label %._crit_edge72, !llvm.loop !18

.lr.ph68:                                         ; preds = %.preheader, %.lr.ph68
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %.lr.ph68 ], [ 1, %.preheader ]
  %65 = getelementptr inbounds [41 x [41 x i8]], ptr @ans, i64 0, i64 %indvars.iv77, i64 %indvars.iv74
  %66 = load i8, ptr %65, align 1, !tbaa !9, !range !11, !noundef !12
  %67 = trunc nuw i8 %66 to i1
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i1 noundef zeroext %67)
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %69 = load i32, ptr @N, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %.not40.not = icmp slt i64 %indvars.iv74, %70
  br i1 %.not40.not, label %.lr.ph68, label %._crit_edge69, !llvm.loop !19
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEb(ptr noundef nonnull align 8 dereferenceable(8), i1 noundef zeroext) 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 #4

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 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 #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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}


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