; LLVM IR from eyangch/competitive-programming :: Codeforces/1554 (e)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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" }

@MOD = external dso_local global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@ans = external dso_local global [100001 x i64], align 16
@G = external dso_local global [100000 x %"class.std::vector"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3dfsxxx(i64 noundef, i64 noundef, i64 noundef) #0

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

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

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

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

26:                                               ; preds = %22
  %27 = 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 8, ptr %2) #7
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %28

28:                                               ; preds = %36, %26
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = load i64, ptr @N, align 8, !tbaa !8
  %31 = icmp slt i64 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  br label %39

33:                                               ; preds = %28
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %34
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #7
  br label %36

36:                                               ; preds = %33
  %37 = load i64, ptr %2, align 8, !tbaa !8
  %38 = add nsw i64 %37, 1
  store i64 %38, ptr %2, align 8, !tbaa !8
  br label %28, !llvm.loop !11

39:                                               ; preds = %32
  %40 = load i64, ptr @N, align 8, !tbaa !8
  %41 = getelementptr inbounds i64, ptr @ans, i64 %40
  %42 = getelementptr inbounds i64, ptr %41, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 0, ptr %3, align 4, !tbaa !13
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef @ans, ptr noundef %42, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %43

43:                                               ; preds = %60, %39
  %44 = load i64, ptr %4, align 8, !tbaa !8
  %45 = load i64, ptr @N, align 8, !tbaa !8
  %46 = sub nsw i64 %45, 1
  %47 = icmp slt i64 %44, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %63

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %51 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %52 = load i64, ptr %5, align 8, !tbaa !8
  %53 = add nsw i64 %52, -1
  store i64 %53, ptr %5, align 8, !tbaa !8
  %54 = load i64, ptr %6, align 8, !tbaa !8
  %55 = add nsw i64 %54, -1
  store i64 %55, ptr %6, align 8, !tbaa !8
  %56 = load i64, ptr %5, align 8, !tbaa !8
  %57 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %56
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %58 = load i64, ptr %6, align 8, !tbaa !8
  %59 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %58
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %59, ptr noundef nonnull align 8 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %60

60:                                               ; preds = %49
  %61 = load i64, ptr %4, align 8, !tbaa !8
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %4, align 8, !tbaa !8
  br label %43, !llvm.loop !15

63:                                               ; preds = %48
  store i64 1, ptr getelementptr inbounds ([100001 x i64], ptr @ans, i64 0, i64 1), align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !8
  br label %64

64:                                               ; preds = %75, %63
  %65 = load i64, ptr %7, align 8, !tbaa !8
  %66 = load i64, ptr @N, align 8, !tbaa !8
  %67 = sub nsw i64 %66, 1
  %68 = icmp slt i64 %65, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %78

70:                                               ; preds = %64
  %71 = load i64, ptr getelementptr inbounds ([100001 x i64], ptr @ans, i64 0, i64 1), align 8, !tbaa !8
  %72 = mul nsw i64 %71, 2
  %73 = load i64, ptr @MOD, align 8, !tbaa !8
  %74 = srem i64 %72, %73
  store i64 %74, ptr getelementptr inbounds ([100001 x i64], ptr @ans, i64 0, i64 1), align 8, !tbaa !8
  br label %75

75:                                               ; preds = %70
  %76 = load i64, ptr %7, align 8, !tbaa !8
  %77 = add nsw i64 %76, 1
  store i64 %77, ptr %7, align 8, !tbaa !8
  br label %64, !llvm.loop !16

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

79:                                               ; preds = %98, %78
  %80 = load i64, ptr %8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %101

84:                                               ; preds = %79
  %85 = load i64, ptr @N, align 8, !tbaa !8
  %86 = sub nsw i64 %85, 1
  %87 = load i64, ptr %8, align 8, !tbaa !8
  %88 = srem i64 %86, %87
  %89 = icmp eq i64 %88, 0
  br i1 %89, label %90, label %97

90:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %91 = load i64, ptr %8, align 8, !tbaa !8
  %92 = call noundef i64 @_Z3dfsxxx(i64 noundef 0, i64 noundef 0, i64 noundef %91)
  store i64 %92, ptr %9, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !8
  %93 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %94 = load i64, ptr %93, align 8, !tbaa !8
  %95 = load i64, ptr %8, align 8, !tbaa !8
  %96 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %95
  store i64 %94, ptr %96, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %97

97:                                               ; preds = %90, %84
  br label %98

98:                                               ; preds = %97
  %99 = load i64, ptr %8, align 8, !tbaa !8
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %8, align 8, !tbaa !8
  br label %79, !llvm.loop !17

101:                                              ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %102 = load i64, ptr @N, align 8, !tbaa !8
  %103 = sub nsw i64 %102, 1
  store i64 %103, ptr %11, align 8, !tbaa !8
  br label %104

104:                                              ; preds = %142, %101
  %105 = load i64, ptr %11, align 8, !tbaa !8
  %106 = icmp sgt i64 %105, 0
  br i1 %106, label %108, label %107

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

108:                                              ; preds = %104
  %109 = load i64, ptr %11, align 8, !tbaa !8
  %110 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %109
  %111 = load i64, ptr %110, align 8, !tbaa !8
  %112 = icmp ne i64 %111, 0
  br i1 %112, label %114, label %113

113:                                              ; preds = %108
  br label %142

114:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %115 = load i64, ptr %11, align 8, !tbaa !8
  %116 = mul nsw i64 2, %115
  store i64 %116, ptr %13, align 8, !tbaa !8
  br label %117

117:                                              ; preds = %137, %114
  %118 = load i64, ptr %13, align 8, !tbaa !8
  %119 = load i64, ptr @N, align 8, !tbaa !8
  %120 = sub nsw i64 %119, 1
  %121 = icmp sle i64 %118, %120
  br i1 %121, label %123, label %122

122:                                              ; preds = %117
  store i32 19, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %141

123:                                              ; preds = %117
  %124 = load i64, ptr %11, align 8, !tbaa !8
  %125 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %124
  %126 = load i64, ptr %125, align 8, !tbaa !8
  %127 = load i64, ptr @MOD, align 8, !tbaa !8
  %128 = add nsw i64 %126, %127
  %129 = load i64, ptr %13, align 8, !tbaa !8
  %130 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %129
  %131 = load i64, ptr %130, align 8, !tbaa !8
  %132 = sub nsw i64 %128, %131
  %133 = load i64, ptr @MOD, align 8, !tbaa !8
  %134 = srem i64 %132, %133
  %135 = load i64, ptr %11, align 8, !tbaa !8
  %136 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %135
  store i64 %134, ptr %136, align 8, !tbaa !8
  br label %137

137:                                              ; preds = %123
  %138 = load i64, ptr %11, align 8, !tbaa !8
  %139 = load i64, ptr %13, align 8, !tbaa !8
  %140 = add nsw i64 %139, %138
  store i64 %140, ptr %13, align 8, !tbaa !8
  br label %117, !llvm.loop !18

141:                                              ; preds = %122
  br label %142

142:                                              ; preds = %141, %113
  %143 = load i64, ptr %11, align 8, !tbaa !8
  %144 = add nsw i64 %143, -1
  store i64 %144, ptr %11, align 8, !tbaa !8
  br label %104, !llvm.loop !19

145:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 1, ptr %14, align 8, !tbaa !8
  br label %146

146:                                              ; preds = %157, %145
  %147 = load i64, ptr %14, align 8, !tbaa !8
  %148 = load i64, ptr @N, align 8, !tbaa !8
  %149 = icmp sle i64 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %146
  store i32 22, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %160

151:                                              ; preds = %146
  %152 = load i64, ptr %14, align 8, !tbaa !8
  %153 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %152
  %154 = load i64, ptr %153, align 8, !tbaa !8
  %155 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %154)
  %156 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %155, i8 noundef signext 32)
  br label %157

157:                                              ; preds = %151
  %158 = load i64, ptr %14, align 8, !tbaa !8
  %159 = add nsw i64 %158, 1
  store i64 %159, ptr %14, align 8, !tbaa !8
  br label %146, !llvm.loop !20

160:                                              ; preds = %150
  %161 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  br label %22, !llvm.loop !21

162:                                              ; preds = %22
  %163 = load i32, ptr %1, align 4
  ret i32 %163
}

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress 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 = !{!14, !14, i64 0}
!14 = !{!"int", !10, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl" = type { %"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" }
%"struct.std::_Vector_base<long long, std::allocator<long long>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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" }

@MOD = external dso_local local_unnamed_addr global i64, align 8
@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@ans = external dso_local global [100001 x i64], align 16
@G = external dso_local global [100000 x %"class.std::vector"], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3dfsxxx(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %7 = getelementptr i8, ptr %6, i64 -24
  %8 = load i64, ptr %7, align 8
  %9 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %8
  %10 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %9, ptr noundef null)
  %11 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %12 = 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)
  %13 = load i64, ptr @T, align 8, !tbaa !8
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr @T, align 8, !tbaa !8
  %.not66 = icmp eq i64 %13, 0
  br i1 %.not66, label %._crit_edge69, label %.lr.ph68

.lr.ph68:                                         ; preds = %0, %._crit_edge65
  %15 = 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)
  %16 = load i64, ptr @N, align 8, !tbaa !8
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph68
  %.lcssa = phi i64 [ %16, %.lr.ph68 ], [ %22, %.lr.ph ]
  %gep = getelementptr i64, ptr getelementptr inbounds (i8, ptr @ans, i64 8), i64 %.lcssa
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 0, ptr %1, align 4, !tbaa !11
  call void @_ZSt4fillIPxiEvT_S1_RKT0_(ptr noundef nonnull @ans, ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp sgt i64 %18, 1
  br i1 %19, label %.lr.ph44, label %.preheader37.thread

.preheader37.thread:                              ; preds = %._crit_edge
  store i64 1, ptr getelementptr inbounds (i8, ptr @ans, i64 8), align 8, !tbaa !8
  br label %.preheader

.lr.ph:                                           ; preds = %.lr.ph68, %.lr.ph
  %.03141 = phi i64 [ %21, %.lr.ph ], [ 0, %.lr.ph68 ]
  %20 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %.03141
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #7
  %21 = add nuw nsw i64 %.03141, 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 !13

._crit_edge45:                                    ; preds = %.lr.ph44
  store i64 1, ptr getelementptr inbounds (i8, ptr @ans, i64 8), align 8, !tbaa !8
  %24 = icmp sgt i64 %38, 1
  br i1 %24, label %.lr.ph49, label %.preheader38

.lr.ph49:                                         ; preds = %._crit_edge45
  %25 = load i64, ptr @MOD, align 8, !tbaa !8
  %26 = add nsw i64 %38, -2
  %xtraiter = and i64 %39, 3
  %27 = icmp ult i64 %26, 3
  br i1 %27, label %..preheader38_crit_edge.unr-lcssa, label %.lr.ph49.new

.lr.ph49.new:                                     ; preds = %.lr.ph49
  %unroll_iter = and i64 %39, -4
  br label %45

.lr.ph44:                                         ; preds = %._crit_edge, %.lr.ph44
  %.03042 = phi i64 [ %37, %.lr.ph44 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %28, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %30 = load i64, ptr %2, align 8, !tbaa !8
  %31 = add nsw i64 %30, -1
  store i64 %31, ptr %2, align 8, !tbaa !8
  %32 = load i64, ptr %3, align 8, !tbaa !8
  %33 = add nsw i64 %32, -1
  store i64 %33, ptr %3, align 8, !tbaa !8
  %34 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %31
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %35 = load i64, ptr %3, align 8, !tbaa !8
  %36 = getelementptr inbounds [100000 x %"class.std::vector"], ptr @G, i64 0, i64 %35
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %36, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %37 = add nuw nsw i64 %.03042, 1
  %38 = load i64, ptr @N, align 8, !tbaa !8
  %39 = add nsw i64 %38, -1
  %40 = icmp slt i64 %37, %39
  br i1 %40, label %.lr.ph44, label %._crit_edge45, !llvm.loop !15

..preheader38_crit_edge.unr-lcssa:                ; preds = %45, %.lr.ph49
  %.lcssa88.ph = phi i64 [ poison, %.lr.ph49 ], [ %54, %45 ]
  %.unr = phi i64 [ 1, %.lr.ph49 ], [ %54, %45 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %..preheader38_crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %..preheader38_crit_edge.unr-lcssa, %.epil.preheader
  %41 = phi i64 [ %43, %.epil.preheader ], [ %.unr, %..preheader38_crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %..preheader38_crit_edge.unr-lcssa ]
  %42 = shl nsw i64 %41, 1
  %43 = srem i64 %42, %25
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %..preheader38_crit_edge, label %.epil.preheader, !llvm.loop !16

..preheader38_crit_edge:                          ; preds = %.epil.preheader, %..preheader38_crit_edge.unr-lcssa
  %.lcssa88 = phi i64 [ %.lcssa88.ph, %..preheader38_crit_edge.unr-lcssa ], [ %43, %.epil.preheader ]
  store i64 %.lcssa88, ptr getelementptr inbounds (i8, ptr @ans, i64 8), align 8, !tbaa !8
  br label %.preheader38

.preheader38:                                     ; preds = %..preheader38_crit_edge, %._crit_edge45
  %44 = icmp sgt i64 %38, 2
  br i1 %44, label %.lr.ph52, label %.preheader37

45:                                               ; preds = %45, %.lr.ph49.new
  %46 = phi i64 [ 1, %.lr.ph49.new ], [ %54, %45 ]
  %niter = phi i64 [ 0, %.lr.ph49.new ], [ %niter.next.3, %45 ]
  %47 = shl nsw i64 %46, 1
  %48 = srem i64 %47, %25
  %49 = shl nsw i64 %48, 1
  %50 = srem i64 %49, %25
  %51 = shl nsw i64 %50, 1
  %52 = srem i64 %51, %25
  %53 = shl nsw i64 %52, 1
  %54 = srem i64 %53, %25
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %..preheader38_crit_edge.unr-lcssa, label %45, !llvm.loop !18

.preheader37:                                     ; preds = %67, %.preheader38
  %55 = phi i64 [ %38, %.preheader38 ], [ %68, %67 ]
  %56 = icmp sgt i64 %55, 1
  br i1 %56, label %.lr.ph61, label %.preheader

.lr.ph61:                                         ; preds = %.preheader37
  %57 = load i64, ptr @MOD, align 8
  br label %72

.lr.ph52:                                         ; preds = %.preheader38, %67
  %58 = phi i64 [ %68, %67 ], [ %38, %.preheader38 ]
  %.02851 = phi i64 [ %69, %67 ], [ 2, %.preheader38 ]
  %59 = add nsw i64 %58, -1
  %60 = srem i64 %59, %.02851
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %67

62:                                               ; preds = %.lr.ph52
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %63 = call noundef i64 @_Z3dfsxxx(i64 noundef 0, i64 noundef 0, i64 noundef %.02851)
  store i64 %63, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  store i64 0, ptr %5, align 8, !tbaa !8
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %65 = load i64, ptr %64, align 8, !tbaa !8
  %66 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.02851
  store i64 %65, ptr %66, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  %.pre = load i64, ptr @N, align 8, !tbaa !8
  br label %67

67:                                               ; preds = %.lr.ph52, %62
  %68 = phi i64 [ %58, %.lr.ph52 ], [ %.pre, %62 ]
  %69 = add nuw nsw i64 %.02851, 1
  %70 = icmp slt i64 %69, %68
  br i1 %70, label %.lr.ph52, label %.preheader37, !llvm.loop !19

.preheader:                                       ; preds = %.loopexit, %.preheader37.thread, %.preheader37
  %71 = phi i64 [ %18, %.preheader37.thread ], [ %55, %.preheader37 ], [ %55, %.loopexit ]
  %.not3462 = icmp slt i64 %71, 1
  br i1 %.not3462, label %._crit_edge65, label %.lr.ph64

72:                                               ; preds = %.lr.ph61, %.loopexit
  %.02760.in = phi i64 [ %55, %.lr.ph61 ], [ %.02760, %.loopexit ]
  %.02760 = add nsw i64 %.02760.in, -1
  %73 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.02760
  %74 = load i64, ptr %73, align 8, !tbaa !8
  %.not35 = icmp ne i64 %74, 0
  %75 = shl nuw nsw i64 %.02760, 1
  %.not36.not54 = icmp slt i64 %75, %55
  %or.cond = select i1 %.not35, i1 %.not36.not54, i1 false
  br i1 %or.cond, label %.lr.ph57, label %.loopexit

.lr.ph57:                                         ; preds = %72, %.lr.ph57
  %76 = phi i64 [ %81, %.lr.ph57 ], [ %74, %72 ]
  %.02655 = phi i64 [ %82, %.lr.ph57 ], [ %75, %72 ]
  %77 = add nsw i64 %57, %76
  %78 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.02655
  %79 = load i64, ptr %78, align 8, !tbaa !8
  %80 = sub i64 %77, %79
  %81 = srem i64 %80, %57
  store i64 %81, ptr %73, align 8, !tbaa !8
  %82 = add nsw i64 %.02655, %.02760
  %.not36.not = icmp slt i64 %82, %55
  br i1 %.not36.not, label %.lr.ph57, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph57, %72
  %83 = icmp sgt i64 %.02760.in, 2
  br i1 %83, label %72, label %.preheader, !llvm.loop !21

._crit_edge65:                                    ; preds = %.lr.ph64, %.preheader
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  %85 = load i64, ptr @T, align 8, !tbaa !8
  %86 = add nsw i64 %85, -1
  store i64 %86, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %85, 0
  br i1 %.not, label %._crit_edge69, label %.lr.ph68, !llvm.loop !22

.lr.ph64:                                         ; preds = %.preheader, %.lr.ph64
  %.063 = phi i64 [ %91, %.lr.ph64 ], [ 1, %.preheader ]
  %87 = getelementptr inbounds [100001 x i64], ptr @ans, i64 0, i64 %.063
  %88 = load i64, ptr %87, align 8, !tbaa !8
  %89 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %88)
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %89, i8 noundef signext 32)
  %91 = add nuw nsw i64 %.063, 1
  %92 = load i64, ptr @N, align 8, !tbaa !8
  %.not34.not = icmp slt i64 %.063, %92
  br i1 %.not34.not, label %.lr.ph64, label %._crit_edge65, !llvm.loop !23

._crit_edge69:                                    ; preds = %._crit_edge65, %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 #3 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress 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 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}


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