; LLVM IR from tfhe/spqlios-arithmetic :: spqlios/cplx (cplx_fft_ref)

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @cplx_set_e2pix(ptr noundef, double noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @fill_cplx_fft_omegas_bfs_16(double noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @fill_cplx_fft_omegas_bfs_2(double noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @fill_cplx_fft_omegas_rec_16(double noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store double %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %8 = load i32, ptr %6, align 4, !tbaa !11
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  br label %50

11:                                               ; preds = %3
  %12 = load i32, ptr %6, align 4, !tbaa !11
  %13 = icmp ule i32 %12, 8
  br i1 %13, label %14, label %18

14:                                               ; preds = %11
  %15 = load double, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !11
  call void @fill_cplx_fft_omegas_bfs_2(double noundef %15, ptr noundef %16, i32 noundef %17)
  br label %50

18:                                               ; preds = %11
  %19 = load i32, ptr %6, align 4, !tbaa !11
  %20 = icmp ule i32 %19, 2048
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = load double, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = load i32, ptr %6, align 4, !tbaa !11
  call void @fill_cplx_fft_omegas_bfs_16(double noundef %22, ptr noundef %23, i32 noundef %24)
  br label %50

25:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %26 = load double, ptr %4, align 8, !tbaa !5
  %27 = fdiv double %26, 2.000000e+00
  store double %27, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds [2 x double], ptr %29, i64 0
  %31 = getelementptr inbounds [2 x double], ptr %30, i64 0, i64 0
  %32 = load double, ptr %7, align 8, !tbaa !5
  call void @cplx_set_e2pix(ptr noundef %31, double noundef %32)
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = getelementptr inbounds [2 x double], ptr %34, i64 1
  %36 = getelementptr inbounds [2 x double], ptr %35, i64 0, i64 0
  %37 = load double, ptr %7, align 8, !tbaa !5
  call void @cplx_set_e2pix(ptr noundef %36, double noundef %37)
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds [2 x double], ptr %39, i64 2
  store ptr %40, ptr %38, align 8, !tbaa !9
  %41 = load double, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = load i32, ptr %6, align 4, !tbaa !11
  %44 = udiv i32 %43, 2
  call void @fill_cplx_fft_omegas_rec_16(double noundef %41, ptr noundef %42, i32 noundef %44)
  %45 = load double, ptr %7, align 8, !tbaa !5
  %46 = fadd double %45, 5.000000e-01
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = load i32, ptr %6, align 4, !tbaa !11
  %49 = udiv i32 %48, 2
  call void @fill_cplx_fft_omegas_rec_16(double noundef %46, ptr noundef %47, i32 noundef %49)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  br label %50

50:                                               ; preds = %25, %21, %14, %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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

; Function Attrs: nounwind uwtable
declare dso_local void @cplx_set_e2pix(ptr noundef, double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @fill_cplx_fft_omegas_bfs_16(double noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @fill_cplx_fft_omegas_bfs_2(double noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @fill_cplx_fft_omegas_rec_16(double noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i32 %2, 1
  br i1 %4, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %5 = icmp ult i32 %2, 9
  br i1 %5, label %6, label %.lr.ph40

6:                                                ; preds = %.lr.ph.preheader
  tail call void @fill_cplx_fft_omegas_bfs_2(double noundef %0, ptr noundef %1, i32 noundef %2)
  br label %.loopexit

.lr.ph40:                                         ; preds = %.lr.ph.preheader, %tailrecurse
  %.tr2639 = phi double [ %16, %tailrecurse ], [ %0, %.lr.ph.preheader ]
  %.tr212738 = phi i32 [ %15, %tailrecurse ], [ %2, %.lr.ph.preheader ]
  %7 = icmp ult i32 %.tr212738, 2049
  br i1 %7, label %8, label %tailrecurse

8:                                                ; preds = %.lr.ph40
  tail call void @fill_cplx_fft_omegas_bfs_16(double noundef %.tr2639, ptr noundef %1, i32 noundef %.tr212738)
  br label %.loopexit

tailrecurse:                                      ; preds = %.lr.ph40
  %9 = fmul double %.tr2639, 5.000000e-01
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  tail call void @cplx_set_e2pix(ptr noundef %10, double noundef %9)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  tail call void @cplx_set_e2pix(ptr noundef nonnull %12, double noundef %9)
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 32
  store ptr %14, ptr %1, align 8, !tbaa !5
  %15 = lshr i32 %.tr212738, 1
  tail call void @fill_cplx_fft_omegas_rec_16(double noundef %9, ptr noundef nonnull %1, i32 noundef %15)
  %16 = fadd double %9, 5.000000e-01
  br label %.lr.ph40

.loopexit:                                        ; preds = %3, %8, %6
  ret void
}

attributes #0 = { 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" }

!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/C++ TBAA"}


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