; LLVM IR from tfhe/spqlios-arithmetic :: spqlios/reim4 (reim4_fftvec_conv_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"

%struct.reim4_from_cplx_precomp = type { ptr, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @reim4_from_cplx_ref(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %18, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.reim4_from_cplx_precomp, ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %21, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !12
  br label %22

22:                                               ; preds = %81, %3
  %23 = load i64, ptr %9, align 8, !tbaa !12
  %24 = load i64, ptr %8, align 8, !tbaa !12
  %25 = udiv i64 %24, 4
  %26 = icmp ult i64 %23, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 0
  %31 = load double, ptr %30, align 8, !tbaa !13
  store double %31, ptr %10, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 1
  %34 = load double, ptr %33, align 8, !tbaa !13
  store double %34, ptr %11, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 2
  %37 = load double, ptr %36, align 8, !tbaa !13
  store double %37, ptr %12, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 3
  %40 = load double, ptr %39, align 8, !tbaa !13
  store double %40, ptr %13, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds double, ptr %41, i64 4
  %43 = load double, ptr %42, align 8, !tbaa !13
  store double %43, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 5
  %46 = load double, ptr %45, align 8, !tbaa !13
  store double %46, ptr %15, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds double, ptr %47, i64 6
  %49 = load double, ptr %48, align 8, !tbaa !13
  store double %49, ptr %16, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds double, ptr %50, i64 7
  %52 = load double, ptr %51, align 8, !tbaa !13
  store double %52, ptr %17, align 8, !tbaa !13
  %53 = load double, ptr %10, align 8, !tbaa !13
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 0
  store double %53, ptr %55, align 8, !tbaa !13
  %56 = load double, ptr %14, align 8, !tbaa !13
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %57, i64 1
  store double %56, ptr %58, align 8, !tbaa !13
  %59 = load double, ptr %12, align 8, !tbaa !13
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds double, ptr %60, i64 2
  store double %59, ptr %61, align 8, !tbaa !13
  %62 = load double, ptr %16, align 8, !tbaa !13
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %63, i64 3
  store double %62, ptr %64, align 8, !tbaa !13
  %65 = load double, ptr %11, align 8, !tbaa !13
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds double, ptr %66, i64 4
  store double %65, ptr %67, align 8, !tbaa !13
  %68 = load double, ptr %15, align 8, !tbaa !13
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i64 5
  store double %68, ptr %70, align 8, !tbaa !13
  %71 = load double, ptr %13, align 8, !tbaa !13
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds double, ptr %72, i64 6
  store double %71, ptr %73, align 8, !tbaa !13
  %74 = load double, ptr %17, align 8, !tbaa !13
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds double, ptr %75, i64 7
  store double %74, ptr %76, align 8, !tbaa !13
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds double, ptr %77, i64 8
  store ptr %78, ptr %7, align 8, !tbaa !5
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds double, ptr %79, i64 8
  store ptr %80, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  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
  br label %81

81:                                               ; preds = %28
  %82 = load i64, ptr %9, align 8, !tbaa !12
  %83 = add i64 %82, 1
  store i64 %83, ptr %9, align 8, !tbaa !12
  br label %22, !llvm.loop !15

84:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

; 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

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"reim4_from_cplx_precomp", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @reim4_from_cplx_ref(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = lshr i64 %5, 2
  %.not = icmp ult i64 %5, 4
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.034 = phi ptr [ %30, %.lr.ph ], [ %1, %3 ]
  %.03033 = phi ptr [ %29, %.lr.ph ], [ %2, %3 ]
  %.03132 = phi i64 [ %31, %.lr.ph ], [ 0, %3 ]
  %7 = load double, ptr %.03033, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %.03033, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %.03033, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %.03033, i64 24
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %.03033, i64 32
  %15 = load double, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds i8, ptr %.03033, i64 40
  %17 = load double, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %.03033, i64 48
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds i8, ptr %.03033, i64 56
  %21 = load double, ptr %20, align 8, !tbaa !11
  store double %7, ptr %.034, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %.034, i64 8
  store double %15, ptr %22, align 8, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %.034, i64 16
  store double %11, ptr %23, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %.034, i64 24
  store double %19, ptr %24, align 8, !tbaa !11
  %25 = getelementptr inbounds i8, ptr %.034, i64 32
  store double %9, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %.034, i64 40
  store double %17, ptr %26, align 8, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %.034, i64 48
  store double %13, ptr %27, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %.034, i64 56
  store double %21, ptr %28, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %.03033, i64 64
  %30 = getelementptr inbounds i8, ptr %.034, i64 64
  %31 = add nuw nsw i64 %.03132, 1
  %exitcond.not = icmp eq i64 %31, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"reim4_from_cplx_precomp", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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