; 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
define dso_local void @reim_ctwiddle(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, double noundef %4, double noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store double %4, ptr %11, align 8, !tbaa !9
  store double %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = load double, ptr %11, align 8, !tbaa !9
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = load double, ptr %12, align 8, !tbaa !9
  %21 = fmul double %19, %20
  %22 = fneg double %21
  %23 = call double @llvm.fmuladd.f64(double %16, double %17, double %22)
  store double %23, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = load double, ptr %12, align 8, !tbaa !9
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = load double, ptr %11, align 8, !tbaa !9
  %30 = fmul double %28, %29
  %31 = call double @llvm.fmuladd.f64(double %25, double %26, double %30)
  store double %31, ptr %14, align 8, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = load double, ptr %13, align 8, !tbaa !9
  %35 = fsub double %33, %34
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  store double %35, ptr %36, align 8, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = load double, ptr %14, align 8, !tbaa !9
  %40 = fsub double %38, %39
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  store double %40, ptr %41, align 8, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = load double, ptr %13, align 8, !tbaa !9
  %45 = fadd double %43, %44
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  store double %45, ptr %46, align 8, !tbaa !9
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = load double, ptr %14, align 8, !tbaa !9
  %50 = fadd double %48, %49
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  store double %50, ptr %51, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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}


; 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: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @reim_ctwiddle(ptr nocapture noundef %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3, double noundef %4, double noundef %5) local_unnamed_addr #0 {
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = fneg double %8
  %10 = fmul double %9, %5
  %11 = tail call double @llvm.fmuladd.f64(double %7, double %4, double %10)
  %12 = fmul double %8, %4
  %13 = tail call double @llvm.fmuladd.f64(double %7, double %5, double %12)
  %14 = load double, ptr %0, align 8, !tbaa !5
  %15 = fsub double %14, %11
  store double %15, ptr %2, align 8, !tbaa !5
  %16 = load double, ptr %1, align 8, !tbaa !5
  %17 = fsub double %16, %13
  store double %17, ptr %3, align 8, !tbaa !5
  %18 = load double, ptr %0, align 8, !tbaa !5
  %19 = fadd double %11, %18
  store double %19, ptr %0, align 8, !tbaa !5
  %20 = load double, ptr %1, align 8, !tbaa !5
  %21 = fadd double %13, %20
  store double %21, ptr %1, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 speculatable willreturn memory(none) }

!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"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass