; LLVM IR from ravireddy07/cpp-book :: src/Common-Problems (NumOfDivisors)

; 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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7isPrimex(i64 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca [1000001 x i64], align 16
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  br label %15

15:                                               ; preds = %149, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %2, align 4, !tbaa !5
  %18 = icmp ne i32 %16, 0
  br i1 %18, label %19, label %154

19:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = call ptr @llvm.stacksave.p0()
  store ptr %23, ptr %4, align 8
  %24 = alloca i64, i64 %22, align 16
  store i64 %22, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %35, %19
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %38

30:                                               ; preds = %25
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i64, ptr %24, i64 %32
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %33)
  br label %35

35:                                               ; preds = %30
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %6, align 4, !tbaa !5
  br label %25, !llvm.loop !9

38:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8000008, ptr %7) #7
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 8000008, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %123, %38
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

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

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i64, ptr %24, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !11
  store i64 %48, ptr %10, align 8, !tbaa !11
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i64, ptr %24, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !11
  %53 = call noundef zeroext i1 @_Z7isPrimex(i64 noundef %52)
  br i1 %53, label %54, label %62

54:                                               ; preds = %44
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i64, ptr %24, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !11
  %59 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !11
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %59, align 8, !tbaa !11
  store i32 9, ptr %9, align 4
  br label %120

62:                                               ; preds = %44
  br label %63

63:                                               ; preds = %67, %62
  %64 = load i64, ptr %10, align 8, !tbaa !11
  %65 = and i64 %64, 1
  %66 = icmp eq i64 %65, 0
  br i1 %66, label %67, label %73

67:                                               ; preds = %63
  %68 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 2
  %69 = load i64, ptr %68, align 16, !tbaa !11
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %68, align 16, !tbaa !11
  %71 = load i64, ptr %10, align 8, !tbaa !11
  %72 = sdiv i64 %71, 2
  store i64 %72, ptr %10, align 8, !tbaa !11
  br label %63, !llvm.loop !13

73:                                               ; preds = %63
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i64, ptr %24, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = call noundef zeroext i1 @_Z7isPrimex(i64 noundef %77)
  br i1 %78, label %79, label %87

79:                                               ; preds = %73
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds i64, ptr %24, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !11
  %84 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !11
  %86 = add nsw i64 %85, 1
  store i64 %86, ptr %84, align 8, !tbaa !11
  store i32 9, ptr %9, align 4
  br label %120

87:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 3, ptr %11, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %115, %87
  %89 = load i64, ptr %11, align 8, !tbaa !11
  %90 = load i32, ptr %8, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i64, ptr %24, i64 %91
  %93 = load i64, ptr %92, align 8, !tbaa !11
  %94 = icmp sle i64 %89, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %88
  store i32 12, ptr %9, align 4
  br label %118

96:                                               ; preds = %88
  %97 = load i64, ptr %10, align 8, !tbaa !11
  %98 = icmp eq i64 %97, 0
  br i1 %98, label %99, label %100

99:                                               ; preds = %96
  store i32 12, ptr %9, align 4
  br label %118

100:                                              ; preds = %96
  br label %101

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

106:                                              ; preds = %101
  %107 = load i64, ptr %11, align 8, !tbaa !11
  %108 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !11
  %110 = add nsw i64 %109, 1
  store i64 %110, ptr %108, align 8, !tbaa !11
  %111 = load i64, ptr %11, align 8, !tbaa !11
  %112 = load i64, ptr %10, align 8, !tbaa !11
  %113 = sdiv i64 %112, %111
  store i64 %113, ptr %10, align 8, !tbaa !11
  br label %101, !llvm.loop !14

114:                                              ; preds = %101
  br label %115

115:                                              ; preds = %114
  %116 = load i64, ptr %11, align 8, !tbaa !11
  %117 = add nsw i64 %116, 2
  store i64 %117, ptr %11, align 8, !tbaa !11
  br label %88, !llvm.loop !15

118:                                              ; preds = %99, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %119

119:                                              ; preds = %118
  store i32 0, ptr %9, align 4
  br label %120

120:                                              ; preds = %119, %79, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  %121 = load i32, ptr %9, align 4
  switch i32 %121, label %156 [
    i32 0, label %122
    i32 9, label %123
  ]

122:                                              ; preds = %120
  br label %123

123:                                              ; preds = %122, %120
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %8, align 4, !tbaa !5
  br label %39, !llvm.loop !16

126:                                              ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 1, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  store i64 2, ptr %13, align 8, !tbaa !11
  br label %127

127:                                              ; preds = %146, %126
  %128 = load i64, ptr %13, align 8, !tbaa !11
  %129 = icmp slt i64 %128, 1000001
  br i1 %129, label %131, label %130

130:                                              ; preds = %127
  store i32 17, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %149

131:                                              ; preds = %127
  %132 = load i64, ptr %13, align 8, !tbaa !11
  %133 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 %132
  %134 = load i64, ptr %133, align 8, !tbaa !11
  %135 = icmp ne i64 %134, 0
  br i1 %135, label %136, label %145

136:                                              ; preds = %131
  %137 = load i64, ptr %13, align 8, !tbaa !11
  %138 = getelementptr inbounds [1000001 x i64], ptr %7, i64 0, i64 %137
  %139 = load i64, ptr %138, align 8, !tbaa !11
  %140 = add nsw i64 %139, 1
  %141 = load i32, ptr %12, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = mul nsw i64 %142, %140
  %144 = trunc i64 %143 to i32
  store i32 %144, ptr %12, align 4, !tbaa !5
  br label %145

145:                                              ; preds = %136, %131
  br label %146

146:                                              ; preds = %145
  %147 = load i64, ptr %13, align 8, !tbaa !11
  %148 = add nsw i64 %147, 1
  store i64 %148, ptr %13, align 8, !tbaa !11
  br label %127, !llvm.loop !17

149:                                              ; preds = %130
  %150 = load i32, ptr %12, align 4, !tbaa !5
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %150)
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %151, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8000008, ptr %7) #7
  %153 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %153)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %15, !llvm.loop !18

154:                                              ; preds = %15
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  %155 = load i32, ptr %1, align 4
  ret i32 %155

156:                                              ; preds = %120
  unreachable
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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)) #6

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !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_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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7isPrimex(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca [1000001 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %1, align 4, !tbaa !5
  %.not59 = icmp eq i32 %5, 0
  br i1 %.not59, label %._crit_edge62, label %.lr.ph61

.lr.ph61:                                         ; preds = %0
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  br label %8

8:                                                ; preds = %.lr.ph61, %58
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = call ptr @llvm.stacksave.p0()
  %13 = alloca i64, i64 %11, align 16
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8000008, ptr nonnull %3) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8000008) %3, i8 0, i64 8000008, i1 false)
  br label %.preheader39.preheader

._crit_edge:                                      ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8000008, ptr nonnull %3) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(8000008) %3, i8 0, i64 8000008, i1 false)
  %16 = icmp sgt i32 %19, 0
  br i1 %16, label %.lr.ph56, label %.preheader39.preheader

.preheader39.preheader:                           ; preds = %.loopexit, %._crit_edge.thread, %._crit_edge
  br label %.preheader39

.lr.ph:                                           ; preds = %8, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %8 ]
  %17 = getelementptr inbounds i64, ptr %13, i64 %indvars.iv
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !9

.lr.ph56:                                         ; preds = %._crit_edge, %.loopexit
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.loopexit ], [ 0, %._crit_edge ]
  %22 = getelementptr inbounds i64, ptr %13, i64 %indvars.iv68
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = call noundef zeroext i1 @_Z7isPrimex(i64 noundef %23)
  br i1 %24, label %27, label %.preheader38

.preheader38:                                     ; preds = %.lr.ph56
  %25 = and i64 %23, 1
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %.lr.ph42, label %35

.lr.ph42:                                         ; preds = %.preheader38
  %.promoted = load i64, ptr %7, align 16, !tbaa !11
  br label %29

27:                                               ; preds = %.lr.ph56
  %28 = load i64, ptr %22, align 8, !tbaa !11
  br label %.loopexit.sink.split

29:                                               ; preds = %.lr.ph42, %29
  %30 = phi i64 [ %.promoted, %.lr.ph42 ], [ %31, %29 ]
  %.03041 = phi i64 [ %23, %.lr.ph42 ], [ %32, %29 ]
  %31 = add nsw i64 %30, 1
  %32 = ashr exact i64 %.03041, 1
  %33 = and i64 %.03041, 2
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %29, label %._crit_edge43, !llvm.loop !13

._crit_edge43:                                    ; preds = %29
  store i64 %31, ptr %7, align 16, !tbaa !11
  br label %35

35:                                               ; preds = %._crit_edge43, %.preheader38
  %.030.lcssa = phi i64 [ %32, %._crit_edge43 ], [ %23, %.preheader38 ]
  %36 = load i64, ptr %22, align 8, !tbaa !11
  %37 = call noundef zeroext i1 @_Z7isPrimex(i64 noundef %36)
  %38 = load i64, ptr %22, align 8, !tbaa !11
  br i1 %37, label %.loopexit.sink.split, label %.preheader37

.preheader37:                                     ; preds = %35
  %.not3650 = icmp slt i64 %38, 3
  %39 = icmp eq i64 %.030.lcssa, 0
  %or.cond51 = or i1 %39, %.not3650
  br i1 %or.cond51, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %.preheader37, %49
  %.02953 = phi i64 [ %50, %49 ], [ 3, %.preheader37 ]
  %.13152 = phi i64 [ %.2.lcssa, %49 ], [ %.030.lcssa, %.preheader37 ]
  %40 = srem i64 %.13152, %.02953
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %.lr.ph45, label %49

.lr.ph45:                                         ; preds = %.preheader
  %42 = getelementptr inbounds [1000001 x i64], ptr %3, i64 0, i64 %.02953
  %.promoted48 = load i64, ptr %42, align 8, !tbaa !11
  br label %43

43:                                               ; preds = %.lr.ph45, %43
  %44 = phi i64 [ %.promoted48, %.lr.ph45 ], [ %45, %43 ]
  %.244 = phi i64 [ %.13152, %.lr.ph45 ], [ %46, %43 ]
  %45 = add nsw i64 %44, 1
  %46 = sdiv i64 %.244, %.02953
  %47 = srem i64 %46, %.02953
  %48 = icmp eq i64 %47, 0
  br i1 %48, label %43, label %._crit_edge46, !llvm.loop !14

._crit_edge46:                                    ; preds = %43
  store i64 %45, ptr %42, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %._crit_edge46, %.preheader
  %.2.lcssa = phi i64 [ %46, %._crit_edge46 ], [ %.13152, %.preheader ]
  %50 = add nuw nsw i64 %.02953, 2
  %.not36 = icmp sgt i64 %50, %38
  %51 = icmp eq i64 %.2.lcssa, 0
  %or.cond = or i1 %51, %.not36
  br i1 %or.cond, label %.loopexit, label %.preheader, !llvm.loop !15

.loopexit.sink.split:                             ; preds = %35, %27
  %.sink78 = phi i64 [ %28, %27 ], [ %38, %35 ]
  %52 = getelementptr inbounds [1000001 x i64], ptr %3, i64 0, i64 %.sink78
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %52, align 8, !tbaa !11
  br label %.loopexit

.loopexit:                                        ; preds = %49, %.loopexit.sink.split, %.preheader37
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next69, %56
  br i1 %57, label %.lr.ph56, label %.preheader39.preheader, !llvm.loop !16

58:                                               ; preds = %.preheader39
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %79)
  %60 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %59, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8000008, ptr nonnull %3) #7
  call void @llvm.stackrestore.p0(ptr %12)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %61 = load i32, ptr %1, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %61, 0
  br i1 %.not, label %._crit_edge62, label %8, !llvm.loop !17

.preheader39:                                     ; preds = %.preheader39, %.preheader39.preheader
  %.058 = phi i64 [ 2, %.preheader39.preheader ], [ %80, %.preheader39 ]
  %.02857 = phi i32 [ 1, %.preheader39.preheader ], [ %79, %.preheader39 ]
  %63 = getelementptr inbounds [1000001 x i64], ptr %3, i64 0, i64 %.058
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = trunc i64 %64 to i32
  %66 = add i32 %65, 1
  %67 = mul i32 %66, %.02857
  %68 = add nuw nsw i64 %.058, 1
  %69 = getelementptr inbounds [1000001 x i64], ptr %3, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !11
  %71 = trunc i64 %70 to i32
  %72 = add i32 %71, 1
  %73 = mul i32 %72, %67
  %74 = add nuw nsw i64 %.058, 2
  %75 = getelementptr inbounds [1000001 x i64], ptr %3, i64 0, i64 %74
  %76 = load i64, ptr %75, align 8, !tbaa !11
  %77 = trunc i64 %76 to i32
  %78 = add i32 %77, 1
  %79 = mul i32 %78, %73
  %80 = add nuw nsw i64 %.058, 3
  %exitcond.not.2 = icmp eq i64 %80, 1000001
  br i1 %exitcond.not.2, label %58, label %.preheader39, !llvm.loop !18

._crit_edge62:                                    ; preds = %58, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #3

; 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 #0 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)) #6

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "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 }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}


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