; LLVM IR from MtSaka/library :: test/yosupo/number_theory/sqrt_mod.test.ll (Z8mod_sqrtRKxS0_)

; 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.Random.1 = type { %"class.std::mersenne_twister_engine.2" }
%"class.std::mersenne_twister_engine.2" = type { [312 x i64], i64 }
%struct.MontgomeryModInt = type { i32 }

@rand64 = external dso_local global %struct.Random.1, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z8mod_sqrtRKxS0_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(8) %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.MontgomeryModInt, align 4
  %7 = alloca %struct.MontgomeryModInt, align 4
  %8 = alloca %struct.MontgomeryModInt, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.MontgomeryModInt, align 4
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.MontgomeryModInt, align 4
  %14 = alloca %struct.Random.1, align 8
  %15 = alloca %struct.MontgomeryModInt, align 4
  %16 = alloca %struct.MontgomeryModInt, align 4
  %17 = alloca %struct.MontgomeryModInt, align 4
  %18 = alloca %struct.MontgomeryModInt, align 4
  %19 = alloca %struct.MontgomeryModInt, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %struct.MontgomeryModInt, align 4
  %23 = alloca %struct.MontgomeryModInt, align 4
  %24 = alloca %struct.MontgomeryModInt, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = srem i64 %26, %28
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %2
  store i64 0, ptr %3, align 8
  br label %137

32:                                               ; preds = %2
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = icmp eq i64 %34, 2
  br i1 %35, label %36, label %42

36:                                               ; preds = %32
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = srem i64 %38, %40
  store i64 %41, ptr %3, align 8
  br label %137

42:                                               ; preds = %32
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = trunc i64 %44 to i32
  call void @_ZN16MontgomeryModIntIjLin1EE7set_modEj(i32 noundef %45)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load i64, ptr %46, align 8, !tbaa !9
  call void @_ZN16MontgomeryModIntIjLin1EEC2IxTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %6, i64 noundef %47)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = sub nsw i64 %49, 1
  %51 = sdiv i64 %50, 2
  %52 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %6, i64 noundef %51)
  %53 = getelementptr inbounds %struct.MontgomeryModInt, ptr %7, i32 0, i32 0
  store i32 %52, ptr %53, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %8, i32 noundef 1)
  %54 = call noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br i1 %54, label %55, label %56

55:                                               ; preds = %42
  store i64 -1, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %136

56:                                               ; preds = %42
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = and i64 %58, 3
  %60 = icmp eq i64 %59, 3
  br i1 %60, label %61, label %70

61:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = add nsw i64 %63, 1
  %65 = sdiv i64 %64, 4
  %66 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %6, i64 noundef %65)
  %67 = getelementptr inbounds %struct.MontgomeryModInt, ptr %10, i32 0, i32 0
  store i32 %66, ptr %67, align 4
  %68 = call noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4) %10)
  %69 = zext i32 %68 to i64
  store i64 %69, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  store i32 1, ptr %9, align 4
  br label %136

70:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load i64, ptr %71, align 8, !tbaa !9
  %73 = sub nsw i64 %72, 1
  store i64 %73, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i64, ptr %74, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 @rand64, i64 2504, i1 false), !tbaa.struct !13
  %76 = call noundef i64 @_Z14primitive_rootI16MontgomeryModIntIyLin4EE6RandomISt23mersenne_twister_engineImLm64ELm312ELm156ELm31ELm13043109905998158313ELm29ELm6148914691236517205ELm17ELm8202884508482404352ELm37ELm18444473444759240704ELm43ELm6364136223846793005EEEEyyT0_(i64 noundef %75, ptr noundef byval(%struct.Random.1) align 8 %14)
  call void @_ZN16MontgomeryModIntIjLin1EEC2IyTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr11is_unsignedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %13, i64 noundef %76)
  br label %77

77:                                               ; preds = %82, %70
  %78 = load i64, ptr %11, align 8, !tbaa !9
  %79 = and i64 %78, 1
  %80 = icmp ne i64 %79, 0
  %81 = xor i1 %80, true
  br i1 %81, label %82, label %87

82:                                               ; preds = %77
  %83 = load i64, ptr %11, align 8, !tbaa !9
  %84 = ashr i64 %83, 1
  store i64 %84, ptr %11, align 8, !tbaa !9
  %85 = load i32, ptr %12, align 4, !tbaa !11
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %12, align 4, !tbaa !11
  br label %77, !llvm.loop !17

87:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %88 = load i64, ptr %11, align 8, !tbaa !9
  %89 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %13, i64 noundef %88)
  %90 = getelementptr inbounds %struct.MontgomeryModInt, ptr %15, i32 0, i32 0
  store i32 %89, ptr %90, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %91 = load i64, ptr %11, align 8, !tbaa !9
  %92 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %6, i64 noundef %91)
  %93 = getelementptr inbounds %struct.MontgomeryModInt, ptr %16, i32 0, i32 0
  store i32 %92, ptr %93, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %94 = load i64, ptr %11, align 8, !tbaa !9
  %95 = add nsw i64 %94, 1
  %96 = sdiv i64 %95, 2
  %97 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %6, i64 noundef %96)
  %98 = getelementptr inbounds %struct.MontgomeryModInt, ptr %17, i32 0, i32 0
  store i32 %97, ptr %98, align 4
  br label %99

99:                                               ; preds = %119, %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %18, i32 noundef 1)
  %100 = call noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br i1 %100, label %101, label %133

101:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %102 = call i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %103 = getelementptr inbounds %struct.MontgomeryModInt, ptr %19, i32 0, i32 0
  store i32 %102, ptr %103, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  store i32 0, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 1, ptr %21, align 4, !tbaa !11
  br label %104

104:                                              ; preds = %115, %101
  %105 = load i32, ptr %21, align 4, !tbaa !11
  %106 = load i32, ptr %12, align 4, !tbaa !11
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %109, label %108

108:                                              ; preds = %104
  store i32 6, ptr %9, align 4
  br label %118

109:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %22, i32 noundef 1)
  %110 = call noundef zeroext i1 @_ZeqRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %22)
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br i1 %110, label %111, label %113

111:                                              ; preds = %109
  %112 = load i32, ptr %21, align 4, !tbaa !11
  store i32 %112, ptr %20, align 4, !tbaa !11
  store i32 6, ptr %9, align 4
  br label %118

113:                                              ; preds = %109
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %19, ptr noundef nonnull align 4 dereferenceable(4) %19)
  br label %115

115:                                              ; preds = %113
  %116 = load i32, ptr %21, align 4, !tbaa !11
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %21, align 4, !tbaa !11
  br label %104, !llvm.loop !19

118:                                              ; preds = %111, %108
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %119

119:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %120 = load i32, ptr %12, align 4, !tbaa !11
  %121 = load i32, ptr %20, align 4, !tbaa !11
  %122 = sub nsw i32 %120, %121
  %123 = sub nsw i32 %122, 1
  %124 = zext i32 %123 to i64
  %125 = shl i64 1, %124
  %126 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %15, i64 noundef %125)
  %127 = getelementptr inbounds %struct.MontgomeryModInt, ptr %23, i32 0, i32 0
  store i32 %126, ptr %127, align 4
  %128 = load i32, ptr %20, align 4, !tbaa !11
  store i32 %128, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %129 = call i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %23, ptr noundef nonnull align 4 dereferenceable(4) %23)
  %130 = getelementptr inbounds %struct.MontgomeryModInt, ptr %24, i32 0, i32 0
  store i32 %129, ptr %130, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %24, i64 4, i1 false)
  %131 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef nonnull align 4 dereferenceable(4) %15)
  %132 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %23)
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %99, !llvm.loop !20

133:                                              ; preds = %99
  %134 = call noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4) %17)
  %135 = zext i32 %134 to i64
  store i64 %135, ptr %3, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %136

136:                                              ; preds = %133, %61, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %137

137:                                              ; preds = %136, %36, %31
  %138 = load i64, ptr %3, align 8
  ret i64 %138
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EE7set_modEj(i32 noundef) #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z14primitive_rootI16MontgomeryModIntIyLin4EE6RandomISt23mersenne_twister_engineImLm64ELm312ELm156ELm31ELm13043109905998158313ELm29ELm6148914691236517205ELm17ELm8202884508482404352ELm37ELm18444473444759240704ELm43ELm6364136223846793005EEEEyyT0_(i64 noundef, ptr noundef byval(%struct.Random.1) align 8) #0

; 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 uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EEC2IyTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr11is_unsignedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZeqRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 2496, !14, i64 2496, i64 8, !15}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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.Random.1 = type { %"class.std::mersenne_twister_engine.2" }
%"class.std::mersenne_twister_engine.2" = type { [312 x i64], i64 }
%struct.MontgomeryModInt = type { i32 }

@rand64 = external dso_local local_unnamed_addr global %struct.Random.1, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z8mod_sqrtRKxS0_(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1) local_unnamed_addr #0 {
  %3 = alloca %struct.MontgomeryModInt, align 4
  %4 = alloca %struct.MontgomeryModInt, align 4
  %5 = alloca %struct.MontgomeryModInt, align 4
  %6 = alloca %struct.MontgomeryModInt, align 4
  %7 = alloca %struct.MontgomeryModInt, align 4
  %8 = alloca %struct.MontgomeryModInt, align 4
  %9 = alloca %struct.MontgomeryModInt, align 4
  %10 = alloca %struct.MontgomeryModInt, align 4
  %11 = alloca %struct.MontgomeryModInt, align 4
  %12 = alloca %struct.MontgomeryModInt, align 4
  %13 = alloca %struct.MontgomeryModInt, align 4
  %14 = alloca %struct.MontgomeryModInt, align 4
  %15 = load i64, ptr %0, align 8, !tbaa !5
  %16 = load i64, ptr %1, align 8, !tbaa !5
  %17 = srem i64 %15, %16
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %70, label %19

19:                                               ; preds = %2
  %20 = icmp eq i64 %16, 2
  br i1 %20, label %70, label %21

21:                                               ; preds = %19
  %22 = trunc i64 %16 to i32
  tail call void @_ZN16MontgomeryModIntIjLin1EE7set_modEj(i32 noundef %22)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %23 = load i64, ptr %0, align 8, !tbaa !5
  call void @_ZN16MontgomeryModIntIjLin1EEC2IxTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %3, i64 noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %24 = load i64, ptr %1, align 8, !tbaa !5
  %25 = add nsw i64 %24, -1
  %26 = sdiv i64 %25, 2
  %27 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %3, i64 noundef %26)
  store i32 %27, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 1)
  %28 = call noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  br i1 %28, label %69, label %29

29:                                               ; preds = %21
  %30 = load i64, ptr %1, align 8, !tbaa !5
  %31 = and i64 %30, 3
  %32 = icmp eq i64 %31, 3
  br i1 %32, label %33, label %39

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %34 = add nsw i64 %30, 1
  %35 = ashr exact i64 %34, 2
  %36 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %3, i64 noundef %35)
  store i32 %36, ptr %6, align 4
  %37 = call noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %38 = zext i32 %37 to i64
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %69

39:                                               ; preds = %29
  %40 = add nsw i64 %30, -1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %41 = call noundef i64 @_Z14primitive_rootI16MontgomeryModIntIyLin4EE6RandomISt23mersenne_twister_engineImLm64ELm312ELm156ELm31ELm13043109905998158313ELm29ELm6148914691236517205ELm17ELm8202884508482404352ELm37ELm18444473444759240704ELm43ELm6364136223846793005EEEEyyT0_(i64 noundef %30, ptr noundef nonnull byval(%struct.Random.1) align 8 @rand64)
  call void @_ZN16MontgomeryModIntIjLin1EEC2IyTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr11is_unsignedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %7, i64 noundef %41)
  %42 = and i64 %40, 1
  %.not32 = icmp eq i64 %42, 0
  br i1 %.not32, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %39, %.lr.ph
  %.02734 = phi i32 [ %44, %.lr.ph ], [ 0, %39 ]
  %.02933 = phi i64 [ %43, %.lr.ph ], [ %40, %39 ]
  %43 = ashr exact i64 %.02933, 1
  %44 = add nuw nsw i32 %.02734, 1
  %45 = and i64 %.02933, 2
  %.not = icmp eq i64 %45, 0
  br i1 %.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %39
  %.029.lcssa = phi i64 [ %40, %39 ], [ %43, %.lr.ph ]
  %.027.lcssa = phi i32 [ 0, %39 ], [ %44, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %46 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %7, i64 noundef %.029.lcssa)
  store i32 %46, ptr %8, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %47 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %3, i64 noundef %.029.lcssa)
  store i32 %47, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #3
  %48 = add nsw i64 %.029.lcssa, 1
  %49 = ashr exact i64 %48, 1
  %50 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %3, i64 noundef %49)
  store i32 %50, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef 1)
  %51 = call noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  br i1 %51, label %.lr.ph45, label %._crit_edge46

.lr.ph45:                                         ; preds = %._crit_edge, %._crit_edge39
  %.12843 = phi i32 [ %.026, %._crit_edge39 ], [ %.027.lcssa, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #3
  %52 = call i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %9)
  store i32 %52, ptr %12, align 4
  %53 = icmp sgt i32 %.12843, 1
  br i1 %53, label %.lr.ph38, label %._crit_edge39

.lr.ph38:                                         ; preds = %.lr.ph45, %55
  %.02536 = phi i32 [ %57, %55 ], [ 1, %.lr.ph45 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %13) #3
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %13, i32 noundef 1)
  %54 = call noundef zeroext i1 @_ZeqRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %13)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %13) #3
  br i1 %54, label %._crit_edge39, label %55

55:                                               ; preds = %.lr.ph38
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %57 = add nuw nsw i32 %.02536, 1
  %exitcond.not = icmp eq i32 %57, %.12843
  br i1 %exitcond.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !11

._crit_edge39:                                    ; preds = %55, %.lr.ph38, %.lr.ph45
  %.026 = phi i32 [ 0, %.lr.ph45 ], [ %.02536, %.lr.ph38 ], [ 0, %55 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %14) #3
  %58 = xor i32 %.026, -1
  %59 = add i32 %.12843, %58
  %60 = zext nneg i32 %59 to i64
  %61 = shl nuw i64 1, %60
  %62 = call i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4) %8, i64 noundef %61)
  store i32 %62, ptr %14, align 4
  %63 = call i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %14)
  store i32 %63, ptr %8, align 4
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %14)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #3
  call void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef 1)
  %66 = call noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #3
  br i1 %66, label %.lr.ph45, label %._crit_edge46, !llvm.loop !12

._crit_edge46:                                    ; preds = %._crit_edge39, %._crit_edge
  %67 = call noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4) %10)
  %68 = zext i32 %67 to i64
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  br label %69

69:                                               ; preds = %21, %._crit_edge46, %33
  %.0 = phi i64 [ %38, %33 ], [ %68, %._crit_edge46 ], [ -1, %21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  br label %70

70:                                               ; preds = %19, %2, %69
  %.1 = phi i64 [ %.0, %69 ], [ 0, %2 ], [ %17, %19 ]
  ret i64 %.1
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EE7set_modEj(i32 noundef) local_unnamed_addr #0 align 2

; 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 uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EEC2IxTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZneRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZNK16MontgomeryModIntIjLin1EE3powEy(ptr noundef nonnull align 4 dereferenceable(4), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MontgomeryModIntIjLin1EEC2IiTnPNSt9enable_ifIXaasr11is_integralIT_EE5valuesr9is_signedIS3_EE5valueEvE4typeELPv0EEES3_(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK16MontgomeryModIntIjLin1EE3getEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z14primitive_rootI16MontgomeryModIntIyLin4EE6RandomISt23mersenne_twister_engineImLm64ELm312ELm156ELm31ELm13043109905998158313ELm29ELm6148914691236517205ELm17ELm8202884508482404352ELm37ELm18444473444759240704ELm43ELm6364136223846793005EEEEyyT0_(i64 noundef, ptr noundef byval(%struct.Random.1) align 8) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @_ZmlRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZeqRK16MontgomeryModIntIjLin1EES2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN16MontgomeryModIntIjLin1EEmLERKS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass