; LLVM IR from zsiciarz/aquila :: lib/ooura (fft4g)

; 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: nounwind uwtable
define dso_local void @rftbsub(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds double, ptr %20, i64 1
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fneg double %22
  %24 = load ptr, ptr %6, align 8, !tbaa !9
  %25 = getelementptr inbounds double, ptr %24, i64 1
  store double %23, ptr %25, align 8, !tbaa !11
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = ashr i32 %26, 1
  store i32 %27, ptr %13, align 4, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = mul nsw i32 2, %28
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = sdiv i32 %29, %30
  store i32 %31, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %133, %4
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = load i32, ptr %13, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %36, label %136

36:                                               ; preds = %32
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !5
  %39 = sub nsw i32 %37, %38
  store i32 %39, ptr %10, align 4, !tbaa !5
  %40 = load i32, ptr %12, align 4, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !5
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %11, align 4, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = sub nsw i32 %44, %45
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %43, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = fsub double 5.000000e-01, %49
  store double %50, ptr %14, align 8, !tbaa !11
  %51 = load ptr, ptr %8, align 8, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !11
  store double %55, ptr %15, align 8, !tbaa !11
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !11
  %66 = fsub double %60, %65
  store double %66, ptr %16, align 8, !tbaa !11
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = load i32, ptr %9, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %67, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = load ptr, ptr %6, align 8, !tbaa !9
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %73, i64 %76
  %78 = load double, ptr %77, align 8, !tbaa !11
  %79 = fadd double %72, %78
  store double %79, ptr %17, align 8, !tbaa !11
  %80 = load double, ptr %14, align 8, !tbaa !11
  %81 = load double, ptr %16, align 8, !tbaa !11
  %82 = load double, ptr %15, align 8, !tbaa !11
  %83 = load double, ptr %17, align 8, !tbaa !11
  %84 = fmul double %82, %83
  %85 = call double @llvm.fmuladd.f64(double %80, double %81, double %84)
  store double %85, ptr %18, align 8, !tbaa !11
  %86 = load double, ptr %14, align 8, !tbaa !11
  %87 = load double, ptr %17, align 8, !tbaa !11
  %88 = load double, ptr %15, align 8, !tbaa !11
  %89 = load double, ptr %16, align 8, !tbaa !11
  %90 = fmul double %88, %89
  %91 = fneg double %90
  %92 = call double @llvm.fmuladd.f64(double %86, double %87, double %91)
  store double %92, ptr %19, align 8, !tbaa !11
  %93 = load double, ptr %18, align 8, !tbaa !11
  %94 = load ptr, ptr %6, align 8, !tbaa !9
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  %98 = load double, ptr %97, align 8, !tbaa !11
  %99 = fsub double %98, %93
  store double %99, ptr %97, align 8, !tbaa !11
  %100 = load double, ptr %19, align 8, !tbaa !11
  %101 = load ptr, ptr %6, align 8, !tbaa !9
  %102 = load i32, ptr %9, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr %101, i64 %104
  %106 = load double, ptr %105, align 8, !tbaa !11
  %107 = fsub double %100, %106
  %108 = load ptr, ptr %6, align 8, !tbaa !9
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds double, ptr %108, i64 %111
  store double %107, ptr %112, align 8, !tbaa !11
  %113 = load double, ptr %18, align 8, !tbaa !11
  %114 = load ptr, ptr %6, align 8, !tbaa !9
  %115 = load i32, ptr %10, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds double, ptr %114, i64 %116
  %118 = load double, ptr %117, align 8, !tbaa !11
  %119 = fadd double %118, %113
  store double %119, ptr %117, align 8, !tbaa !11
  %120 = load double, ptr %19, align 8, !tbaa !11
  %121 = load ptr, ptr %6, align 8, !tbaa !9
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = add nsw i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds double, ptr %121, i64 %124
  %126 = load double, ptr %125, align 8, !tbaa !11
  %127 = fsub double %120, %126
  %128 = load ptr, ptr %6, align 8, !tbaa !9
  %129 = load i32, ptr %10, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds double, ptr %128, i64 %131
  store double %127, ptr %132, align 8, !tbaa !11
  br label %133

133:                                              ; preds = %36
  %134 = load i32, ptr %9, align 4, !tbaa !5
  %135 = add nsw i32 %134, 2
  store i32 %135, ptr %9, align 4, !tbaa !5
  br label %32, !llvm.loop !13

136:                                              ; preds = %32
  %137 = load ptr, ptr %6, align 8, !tbaa !9
  %138 = load i32, ptr %13, align 4, !tbaa !5
  %139 = add nsw i32 %138, 1
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds double, ptr %137, i64 %140
  %142 = load double, ptr %141, align 8, !tbaa !11
  %143 = fneg double %142
  %144 = load ptr, ptr %6, align 8, !tbaa !9
  %145 = load i32, ptr %13, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds double, ptr %144, i64 %147
  store double %143, ptr %148, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

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

; 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 = !{!"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 = !{!"double", !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @rftbsub(i32 noundef %0, ptr nocapture noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fneg double %6
  store double %7, ptr %5, align 8, !tbaa !5
  %8 = ashr i32 %0, 1
  %9 = icmp sgt i32 %8, 2
  br i1 %9, label %.lr.ph.preheader, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %4
  %.pre = sext i32 %8 to i64
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %10 = shl nsw i32 %2, 1
  %11 = sdiv i32 %10, %8
  %12 = zext nneg i32 %0 to i64
  %13 = zext nneg i32 %8 to i64
  %14 = sext i32 %11 to i64
  %15 = sext i32 %2 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv56 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next57, %.lr.ph ]
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %16 = sub nsw i64 %12, %indvars.iv
  %indvars.iv.next57 = add nsw i64 %indvars.iv56, %14
  %17 = sub nsw i64 %15, %indvars.iv.next57
  %18 = getelementptr inbounds double, ptr %3, i64 %17
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fsub double 5.000000e-01, %19
  %21 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next57
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %24 = getelementptr inbounds double, ptr %1, i64 %16
  %25 = fneg double %22
  %26 = load <2 x double>, ptr %23, align 8, !tbaa !5
  %27 = load <2 x double>, ptr %24, align 8, !tbaa !5
  %28 = fsub <2 x double> %26, %27
  %29 = fadd <2 x double> %26, %27
  %30 = shufflevector <2 x double> %28, <2 x double> %29, <2 x i32> <i32 0, i32 3>
  %31 = insertelement <2 x double> poison, double %22, i64 0
  %32 = insertelement <2 x double> %31, double %25, i64 1
  %33 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %34 = fmul <2 x double> %32, %33
  %35 = insertelement <2 x double> poison, double %20, i64 0
  %36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
  %37 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %30, <2 x double> %34)
  %38 = shufflevector <2 x double> %26, <2 x double> %37, <2 x i32> <i32 0, i32 3>
  %39 = shufflevector <2 x double> %37, <2 x double> %26, <2 x i32> <i32 0, i32 3>
  %40 = fsub <2 x double> %38, %39
  store <2 x double> %40, ptr %23, align 8, !tbaa !5
  %41 = load <2 x double>, ptr %24, align 8, !tbaa !5
  %42 = fadd <2 x double> %37, %41
  %43 = fsub <2 x double> %37, %41
  %44 = shufflevector <2 x double> %42, <2 x double> %43, <2 x i32> <i32 0, i32 3>
  store <2 x double> %44, ptr %24, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %45 = icmp ult i64 %indvars.iv.next, %13
  br i1 %45, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %13, %.lr.ph ]
  %46 = getelementptr double, ptr %1, i64 %.pre-phi
  %47 = getelementptr i8, ptr %46, i64 8
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fneg double %48
  store double %49, ptr %47, align 8, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1

attributes #0 = { nofree norecurse nosync nounwind 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 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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