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

; 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: nounwind uwtable
declare dso_local void @cplx_add(ptr noundef, ptr noundef, ptr noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @cplx_split_fft_ref(i32 noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca [2 x double], align 16
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %11, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = load ptr, ptr %5, align 8, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [2 x double], ptr %12, i64 %14
  store ptr %15, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %16

16:                                               ; preds = %50, %3
  %17 = load i64, ptr %9, align 8, !tbaa !11
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp ult i64 %17, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %53

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #2
  %23 = getelementptr inbounds [2 x double], ptr %10, i64 0, i64 0
  %24 = load ptr, ptr %7, align 8, !tbaa !9
  %25 = load i64, ptr %9, align 8, !tbaa !11
  %26 = getelementptr inbounds [2 x double], ptr %24, i64 %25
  %27 = getelementptr inbounds [2 x double], ptr %26, i64 0, i64 0
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = load i64, ptr %9, align 8, !tbaa !11
  %30 = getelementptr inbounds [2 x double], ptr %28, i64 %29
  %31 = getelementptr inbounds [2 x double], ptr %30, i64 0, i64 0
  call void @cplx_sub(ptr noundef %23, ptr noundef %27, ptr noundef %31)
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load i64, ptr %9, align 8, !tbaa !11
  %34 = getelementptr inbounds [2 x double], ptr %32, i64 %33
  %35 = getelementptr inbounds [2 x double], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = load i64, ptr %9, align 8, !tbaa !11
  %38 = getelementptr inbounds [2 x double], ptr %36, i64 %37
  %39 = getelementptr inbounds [2 x double], ptr %38, i64 0, i64 0
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = load i64, ptr %9, align 8, !tbaa !11
  %42 = getelementptr inbounds [2 x double], ptr %40, i64 %41
  %43 = getelementptr inbounds [2 x double], ptr %42, i64 0, i64 0
  call void @cplx_add(ptr noundef %35, ptr noundef %39, ptr noundef %43)
  %44 = load ptr, ptr %8, align 8, !tbaa !9
  %45 = load i64, ptr %9, align 8, !tbaa !11
  %46 = getelementptr inbounds [2 x double], ptr %44, i64 %45
  %47 = getelementptr inbounds [2 x double], ptr %46, i64 0, i64 0
  %48 = getelementptr inbounds [2 x double], ptr %10, i64 0, i64 0
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  call void @cplx_mul(ptr noundef %47, ptr noundef %48, ptr noundef %49)
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #2
  br label %50

50:                                               ; preds = %22
  %51 = load i64, ptr %9, align 8, !tbaa !11
  %52 = add i64 %51, 1
  store i64 %52, ptr %9, align 8, !tbaa !11
  br label %16, !llvm.loop !13

53:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !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 = !{!"long", !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"

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @cplx_split_fft_ref(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [2 x double], align 16
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [2 x double], ptr %1, i64 %5
  %.not = icmp eq i32 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  ret void

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.018 = phi i64 [ %9, %.lr.ph ], [ 0, %3 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #2
  %7 = getelementptr inbounds [2 x double], ptr %1, i64 %.018
  %8 = getelementptr inbounds [2 x double], ptr %6, i64 %.018
  call void @cplx_sub(ptr noundef nonnull %4, ptr noundef %7, ptr noundef nonnull %8)
  call void @cplx_add(ptr noundef %7, ptr noundef %7, ptr noundef nonnull %8)
  call void @cplx_mul(ptr noundef nonnull %8, ptr noundef nonnull %4, ptr noundef %2)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #2
  %9 = add nuw i64 %.018, 1
  %exitcond.not = icmp eq i64 %9, %5
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5
}

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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