; LLVM IR from ritikbanger/Hacktoberfest2022-DSA :: 01. Mathematics (sum of all div using seive)

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

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

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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 ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %15 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %16 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %17 = getelementptr i8, ptr %16, i64 -24
  %18 = load i64, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %18
  %20 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %19, ptr noundef null)
  %21 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %22 = getelementptr i8, ptr %21, i64 -24
  %23 = load i64, ptr %22, align 8
  %24 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %23
  %25 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %24, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #9
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %27 = load i64, ptr %2, align 8, !tbaa !8
  %28 = add nsw i64 %27, 1
  %29 = call ptr @llvm.stacksave.p0()
  store ptr %29, ptr %3, align 8
  %30 = alloca i8, i64 %28, align 16
  store i64 %28, ptr %4, align 8
  %31 = load i64, ptr %2, align 8, !tbaa !8
  %32 = add nsw i64 %31, 1
  %33 = alloca i64, i64 %32, align 16
  store i64 %32, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #9
  store i64 0, ptr %6, align 8, !tbaa !8
  br label %34

34:                                               ; preds = %43, %0
  %35 = load i64, ptr %6, align 8, !tbaa !8
  %36 = load i64, ptr %2, align 8, !tbaa !8
  %37 = icmp sle i64 %35, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %34
  %40 = load i64, ptr %6, align 8, !tbaa !8
  %41 = load i64, ptr %6, align 8, !tbaa !8
  %42 = getelementptr inbounds i64, ptr %33, i64 %41
  store i64 %40, ptr %42, align 8, !tbaa !8
  br label %43

43:                                               ; preds = %39
  %44 = load i64, ptr %6, align 8, !tbaa !8
  %45 = add nsw i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !8
  br label %34, !llvm.loop !11

46:                                               ; preds = %38
  call void @llvm.memset.p0.i64(ptr align 16 %30, i8 1, i64 %28, i1 false)
  %47 = getelementptr inbounds i8, ptr %30, i64 0
  store i8 0, ptr %47, align 16, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %30, i64 1
  store i8 0, ptr %48, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #9
  store i64 2, ptr %7, align 8, !tbaa !8
  br label %49

49:                                               ; preds = %90, %46
  %50 = load i64, ptr %7, align 8, !tbaa !8
  %51 = load i64, ptr %7, align 8, !tbaa !8
  %52 = mul nsw i64 %50, %51
  %53 = load i64, ptr %2, align 8, !tbaa !8
  %54 = icmp sle i64 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %49
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #9
  br label %93

56:                                               ; preds = %49
  %57 = load i64, ptr %7, align 8, !tbaa !8
  %58 = getelementptr inbounds i8, ptr %30, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !13, !range !15, !noundef !16
  %60 = trunc i8 %59 to i1
  %61 = zext i1 %60 to i32
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %89

63:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #9
  %64 = load i64, ptr %7, align 8, !tbaa !8
  %65 = mul nsw i64 2, %64
  store i64 %65, ptr %9, align 8, !tbaa !17
  br label %66

66:                                               ; preds = %84, %63
  %67 = load i64, ptr %9, align 8, !tbaa !17
  %68 = load i64, ptr %2, align 8, !tbaa !8
  %69 = icmp sle i64 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  br label %88

71:                                               ; preds = %66
  %72 = load i64, ptr %9, align 8, !tbaa !17
  %73 = getelementptr inbounds i8, ptr %30, i64 %72
  store i8 0, ptr %73, align 1, !tbaa !13
  %74 = load i64, ptr %9, align 8, !tbaa !17
  %75 = getelementptr inbounds i64, ptr %33, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !8
  %77 = load i64, ptr %9, align 8, !tbaa !17
  %78 = icmp eq i64 %76, %77
  br i1 %78, label %79, label %83

79:                                               ; preds = %71
  %80 = load i64, ptr %7, align 8, !tbaa !8
  %81 = load i64, ptr %9, align 8, !tbaa !17
  %82 = getelementptr inbounds i64, ptr %33, i64 %81
  store i64 %80, ptr %82, align 8, !tbaa !8
  br label %83

83:                                               ; preds = %79, %71
  br label %84

84:                                               ; preds = %83
  %85 = load i64, ptr %7, align 8, !tbaa !8
  %86 = load i64, ptr %9, align 8, !tbaa !17
  %87 = add nsw i64 %86, %85
  store i64 %87, ptr %9, align 8, !tbaa !17
  br label %66, !llvm.loop !19

88:                                               ; preds = %70
  br label %89

89:                                               ; preds = %88, %56
  br label %90

90:                                               ; preds = %89
  %91 = load i64, ptr %7, align 8, !tbaa !8
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %7, align 8, !tbaa !8
  br label %49, !llvm.loop !20

93:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #9
  store i64 1, ptr %10, align 8, !tbaa !17
  br label %94

94:                                               ; preds = %112, %93
  %95 = load i64, ptr %2, align 8, !tbaa !8
  %96 = icmp sgt i64 %95, 1
  br i1 %96, label %97, label %126

97:                                               ; preds = %94
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %98 = load i64, ptr %2, align 8, !tbaa !8
  %99 = getelementptr inbounds i64, ptr %33, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !8
  store i64 %100, ptr %11, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  store i64 0, ptr %12, align 8, !tbaa !8
  br label %101

101:                                              ; preds = %106, %97
  %102 = load i64, ptr %2, align 8, !tbaa !8
  %103 = load i64, ptr %11, align 8, !tbaa !8
  %104 = srem i64 %102, %103
  %105 = icmp eq i64 %104, 0
  br i1 %105, label %106, label %112

106:                                              ; preds = %101
  %107 = load i64, ptr %12, align 8, !tbaa !8
  %108 = add nsw i64 %107, 1
  store i64 %108, ptr %12, align 8, !tbaa !8
  %109 = load i64, ptr %11, align 8, !tbaa !8
  %110 = load i64, ptr %2, align 8, !tbaa !8
  %111 = sdiv i64 %110, %109
  store i64 %111, ptr %2, align 8, !tbaa !8
  br label %101, !llvm.loop !21

112:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #9
  %113 = load i64, ptr %11, align 8, !tbaa !8
  %114 = load i64, ptr %12, align 8, !tbaa !8
  %115 = add nsw i64 %114, 1
  %116 = call noundef double @_ZSt3powIllEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef %113, i64 noundef %115)
  %117 = fsub double %116, 1.000000e+00
  %118 = fptosi double %117 to i64
  store i64 %118, ptr %13, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  %119 = load i64, ptr %11, align 8, !tbaa !8
  %120 = sub nsw i64 %119, 1
  store i64 %120, ptr %14, align 8, !tbaa !17
  %121 = load i64, ptr %13, align 8, !tbaa !17
  %122 = load i64, ptr %14, align 8, !tbaa !17
  %123 = sdiv i64 %121, %122
  %124 = load i64, ptr %10, align 8, !tbaa !17
  %125 = mul nsw i64 %124, %123
  store i64 %125, ptr %10, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  br label %94, !llvm.loop !22

126:                                              ; preds = %94
  %127 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  %128 = load i64, ptr %10, align 8, !tbaa !17
  %129 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %127, i64 noundef %128)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #9
  %130 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %130)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #9
  %131 = load i32, ptr %1, align 4
  ret i32 %131
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIllEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef, i64 noundef) #7

; 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) #8

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { "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 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind willreturn }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 #8 = { 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 #9 = { 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", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !10, i64 0}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !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::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" }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 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 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %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 = load ptr, ptr @_ZSt4cout, align 8, !tbaa !5
  %9 = getelementptr i8, ptr %8, i64 -24
  %10 = load i64, ptr %9, align 8
  %11 = getelementptr inbounds i8, ptr @_ZSt4cout, i64 %10
  %12 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %11, ptr noundef null)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #9
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %14 = load i64, ptr %1, align 8, !tbaa !8
  %15 = add nsw i64 %14, 1
  %16 = call ptr @llvm.stacksave.p0()
  %17 = alloca i8, i64 %15, align 16
  %18 = load i64, ptr %1, align 8, !tbaa !8
  %19 = add i64 %18, 1
  %20 = alloca i64, i64 %19, align 16
  %.not35 = icmp slt i64 %18, 0
  br i1 %.not35, label %._crit_edge52, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %21 = add nuw i64 %18, 1
  %min.iters.check = icmp ult i64 %18, 3
  br i1 %min.iters.check, label %.lr.ph.preheader65, label %vector.ph

.lr.ph.preheader65:                               ; preds = %middle.block, %.lr.ph.preheader
  %.036.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %21, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i64> [ <i64 0, i64 1>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i64> %vec.ind, <i64 2, i64 2>
  %22 = getelementptr inbounds i64, ptr %20, i64 %index
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store <2 x i64> %vec.ind, ptr %22, align 16, !tbaa !8
  store <2 x i64> %step.add, ptr %23, align 16, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %21, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader65

._crit_edge:                                      ; preds = %.lr.ph, %middle.block
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %17, i8 1, i64 %15, i1 false)
  %25 = getelementptr inbounds i8, ptr %17, i64 1
  store i8 0, ptr %25, align 1, !tbaa !15
  %.not3341 = icmp slt i64 %18, 4
  br i1 %.not3341, label %.preheader, label %.lr.ph45

.lr.ph:                                           ; preds = %.lr.ph.preheader65, %.lr.ph
  %.036 = phi i64 [ %27, %.lr.ph ], [ %.036.ph, %.lr.ph.preheader65 ]
  %26 = getelementptr inbounds i64, ptr %20, i64 %.036
  store i64 %.036, ptr %26, align 8, !tbaa !8
  %27 = add nuw i64 %.036, 1
  %exitcond.not = icmp eq i64 %.036, %18
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !17

.preheader:                                       ; preds = %.loopexit, %._crit_edge
  %28 = icmp sgt i64 %18, 1
  br i1 %28, label %.lr.ph51, label %._crit_edge52

.lr.ph45:                                         ; preds = %._crit_edge, %.loopexit
  %.02942 = phi i64 [ %38, %.loopexit ], [ 2, %._crit_edge ]
  %29 = getelementptr inbounds i8, ptr %17, i64 %.02942
  %30 = load i8, ptr %29, align 1, !tbaa !15, !range !18, !noundef !19
  %31 = trunc nuw i8 %30 to i1
  %32 = shl nuw nsw i64 %.02942, 1
  %.not3437 = icmp sle i64 %32, %18
  %or.cond.not = select i1 %31, i1 %.not3437, i1 false
  br i1 %or.cond.not, label %.lr.ph40, label %.loopexit

.lr.ph40:                                         ; preds = %.lr.ph45, %.lr.ph40
  %.03138 = phi i64 [ %37, %.lr.ph40 ], [ %32, %.lr.ph45 ]
  %33 = getelementptr inbounds i8, ptr %17, i64 %.03138
  store i8 0, ptr %33, align 1, !tbaa !15
  %34 = getelementptr inbounds i64, ptr %20, i64 %.03138
  %35 = load i64, ptr %34, align 8, !tbaa !8
  %36 = icmp eq i64 %35, %.03138
  %spec.store.select = select i1 %36, i64 %.02942, i64 %35
  store i64 %spec.store.select, ptr %34, align 8
  %37 = add nuw nsw i64 %.03138, %.02942
  %.not34 = icmp sgt i64 %37, %18
  br i1 %.not34, label %.loopexit, label %.lr.ph40, !llvm.loop !20

.loopexit:                                        ; preds = %.lr.ph40, %.lr.ph45
  %38 = add nuw nsw i64 %.02942, 1
  %39 = mul nuw nsw i64 %38, %38
  %.not33 = icmp sgt i64 %39, %18
  br i1 %.not33, label %.preheader, label %.lr.ph45, !llvm.loop !21

.lr.ph51:                                         ; preds = %.preheader, %49
  %.promoted = phi i64 [ %57, %49 ], [ %18, %.preheader ]
  %.03050 = phi i64 [ %56, %49 ], [ 1, %.preheader ]
  %40 = getelementptr inbounds i64, ptr %20, i64 %.promoted
  %41 = load i64, ptr %40, align 8, !tbaa !8
  %42 = srem i64 %.promoted, %41
  %43 = icmp eq i64 %42, 0
  br i1 %43, label %.lr.ph48, label %49

.lr.ph48:                                         ; preds = %.lr.ph51, %.lr.ph48
  %.02846 = phi i64 [ %45, %.lr.ph48 ], [ 0, %.lr.ph51 ]
  %44 = phi i64 [ %46, %.lr.ph48 ], [ %.promoted, %.lr.ph51 ]
  %45 = add nuw nsw i64 %.02846, 1
  %46 = sdiv i64 %44, %41
  %47 = srem i64 %46, %41
  %48 = icmp eq i64 %47, 0
  br i1 %48, label %.lr.ph48, label %._crit_edge49, !llvm.loop !22

._crit_edge49:                                    ; preds = %.lr.ph48
  store i64 %46, ptr %1, align 8, !tbaa !8
  br label %49

49:                                               ; preds = %._crit_edge49, %.lr.ph51
  %.028.lcssa = phi i64 [ %45, %._crit_edge49 ], [ 0, %.lr.ph51 ]
  %50 = add nuw nsw i64 %.028.lcssa, 1
  %51 = call noundef double @_ZSt3powIllEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef %41, i64 noundef %50)
  %52 = fadd double %51, -1.000000e+00
  %53 = fptosi double %52 to i64
  %54 = add nsw i64 %41, -1
  %55 = sdiv i64 %53, %54
  %56 = mul nsw i64 %55, %.03050
  %57 = load i64, ptr %1, align 8, !tbaa !8
  %58 = icmp sgt i64 %57, 1
  br i1 %58, label %.lr.ph51, label %._crit_edge52, !llvm.loop !23

._crit_edge52:                                    ; preds = %49, %0, %.preheader
  %.030.lcssa = phi i64 [ 1, %.preheader ], [ 1, %0 ], [ %56, %49 ]
  %59 = 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)
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) %59, i64 noundef %.030.lcssa)
  call void @llvm.stackrestore.p0(ptr %16)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #9
  ret i32 0
}

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIllEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef, i64 noundef) local_unnamed_addr #7

; 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 #8

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { "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 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 #8 = { 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 #9 = { 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", !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 = !{!16, !16, i64 0}
!16 = !{!"bool", !10, i64 0}
!17 = distinct !{!17, !12, !14, !13}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}


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