; LLVM IR from ADJA/algos :: NumberTheory (CatalanNumbers)

; 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_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@sieve = external dso_local global [1001000 x i32], align 16
@p = external dso_local global [1001000 x i32], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@_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 i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @mod)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %51, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = mul nsw i32 2, %14
  %16 = icmp sle i32 %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %54

18:                                               ; preds = %12
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %50

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = mul nsw i32 2, %25
  store i32 %26, ptr %4, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %45, %24
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = mul nsw i32 2, %29
  %31 = icmp sle i32 %28, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %27
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %49

33:                                               ; preds = %27
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %33
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %42
  store i32 %40, ptr %43, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %39, %33
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, %46
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %27, !llvm.loop !9

49:                                               ; preds = %32
  br label %50

50:                                               ; preds = %49, %18
  br label %51

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

54:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %55 = load i32, ptr @n, align 4, !tbaa !5
  %56 = add nsw i32 %55, 2
  store i32 %56, ptr %5, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %92, %54
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = load i32, ptr @n, align 4, !tbaa !5
  %60 = mul nsw i32 2, %59
  %61 = icmp sle i32 %58, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %95

63:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %64 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %64, ptr %6, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %71, %63
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %86

71:                                               ; preds = %65
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %77, align 4, !tbaa !5
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = sdiv i32 %84, %83
  store i32 %85, ptr %6, align 4, !tbaa !5
  br label %65, !llvm.loop !12

86:                                               ; preds = %65
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %89, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %92

92:                                               ; preds = %86
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %5, align 4, !tbaa !5
  br label %57, !llvm.loop !13

95:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %130, %95
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = load i32, ptr @n, align 4, !tbaa !5
  %99 = icmp sle i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %133

101:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %102 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %102, ptr %8, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %109, %101
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %124

109:                                              ; preds = %103
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = add nsw i32 %116, -1
  store i32 %117, ptr %115, align 4, !tbaa !5
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = load i32, ptr %8, align 4, !tbaa !5
  %123 = sdiv i32 %122, %121
  store i32 %123, ptr %8, align 4, !tbaa !5
  br label %103, !llvm.loop !14

124:                                              ; preds = %103
  %125 = load i32, ptr %8, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = add nsw i32 %128, -1
  store i32 %129, ptr %127, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %130

130:                                              ; preds = %124
  %131 = load i32, ptr %7, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %7, align 4, !tbaa !5
  br label %96, !llvm.loop !15

133:                                              ; preds = %100
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %162, %133
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = load i32, ptr @n, align 4, !tbaa !5
  %137 = mul nsw i32 2, %136
  %138 = icmp sle i32 %135, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %134
  store i32 18, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %165

140:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %141

141:                                              ; preds = %158, %140
  %142 = load i32, ptr %10, align 4, !tbaa !5
  %143 = load i32, ptr %9, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = icmp sle i32 %142, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %141
  store i32 21, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %161

149:                                              ; preds = %141
  %150 = load i64, ptr @ans, align 8, !tbaa !16
  %151 = mul nsw i64 1, %150
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = mul nsw i64 %151, %153
  %155 = load i32, ptr @mod, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = srem i64 %154, %156
  store i64 %157, ptr @ans, align 8, !tbaa !16
  br label %158

158:                                              ; preds = %149
  %159 = load i32, ptr %10, align 4, !tbaa !5
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %10, align 4, !tbaa !5
  br label %141, !llvm.loop !18

161:                                              ; preds = %148
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %9, align 4, !tbaa !5
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %9, align 4, !tbaa !5
  br label %134, !llvm.loop !19

165:                                              ; preds = %139
  %166 = load i64, ptr @ans, align 8, !tbaa !16
  %167 = load i32, ptr @mod, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = srem i64 %166, %168
  %170 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %169)
  %171 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %170, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }

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

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


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

%"class.std::basic_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@mod = external dso_local global i32, align 4
@sieve = external dso_local local_unnamed_addr global [1001000 x i32], align 16
@p = external dso_local local_unnamed_addr global [1001000 x i32], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@_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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @mod)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = shl i32 %2, 1
  %.not57 = icmp slt i32 %2, 1
  br i1 %.not57, label %._crit_edge, label %.lr.ph60.preheader

.lr.ph60.preheader:                               ; preds = %0
  %smax = tail call i32 @llvm.smax.i32(i32 %3, i32 2)
  %4 = or disjoint i32 %smax, 1
  %wide.trip.count = zext nneg i32 %4 to i64
  br label %.lr.ph60

._crit_edge:                                      ; preds = %.loopexit, %0
  %5 = add nsw i32 %2, 2
  %.not4167 = icmp sgt i32 %5, %3
  br i1 %.not4167, label %.preheader50, label %.preheader51.preheader

.preheader51.preheader:                           ; preds = %._crit_edge
  %6 = sext i32 %5 to i64
  %7 = or disjoint i32 %3, 1
  br label %.preheader51

.lr.ph60:                                         ; preds = %.lr.ph60.preheader, %.loopexit
  %indvars.iv91 = phi i64 [ 2, %.lr.ph60.preheader ], [ %indvars.iv.next92, %.loopexit ]
  %indvars.iv = phi i64 [ 4, %.lr.ph60.preheader ], [ %indvars.iv.next, %.loopexit ]
  %8 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %indvars.iv91
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = icmp ne i32 %9, 0
  %indvars.iv91.tr = trunc i64 %indvars.iv91 to i32
  %11 = shl i32 %indvars.iv91.tr, 1
  %.not4755 = icmp sgt i32 %11, %3
  %or.cond = or i1 %10, %.not4755
  br i1 %or.cond, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph60
  %12 = trunc nuw nsw i64 %indvars.iv91 to i32
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %indvars.iv93 = phi i64 [ %indvars.iv, %.lr.ph.preheader ], [ %indvars.iv.next94, %17 ]
  %13 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %indvars.iv93
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %.lr.ph
  store i32 %12, ptr %13, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %.lr.ph, %16
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, %indvars.iv91
  %18 = trunc nuw i64 %indvars.iv.next94 to i32
  %.not47 = icmp slt i32 %3, %18
  br i1 %.not47, label %.loopexit, label %.lr.ph, !llvm.loop !9

.loopexit:                                        ; preds = %17, %.lr.ph60
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not = icmp eq i64 %indvars.iv.next92, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph60, !llvm.loop !11

.preheader51:                                     ; preds = %.preheader51.preheader, %._crit_edge65
  %indvars.iv97 = phi i64 [ %6, %.preheader51.preheader ], [ %indvars.iv.next98, %._crit_edge65 ]
  %19 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %indvars.iv97
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not4662 = icmp eq i32 %20, 0
  br i1 %.not4662, label %._crit_edge65, label %.lr.ph64.preheader

.lr.ph64.preheader:                               ; preds = %.preheader51
  %21 = trunc nsw i64 %indvars.iv97 to i32
  br label %.lr.ph64

.preheader50:                                     ; preds = %._crit_edge65, %._crit_edge
  br i1 %.not57, label %.preheader48.._crit_edge87_crit_edge, label %.preheader49.preheader

.preheader49.preheader:                           ; preds = %.preheader50
  %22 = add nuw i32 %2, 1
  %wide.trip.count104 = zext i32 %22 to i64
  br label %.preheader49

.lr.ph64:                                         ; preds = %.lr.ph64.preheader, %.lr.ph64
  %23 = phi i32 [ %31, %.lr.ph64 ], [ %20, %.lr.ph64.preheader ]
  %.03563 = phi i32 [ %28, %.lr.ph64 ], [ %21, %.lr.ph64.preheader ]
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !5
  %28 = sdiv i32 %.03563, %23
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %.not46 = icmp eq i32 %31, 0
  br i1 %.not46, label %._crit_edge65, label %.lr.ph64, !llvm.loop !12

._crit_edge65:                                    ; preds = %.lr.ph64, %.preheader51
  %.lcssa52 = phi i64 [ %indvars.iv97, %.preheader51 ], [ %29, %.lr.ph64 ]
  %32 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %.lcssa52
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %32, align 4, !tbaa !5
  %indvars.iv.next98 = add nsw i64 %indvars.iv97, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next98 to i32
  %exitcond100.not = icmp eq i32 %7, %lftr.wideiv
  br i1 %exitcond100.not, label %.preheader50, label %.preheader51, !llvm.loop !13

.preheader49:                                     ; preds = %.preheader49.preheader, %._crit_edge72
  %indvars.iv101 = phi i64 [ 1, %.preheader49.preheader ], [ %indvars.iv.next102, %._crit_edge72 ]
  %35 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %indvars.iv101
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not4569 = icmp eq i32 %36, 0
  br i1 %.not4569, label %._crit_edge72, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %.preheader49
  %37 = trunc nuw nsw i64 %indvars.iv101 to i32
  br label %.lr.ph71

.preheader48:                                     ; preds = %._crit_edge72
  br i1 %.not57, label %.preheader48.._crit_edge87_crit_edge, label %.preheader.lr.ph

.preheader48.._crit_edge87_crit_edge:             ; preds = %.preheader50, %.preheader48
  %.pre = load i64, ptr @ans, align 8, !tbaa !14
  %.pre113 = load i32, ptr @mod, align 4, !tbaa !5
  %.pre114 = sext i32 %.pre113 to i64
  br label %._crit_edge87

.preheader.lr.ph:                                 ; preds = %.preheader48
  %ans.promoted81 = load i64, ptr @ans, align 8, !tbaa !14
  %38 = load i32, ptr @mod, align 4
  %39 = sext i32 %38 to i64
  %smax110 = tail call i32 @llvm.smax.i32(i32 %3, i32 2)
  %40 = or disjoint i32 %smax110, 1
  %wide.trip.count111 = zext nneg i32 %40 to i64
  br label %.preheader

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %.lr.ph71
  %41 = phi i32 [ %49, %.lr.ph71 ], [ %36, %.lr.ph71.preheader ]
  %.03370 = phi i32 [ %46, %.lr.ph71 ], [ %37, %.lr.ph71.preheader ]
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr %43, align 4, !tbaa !5
  %46 = sdiv i32 %.03370, %41
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1001000 x i32], ptr @sieve, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %.not45 = icmp eq i32 %49, 0
  br i1 %.not45, label %._crit_edge72, label %.lr.ph71, !llvm.loop !16

._crit_edge72:                                    ; preds = %.lr.ph71, %.preheader49
  %.lcssa = phi i64 [ %indvars.iv101, %.preheader49 ], [ %47, %.lr.ph71 ]
  %50 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %.lcssa
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %50, align 4, !tbaa !5
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %exitcond105.not = icmp eq i64 %indvars.iv.next102, %wide.trip.count104
  br i1 %exitcond105.not, label %.preheader48, label %.preheader49, !llvm.loop !17

.preheader:                                       ; preds = %.preheader.lr.ph, %63
  %indvars.iv107 = phi i64 [ 2, %.preheader.lr.ph ], [ %indvars.iv.next108, %63 ]
  %.lcssa808385 = phi i64 [ %ans.promoted81, %.preheader.lr.ph ], [ %.lcssa8082, %63 ]
  %53 = getelementptr inbounds [1001000 x i32], ptr @p, i64 0, i64 %indvars.iv107
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %.not4476 = icmp slt i32 %54, 1
  br i1 %.not4476, label %63, label %.lr.ph78.preheader

.lr.ph78.preheader:                               ; preds = %.preheader
  %xtraiter = and i32 %54, 3
  %55 = icmp ult i32 %54, 4
  br i1 %55, label %._crit_edge79.unr-lcssa, label %.lr.ph78.preheader.new

.lr.ph78.preheader.new:                           ; preds = %.lr.ph78.preheader
  %unroll_iter = and i32 %54, 2147483644
  br label %.lr.ph78

._crit_edge87:                                    ; preds = %63, %.preheader48.._crit_edge87_crit_edge
  %.pre-phi = phi i64 [ %.pre114, %.preheader48.._crit_edge87_crit_edge ], [ %39, %63 ]
  %56 = phi i64 [ %.pre, %.preheader48.._crit_edge87_crit_edge ], [ %.lcssa8082, %63 ]
  %57 = srem i64 %56, %.pre-phi
  %58 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %57)
  %59 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %58, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

._crit_edge79.unr-lcssa:                          ; preds = %.lr.ph78, %.lr.ph78.preheader
  %.lcssa121.ph = phi i64 [ poison, %.lr.ph78.preheader ], [ %72, %.lr.ph78 ]
  %.unr = phi i64 [ %.lcssa808385, %.lr.ph78.preheader ], [ %72, %.lr.ph78 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge79, label %.lr.ph78.epil

.lr.ph78.epil:                                    ; preds = %._crit_edge79.unr-lcssa, %.lr.ph78.epil
  %60 = phi i64 [ %62, %.lr.ph78.epil ], [ %.unr, %._crit_edge79.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph78.epil ], [ 0, %._crit_edge79.unr-lcssa ]
  %61 = mul nsw i64 %60, %indvars.iv107
  %62 = srem i64 %61, %39
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge79, label %.lr.ph78.epil, !llvm.loop !18

._crit_edge79:                                    ; preds = %.lr.ph78.epil, %._crit_edge79.unr-lcssa
  %.lcssa121 = phi i64 [ %.lcssa121.ph, %._crit_edge79.unr-lcssa ], [ %62, %.lr.ph78.epil ]
  store i64 %.lcssa121, ptr @ans, align 8, !tbaa !14
  br label %63

63:                                               ; preds = %._crit_edge79, %.preheader
  %.lcssa8082 = phi i64 [ %.lcssa121, %._crit_edge79 ], [ %.lcssa808385, %.preheader ]
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %exitcond112.not = icmp eq i64 %indvars.iv.next108, %wide.trip.count111
  br i1 %exitcond112.not, label %._crit_edge87, label %.preheader, !llvm.loop !20

.lr.ph78:                                         ; preds = %.lr.ph78, %.lr.ph78.preheader.new
  %64 = phi i64 [ %.lcssa808385, %.lr.ph78.preheader.new ], [ %72, %.lr.ph78 ]
  %niter = phi i32 [ 0, %.lr.ph78.preheader.new ], [ %niter.next.3, %.lr.ph78 ]
  %65 = mul nsw i64 %64, %indvars.iv107
  %66 = srem i64 %65, %39
  %67 = mul nsw i64 %66, %indvars.iv107
  %68 = srem i64 %67, %39
  %69 = mul nsw i64 %68, %indvars.iv107
  %70 = srem i64 %69, %39
  %71 = mul nsw i64 %70, %indvars.iv107
  %72 = srem i64 %71, %39
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge79.unr-lcssa, label %.lr.ph78, !llvm.loop !21
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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

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

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


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass