; LLVM IR from tfhe/spqlios-arithmetic :: test/testlib/ntt120_dft.ll (Z13simple_ntt120RK10polynomialIlE)

; 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.q120_nttvec = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl" }
%"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl" = type { %"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl_data" }
%"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.mod_q120 = type { [4 x i64] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13simple_ntt120RK10polynomialIlE(ptr dead_on_unwind noalias writable sret(%class.q120_nttvec) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i1, align 1
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca %class.mod_q120, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef i64 @_ZNK10polynomialIlE2nnEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
  store i64 %13, ptr %5, align 8, !tbaa !9
  store i1 false, ptr %6, align 1
  %14 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZN11q120_nttvecC1Em(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %33, %2
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %45

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = invoke noundef i64 @_ZNK10polynomialIlE9get_coeffEl(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %22)
          to label %24 unwind label %36

24:                                               ; preds = %20
  store i64 %23, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #6
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = load i64, ptr %8, align 8, !tbaa !9
  invoke void @_ZN8mod_q120C1Ellll(ptr noundef nonnull align 8 dereferenceable(32) %11, i64 noundef %25, i64 noundef %26, i64 noundef %27, i64 noundef %28)
          to label %29 unwind label %40

29:                                               ; preds = %24
  %30 = getelementptr inbounds %class.q120_nttvec, ptr %0, i32 0, i32 0
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorI8mod_q120SaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %31) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %32, ptr align 8 %11, i64 32, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %33

33:                                               ; preds = %29
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %7, align 8, !tbaa !9
  br label %15, !llvm.loop !13

36:                                               ; preds = %20
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %9, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %10, align 4
  br label %44

40:                                               ; preds = %24
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %9, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #6
  br label %44

44:                                               ; preds = %40, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %57

45:                                               ; preds = %19
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = getelementptr inbounds %class.q120_nttvec, ptr %0, i32 0, i32 0
  %48 = call noundef ptr @_ZNSt6vectorI8mod_q120SaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %47) #6
  invoke void @_ZL18q120_ntt_naive_recmdP8mod_q120(i64 noundef %46, double noundef 5.000000e-01, ptr noundef %48)
          to label %49 unwind label %51

49:                                               ; preds = %45
  store i1 true, ptr %6, align 1
  %50 = load i1, ptr %6, align 1
  br i1 %50, label %56, label %55

51:                                               ; preds = %45
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %9, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %10, align 4
  br label %57

55:                                               ; preds = %49
  call void @_ZN11q120_nttvecD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  br label %56

56:                                               ; preds = %55, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret void

57:                                               ; preds = %51, %44
  call void @_ZN11q120_nttvecD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %9, align 8
  %60 = load i32, ptr %10, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

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

declare noundef i64 @_ZNK10polynomialIlE2nnEv(ptr noundef nonnull align 8 dereferenceable(24)) #2

declare noundef i64 @_ZNK10polynomialIlE9get_coeffEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2

declare i32 @__gxx_personality_v0(...)

declare void @_ZN8mod_q120C1Ellll(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i64 noundef, i64 noundef) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorI8mod_q120SaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 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) #4

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL18q120_ntt_naive_recmdP8mod_q120(i64 noundef, double noundef, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorI8mod_q120SaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11q120_nttvecD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #5 align 2

declare void @_ZN11q120_nttvecC1Em(ptr, i64)

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 = { "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { 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 32, !12}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.q120_nttvec = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl" }
%"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl" = type { %"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl_data" }
%"struct.std::_Vector_base<mod_q120, std::allocator<mod_q120>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.mod_q120 = type { [4 x i64] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z13simple_ntt120RK10polynomialIlE(ptr dead_on_unwind noalias writable sret(%class.q120_nttvec) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.mod_q120, align 8
  %4 = tail call noundef i64 @_ZNK10polynomialIlE2nnEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  tail call void @_ZN11q120_nttvecC1Em(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %4)
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %8, %2
  %5 = call noundef ptr @_ZNSt6vectorI8mod_q120SaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  invoke void @_ZL18q120_ntt_naive_recmdP8mod_q120(i64 noundef %4, double noundef 5.000000e-01, ptr noundef %5)
          to label %17 unwind label %15

.lr.ph:                                           ; preds = %2, %8
  %.01721 = phi i64 [ %10, %8 ], [ 0, %2 ]
  %6 = invoke noundef i64 @_ZNK10polynomialIlE9get_coeffEl(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01721)
          to label %7 unwind label %11

7:                                                ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  invoke void @_ZN8mod_q120C1Ellll(ptr noundef nonnull align 8 dereferenceable(32) %3, i64 noundef %6, i64 noundef %6, i64 noundef %6, i64 noundef %6)
          to label %8 unwind label %13

8:                                                ; preds = %7
  %9 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorI8mod_q120SaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.01721) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(32) %3, i64 32, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  %10 = add nuw i64 %.01721, 1
  %exitcond.not = icmp eq i64 %10, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

11:                                               ; preds = %.lr.ph
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %18

13:                                               ; preds = %7
  %14 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  br label %18

15:                                               ; preds = %._crit_edge
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %18

17:                                               ; preds = %._crit_edge
  ret void

18:                                               ; preds = %11, %13, %15
  %.pn.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ], [ %12, %11 ]
  call void @_ZN11q120_nttvecD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #6
  resume { ptr, i32 } %.pn.pn
}

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

declare noundef i64 @_ZNK10polynomialIlE2nnEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2

declare noundef i64 @_ZNK10polynomialIlE9get_coeffEl(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

declare void @_ZN8mod_q120C1Ellll(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i64 noundef, i64 noundef) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6vectorI8mod_q120SaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress 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) #4

; 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 uwtable
declare hidden void @_ZL18q120_ntt_naive_recmdP8mod_q120(i64 noundef, double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorI8mod_q120SaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11q120_nttvecD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #5 align 2

declare void @_ZN11q120_nttvecC1Em(ptr, i64) local_unnamed_addr

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


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