; LLVM IR from eyangch/competitive-programming :: Codeforces/1611 (d)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@b = external dso_local global [200000 x i64], align 16
@p = external dso_local global [200000 x i64], align 16
@rt = external dso_local global i64, align 8
@pt = external dso_local global i64, align 8
@ans = external dso_local global [200000 x i64], align 16
@sum = external dso_local global [200000 x i64], align 16
@g = external dso_local global [200000 x i64], align 16
@msum = external dso_local global i64, align 8
@vis = external dso_local global [200000 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

17:                                               ; preds = %168, %90, %0
  %18 = load i64, ptr @T, align 8, !tbaa !8
  %19 = add nsw i64 %18, -1
  store i64 %19, ptr @T, align 8, !tbaa !8
  %20 = icmp ne i64 %18, 0
  br i1 %20, label %21, label %169

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

23:                                               ; preds = %35, %21
  %24 = load i64, ptr %2, align 8, !tbaa !8
  %25 = load i64, ptr @N, align 8, !tbaa !8
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  br label %38

28:                                               ; preds = %23
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %29
  store i8 0, ptr %30, align 1, !tbaa !11
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %31
  store i64 0, ptr %32, align 8, !tbaa !8
  %33 = load i64, ptr %2, align 8, !tbaa !8
  %34 = getelementptr inbounds [200000 x i64], ptr @g, i64 0, i64 %33
  store i64 0, ptr %34, align 8, !tbaa !8
  br label %35

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

38:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %39

39:                                               ; preds = %66, %38
  %40 = load i64, ptr %3, align 8, !tbaa !8
  %41 = load i64, ptr @N, align 8, !tbaa !8
  %42 = icmp slt i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %69

44:                                               ; preds = %39
  %45 = load i64, ptr %3, align 8, !tbaa !8
  %46 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %45
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %46)
  %48 = load i64, ptr %3, align 8, !tbaa !8
  %49 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = add nsw i64 %50, -1
  store i64 %51, ptr %49, align 8, !tbaa !8
  %52 = load i64, ptr %3, align 8, !tbaa !8
  %53 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !8
  %55 = load i64, ptr %3, align 8, !tbaa !8
  %56 = icmp eq i64 %54, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %44
  %58 = load i64, ptr %3, align 8, !tbaa !8
  store i64 %58, ptr @rt, align 8, !tbaa !8
  br label %66

59:                                               ; preds = %44
  %60 = load i64, ptr %3, align 8, !tbaa !8
  %61 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !8
  %63 = getelementptr inbounds [200000 x i64], ptr @g, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !8
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %63, align 8, !tbaa !8
  br label %66

66:                                               ; preds = %59, %57
  %67 = load i64, ptr %3, align 8, !tbaa !8
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %3, align 8, !tbaa !8
  br label %39, !llvm.loop !15

69:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !8
  br label %70

70:                                               ; preds = %83, %69
  %71 = load i64, ptr %4, align 8, !tbaa !8
  %72 = load i64, ptr @N, align 8, !tbaa !8
  %73 = icmp slt i64 %71, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %86

75:                                               ; preds = %70
  %76 = load i64, ptr %4, align 8, !tbaa !8
  %77 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %76
  %78 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %77)
  %79 = load i64, ptr %4, align 8, !tbaa !8
  %80 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %79
  %81 = load i64, ptr %80, align 8, !tbaa !8
  %82 = add nsw i64 %81, -1
  store i64 %82, ptr %80, align 8, !tbaa !8
  br label %83

83:                                               ; preds = %75
  %84 = load i64, ptr %4, align 8, !tbaa !8
  %85 = add nsw i64 %84, 1
  store i64 %85, ptr %4, align 8, !tbaa !8
  br label %70, !llvm.loop !16

86:                                               ; preds = %74
  store i64 0, ptr @pt, align 8, !tbaa !8
  %87 = load i64, ptr @p, align 16, !tbaa !8
  %88 = load i64, ptr @rt, align 8, !tbaa !8
  %89 = icmp ne i64 %87, %88
  br i1 %89, label %90, label %93

90:                                               ; preds = %86
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %91, i8 noundef signext 10)
  br label %17, !llvm.loop !17

93:                                               ; preds = %86
  store i64 0, ptr @msum, align 8, !tbaa !8
  %94 = load i64, ptr @rt, align 8, !tbaa !8
  %95 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %94
  store i64 0, ptr %95, align 8, !tbaa !8
  %96 = load i64, ptr @rt, align 8, !tbaa !8
  %97 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %96
  store i8 1, ptr %97, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 1, ptr %5, align 8, !tbaa !8
  br label %98

98:                                               ; preds = %141, %93
  %99 = load i64, ptr %5, align 8, !tbaa !8
  %100 = load i64, ptr @N, align 8, !tbaa !8
  %101 = icmp slt i64 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 13, ptr %6, align 4
  br label %144

103:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %104 = load i64, ptr %5, align 8, !tbaa !8
  %105 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %104
  %106 = load i64, ptr %105, align 8, !tbaa !8
  store i64 %106, ptr %7, align 8, !tbaa !8
  %107 = load i64, ptr %7, align 8, !tbaa !8
  %108 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !8
  %110 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %109
  %111 = load i8, ptr %110, align 1, !tbaa !11, !range !18, !noundef !19
  %112 = trunc i8 %111 to i1
  br i1 %112, label %114, label %113

113:                                              ; preds = %103
  store i64 -1, ptr @rt, align 8, !tbaa !8
  store i32 13, ptr %6, align 4
  br label %138

114:                                              ; preds = %103
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %115 = load i64, ptr @msum, align 8, !tbaa !8
  %116 = load i64, ptr %7, align 8, !tbaa !8
  %117 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %116
  %118 = load i64, ptr %117, align 8, !tbaa !8
  %119 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !8
  %121 = sub nsw i64 %115, %120
  %122 = add nsw i64 %121, 1
  store i64 %122, ptr %8, align 8, !tbaa !8
  %123 = load i64, ptr %7, align 8, !tbaa !8
  %124 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %123
  %125 = load i64, ptr %124, align 8, !tbaa !8
  %126 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %125
  %127 = load i64, ptr %126, align 8, !tbaa !8
  %128 = load i64, ptr %8, align 8, !tbaa !8
  %129 = add nsw i64 %127, %128
  store i64 %129, ptr @msum, align 8, !tbaa !8
  %130 = load i64, ptr %8, align 8, !tbaa !8
  %131 = load i64, ptr %7, align 8, !tbaa !8
  %132 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %131
  store i64 %130, ptr %132, align 8, !tbaa !8
  %133 = load i64, ptr @msum, align 8, !tbaa !8
  %134 = load i64, ptr %7, align 8, !tbaa !8
  %135 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %134
  store i64 %133, ptr %135, align 8, !tbaa !8
  %136 = load i64, ptr %7, align 8, !tbaa !8
  %137 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %136
  store i8 1, ptr %137, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  store i32 0, ptr %6, align 4
  br label %138

138:                                              ; preds = %114, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %139 = load i32, ptr %6, align 4
  switch i32 %139, label %144 [
    i32 0, label %140
  ]

140:                                              ; preds = %138
  br label %141

141:                                              ; preds = %140
  %142 = load i64, ptr %5, align 8, !tbaa !8
  %143 = add nsw i64 %142, 1
  store i64 %143, ptr %5, align 8, !tbaa !8
  br label %98, !llvm.loop !20

144:                                              ; preds = %138, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %145

145:                                              ; preds = %144
  %146 = load i64, ptr @rt, align 8, !tbaa !8
  %147 = icmp eq i64 %146, -1
  br i1 %147, label %148, label %151

148:                                              ; preds = %145
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %150 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %149, i8 noundef signext 10)
  br label %168

151:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !8
  br label %152

152:                                              ; preds = %163, %151
  %153 = load i64, ptr %9, align 8, !tbaa !8
  %154 = load i64, ptr @N, align 8, !tbaa !8
  %155 = icmp slt i64 %153, %154
  br i1 %155, label %157, label %156

156:                                              ; preds = %152
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %166

157:                                              ; preds = %152
  %158 = load i64, ptr %9, align 8, !tbaa !8
  %159 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %158
  %160 = load i64, ptr %159, align 8, !tbaa !8
  %161 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %160)
  %162 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %161, i8 noundef signext 32)
  br label %163

163:                                              ; preds = %157
  %164 = load i64, ptr %9, align 8, !tbaa !8
  %165 = add nsw i64 %164, 1
  store i64 %165, ptr %9, align 8, !tbaa !8
  br label %152, !llvm.loop !21

166:                                              ; preds = %156
  %167 = 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 %168

168:                                              ; preds = %166, %148
  br label %17, !llvm.loop !17

169:                                              ; preds = %17
  %170 = load i32, ptr %1, align 4
  ret i32 %170
}

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

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

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

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

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

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

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

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

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

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

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


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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@b = external dso_local global [200000 x i64], align 16
@p = external dso_local global [200000 x i64], align 16
@rt = external dso_local local_unnamed_addr global i64, align 8
@pt = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global [200000 x i64], align 16
@sum = external dso_local local_unnamed_addr global [200000 x i64], align 16
@g = external dso_local local_unnamed_addr global [200000 x i64], align 16
@msum = external dso_local local_unnamed_addr global i64, align 8
@vis = external dso_local local_unnamed_addr global [200000 x i8], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

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

.lr.ph57:                                         ; preds = %0, %.backedge
  %10 = 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) @N)
  %11 = load i64, ptr @N, align 8, !tbaa !8
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph45.preheader, label %._crit_edge

.lr.ph45.preheader:                               ; preds = %.lr.ph57
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @vis, i8 0, i64 %11, i1 false), !tbaa !11
  %13 = shl nuw i64 %11, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @sum, i8 0, i64 %13, i1 false), !tbaa !8
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @g, i8 0, i64 %13, i1 false), !tbaa !8
  br label %.lr.ph45

.preheader41:                                     ; preds = %25
  %14 = icmp sgt i64 %27, 0
  br i1 %14, label %.lr.ph47, label %._crit_edge

.lr.ph45:                                         ; preds = %.lr.ph45.preheader, %25
  %.03444 = phi i64 [ %26, %25 ], [ 0, %.lr.ph45.preheader ]
  %15 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %.03444
  %16 = 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) %15)
  %17 = load i64, ptr %15, align 8, !tbaa !8
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr %15, align 8, !tbaa !8
  %19 = icmp eq i64 %18, %.03444
  br i1 %19, label %20, label %21

20:                                               ; preds = %.lr.ph45
  store i64 %.03444, ptr @rt, align 8, !tbaa !8
  br label %25

21:                                               ; preds = %.lr.ph45
  %22 = getelementptr inbounds [200000 x i64], ptr @g, i64 0, i64 %18
  %23 = load i64, ptr %22, align 8, !tbaa !8
  %24 = add nsw i64 %23, 1
  store i64 %24, ptr %22, align 8, !tbaa !8
  br label %25

25:                                               ; preds = %21, %20
  %26 = add nuw nsw i64 %.03444, 1
  %27 = load i64, ptr @N, align 8, !tbaa !8
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %.lr.ph45, label %.preheader41, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph47, %.lr.ph57, %.preheader41
  %29 = phi i64 [ %27, %.preheader41 ], [ %11, %.lr.ph57 ], [ %37, %.lr.ph47 ]
  store i64 0, ptr @pt, align 8, !tbaa !8
  %30 = load i64, ptr @p, align 16, !tbaa !8
  %31 = load i64, ptr @rt, align 8, !tbaa !8
  %.not39 = icmp eq i64 %30, %31
  br i1 %.not39, label %43, label %.backedge.sink.split

.lr.ph47:                                         ; preds = %.preheader41, %.lr.ph47
  %.03746 = phi i64 [ %36, %.lr.ph47 ], [ 0, %.preheader41 ]
  %32 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %.03746
  %33 = 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) %32)
  %34 = load i64, ptr %32, align 8, !tbaa !8
  %35 = add nsw i64 %34, -1
  store i64 %35, ptr %32, align 8, !tbaa !8
  %36 = add nuw nsw i64 %.03746, 1
  %37 = load i64, ptr @N, align 8, !tbaa !8
  %38 = icmp slt i64 %36, %37
  br i1 %38, label %.lr.ph47, label %._crit_edge, !llvm.loop !15

.backedge.sink.split:                             ; preds = %._crit_edge, %._crit_edge51, %.thread40
  %39 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  br label %.backedge

.backedge:                                        ; preds = %.lr.ph53, %.backedge.sink.split, %.preheader
  %.sink = phi ptr [ @_ZSt4cout, %.preheader ], [ %39, %.backedge.sink.split ], [ @_ZSt4cout, %.lr.ph53 ]
  %40 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %.sink, i8 noundef signext 10)
  %41 = load i64, ptr @T, align 8, !tbaa !8
  %42 = add nsw i64 %41, -1
  store i64 %42, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %41, 0
  br i1 %.not, label %._crit_edge58, label %.lr.ph57, !llvm.loop !16

43:                                               ; preds = %._crit_edge
  store i64 0, ptr @msum, align 8, !tbaa !8
  %44 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %30
  store i64 0, ptr %44, align 8, !tbaa !8
  %45 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %30
  store i8 1, ptr %45, align 1, !tbaa !11
  %46 = icmp sgt i64 %29, 1
  br i1 %46, label %.lr.ph50.preheader, label %._crit_edge51

.lr.ph50.preheader:                               ; preds = %43
  %47 = add nsw i64 %29, -2
  br label %.lr.ph50

.lr.ph50:                                         ; preds = %.lr.ph50.preheader, %56
  %.03648 = phi i64 [ %64, %56 ], [ 1, %.lr.ph50.preheader ]
  %48 = phi i64 [ %59, %56 ], [ 0, %.lr.ph50.preheader ]
  %49 = getelementptr inbounds [200000 x i64], ptr @p, i64 0, i64 %.03648
  %50 = load i64, ptr %49, align 8, !tbaa !8
  %51 = getelementptr inbounds [200000 x i64], ptr @b, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !8
  %53 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %52
  %54 = load i8, ptr %53, align 1, !tbaa !11, !range !17, !noundef !18
  %55 = trunc nuw i8 %54 to i1
  br i1 %55, label %56, label %.thread40

.thread40:                                        ; preds = %.lr.ph50
  store i64 -1, ptr @rt, align 8, !tbaa !8
  br label %.backedge.sink.split

56:                                               ; preds = %.lr.ph50
  %57 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %52
  %58 = load i64, ptr %57, align 8, !tbaa !8
  %59 = add nuw nsw i64 %48, 1
  %60 = sub i64 %59, %58
  store i64 %59, ptr @msum, align 8, !tbaa !8
  %61 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %50
  store i64 %60, ptr %61, align 8, !tbaa !8
  %62 = getelementptr inbounds [200000 x i64], ptr @sum, i64 0, i64 %50
  store i64 %59, ptr %62, align 8, !tbaa !8
  %63 = getelementptr inbounds [200000 x i8], ptr @vis, i64 0, i64 %50
  store i8 1, ptr %63, align 1, !tbaa !11
  %64 = add nuw nsw i64 %.03648, 1
  %exitcond.not = icmp eq i64 %48, %47
  br i1 %exitcond.not, label %._crit_edge51, label %.lr.ph50, !llvm.loop !19

._crit_edge51:                                    ; preds = %56, %43
  %65 = icmp eq i64 %30, -1
  br i1 %65, label %.backedge.sink.split, label %.preheader

.preheader:                                       ; preds = %._crit_edge51
  %66 = icmp sgt i64 %29, 0
  br i1 %66, label %.lr.ph53, label %.backedge

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %.052 = phi i64 [ %71, %.lr.ph53 ], [ 0, %.preheader ]
  %67 = getelementptr inbounds [200000 x i64], ptr @ans, i64 0, i64 %.052
  %68 = load i64, ptr %67, align 8, !tbaa !8
  %69 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %68)
  %70 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %69, i8 noundef signext 32)
  %71 = add nuw nsw i64 %.052, 1
  %72 = load i64, ptr @N, align 8, !tbaa !8
  %73 = icmp slt i64 %71, %72
  br i1 %73, label %.lr.ph53, label %.backedge, !llvm.loop !20

._crit_edge58:                                    ; preds = %.backedge, %0
  ret i32 0
}

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

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

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

; Function Attrs: 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 #4

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

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

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


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