; LLVM IR from tfhe/spqlios-arithmetic :: spqlios/reim (reim_ifft_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 @fill_reim_ifft16_omegas(double noundef, ptr noundef) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind
declare double @log2(double noundef) #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

; Function Attrs: nounwind uwtable
define dso_local void @fill_reim_ifft_bfs_16_omegas(i64 noundef %0, double noundef %1, ptr noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca double, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = uitofp i64 %17 to double
  %19 = call double @log2(double noundef %18) #5
  %20 = fptoui double %19 to i64
  store i64 %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = load double, ptr %5, align 8, !tbaa !9
  %22 = fmul double %21, 1.600000e+01
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = uitofp i64 %23 to double
  %25 = fdiv double %22, %24
  store double %25, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %40, %3
  %27 = load i64, ptr %9, align 8, !tbaa !5
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %43

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %32 = load double, ptr %8, align 8, !tbaa !9
  %33 = load i64, ptr %9, align 8, !tbaa !5
  %34 = udiv i64 %33, 16
  %35 = trunc i64 %34 to i32
  %36 = call double @fracrevbits(i32 noundef %35)
  %37 = fadd double %32, %36
  store double %37, ptr %10, align 8, !tbaa !9
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !11
  call void @fill_reim_ifft16_omegas(double noundef %38, ptr noundef %39)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %40

40:                                               ; preds = %31
  %41 = load i64, ptr %9, align 8, !tbaa !5
  %42 = add i64 %41, 16
  store i64 %42, ptr %9, align 8, !tbaa !5
  br label %26, !llvm.loop !13

43:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 16, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %44 = load i64, ptr %4, align 8, !tbaa !5
  %45 = udiv i64 %44, 2
  store i64 %45, ptr %12, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %102, %43
  %47 = load i64, ptr %11, align 8, !tbaa !5
  %48 = load i64, ptr %12, align 8, !tbaa !5
  %49 = icmp ult i64 %47, %48
  br i1 %49, label %50, label %106

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %51 = load i64, ptr %11, align 8, !tbaa !5
  %52 = shl i64 %51, 2
  store i64 %52, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i64 0, ptr %14, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %98, %50
  %54 = load i64, ptr %14, align 8, !tbaa !5
  %55 = load i64, ptr %4, align 8, !tbaa !5
  %56 = icmp ult i64 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %102

58:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %59 = load double, ptr %8, align 8, !tbaa !9
  %60 = load i64, ptr %14, align 8, !tbaa !5
  %61 = load i64, ptr %13, align 8, !tbaa !5
  %62 = udiv i64 %60, %61
  %63 = trunc i64 %62 to i32
  %64 = call double @fracrevbits(i32 noundef %63)
  %65 = fdiv double %64, 4.000000e+00
  %66 = fadd double %59, %65
  store double %66, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %67 = load double, ptr %15, align 8, !tbaa !9
  %68 = fmul double 2.000000e+00, %67
  store double %68, ptr %16, align 8, !tbaa !9
  %69 = load double, ptr %15, align 8, !tbaa !9
  %70 = fmul double 0x401921FB54442D18, %69
  %71 = call double @cos(double noundef %70) #5
  %72 = load ptr, ptr %6, align 8, !tbaa !11
  %73 = load ptr, ptr %72, align 8, !tbaa !11
  %74 = getelementptr inbounds double, ptr %73, i64 0
  store double %71, ptr %74, align 8, !tbaa !9
  %75 = load double, ptr %15, align 8, !tbaa !9
  %76 = fmul double 0x401921FB54442D18, %75
  %77 = call double @sin(double noundef %76) #5
  %78 = fneg double %77
  %79 = load ptr, ptr %6, align 8, !tbaa !11
  %80 = load ptr, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds double, ptr %80, i64 1
  store double %78, ptr %81, align 8, !tbaa !9
  %82 = load double, ptr %16, align 8, !tbaa !9
  %83 = fmul double 0x401921FB54442D18, %82
  %84 = call double @cos(double noundef %83) #5
  %85 = load ptr, ptr %6, align 8, !tbaa !11
  %86 = load ptr, ptr %85, align 8, !tbaa !11
  %87 = getelementptr inbounds double, ptr %86, i64 2
  store double %84, ptr %87, align 8, !tbaa !9
  %88 = load double, ptr %16, align 8, !tbaa !9
  %89 = fmul double 0x401921FB54442D18, %88
  %90 = call double @sin(double noundef %89) #5
  %91 = fneg double %90
  %92 = load ptr, ptr %6, align 8, !tbaa !11
  %93 = load ptr, ptr %92, align 8, !tbaa !11
  %94 = getelementptr inbounds double, ptr %93, i64 3
  store double %91, ptr %94, align 8, !tbaa !9
  %95 = load ptr, ptr %6, align 8, !tbaa !11
  %96 = load ptr, ptr %95, align 8, !tbaa !11
  %97 = getelementptr inbounds double, ptr %96, i64 4
  store ptr %97, ptr %95, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  br label %98

98:                                               ; preds = %58
  %99 = load i64, ptr %13, align 8, !tbaa !5
  %100 = load i64, ptr %14, align 8, !tbaa !5
  %101 = add i64 %100, %99
  store i64 %101, ptr %14, align 8, !tbaa !5
  br label %53, !llvm.loop !15

102:                                              ; preds = %57
  %103 = load double, ptr %8, align 8, !tbaa !9
  %104 = fmul double %103, 4.000000e+00
  store double %104, ptr %8, align 8, !tbaa !9
  %105 = load i64, ptr %13, align 8, !tbaa !5
  store i64 %105, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %46, !llvm.loop !16

106:                                              ; preds = %46
  %107 = load i64, ptr %7, align 8, !tbaa !5
  %108 = urem i64 %107, 2
  %109 = icmp ne i64 %108, 0
  br i1 %109, label %110, label %135

110:                                              ; preds = %106
  %111 = load i64, ptr %11, align 8, !tbaa !5
  %112 = load i64, ptr %12, align 8, !tbaa !5
  %113 = icmp ne i64 %111, %112
  br i1 %113, label %114, label %115

114:                                              ; preds = %110
  call void @abort() #6
  unreachable

115:                                              ; preds = %110
  %116 = load double, ptr %8, align 8, !tbaa !9
  %117 = fmul double 0x401921FB54442D18, %116
  %118 = call double @cos(double noundef %117) #5
  %119 = load ptr, ptr %6, align 8, !tbaa !11
  %120 = load ptr, ptr %119, align 8, !tbaa !11
  %121 = getelementptr inbounds double, ptr %120, i64 0
  store double %118, ptr %121, align 8, !tbaa !9
  %122 = load double, ptr %8, align 8, !tbaa !9
  %123 = fmul double 0x401921FB54442D18, %122
  %124 = call double @sin(double noundef %123) #5
  %125 = fneg double %124
  %126 = load ptr, ptr %6, align 8, !tbaa !11
  %127 = load ptr, ptr %126, align 8, !tbaa !11
  %128 = getelementptr inbounds double, ptr %127, i64 1
  store double %125, ptr %128, align 8, !tbaa !9
  %129 = load ptr, ptr %6, align 8, !tbaa !11
  %130 = load ptr, ptr %129, align 8, !tbaa !11
  %131 = getelementptr inbounds double, ptr %130, i64 2
  store ptr %131, ptr %129, align 8, !tbaa !11
  %132 = load i64, ptr %4, align 8, !tbaa !5
  store i64 %132, ptr %11, align 8, !tbaa !5
  %133 = load double, ptr %8, align 8, !tbaa !9
  %134 = fmul double %133, 2.000000e+00
  store double %134, ptr %8, align 8, !tbaa !9
  br label %135

135:                                              ; preds = %115, %106
  %136 = load double, ptr %8, align 8, !tbaa !9
  %137 = load double, ptr %5, align 8, !tbaa !9
  %138 = fcmp une double %136, %137
  br i1 %138, label %139, label %140

139:                                              ; preds = %135
  call void @abort() #6
  unreachable

140:                                              ; preds = %135
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

declare double @fracrevbits(i32 noundef) #4

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 "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 = { noreturn nounwind "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 = { "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 #5 = { nounwind }
attributes #6 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 @fill_reim_ifft16_omegas(double noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log2(double noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @fill_reim_ifft_bfs_16_omegas(i64 noundef %0, double noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = uitofp i64 %0 to double
  %5 = tail call double @log2(double noundef %4) #4
  %6 = fptoui double %5 to i64
  %7 = fmul double %1, 1.600000e+01
  %8 = fdiv double %7, %4
  %.not62 = icmp eq i64 %0, 0
  br i1 %.not62, label %._crit_edge59, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %9 = lshr i64 %0, 1
  %10 = icmp ugt i64 %0, 33
  br i1 %10, label %.lr.ph53.us, label %._crit_edge59

.lr.ph53.us:                                      ; preds = %._crit_edge, %._crit_edge54.us
  %.056.us = phi double [ %37, %._crit_edge54.us ], [ %8, %._crit_edge ]
  %.04655.us = phi i64 [ %11, %._crit_edge54.us ], [ 16, %._crit_edge ]
  %11 = shl i64 %.04655.us, 2
  br label %12

12:                                               ; preds = %.lr.ph53.us, %12
  %.04551.us = phi i64 [ 0, %.lr.ph53.us ], [ %35, %12 ]
  %13 = udiv i64 %.04551.us, %11
  %14 = trunc i64 %13 to i32
  %15 = tail call double @fracrevbits(i32 noundef %14) #4
  %16 = fmul double %15, 2.500000e-01
  %17 = fadd double %.056.us, %16
  %18 = fmul double %17, 2.000000e+00
  %19 = fmul double %17, 0x401921FB54442D18
  %20 = tail call double @cos(double noundef %19) #4
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  store double %20, ptr %21, align 8, !tbaa !9
  %22 = tail call double @sin(double noundef %19) #4
  %23 = fneg double %22
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  store double %23, ptr %25, align 8, !tbaa !9
  %26 = fmul double %18, 0x401921FB54442D18
  %27 = tail call double @cos(double noundef %26) #4
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  store double %27, ptr %29, align 8, !tbaa !9
  %30 = tail call double @sin(double noundef %26) #4
  %31 = fneg double %30
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 24
  store double %31, ptr %33, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 32
  store ptr %34, ptr %2, align 8, !tbaa !5
  %35 = add i64 %.04551.us, %11
  %36 = icmp ult i64 %35, %0
  br i1 %36, label %12, label %._crit_edge54.us, !llvm.loop !11

._crit_edge54.us:                                 ; preds = %12
  %37 = fmul double %.056.us, 4.000000e+00
  %38 = icmp ult i64 %11, %9
  br i1 %38, label %.lr.ph53.us, label %._crit_edge59, !llvm.loop !13

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.04450 = phi i64 [ %43, %.lr.ph ], [ 0, %3 ]
  %39 = lshr exact i64 %.04450, 4
  %40 = trunc i64 %39 to i32
  %41 = tail call double @fracrevbits(i32 noundef %40) #4
  %42 = fadd double %8, %41
  tail call void @fill_reim_ifft16_omegas(double noundef %42, ptr noundef %2)
  %43 = add i64 %.04450, 16
  %44 = icmp ult i64 %43, %0
  br i1 %44, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge59:                                    ; preds = %._crit_edge54.us, %3, %._crit_edge
  %45 = phi i64 [ %9, %._crit_edge ], [ 0, %3 ], [ %9, %._crit_edge54.us ]
  %.046.lcssa = phi i64 [ 16, %._crit_edge ], [ 16, %3 ], [ %11, %._crit_edge54.us ]
  %.0.lcssa = phi double [ %8, %._crit_edge ], [ %8, %3 ], [ %37, %._crit_edge54.us ]
  %46 = and i64 %6, 1
  %.not = icmp eq i64 %46, 0
  br i1 %.not, label %59, label %47

47:                                               ; preds = %._crit_edge59
  %.not49 = icmp eq i64 %.046.lcssa, %45
  br i1 %.not49, label %49, label %48

48:                                               ; preds = %47
  tail call void @abort() #5
  unreachable

49:                                               ; preds = %47
  %50 = fmul double %.0.lcssa, 0x401921FB54442D18
  %51 = tail call double @cos(double noundef %50) #4
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  store double %51, ptr %52, align 8, !tbaa !9
  %53 = tail call double @sin(double noundef %50) #4
  %54 = fneg double %53
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  store double %54, ptr %56, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 16
  store ptr %57, ptr %2, align 8, !tbaa !5
  %58 = fmul double %.0.lcssa, 2.000000e+00
  br label %59

59:                                               ; preds = %49, %._crit_edge59
  %.1 = phi double [ %58, %49 ], [ %.0.lcssa, %._crit_edge59 ]
  %60 = fcmp une double %.1, %1
  br i1 %60, label %61, label %62

61:                                               ; preds = %59
  tail call void @abort() #5
  unreachable

62:                                               ; preds = %59
  ret void
}

declare double @fracrevbits(i32 noundef) local_unnamed_addr #3

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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { noreturn nounwind "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 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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