; LLVM IR from eyangch/competitive-programming :: Codeforces/1738 (f)

; 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" }
%class.anon = type { i8 }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@D = external dso_local global [1000 x i64], align 16
@I = external dso_local global [1000 x i64], align 16
@vis = external dso_local global [1000 x i8], align 16
@G = external dso_local global [1000 x %"class.std::vector"], align 16
@ans = external dso_local global [1000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsxx(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 %class.anon, align 1
  %4 = alloca i32, align 4
  %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
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %13 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %14 = getelementptr i8, ptr %13, i64 -24
  %15 = load i64, ptr %14, align 8
  %16 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %15
  %17 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %16, ptr noundef null)
  %18 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %19 = 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 %20

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

24:                                               ; preds = %20
  %25 = 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 %26

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

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

31:                                               ; preds = %26
  %32 = load i64, ptr %2, align 8, !tbaa !8
  %33 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %32
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #6
  %34 = load i64, ptr %2, align 8, !tbaa !8
  %35 = getelementptr inbounds [1000 x i64], ptr @D, i64 0, i64 %34
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %35)
  br label %37

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

40:                                               ; preds = %30
  %41 = load i64, ptr @N, align 8, !tbaa !8
  %42 = getelementptr inbounds i64, ptr @I, i64 %41
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef @I, ptr noundef %42, i32 noundef 0)
  %43 = load i64, ptr @N, align 8, !tbaa !8
  %44 = getelementptr inbounds i64, ptr @I, i64 %43
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef @I, ptr noundef %44)
  %45 = load i64, ptr @N, align 8, !tbaa !8
  %46 = getelementptr inbounds i8, ptr @vis, i64 %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !13
  call void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef @vis, ptr noundef %46, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !8
  br label %47

47:                                               ; preds = %104, %40
  %48 = load i64, ptr %5, align 8, !tbaa !8
  %49 = load i64, ptr @N, align 8, !tbaa !8
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 7, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %107

52:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %53 = load i64, ptr %5, align 8, !tbaa !8
  %54 = getelementptr inbounds [1000 x i64], ptr @I, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !8
  store i64 %55, ptr %7, align 8, !tbaa !8
  %56 = load i64, ptr %7, align 8, !tbaa !8
  %57 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !15, !range !17, !noundef !18
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %61

60:                                               ; preds = %52
  store i32 9, ptr %6, align 4
  br label %101

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

62:                                               ; preds = %94, %61
  %63 = load i64, ptr %8, align 8, !tbaa !8
  %64 = load i64, ptr %7, align 8, !tbaa !8
  %65 = getelementptr inbounds [1000 x i64], ptr @D, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = icmp slt i64 %63, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %62
  store i32 10, ptr %6, align 4
  br label %97

69:                                               ; preds = %62
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %71 = load i64, ptr %7, align 8, !tbaa !8
  %72 = add nsw i64 %71, 1
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %70, i64 noundef %72)
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %73, i8 noundef signext 10)
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %76 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %77 = load i64, ptr %9, align 8, !tbaa !8
  %78 = add nsw i64 %77, -1
  store i64 %78, ptr %9, align 8, !tbaa !8
  %79 = load i64, ptr %7, align 8, !tbaa !8
  %80 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %79
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %80, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %81 = load i64, ptr %9, align 8, !tbaa !8
  %82 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %81
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %82, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %83 = load i64, ptr %9, align 8, !tbaa !8
  %84 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %83
  %85 = load i8, ptr %84, align 1, !tbaa !15, !range !17, !noundef !18
  %86 = trunc i8 %85 to i1
  br i1 %86, label %87, label %88

87:                                               ; preds = %69
  store i32 10, ptr %6, align 4
  br label %91

88:                                               ; preds = %69
  %89 = load i64, ptr %9, align 8, !tbaa !8
  %90 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %89
  store i8 1, ptr %90, align 1, !tbaa !15
  store i32 0, ptr %6, align 4
  br label %91

91:                                               ; preds = %88, %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %92 = load i32, ptr %6, align 4
  switch i32 %92, label %97 [
    i32 0, label %93
  ]

93:                                               ; preds = %91
  br label %94

94:                                               ; preds = %93
  %95 = load i64, ptr %8, align 8, !tbaa !8
  %96 = add nsw i64 %95, 1
  store i64 %96, ptr %8, align 8, !tbaa !8
  br label %62, !llvm.loop !19

97:                                               ; preds = %91, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %98

98:                                               ; preds = %97
  %99 = load i64, ptr %7, align 8, !tbaa !8
  %100 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %99
  store i8 1, ptr %100, align 1, !tbaa !15
  store i32 0, ptr %6, align 4
  br label %101

101:                                              ; preds = %98, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %102 = load i32, ptr %6, align 4
  switch i32 %102, label %143 [
    i32 0, label %103
    i32 9, label %104
  ]

103:                                              ; preds = %101
  br label %104

104:                                              ; preds = %103, %101
  %105 = load i64, ptr %5, align 8, !tbaa !8
  %106 = add nsw i64 %105, 1
  store i64 %106, ptr %5, align 8, !tbaa !8
  br label %47, !llvm.loop !20

107:                                              ; preds = %51
  %108 = load i64, ptr @N, align 8, !tbaa !8
  %109 = getelementptr inbounds i8, ptr @vis, i64 %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !13
  call void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef @vis, ptr noundef %109, ptr noundef nonnull align 4 dereferenceable(4) %10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 0, ptr %11, align 8, !tbaa !8
  br label %110

110:                                              ; preds = %119, %107
  %111 = load i64, ptr %11, align 8, !tbaa !8
  %112 = load i64, ptr @N, align 8, !tbaa !8
  %113 = icmp slt i64 %111, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %110
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %122

115:                                              ; preds = %110
  %116 = load i64, ptr %11, align 8, !tbaa !8
  %117 = load i64, ptr %11, align 8, !tbaa !8
  %118 = add nsw i64 %117, 1
  call void @_Z3dfsxx(i64 noundef %116, i64 noundef %118)
  br label %119

119:                                              ; preds = %115
  %120 = load i64, ptr %11, align 8, !tbaa !8
  %121 = add nsw i64 %120, 1
  store i64 %121, ptr %11, align 8, !tbaa !8
  br label %110, !llvm.loop !21

122:                                              ; preds = %114
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %124

124:                                              ; preds = %135, %122
  %125 = load i64, ptr %12, align 8, !tbaa !8
  %126 = load i64, ptr @N, align 8, !tbaa !8
  %127 = icmp slt i64 %125, %126
  br i1 %127, label %129, label %128

128:                                              ; preds = %124
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  br label %138

129:                                              ; preds = %124
  %130 = load i64, ptr %12, align 8, !tbaa !8
  %131 = getelementptr inbounds [1000 x i64], ptr @ans, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !8
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %132)
  %134 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %133, i8 noundef signext 32)
  br label %135

135:                                              ; preds = %129
  %136 = load i64, ptr %12, align 8, !tbaa !8
  %137 = add nsw i64 %136, 1
  store i64 %137, ptr %12, align 8, !tbaa !8
  br label %124, !llvm.loop !22

138:                                              ; preds = %128
  %139 = 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)
  %140 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  br label %20, !llvm.loop !23

141:                                              ; preds = %20
  %142 = load i32, ptr %1, align 4
  ret i32 %142

143:                                              ; preds = %101
  unreachable
}

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) #5

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

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) #4

; 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

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 = { 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 = !{!16, !16, i64 0}
!16 = !{!"bool", !10, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@D = external dso_local global [1000 x i64], align 16
@I = external dso_local global [1000 x i64], align 16
@vis = external dso_local global [1000 x i8], align 16
@G = external dso_local global [1000 x %"class.std::vector"], align 16
@ans = external dso_local local_unnamed_addr global [1000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z3dfsxx(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 i32, align 4
  %5 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %6 = getelementptr i8, ptr %5, i64 -24
  %7 = load i64, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %7
  %9 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %8, ptr noundef null)
  %10 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @T)
  %12 = load i64, ptr @T, align 8, !tbaa !8
  %13 = add nsw i64 %12, -1
  store i64 %13, ptr @T, align 8, !tbaa !8
  %.not42 = icmp eq i64 %12, 0
  br i1 %.not42, label %._crit_edge45, label %.lr.ph44

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

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph44
  %.lcssa = phi i64 [ %15, %.lr.ph44 ], [ %28, %.lr.ph ]
  %17 = getelementptr inbounds i64, ptr @I, i64 %.lcssa
  call void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef nonnull @I, ptr noundef nonnull %17, i32 noundef 0)
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = getelementptr inbounds i64, ptr @I, i64 %18
  call void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef nonnull @I, ptr noundef nonnull %19)
  %20 = load i64, ptr @N, align 8, !tbaa !8
  %21 = getelementptr inbounds i8, ptr @vis, i64 %20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  store i32 0, ptr %1, align 4, !tbaa !11
  call void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef nonnull @vis, ptr noundef nonnull %21, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %22 = load i64, ptr @N, align 8, !tbaa !8
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %.lr.ph31, label %._crit_edge32

.lr.ph:                                           ; preds = %.lr.ph44, %.lr.ph
  %.02226 = phi i64 [ %27, %.lr.ph ], [ 0, %.lr.ph44 ]
  %24 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %.02226
  call void @_ZNSt6vectorIxSaIxEE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %24) #6
  %25 = getelementptr inbounds [1000 x i64], ptr @D, i64 0, i64 %.02226
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %25)
  %27 = add nuw nsw i64 %.02226, 1
  %28 = load i64, ptr @N, align 8, !tbaa !8
  %29 = icmp slt i64 %27, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge32:                                    ; preds = %67, %._crit_edge
  %.lcssa25 = phi i64 [ %22, %._crit_edge ], [ %68, %67 ]
  %30 = getelementptr inbounds i8, ptr @vis, i64 %.lcssa25
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  store i32 0, ptr %4, align 4, !tbaa !11
  call void @_ZSt4fillIPbiEvT_S1_RKT0_(ptr noundef nonnull @vis, ptr noundef nonnull %30, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %31 = load i64, ptr @N, align 8, !tbaa !8
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %.lr.ph36, label %._crit_edge37

.lr.ph31:                                         ; preds = %._crit_edge, %67
  %33 = phi i64 [ %68, %67 ], [ %22, %._crit_edge ]
  %.02129 = phi i64 [ %69, %67 ], [ 0, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %34 = getelementptr inbounds [1000 x i64], ptr @I, i64 0, i64 %.02129
  %35 = load i64, ptr %34, align 8, !tbaa !8
  store i64 %35, ptr %2, align 8, !tbaa !8
  %36 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !15, !range !17, !noundef !18
  %38 = trunc nuw i8 %37 to i1
  br i1 %38, label %67, label %.preheader

.preheader:                                       ; preds = %.lr.ph31
  %39 = getelementptr inbounds [1000 x i64], ptr @D, i64 0, i64 %35
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = icmp sgt i64 %40, 0
  br i1 %41, label %.lr.ph28, label %.loopexit

.lr.ph28:                                         ; preds = %.preheader, %59
  %.01927 = phi i64 [ %60, %59 ], [ 0, %.preheader ]
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  %43 = load i64, ptr %2, align 8, !tbaa !8
  %44 = add nsw i64 %43, 1
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %42, i64 noundef %44)
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %45, i8 noundef signext 10)
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %49 = load i64, ptr %3, align 8, !tbaa !8
  %50 = add nsw i64 %49, -1
  store i64 %50, ptr %3, align 8, !tbaa !8
  %51 = load i64, ptr %2, align 8, !tbaa !8
  %52 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %51
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %52, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %53 = load i64, ptr %3, align 8, !tbaa !8
  %54 = getelementptr inbounds [1000 x %"class.std::vector"], ptr @G, i64 0, i64 %53
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %55 = load i64, ptr %3, align 8, !tbaa !8
  %56 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %55
  %57 = load i8, ptr %56, align 1, !tbaa !15, !range !17, !noundef !18
  %58 = trunc nuw i8 %57 to i1
  br i1 %58, label %.critedge, label %59

59:                                               ; preds = %.lr.ph28
  store i8 1, ptr %56, align 1, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %60 = add nuw nsw i64 %.01927, 1
  %61 = load i64, ptr %2, align 8, !tbaa !8
  %62 = getelementptr inbounds [1000 x i64], ptr @D, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !8
  %64 = icmp slt i64 %60, %63
  br i1 %64, label %.lr.ph28, label %.loopexit, !llvm.loop !19

.critedge:                                        ; preds = %.lr.ph28
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %.pre = load i64, ptr %2, align 8, !tbaa !8
  br label %.loopexit

.loopexit:                                        ; preds = %59, %.preheader, %.critedge
  %65 = phi i64 [ %35, %.preheader ], [ %.pre, %.critedge ], [ %61, %59 ]
  %66 = getelementptr inbounds [1000 x i8], ptr @vis, i64 0, i64 %65
  store i8 1, ptr %66, align 1, !tbaa !15
  %.pre48 = load i64, ptr @N, align 8, !tbaa !8
  br label %67

67:                                               ; preds = %.lr.ph31, %.loopexit
  %68 = phi i64 [ %33, %.lr.ph31 ], [ %.pre48, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %69 = add nuw nsw i64 %.02129, 1
  %70 = icmp slt i64 %69, %68
  br i1 %70, label %.lr.ph31, label %._crit_edge32, !llvm.loop !20

._crit_edge37:                                    ; preds = %.lr.ph36, %._crit_edge32
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str.2)
  %72 = load i64, ptr @N, align 8, !tbaa !8
  %73 = icmp sgt i64 %72, 0
  br i1 %73, label %.lr.ph40, label %._crit_edge41

.lr.ph36:                                         ; preds = %._crit_edge32, %.lr.ph36
  %.01834 = phi i64 [ %74, %.lr.ph36 ], [ 0, %._crit_edge32 ]
  %74 = add nuw nsw i64 %.01834, 1
  call void @_Z3dfsxx(i64 noundef %.01834, i64 noundef %74)
  %75 = load i64, ptr @N, align 8, !tbaa !8
  %76 = icmp slt i64 %74, %75
  br i1 %76, label %.lr.ph36, label %._crit_edge37, !llvm.loop !21

._crit_edge41:                                    ; preds = %.lr.ph40, %._crit_edge37
  %77 = 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)
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout)
  %79 = load i64, ptr @T, align 8, !tbaa !8
  %80 = add nsw i64 %79, -1
  store i64 %80, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %79, 0
  br i1 %.not, label %._crit_edge45, label %.lr.ph44, !llvm.loop !22

.lr.ph40:                                         ; preds = %._crit_edge37, %.lr.ph40
  %.038 = phi i64 [ %85, %.lr.ph40 ], [ 0, %._crit_edge37 ]
  %81 = getelementptr inbounds [1000 x i64], ptr @ans, i64 0, i64 %.038
  %82 = load i64, ptr %81, align 8, !tbaa !8
  %83 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %82)
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %83, i8 noundef signext 32)
  %85 = add nuw nsw i64 %.038, 1
  %86 = load i64, ptr @N, align 8, !tbaa !8
  %87 = icmp slt i64 %85, %86
  br i1 %87, label %.lr.ph40, label %._crit_edge41, !llvm.loop !23

._crit_edge45:                                    ; preds = %._crit_edge41, %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: mustprogress nounwind uwtable
declare dso_local void @_ZSt4iotaIPxiEvT_S1_T0_(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZSt4sortIPxZ4mainE3$_0EvT_S2_T0_"(ptr noundef, ptr noundef) local_unnamed_addr #5

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

; 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: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

; 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

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 = { 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 = !{!16, !16, i64 0}
!16 = !{!"bool", !10, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}


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