; LLVM IR from ShahjalalShohag/code-library :: Number Theory/Prime Factorization Fastest.ll (Z7suspectRKmS0_mS0_)

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

%struct.Mint = type { i64 }

@_ZN4Mint3modE = external dso_local global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7suspectRKmS0_mS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.Mint, align 8
  %11 = alloca i64, align 8
  %12 = alloca %struct.Mint, align 8
  %13 = alloca %struct.Mint, align 8
  %14 = alloca %struct.Mint, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %18 = load i64, ptr @_ZN4Mint3modE, align 8, !tbaa !9
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = load i64, ptr %19, align 8, !tbaa !9
  %21 = icmp ne i64 %18, %20
  br i1 %21, label %22, label %24

22:                                               ; preds = %4
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN4Mint7set_modERKm(ptr noundef nonnull align 8 dereferenceable(8) %23)
  br label %24

24:                                               ; preds = %22, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 1, ptr %11, align 8, !tbaa !9
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %25)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %10, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = sub i64 %27, 1
  store i64 %28, ptr %15, align 8, !tbaa !9
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %29

29:                                               ; preds = %38, %24
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = icmp ugt i64 %30, 0
  br i1 %31, label %32, label %42

32:                                               ; preds = %29
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = and i64 %33, 1
  %35 = icmp ne i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %12)
  br label %38

38:                                               ; preds = %36, %32
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %40 = load i64, ptr %8, align 8, !tbaa !9
  %41 = lshr i64 %40, 1
  store i64 %41, ptr %8, align 8, !tbaa !9
  br label %29, !llvm.loop !12

42:                                               ; preds = %29
  %43 = getelementptr inbounds %struct.Mint, ptr %10, i32 0, i32 0
  %44 = load i64, ptr %43, align 8, !tbaa !14
  %45 = getelementptr inbounds %struct.Mint, ptr %13, i32 0, i32 0
  %46 = load i64, ptr %45, align 8, !tbaa !14
  %47 = icmp eq i64 %44, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %42
  store i1 true, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %72

49:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !16
  br label %50

50:                                               ; preds = %66, %49
  %51 = load i32, ptr %17, align 4, !tbaa !16
  %52 = zext i32 %51 to i64
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = icmp ult i64 %52, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  store i32 4, ptr %16, align 4
  br label %69

57:                                               ; preds = %50
  %58 = getelementptr inbounds %struct.Mint, ptr %10, i32 0, i32 0
  %59 = load i64, ptr %58, align 8, !tbaa !14
  %60 = getelementptr inbounds %struct.Mint, ptr %14, i32 0, i32 0
  %61 = load i64, ptr %60, align 8, !tbaa !14
  %62 = icmp eq i64 %59, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %57
  store i1 true, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %69

64:                                               ; preds = %57
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %10)
  br label %66

66:                                               ; preds = %64
  %67 = load i32, ptr %17, align 4, !tbaa !16
  %68 = add i32 %67, 1
  store i32 %68, ptr %17, align 4, !tbaa !16
  br label %50, !llvm.loop !18

69:                                               ; preds = %63, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  %70 = load i32, ptr %16, align 4
  switch i32 %70, label %72 [
    i32 4, label %71
  ]

71:                                               ; preds = %69
  store i1 false, ptr %5, align 1
  store i32 1, ptr %16, align 4
  br label %72

72:                                               ; preds = %71, %69, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %73 = load i1, ptr %5, align 1
  ret i1 %73
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Mint7set_modERKm(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

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


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

%struct.Mint = type { i64 }

@_ZN4Mint3modE = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7suspectRKmS0_mS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1, i64 noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3) local_unnamed_addr #0 {
  %5 = alloca %struct.Mint, align 8
  %6 = alloca i64, align 8
  %7 = alloca %struct.Mint, align 8
  %8 = alloca %struct.Mint, align 8
  %9 = alloca i64, align 8
  %10 = load i64, ptr @_ZN4Mint3modE, align 8, !tbaa !5
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i64 %10, %11
  br i1 %.not, label %13, label %12

12:                                               ; preds = %4
  tail call void @_ZN4Mint7set_modERKm(ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %13

13:                                               ; preds = %12, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store i64 1, ptr %6, align 8, !tbaa !5
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.sroa.0.0.copyload = load i64, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  %14 = load i64, ptr %3, align 8, !tbaa !5
  %15 = add i64 %14, -1
  store i64 %15, ptr %9, align 8, !tbaa !5
  call void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  %.not1417 = icmp eq i64 %2, 0
  br i1 %.not1417, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %13, %19
  %.01318 = phi i64 [ %21, %19 ], [ %2, %13 ]
  %16 = and i64 %.01318, 1
  %.not16 = icmp eq i64 %16, 0
  br i1 %.not16, label %19, label %17

17:                                               ; preds = %.lr.ph
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
  br label %19

19:                                               ; preds = %17, %.lr.ph
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %21 = lshr i64 %.01318, 1
  %.not14 = icmp ult i64 %.01318, 2
  br i1 %.not14, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %19, %13
  %22 = load i64, ptr %5, align 8, !tbaa !11
  %23 = icmp eq i64 %22, %.sroa.0.0.copyload
  br i1 %23, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %._crit_edge
  %24 = load i64, ptr %1, align 8, !tbaa !5
  %.not1519.not = icmp eq i64 %24, 0
  br i1 %.not1519.not, label %.loopexit, label %.lr.ph21

.lr.ph21:                                         ; preds = %.preheader, %28
  %.020 = phi i32 [ %30, %28 ], [ 0, %.preheader ]
  %25 = load i64, ptr %5, align 8, !tbaa !11
  %26 = load i64, ptr %8, align 8, !tbaa !11
  %27 = icmp eq i64 %25, %26
  br i1 %27, label %.loopexit, label %28

28:                                               ; preds = %.lr.ph21
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintmLERKS_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %30 = add i32 %.020, 1
  %31 = zext i32 %30 to i64
  %32 = load i64, ptr %1, align 8, !tbaa !5
  %.not15 = icmp ugt i64 %32, %31
  br i1 %.not15, label %.lr.ph21, label %.loopexit, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph21, %28, %.preheader, %._crit_edge
  %.1 = phi i1 [ true, %._crit_edge ], [ false, %.preheader ], [ %27, %28 ], [ %27, %.lr.ph21 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4Mint7set_modERKm(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4MintC2ERKm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

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

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass