; LLVM IR from zsiciarz/aquila :: aquila/transform/OouraFft.ll (ZN6Aquila8OouraFft4ifftESt6vectorISt7complexIdESaIS3_EEPd)

; 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"

%"class.Aquila::Fft" = type { ptr, i64 }
%"class.Aquila::OouraFft" = type { %"class.Aquila::Fft", ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #0

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #2

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

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

declare void @cdft(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Aquila8OouraFft4ifftESt6vectorISt7complexIdESaIS3_EEPd(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #5 align 2 {
  %4 = alloca ptr, align 8
  %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
  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
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt7complexIdESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #8
  store ptr %11, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  %12 = getelementptr inbounds %"class.Aquila::Fft", ptr %10, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = mul i64 2, %13
  %15 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %14, i64 8)
  %16 = extractvalue { i64, i1 } %15, 1
  %17 = extractvalue { i64, i1 } %15, 0
  %18 = select i1 %16, i64 -1, i64 %17
  %19 = call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #9
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.Aquila::Fft", ptr %10, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = mul i64 2, %23
  %25 = getelementptr inbounds double, ptr %21, i64 %24
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call noundef ptr @_ZSt4copyIPdS0_ET0_T_S2_S1_(ptr noundef %20, ptr noundef %25, ptr noundef %26)
  %28 = getelementptr inbounds %"class.Aquila::Fft", ptr %10, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = mul i64 2, %29
  %31 = trunc i64 %30 to i32
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.Aquila::OouraFft", ptr %10, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !12
  %35 = getelementptr inbounds %"class.Aquila::OouraFft", ptr %10, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !14
  call void @cdft(i32 noundef %31, i32 noundef 1, ptr noundef %32, ptr noundef %34, ptr noundef %36)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store i64 0, ptr %9, align 8, !tbaa !15
  br label %37

37:                                               ; preds = %56, %3
  %38 = load i64, ptr %9, align 8, !tbaa !15
  %39 = getelementptr inbounds %"class.Aquila::Fft", ptr %10, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = icmp ult i64 %38, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %59

43:                                               ; preds = %37
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load i64, ptr %9, align 8, !tbaa !15
  %46 = mul i64 2, %45
  %47 = getelementptr inbounds double, ptr %44, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !16
  %49 = getelementptr inbounds %"class.Aquila::Fft", ptr %10, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = uitofp i64 %50 to double
  %52 = fdiv double %48, %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load i64, ptr %9, align 8, !tbaa !15
  %55 = getelementptr inbounds double, ptr %53, i64 %54
  store double %52, ptr %55, align 8, !tbaa !16
  br label %56

56:                                               ; preds = %43
  %57 = load i64, ptr %9, align 8, !tbaa !15
  %58 = add i64 %57, 1
  store i64 %58, ptr %9, align 8, !tbaa !15
  br label %37, !llvm.loop !18

59:                                               ; preds = %42
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = icmp eq ptr %60, null
  br i1 %61, label %63, label %62

62:                                               ; preds = %59
  call void @_ZdaPv(ptr noundef %60) #10
  br label %63

63:                                               ; preds = %62, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt7complexIdESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #6 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPdS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) #7

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nobuiltin allocsize(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 = { nobuiltin 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress 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 #6 = { mustprogress 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 #7 = { inlinehint mustprogress 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin 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++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN6Aquila3FftE", !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"_ZTSN6Aquila8OouraFftE", !10, i64 0, !6, i64 16, !6, i64 24}
!14 = !{!13, !6, i64 24}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #1

declare void @cdft(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Aquila8OouraFft4ifftESt6vectorISt7complexIdESaIS3_EEPd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, ptr noundef nonnull %1, ptr nocapture noundef writeonly %2) unnamed_addr #3 align 2 {
  %4 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt7complexIdESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #6
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = and i64 %6, 8070450532247928832
  %.not = icmp eq i64 %7, 0
  %8 = shl i64 %6, 4
  %9 = select i1 %.not, i64 %8, i64 -1
  %10 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %9) #7
  %11 = getelementptr inbounds i8, ptr %4, i64 %8
  %12 = tail call noundef ptr @_ZSt4copyIPdS0_ET0_T_S2_S1_(ptr noundef nonnull %4, ptr noundef nonnull %11, ptr noundef nonnull %10)
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %.tr = trunc i64 %13 to i32
  %14 = shl i32 %.tr, 1
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !10
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  tail call void @cdft(i32 noundef %14, i32 noundef 1, ptr noundef nonnull %10, ptr noundef %16, ptr noundef %18)
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %.not14 = icmp eq i64 %19, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %20 = uitofp i64 %19 to double
  %xtraiter = and i64 %19, 3
  %21 = icmp ult i64 %19, 4
  br i1 %21, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %19, -4
  br label %22

22:                                               ; preds = %22, %.lr.ph.new
  %.013 = phi i64 [ 0, %.lr.ph.new ], [ %42, %22 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %22 ]
  %.idx12 = shl i64 %.013, 4
  %23 = getelementptr inbounds i8, ptr %10, i64 %.idx12
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = fdiv double %24, %20
  %26 = getelementptr inbounds double, ptr %2, i64 %.013
  store double %25, ptr %26, align 8, !tbaa !14
  %27 = or disjoint i64 %.013, 1
  %.idx12.1 = shl i64 %27, 4
  %28 = getelementptr inbounds i8, ptr %10, i64 %.idx12.1
  %29 = load double, ptr %28, align 8, !tbaa !14
  %30 = fdiv double %29, %20
  %31 = getelementptr inbounds double, ptr %2, i64 %27
  store double %30, ptr %31, align 8, !tbaa !14
  %32 = or disjoint i64 %.013, 2
  %.idx12.2 = shl i64 %32, 4
  %33 = getelementptr inbounds i8, ptr %10, i64 %.idx12.2
  %34 = load double, ptr %33, align 8, !tbaa !14
  %35 = fdiv double %34, %20
  %36 = getelementptr inbounds double, ptr %2, i64 %32
  store double %35, ptr %36, align 8, !tbaa !14
  %37 = or disjoint i64 %.013, 3
  %.idx12.3 = shl i64 %37, 4
  %38 = getelementptr inbounds i8, ptr %10, i64 %.idx12.3
  %39 = load double, ptr %38, align 8, !tbaa !14
  %40 = fdiv double %39, %20
  %41 = getelementptr inbounds double, ptr %2, i64 %37
  store double %40, ptr %41, align 8, !tbaa !14
  %42 = add nuw i64 %.013, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %22, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %22, %.lr.ph
  %.013.unr = phi i64 [ 0, %.lr.ph ], [ %42, %22 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.013.epil = phi i64 [ %47, %.epil.preheader ], [ %.013.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %.idx12.epil = shl i64 %.013.epil, 4
  %43 = getelementptr inbounds i8, ptr %10, i64 %.idx12.epil
  %44 = load double, ptr %43, align 8, !tbaa !14
  %45 = fdiv double %44, %20
  %46 = getelementptr inbounds double, ptr %2, i64 %.013.epil
  store double %45, ptr %46, align 8, !tbaa !14
  %47 = add nuw i64 %.013.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !18

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %3
  tail call void @_ZdaPv(ptr noundef nonnull %10) #8
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt7complexIdESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPdS0_ET0_T_S2_S1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin 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 #2 = { "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 = { mustprogress 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 #4 = { mustprogress 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 #5 = { inlinehint mustprogress 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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, !7, i64 8}
!6 = !{!"_ZTSN6Aquila3FftE", !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !12, i64 16}
!11 = !{!"_ZTSN6Aquila8OouraFftE", !6, i64 0, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!11, !12, i64 24}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}


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