; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (327B-HungrySequence-PrimesSolution)

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

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; 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 i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 8, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 20, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 10000000, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = mul nsw i64 8, %17
  store i64 %18, ptr %7, align 8, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %20 = load i64, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  store i64 %20, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = add nsw i64 %21, 1
  %23 = call noalias noundef nonnull ptr @_Znam(i64 noundef %22) #6
  store ptr %23, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %32, %0
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = icmp sle i64 %25, 20
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %35

28:                                               ; preds = %24
  %29 = load ptr, ptr %8, align 8, !tbaa !11
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  store i8 0, ptr %31, align 1, !tbaa !13
  br label %32

32:                                               ; preds = %28
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = add nsw i64 %33, 1
  store i64 %34, ptr %9, align 8, !tbaa !9
  br label %24, !llvm.loop !15

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 21, ptr %10, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %45, %35
  %37 = load i64, ptr %10, align 8, !tbaa !9
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = icmp slt i64 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %48

41:                                               ; preds = %36
  %42 = load ptr, ptr %8, align 8, !tbaa !11
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  store i8 1, ptr %44, align 1, !tbaa !13
  br label %45

45:                                               ; preds = %41
  %46 = load i64, ptr %10, align 8, !tbaa !9
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %10, align 8, !tbaa !9
  br label %36, !llvm.loop !17

48:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %81, %48
  %50 = load i64, ptr %11, align 8, !tbaa !9
  %51 = load i64, ptr %6, align 8, !tbaa !9
  %52 = icmp slt i64 %50, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %49
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %84

54:                                               ; preds = %49
  %55 = load ptr, ptr %8, align 8, !tbaa !11
  %56 = load i64, ptr %11, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !13, !range !18, !noundef !19
  %59 = trunc i8 %58 to i1
  br i1 %59, label %60, label %80

60:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 2, ptr %13, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %76, %60
  %62 = load i64, ptr %11, align 8, !tbaa !9
  %63 = load i32, ptr %13, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = mul nsw i64 %62, %64
  %66 = load i64, ptr %6, align 8, !tbaa !9
  %67 = icmp slt i64 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %61
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %79

69:                                               ; preds = %61
  %70 = load ptr, ptr %8, align 8, !tbaa !11
  %71 = load i32, ptr %13, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = load i64, ptr %11, align 8, !tbaa !9
  %74 = mul nsw i64 %72, %73
  %75 = getelementptr inbounds i8, ptr %70, i64 %74
  store i8 0, ptr %75, align 1, !tbaa !13
  br label %76

76:                                               ; preds = %69
  %77 = load i32, ptr %13, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %13, align 4, !tbaa !5
  br label %61, !llvm.loop !20

79:                                               ; preds = %68
  br label %80

80:                                               ; preds = %79, %54
  br label %81

81:                                               ; preds = %80
  %82 = load i64, ptr %11, align 8, !tbaa !9
  %83 = add nsw i64 %82, 1
  store i64 %83, ptr %11, align 8, !tbaa !9
  br label %49, !llvm.loop !21

84:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %85 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %85, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %107, %84
  %87 = load i64, ptr %15, align 8, !tbaa !9
  %88 = load i64, ptr %6, align 8, !tbaa !9
  %89 = icmp slt i64 %87, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %86
  store i32 14, ptr %12, align 4
  br label %110

91:                                               ; preds = %86
  %92 = load ptr, ptr %8, align 8, !tbaa !11
  %93 = load i64, ptr %15, align 8, !tbaa !9
  %94 = getelementptr inbounds i8, ptr %92, i64 %93
  %95 = load i8, ptr %94, align 1, !tbaa !13, !range !18, !noundef !19
  %96 = trunc i8 %95 to i1
  br i1 %96, label %97, label %106

97:                                               ; preds = %91
  %98 = load i64, ptr %15, align 8, !tbaa !9
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %98)
  %100 = load i64, ptr %14, align 8, !tbaa !9
  %101 = add nsw i64 %100, -1
  store i64 %101, ptr %14, align 8, !tbaa !9
  %102 = load i64, ptr %14, align 8, !tbaa !9
  %103 = icmp ne i64 %102, 0
  br i1 %103, label %105, label %104

104:                                              ; preds = %97
  store i32 14, ptr %12, align 4
  br label %110

105:                                              ; preds = %97
  br label %106

106:                                              ; preds = %105, %91
  br label %107

107:                                              ; preds = %106
  %108 = load i64, ptr %15, align 8, !tbaa !9
  %109 = add nsw i64 %108, 1
  store i64 %109, ptr %15, align 8, !tbaa !9
  br label %86, !llvm.loop !22

110:                                              ; preds = %104, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %111

111:                                              ; preds = %110
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %112 = load i32, ptr %1, align 4
  ret i32 %112
}

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

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

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

declare i32 @printf(ptr noundef, ...) #2

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

!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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16}


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

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader39:
  %0 = alloca i64, align 8
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) #6
  store i64 10000000, ptr %0, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = shl nsw i64 %4, 3
  store i64 %5, ptr %2, align 8, !tbaa !5
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %7 = load i64, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  %8 = add nsw i64 %7, 1
  %9 = call noalias noundef nonnull ptr @_Znam(i64 noundef %8) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(21) %9, i8 0, i64 21, i1 false), !tbaa !9
  %10 = icmp sgt i64 %7, 21
  br i1 %10, label %.preheader38.thread, label %.preheader38

.preheader38.thread:                              ; preds = %.preheader39
  %scevgep = getelementptr i8, ptr %9, i64 21
  %11 = add nsw i64 %7, -21
  call void @llvm.memset.p0.i64(ptr align 1 %scevgep, i8 1, i64 %11, i1 false), !tbaa !9
  br label %.lr.ph46.preheader

.preheader38:                                     ; preds = %.preheader39
  %12 = icmp sgt i64 %7, 0
  br i1 %12, label %.lr.ph46.preheader, label %._crit_edge51

.lr.ph46.preheader:                               ; preds = %.preheader38.thread, %.preheader38
  br label %.lr.ph46

.lr.ph50.preheader:                               ; preds = %.loopexit
  %13 = load i64, ptr %1, align 8, !tbaa !5
  br label %.lr.ph50

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %.loopexit
  %.03244 = phi i64 [ %23, %.loopexit ], [ 0, %.lr.ph46.preheader ]
  %14 = getelementptr inbounds i8, ptr %9, i64 %.03244
  %15 = load i8, ptr %14, align 1, !tbaa !9, !range !11, !noundef !12
  %16 = trunc nuw i8 %15 to i1
  %17 = shl nuw nsw i64 %.03244, 1
  %18 = icmp slt i64 %17, %7
  %or.cond = select i1 %16, i1 %18, i1 false
  br i1 %or.cond, label %.lr.ph43, label %.loopexit

.lr.ph43:                                         ; preds = %.lr.ph46, %.lr.ph43
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph43 ], [ 2, %.lr.ph46 ]
  %19 = phi i64 [ %21, %.lr.ph43 ], [ %17, %.lr.ph46 ]
  %20 = getelementptr inbounds i8, ptr %9, i64 %19
  store i8 0, ptr %20, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = mul nuw nsw i64 %.03244, %indvars.iv.next
  %22 = icmp slt i64 %21, %7
  br i1 %22, label %.lr.ph43, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph43, %.lr.ph46
  %23 = add nuw nsw i64 %.03244, 1
  %exitcond.not = icmp eq i64 %23, %7
  br i1 %exitcond.not, label %.lr.ph50.preheader, label %.lr.ph46, !llvm.loop !15

.lr.ph50:                                         ; preds = %.lr.ph50.preheader, %30
  %.048 = phi i64 [ %31, %30 ], [ 0, %.lr.ph50.preheader ]
  %.03047 = phi i64 [ %.1, %30 ], [ %13, %.lr.ph50.preheader ]
  %24 = getelementptr inbounds i8, ptr %9, i64 %.048
  %25 = load i8, ptr %24, align 1, !tbaa !9, !range !11, !noundef !12
  %26 = trunc nuw i8 %25 to i1
  br i1 %26, label %27, label %30

27:                                               ; preds = %.lr.ph50
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.048)
  %29 = add nsw i64 %.03047, -1
  %.not = icmp eq i64 %29, 0
  br i1 %.not, label %._crit_edge51, label %30

30:                                               ; preds = %.lr.ph50, %27
  %.1 = phi i64 [ %29, %27 ], [ %.03047, %.lr.ph50 ]
  %31 = add nuw nsw i64 %.048, 1
  %exitcond55.not = icmp eq i64 %31, %7
  br i1 %exitcond55.not, label %._crit_edge51, label %.lr.ph50, !llvm.loop !16

._crit_edge51:                                    ; preds = %30, %27, %.preheader38
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) #6
  ret i32 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

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

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

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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