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

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

; Function Attrs: nounwind uwtable
define dso_local void @reim_bitwiddle_fft_ref(i64 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %19, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = load i64, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds double, ptr %20, i64 %21
  store ptr %22, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = load i64, ptr %5, align 8, !tbaa !5
  %25 = mul i64 2, %24
  %26 = getelementptr inbounds double, ptr %23, i64 %25
  store ptr %26, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = load i64, ptr %5, align 8, !tbaa !5
  %29 = mul i64 3, %28
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  store ptr %30, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %31, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i64, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds double, ptr %32, i64 %33
  store ptr %34, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %35 = load ptr, ptr %7, align 8, !tbaa !9
  %36 = load i64, ptr %5, align 8, !tbaa !5
  %37 = mul i64 2, %36
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  store ptr %38, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = load i64, ptr %5, align 8, !tbaa !5
  %41 = mul i64 3, %40
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  store ptr %42, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  store i64 0, ptr %17, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %85, %4
  %44 = load i64, ptr %17, align 8, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !5
  %46 = icmp ult i64 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  br label %88

48:                                               ; preds = %43
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = load i64, ptr %17, align 8, !tbaa !5
  %51 = getelementptr inbounds double, ptr %49, i64 %50
  %52 = load ptr, ptr %13, align 8, !tbaa !9
  %53 = load i64, ptr %17, align 8, !tbaa !5
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  %55 = load ptr, ptr %11, align 8, !tbaa !9
  %56 = load i64, ptr %17, align 8, !tbaa !5
  %57 = getelementptr inbounds double, ptr %55, i64 %56
  %58 = load ptr, ptr %15, align 8, !tbaa !9
  %59 = load i64, ptr %17, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %58, i64 %59
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = getelementptr inbounds double, ptr %61, i64 0
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  %65 = getelementptr inbounds double, ptr %64, i64 1
  %66 = load double, ptr %65, align 8, !tbaa !11
  call void @reim_ctwiddle(ptr noundef %51, ptr noundef %54, ptr noundef %57, ptr noundef %60, double noundef %63, double noundef %66)
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = load i64, ptr %17, align 8, !tbaa !5
  %69 = getelementptr inbounds double, ptr %67, i64 %68
  %70 = load ptr, ptr %14, align 8, !tbaa !9
  %71 = load i64, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds double, ptr %70, i64 %71
  %73 = load ptr, ptr %12, align 8, !tbaa !9
  %74 = load i64, ptr %17, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %73, i64 %74
  %76 = load ptr, ptr %16, align 8, !tbaa !9
  %77 = load i64, ptr %17, align 8, !tbaa !5
  %78 = getelementptr inbounds double, ptr %76, i64 %77
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  %80 = getelementptr inbounds double, ptr %79, i64 0
  %81 = load double, ptr %80, align 8, !tbaa !11
  %82 = load ptr, ptr %8, align 8, !tbaa !9
  %83 = getelementptr inbounds double, ptr %82, i64 1
  %84 = load double, ptr %83, align 8, !tbaa !11
  call void @reim_ctwiddle(ptr noundef %69, ptr noundef %72, ptr noundef %75, ptr noundef %78, double noundef %81, double noundef %84)
  br label %85

85:                                               ; preds = %48
  %86 = load i64, ptr %17, align 8, !tbaa !5
  %87 = add i64 %86, 1
  store i64 %87, ptr %17, align 8, !tbaa !5
  br label %43, !llvm.loop !13

88:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #2
  store i64 0, ptr %18, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %131, %88
  %90 = load i64, ptr %18, align 8, !tbaa !5
  %91 = load i64, ptr %5, align 8, !tbaa !5
  %92 = icmp ult i64 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  br label %134

94:                                               ; preds = %89
  %95 = load ptr, ptr %9, align 8, !tbaa !9
  %96 = load i64, ptr %18, align 8, !tbaa !5
  %97 = getelementptr inbounds double, ptr %95, i64 %96
  %98 = load ptr, ptr %13, align 8, !tbaa !9
  %99 = load i64, ptr %18, align 8, !tbaa !5
  %100 = getelementptr inbounds double, ptr %98, i64 %99
  %101 = load ptr, ptr %10, align 8, !tbaa !9
  %102 = load i64, ptr %18, align 8, !tbaa !5
  %103 = getelementptr inbounds double, ptr %101, i64 %102
  %104 = load ptr, ptr %14, align 8, !tbaa !9
  %105 = load i64, ptr %18, align 8, !tbaa !5
  %106 = getelementptr inbounds double, ptr %104, i64 %105
  %107 = load ptr, ptr %8, align 8, !tbaa !9
  %108 = getelementptr inbounds double, ptr %107, i64 2
  %109 = load double, ptr %108, align 8, !tbaa !11
  %110 = load ptr, ptr %8, align 8, !tbaa !9
  %111 = getelementptr inbounds double, ptr %110, i64 3
  %112 = load double, ptr %111, align 8, !tbaa !11
  call void @reim_ctwiddle(ptr noundef %97, ptr noundef %100, ptr noundef %103, ptr noundef %106, double noundef %109, double noundef %112)
  %113 = load ptr, ptr %11, align 8, !tbaa !9
  %114 = load i64, ptr %18, align 8, !tbaa !5
  %115 = getelementptr inbounds double, ptr %113, i64 %114
  %116 = load ptr, ptr %15, align 8, !tbaa !9
  %117 = load i64, ptr %18, align 8, !tbaa !5
  %118 = getelementptr inbounds double, ptr %116, i64 %117
  %119 = load ptr, ptr %12, align 8, !tbaa !9
  %120 = load i64, ptr %18, align 8, !tbaa !5
  %121 = getelementptr inbounds double, ptr %119, i64 %120
  %122 = load ptr, ptr %16, align 8, !tbaa !9
  %123 = load i64, ptr %18, align 8, !tbaa !5
  %124 = getelementptr inbounds double, ptr %122, i64 %123
  %125 = load ptr, ptr %8, align 8, !tbaa !9
  %126 = getelementptr inbounds double, ptr %125, i64 2
  %127 = load double, ptr %126, align 8, !tbaa !11
  %128 = load ptr, ptr %8, align 8, !tbaa !9
  %129 = getelementptr inbounds double, ptr %128, i64 3
  %130 = load double, ptr %129, align 8, !tbaa !11
  call void @reim_citwiddle(ptr noundef %115, ptr noundef %118, ptr noundef %121, ptr noundef %124, double noundef %127, double noundef %130)
  br label %131

131:                                              ; preds = %94
  %132 = load i64, ptr %18, align 8, !tbaa !5
  %133 = add i64 %132, 1
  store i64 %133, ptr %18, align 8, !tbaa !5
  br label %89, !llvm.loop !15

134:                                              ; preds = %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  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 = !{!"long", !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 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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 @reim_ctwiddle(ptr noundef, ptr noundef, ptr noundef, ptr noundef, double noundef, double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @reim_bitwiddle_fft_ref(i64 noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds double, ptr %1, i64 %0
  %6 = shl i64 %0, 1
  %7 = getelementptr inbounds double, ptr %1, i64 %6
  %8 = mul i64 %0, 3
  %9 = getelementptr inbounds double, ptr %1, i64 %8
  %10 = getelementptr inbounds double, ptr %2, i64 %0
  %11 = getelementptr inbounds double, ptr %2, i64 %6
  %12 = getelementptr inbounds double, ptr %2, i64 %8
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  br label %16

.lr.ph63:                                         ; preds = %16
  %14 = getelementptr inbounds i8, ptr %3, i64 16
  %15 = getelementptr inbounds i8, ptr %3, i64 24
  br label %30

16:                                               ; preds = %.lr.ph, %16
  %.05961 = phi i64 [ 0, %.lr.ph ], [ %29, %16 ]
  %17 = getelementptr inbounds double, ptr %1, i64 %.05961
  %18 = getelementptr inbounds double, ptr %2, i64 %.05961
  %19 = getelementptr inbounds double, ptr %7, i64 %.05961
  %20 = getelementptr inbounds double, ptr %11, i64 %.05961
  %21 = load double, ptr %3, align 8, !tbaa !5
  %22 = load double, ptr %13, align 8, !tbaa !5
  tail call void @reim_ctwiddle(ptr noundef %17, ptr noundef %18, ptr noundef %19, ptr noundef %20, double noundef %21, double noundef %22)
  %23 = getelementptr inbounds double, ptr %5, i64 %.05961
  %24 = getelementptr inbounds double, ptr %10, i64 %.05961
  %25 = getelementptr inbounds double, ptr %9, i64 %.05961
  %26 = getelementptr inbounds double, ptr %12, i64 %.05961
  %27 = load double, ptr %3, align 8, !tbaa !5
  %28 = load double, ptr %13, align 8, !tbaa !5
  tail call void @reim_ctwiddle(ptr noundef nonnull %23, ptr noundef nonnull %24, ptr noundef nonnull %25, ptr noundef nonnull %26, double noundef %27, double noundef %28)
  %29 = add nuw i64 %.05961, 1
  %exitcond.not = icmp eq i64 %29, %0
  br i1 %exitcond.not, label %.lr.ph63, label %16, !llvm.loop !9

._crit_edge:                                      ; preds = %30, %4
  ret void

30:                                               ; preds = %.lr.ph63, %30
  %.062 = phi i64 [ 0, %.lr.ph63 ], [ %43, %30 ]
  %31 = getelementptr inbounds double, ptr %1, i64 %.062
  %32 = getelementptr inbounds double, ptr %2, i64 %.062
  %33 = getelementptr inbounds double, ptr %5, i64 %.062
  %34 = getelementptr inbounds double, ptr %10, i64 %.062
  %35 = load double, ptr %14, align 8, !tbaa !5
  %36 = load double, ptr %15, align 8, !tbaa !5
  tail call void @reim_ctwiddle(ptr noundef %31, ptr noundef %32, ptr noundef nonnull %33, ptr noundef nonnull %34, double noundef %35, double noundef %36)
  %37 = getelementptr inbounds double, ptr %7, i64 %.062
  %38 = getelementptr inbounds double, ptr %11, i64 %.062
  %39 = getelementptr inbounds double, ptr %9, i64 %.062
  %40 = getelementptr inbounds double, ptr %12, i64 %.062
  %41 = load double, ptr %14, align 8, !tbaa !5
  %42 = load double, ptr %15, align 8, !tbaa !5
  tail call void @reim_citwiddle(ptr noundef %37, ptr noundef %38, ptr noundef nonnull %39, ptr noundef nonnull %40, double noundef %41, double noundef %42)
  %43 = add nuw i64 %.062, 1
  %exitcond65.not = icmp eq i64 %43, %0
  br i1 %exitcond65.not, label %._crit_edge, label %30, !llvm.loop !11
}

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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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