; LLVM IR from eyangch/competitive-programming :: USACOcontests/silver/2022.12 (circular_barn)

; 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" }

@T = external dso_local global i64, align 8
@N = external dso_local global i64, align 8
@A = external dso_local global [100000 x i64], align 16
@P = external dso_local global %"class.std::vector", align 8
@sieve = external dso_local global [5000005 x i64], align 16
@dp = external dso_local global [5000005 x i64], align 16
@pm4 = external dso_local global [4 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 [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1

; 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 i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  store i64 1, ptr %2, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) @P, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  store i64 2, ptr %3, align 8, !tbaa !8
  br label %15

15:                                               ; preds = %40, %0
  %16 = load i64, ptr %3, align 8, !tbaa !8
  %17 = icmp sle i64 %16, 5000000
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %43

19:                                               ; preds = %15
  %20 = load i64, ptr %3, align 8, !tbaa !8
  %21 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !8
  %23 = icmp ne i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  br label %40

25:                                               ; preds = %19
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) @P, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %26 = load i64, ptr %3, align 8, !tbaa !8
  %27 = mul nsw i64 2, %26
  store i64 %27, ptr %5, align 8, !tbaa !8
  br label %28

28:                                               ; preds = %35, %25
  %29 = load i64, ptr %5, align 8, !tbaa !8
  %30 = icmp sle i64 %29, 5000000
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28
  %33 = load i64, ptr %5, align 8, !tbaa !8
  %34 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %33
  store i64 1, ptr %34, align 8, !tbaa !8
  br label %35

35:                                               ; preds = %32
  %36 = load i64, ptr %3, align 8, !tbaa !8
  %37 = load i64, ptr %5, align 8, !tbaa !8
  %38 = add nsw i64 %37, %36
  store i64 %38, ptr %5, align 8, !tbaa !8
  br label %28, !llvm.loop !11

39:                                               ; preds = %31
  br label %40

40:                                               ; preds = %39, %24
  %41 = load i64, ptr %3, align 8, !tbaa !8
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %3, align 8, !tbaa !8
  br label %15, !llvm.loop !13

43:                                               ; preds = %18
  store i64 0, ptr @dp, align 16, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 1, ptr %6, align 8, !tbaa !8
  br label %44

44:                                               ; preds = %83, %43
  %45 = load i64, ptr %6, align 8, !tbaa !8
  %46 = icmp sle i64 %45, 5000000
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %44
  %49 = load i64, ptr %6, align 8, !tbaa !8
  %50 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !8
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %58, label %53

53:                                               ; preds = %48
  %54 = load i64, ptr %6, align 8, !tbaa !8
  %55 = load i64, ptr %6, align 8, !tbaa !8
  %56 = srem i64 %55, 4
  %57 = getelementptr inbounds [4 x i64], ptr @pm4, i64 0, i64 %56
  store i64 %54, ptr %57, align 8, !tbaa !8
  br label %58

58:                                               ; preds = %53, %48
  %59 = load i64, ptr %6, align 8, !tbaa !8
  %60 = srem i64 %59, 4
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %70

62:                                               ; preds = %58
  %63 = load i64, ptr %6, align 8, !tbaa !8
  %64 = sub nsw i64 %63, 2
  %65 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %64
  %66 = load i64, ptr %65, align 8, !tbaa !8
  %67 = add nsw i64 %66, 1
  %68 = load i64, ptr %6, align 8, !tbaa !8
  %69 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %68
  store i64 %67, ptr %69, align 8, !tbaa !8
  br label %82

70:                                               ; preds = %58
  %71 = load i64, ptr %6, align 8, !tbaa !8
  %72 = load i64, ptr %6, align 8, !tbaa !8
  %73 = srem i64 %72, 4
  %74 = getelementptr inbounds [4 x i64], ptr @pm4, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !8
  %76 = sub nsw i64 %71, %75
  %77 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !8
  %79 = add nsw i64 %78, 1
  %80 = load i64, ptr %6, align 8, !tbaa !8
  %81 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %80
  store i64 %79, ptr %81, align 8, !tbaa !8
  br label %82

82:                                               ; preds = %70, %62
  br label %83

83:                                               ; preds = %82
  %84 = load i64, ptr %6, align 8, !tbaa !8
  %85 = add nsw i64 %84, 1
  store i64 %85, ptr %6, align 8, !tbaa !8
  br label %44, !llvm.loop !14

86:                                               ; preds = %47
  %87 = 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 %88

88:                                               ; preds = %135, %86
  %89 = load i64, ptr @T, align 8, !tbaa !8
  %90 = add nsw i64 %89, -1
  store i64 %90, ptr @T, align 8, !tbaa !8
  %91 = icmp ne i64 %89, 0
  br i1 %91, label %92, label %136

92:                                               ; preds = %88
  %93 = 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 %7) #6
  store i64 1000000000000000, ptr %7, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 0, ptr %8, align 8, !tbaa !8
  br label %94

94:                                               ; preds = %122, %92
  %95 = load i64, ptr %8, align 8, !tbaa !8
  %96 = load i64, ptr @N, align 8, !tbaa !8
  %97 = icmp slt i64 %95, %96
  br i1 %97, label %99, label %98

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

99:                                               ; preds = %94
  %100 = load i64, ptr %8, align 8, !tbaa !8
  %101 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %100
  %102 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %101)
  %103 = load i64, ptr %8, align 8, !tbaa !8
  %104 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %103
  %105 = load i64, ptr %104, align 8, !tbaa !8
  %106 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !8
  %108 = load i64, ptr %8, align 8, !tbaa !8
  %109 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %108
  store i64 %107, ptr %109, align 8, !tbaa !8
  %110 = load i64, ptr %8, align 8, !tbaa !8
  %111 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !8
  %113 = sdiv i64 %112, 2
  %114 = load i64, ptr %7, align 8, !tbaa !8
  %115 = sdiv i64 %114, 2
  %116 = icmp slt i64 %113, %115
  br i1 %116, label %117, label %121

117:                                              ; preds = %99
  %118 = load i64, ptr %8, align 8, !tbaa !8
  %119 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !8
  store i64 %120, ptr %7, align 8, !tbaa !8
  br label %121

121:                                              ; preds = %117, %99
  br label %122

122:                                              ; preds = %121
  %123 = load i64, ptr %8, align 8, !tbaa !8
  %124 = add nsw i64 %123, 1
  store i64 %124, ptr %8, align 8, !tbaa !8
  br label %94, !llvm.loop !15

125:                                              ; preds = %98
  %126 = load i64, ptr %7, align 8, !tbaa !8
  %127 = srem i64 %126, 2
  %128 = icmp eq i64 %127, 0
  br i1 %128, label %129, label %132

129:                                              ; preds = %125
  %130 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %131 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %130, i8 noundef signext 10)
  br label %135

132:                                              ; preds = %125
  %133 = 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)
  %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 10)
  br label %135

135:                                              ; preds = %132, %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %88, !llvm.loop !16

136:                                              ; preds = %88
  %137 = load i32, ptr %1, align 4
  ret i32 %137
}

; 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 dso_local void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24), 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: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 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: 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

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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
@A = external dso_local global [100000 x i64], align 16
@P = external dso_local global %"class.std::vector", align 8
@sieve = external dso_local local_unnamed_addr global [5000005 x i64], align 16
@dp = external dso_local local_unnamed_addr global [5000005 x i64], align 16
@pm4 = external dso_local local_unnamed_addr global [4 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 [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %4 = getelementptr i8, ptr %3, i64 -24
  %5 = load i64, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %5
  %7 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %6, ptr noundef null)
  %8 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  store i64 1, ptr %1, align 8, !tbaa !8
  call void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24) @P, ptr noundef nonnull align 8 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 2, ptr %2, align 8, !tbaa !8
  br label %10

9:                                                ; preds = %.loopexit
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  store i64 0, ptr @dp, align 16, !tbaa !8
  br label %38

10:                                               ; preds = %0, %.loopexit
  %storemerge32 = phi i64 [ 2, %0 ], [ %32, %.loopexit ]
  %11 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %storemerge32
  %12 = load i64, ptr %11, align 8, !tbaa !8
  %.not30 = icmp eq i64 %12, 0
  br i1 %.not30, label %13, label %.loopexit

13:                                               ; preds = %10
  call void @_ZNSt6vectorIxSaIxEE9push_backERKx(ptr noundef nonnull align 8 dereferenceable(24) @P, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %14 = load i64, ptr %2, align 8, !tbaa !8
  %15 = icmp slt i64 %14, 2500001
  br i1 %15, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %13
  %16 = shl nsw i64 %14, 1
  %17 = mul i64 %14, 3
  %smax = call i64 @llvm.smax.i64(i64 %17, i64 5000001)
  %18 = icmp slt i64 %17, 5000001
  %umin.neg = sext i1 %18 to i64
  %19 = select i1 %18, i64 2, i64 1
  %20 = add i64 %smax, %umin.neg
  %21 = sub i64 %20, %17
  %umax = call i64 @llvm.umax.i64(i64 %14, i64 1)
  %22 = udiv i64 %21, %umax
  %23 = add i64 %19, %22
  %min.iters.check = icmp ugt i64 %23, 3
  %ident.check.not = icmp eq i64 %14, 1
  %or.cond = and i1 %min.iters.check, %ident.check.not
  br i1 %or.cond, label %vector.ph, label %.lr.ph.preheader45

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %23, -4
  %24 = or disjoint i64 %n.vec, 2
  %ind.end = mul nuw i64 %14, %24
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 2
  %25 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %offset.idx
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  store <2 x i64> <i64 1, i64 1>, ptr %25, align 16, !tbaa !8
  store <2 x i64> <i64 1, i64 1>, ptr %26, align 16, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %27 = icmp eq i64 %index.next, %n.vec
  br i1 %27, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %23, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader45

.lr.ph.preheader45:                               ; preds = %middle.block, %.lr.ph.preheader
  %.02631.ph = phi i64 [ %16, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader45, %.lr.ph
  %.02631 = phi i64 [ %29, %.lr.ph ], [ %.02631.ph, %.lr.ph.preheader45 ]
  %28 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %.02631
  store i64 1, ptr %28, align 8, !tbaa !8
  %29 = add nsw i64 %.02631, %14
  %30 = icmp slt i64 %29, 5000001
  br i1 %30, label %.lr.ph, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph, %middle.block, %13, %10
  %31 = phi i64 [ %14, %13 ], [ %storemerge32, %10 ], [ %14, %middle.block ], [ %14, %.lr.ph ]
  %32 = add nsw i64 %31, 1
  store i64 %32, ptr %2, align 8, !tbaa !8
  %33 = icmp slt i64 %31, 5000000
  br i1 %33, label %10, label %9, !llvm.loop !16

34:                                               ; preds = %51
  %35 = 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)
  %36 = load i64, ptr @T, align 8, !tbaa !8
  %37 = add nsw i64 %36, -1
  store i64 %37, ptr @T, align 8, !tbaa !8
  %.not37 = icmp eq i64 %36, 0
  br i1 %.not37, label %._crit_edge40, label %.lr.ph39

38:                                               ; preds = %9, %51
  %.02533 = phi i64 [ 1, %9 ], [ %53, %51 ]
  %39 = getelementptr inbounds [5000005 x i64], ptr @sieve, i64 0, i64 %.02533
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %.not29 = icmp eq i64 %40, 0
  %41 = and i64 %.02533, 3
  br i1 %.not29, label %42, label %._crit_edge41

42:                                               ; preds = %38
  %43 = getelementptr inbounds [4 x i64], ptr @pm4, i64 0, i64 %41
  store i64 %.02533, ptr %43, align 8, !tbaa !8
  br label %._crit_edge41

._crit_edge41:                                    ; preds = %38, %42
  %44 = icmp eq i64 %41, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %._crit_edge41
  %46 = add nsw i64 %.02533, -2
  br label %51

47:                                               ; preds = %._crit_edge41
  %48 = getelementptr inbounds [4 x i64], ptr @pm4, i64 0, i64 %41
  %49 = load i64, ptr %48, align 8, !tbaa !8
  %50 = sub nsw i64 %.02533, %49
  br label %51

51:                                               ; preds = %45, %47
  %.pn = phi i64 [ %46, %45 ], [ %50, %47 ]
  %.sink.in.in = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %.pn
  %.sink.in = load i64, ptr %.sink.in.in, align 8, !tbaa !8
  %.sink = add nsw i64 %.sink.in, 1
  %52 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %.02533
  store i64 %.sink, ptr %52, align 8
  %53 = add nuw nsw i64 %.02533, 1
  %exitcond.not = icmp eq i64 %53, 5000001
  br i1 %exitcond.not, label %34, label %38, !llvm.loop !17

.lr.ph39:                                         ; preds = %34, %._crit_edge.thread
  %54 = 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)
  %55 = load i64, ptr @N, align 8, !tbaa !8
  %56 = icmp sgt i64 %55, 0
  br i1 %56, label %.lr.ph36, label %._crit_edge.thread

._crit_edge:                                      ; preds = %.lr.ph36
  %57 = and i64 %spec.select, 1
  %58 = icmp eq i64 %57, 0
  %spec.select44 = select i1 %58, ptr @.str, ptr @.str.2
  br label %._crit_edge.thread

.lr.ph36:                                         ; preds = %.lr.ph39, %.lr.ph36
  %.035 = phi i64 [ %67, %.lr.ph36 ], [ 0, %.lr.ph39 ]
  %.02434 = phi i64 [ %spec.select, %.lr.ph36 ], [ 1000000000000000, %.lr.ph39 ]
  %59 = getelementptr inbounds [100000 x i64], ptr @A, i64 0, i64 %.035
  %60 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %59)
  %61 = load i64, ptr %59, align 8, !tbaa !8
  %62 = getelementptr inbounds [5000005 x i64], ptr @dp, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !8
  store i64 %63, ptr %59, align 8, !tbaa !8
  %64 = sdiv i64 %63, 2
  %65 = sdiv i64 %.02434, 2
  %66 = icmp slt i64 %64, %65
  %spec.select = select i1 %66, i64 %63, i64 %.02434
  %67 = add nuw nsw i64 %.035, 1
  %68 = load i64, ptr @N, align 8, !tbaa !8
  %69 = icmp slt i64 %67, %68
  br i1 %69, label %.lr.ph36, label %._crit_edge, !llvm.loop !18

._crit_edge.thread:                               ; preds = %._crit_edge, %.lr.ph39
  %.str.2.sink = phi ptr [ @.str, %.lr.ph39 ], [ %spec.select44, %._crit_edge ]
  %70 = 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.sink)
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %70, i8 noundef signext 10)
  %72 = load i64, ptr @T, align 8, !tbaa !8
  %73 = add nsw i64 %72, -1
  store i64 %73, ptr @T, align 8, !tbaa !8
  %.not = icmp eq i64 %72, 0
  br i1 %.not, label %._crit_edge40, label %.lr.ph39, !llvm.loop !19

._crit_edge40:                                    ; preds = %._crit_edge.thread, %34
  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 dso_local void @_ZNSt6vectorIxSaIxEE9push_backEOx(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 #3 align 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 #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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #6

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 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12, !13}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass