; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2018-19/Feb 2019/Gold (cowland)

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

%struct.BIT.0 = type { [100002 x %struct.BIT] }
%struct.BIT = type { i32 }
%struct.LCA = type <{ i32, i32, i32, [4 x i8], [100001 x %"class.std::vector"], [17 x [100001 x i32]], [100001 x i32], [100001 x %"struct.std::pair"], i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator" = type { i8 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@N = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@e = external dso_local global [100001 x i32], align 16
@B = external dso_local global %struct.BIT.0, align 4
@L = external dso_local global %struct.LCA, align 8
@.str.7 = external hidden unnamed_addr constant [8 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; 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 @_ZN2io5setIOENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::__cxx11::basic_string", align 8
  %3 = alloca %"class.std::allocator", align 1
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef @.str.7, ptr noundef nonnull align 1 dereferenceable(1) %3)
          to label %16 unwind label %24

16:                                               ; preds = %0
  invoke void @_ZN2io5setIOENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef %2)
          to label %17 unwind label %28

17:                                               ; preds = %16
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #4
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  call void @_ZN5input2reIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @N, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %37, %17
  %19 = load i32, ptr %6, 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 %33, label %23

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

24:                                               ; preds = %0
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %4, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %5, align 4
  br label %32

28:                                               ; preds = %16
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %4, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %5, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %2) #4
  br label %32

32:                                               ; preds = %28, %24
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %3) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  br label %148

33:                                               ; preds = %18
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %35
  call void @_ZN5input2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %36)
  br label %37

37:                                               ; preds = %33
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !5
  br label %18, !llvm.loop !9

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

41:                                               ; preds = %50, %40
  %42 = load i32, ptr %7, align 4, !tbaa !5
  %43 = load i32, ptr @N, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 1
  %45 = icmp slt i32 %42, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %53

47:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @_ZN5input2reIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %48 = load i32, ptr %8, align 4, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !5
  call void @_ZN3LCAILi100001EE7addEdgeEii(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %48, i32 noundef %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %50

50:                                               ; preds = %47
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %7, align 4, !tbaa !5
  br label %41, !llvm.loop !11

53:                                               ; preds = %46
  %54 = load i32, ptr @N, align 4, !tbaa !5
  call void @_ZN3LCAILi100001EE4initEi(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %54)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %81, %53
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = load i32, ptr @N, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  %59 = icmp slt i32 %56, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %84

61:                                               ; preds = %55
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %63
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 8, !tbaa !12
  %67 = load i32, ptr %10, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %66, i32 noundef %70)
  %71 = load i32, ptr %10, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %72
  %74 = getelementptr inbounds %"struct.std::pair", ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 4, !tbaa !14
  %76 = add nsw i32 %75, 1
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %76, i32 noundef %80)
  br label %81

81:                                               ; preds = %61
  %82 = load i32, ptr %10, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %10, align 4, !tbaa !5
  br label %55, !llvm.loop !15

84:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %143, %84
  %86 = load i32, ptr %11, align 4, !tbaa !5
  %87 = load i32, ptr @Q, align 4, !tbaa !5
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %146

90:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @_ZN5input2reIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %91 = load i32, ptr %12, align 4, !tbaa !5
  %92 = icmp eq i32 %91, 1
  br i1 %92, label %93, label %121

93:                                               ; preds = %90
  %94 = load i32, ptr %13, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %95
  %97 = getelementptr inbounds %"struct.std::pair", ptr %96, i32 0, i32 0
  %98 = load i32, ptr %97, align 8, !tbaa !12
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = load i32, ptr %14, align 4, !tbaa !5
  %104 = xor i32 %102, %103
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %98, i32 noundef %104)
  %105 = load i32, ptr %13, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %106
  %108 = getelementptr inbounds %"struct.std::pair", ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !14
  %110 = add nsw i32 %109, 1
  %111 = load i32, ptr %13, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = load i32, ptr %14, align 4, !tbaa !5
  %116 = xor i32 %114, %115
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %110, i32 noundef %116)
  %117 = load i32, ptr %14, align 4, !tbaa !5
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %119
  store i32 %117, ptr %120, align 4, !tbaa !5
  br label %142

121:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %122 = load i32, ptr %13, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %123
  %125 = getelementptr inbounds %"struct.std::pair", ptr %124, i32 0, i32 0
  %126 = load i32, ptr %125, align 8, !tbaa !12
  %127 = call noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %126)
  %128 = load i32, ptr %14, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (%struct.LCA, ptr @L, i32 0, i32 7), i64 0, i64 %129
  %131 = getelementptr inbounds %"struct.std::pair", ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 8, !tbaa !12
  %133 = call noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %132)
  %134 = xor i32 %127, %133
  %135 = load i32, ptr %13, align 4, !tbaa !5
  %136 = load i32, ptr %14, align 4, !tbaa !5
  %137 = call noundef i32 @_ZN3LCAILi100001EE3lcaEii(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %135, i32 noundef %136)
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = xor i32 %134, %140
  store i32 %141, ptr %15, align 4, !tbaa !5
  call void @_ZN6output2prIiJA2_cEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 1 dereferenceable(2) @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %142

142:                                              ; preds = %121, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %143

143:                                              ; preds = %142
  %144 = load i32, ptr %11, align 4, !tbaa !5
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %11, align 4, !tbaa !5
  br label %85, !llvm.loop !16

146:                                              ; preds = %89
  %147 = load i32, ptr %1, align 4
  ret i32 %147

148:                                              ; preds = %32
  %149 = load ptr, ptr %4, align 8
  %150 = load i32, ptr %5, align 4
  %151 = insertvalue { ptr, i32 } poison, ptr %149, 0
  %152 = insertvalue { ptr, i32 } %151, i32 %150, 1
  resume { ptr, i32 } %152
}

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3LCAILi100001EE7addEdgeEii(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3LCAILi100001EE4initEi(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008), i32 noundef, i32 noundef) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008), i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3LCAILi100001EE3lcaEii(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef, i32 noundef) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!14 = !{!13, !6, i64 4}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.BIT.0 = type { [100002 x %struct.BIT] }
%struct.BIT = type { i32 }
%struct.LCA = type <{ i32, i32, i32, [4 x i8], [100001 x %"class.std::vector"], [17 x [100001 x i32]], [100001 x i32], [100001 x %"struct.std::pair"], i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator" = type { i8 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@N = external dso_local global i32, align 4
@Q = external dso_local global i32, align 4
@e = external dso_local global [100001 x i32], align 16
@B = external dso_local global %struct.BIT.0, align 4
@L = external dso_local global %struct.LCA, align 8
@.str.7 = external hidden unnamed_addr constant [8 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; 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 @_ZN2io5setIOENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %1 = alloca %"class.std::__cxx11::basic_string", align 8
  %2 = alloca %"class.std::allocator", align 1
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #4
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %2) #4
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull @.str.7, ptr noundef nonnull align 1 dereferenceable(1) %2)
          to label %9 unwind label %13

9:                                                ; preds = %0
  invoke void @_ZN2io5setIOENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull %1)
          to label %10 unwind label %15

10:                                               ; preds = %9
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #4
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %2) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  call void @_ZN5input2reIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @N, ptr noundef nonnull align 4 dereferenceable(4) @Q)
  %11 = load i32, ptr @N, align 4, !tbaa !5
  %.not23 = icmp slt i32 %11, 1
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.preheader22:                                     ; preds = %.lr.ph
  %12 = icmp sgt i32 %19, 1
  br i1 %12, label %.lr.ph26, label %._crit_edge

13:                                               ; preds = %0
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %9
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %1) #4
  br label %17

17:                                               ; preds = %15, %13
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %2) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  resume { ptr, i32 } %.pn

.lr.ph:                                           ; preds = %10, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %10 ]
  %18 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %indvars.iv
  call void @_ZN5input2reIiEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %18)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr @N, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %.not.not = icmp slt i64 %indvars.iv, %20
  br i1 %.not.not, label %.lr.ph, label %.preheader22, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph26, %10, %.preheader22
  %.lcssa = phi i32 [ %19, %.preheader22 ], [ %11, %10 ], [ %25, %.lr.ph26 ]
  call void @_ZN3LCAILi100001EE4initEi(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %.lcssa)
  %21 = load i32, ptr @N, align 4, !tbaa !5
  %.not2127 = icmp slt i32 %21, 1
  br i1 %.not2127, label %.preheader, label %.lr.ph30

.lr.ph26:                                         ; preds = %.preheader22, %.lr.ph26
  %.01625 = phi i32 [ %24, %.lr.ph26 ], [ 0, %.preheader22 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @_ZN5input2reIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !5
  call void @_ZN3LCAILi100001EE7addEdgeEii(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %22, i32 noundef %23)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %24 = add nuw nsw i32 %.01625, 1
  %25 = load i32, ptr @N, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %.lr.ph26, label %._crit_edge, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph30, %._crit_edge
  %28 = load i32, ptr @Q, align 4, !tbaa !5
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %.lr.ph32, label %._crit_edge33

.lr.ph30:                                         ; preds = %._crit_edge, %.lr.ph30
  %indvars.iv36 = phi i64 [ %indvars.iv.next37, %.lr.ph30 ], [ 1, %._crit_edge ]
  %30 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @L, i64 9600112), i64 0, i64 %indvars.iv36
  %31 = load i32, ptr %30, align 8, !tbaa !12
  %32 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %indvars.iv36
  %33 = load i32, ptr %32, align 4, !tbaa !5
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %31, i32 noundef %33)
  %34 = getelementptr inbounds i8, ptr %30, i64 4
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = add nsw i32 %35, 1
  %37 = load i32, ptr %32, align 4, !tbaa !5
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %36, i32 noundef %37)
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %38 = load i32, ptr @N, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %.not21.not = icmp slt i64 %indvars.iv36, %39
  br i1 %.not21.not, label %.lr.ph30, label %.preheader, !llvm.loop !15

._crit_edge33:                                    ; preds = %83, %.preheader
  ret i32 0

.lr.ph32:                                         ; preds = %.preheader, %83
  %.031 = phi i32 [ %84, %83 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @_ZN5input2reIiJiiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %64

42:                                               ; preds = %.lr.ph32
  %43 = load i32, ptr %6, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @L, i64 9600112), i64 0, i64 %44
  %46 = load i32, ptr %45, align 8, !tbaa !12
  %47 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %44
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = xor i32 %49, %48
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %46, i32 noundef %50)
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @L, i64 9600112), i64 0, i64 %52, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !14
  %55 = add nsw i32 %54, 1
  %56 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %52
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = xor i32 %58, %57
  call void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %55, i32 noundef %59)
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %62
  store i32 %60, ptr %63, align 4, !tbaa !5
  br label %83

64:                                               ; preds = %.lr.ph32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @L, i64 9600112), i64 0, i64 %66
  %68 = load i32, ptr %67, align 8, !tbaa !12
  %69 = call noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %68)
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [100001 x %"struct.std::pair"], ptr getelementptr inbounds (i8, ptr @L, i64 9600112), i64 0, i64 %71
  %73 = load i32, ptr %72, align 8, !tbaa !12
  %74 = call noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008) @B, i32 noundef %73)
  %75 = xor i32 %74, %69
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = call noundef i32 @_ZN3LCAILi100001EE3lcaEii(ptr noundef nonnull align 8 dereferenceable(10400124) @L, i32 noundef %76, i32 noundef %77)
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [100001 x i32], ptr @e, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = xor i32 %75, %81
  store i32 %82, ptr %8, align 4, !tbaa !5
  call void @_ZN6output2prIiJA2_cEEEvRKT_DpRKT0_(ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 1 dereferenceable(2) @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  br label %83

83:                                               ; preds = %64, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %84 = add nuw nsw i32 %.031, 1
  %85 = load i32, ptr @Q, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %.lr.ph32, label %._crit_edge33, !llvm.loop !16
}

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3LCAILi100001EE7addEdgeEii(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3LCAILi100001EE4initEi(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BITIiJLi100001EEE3updIJiEEEviDpT_(ptr noundef nonnull align 4 dereferenceable(400008), i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN3BITIiJLi100001EEE3sumIJEEEiiDpT_(ptr noundef nonnull align 4 dereferenceable(400008), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3LCAILi100001EE3lcaEii(ptr noundef nonnull align 8 dereferenceable(10400124), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!14 = !{!13, !6, i64 4}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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