; LLVM IR from glaretechnologies/substrata :: libs/fft2d (fft4f2d)

; 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 @rftfcol(i32 noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  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 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = shl i32 %22, 2
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = sdiv i32 %23, %24
  store i32 %25, ptr %15, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %161, %5
  %27 = load i32, ptr %11, align 4, !tbaa !5
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = sub nsw i32 %28, 1
  %30 = icmp sle i32 %27, %29
  br i1 %30, label %31, label %164

31:                                               ; preds = %26
  store i32 0, ptr %14, align 4, !tbaa !5
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = ashr i32 %32, 1
  %34 = sub nsw i32 %33, 2
  store i32 %34, ptr %13, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %157, %31
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = icmp sge i32 %36, 2
  br i1 %37, label %38, label %160

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

157:                                              ; preds = %38
  %158 = load i32, ptr %13, align 4, !tbaa !5
  %159 = sub nsw i32 %158, 2
  store i32 %159, ptr %13, align 4, !tbaa !5
  br label %35, !llvm.loop !13

160:                                              ; preds = %35
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %11, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %11, align 4, !tbaa !5
  br label %26, !llvm.loop !15

164:                                              ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  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 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  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 = !{!"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"}
!15 = distinct !{!15, !14}


; 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 @rftfcol(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = shl i32 %3, 2
  %7 = sdiv i32 %6, %1
  %.not.not58 = icmp sgt i32 %0, 0
  br i1 %.not.not58, label %.lr.ph61, label %._crit_edge62

.lr.ph61:                                         ; preds = %5
  %8 = ashr i32 %1, 1
  %9 = icmp sgt i32 %8, 3
  br i1 %9, label %.lr.ph.us.preheader, label %._crit_edge62

.lr.ph.us.preheader:                              ; preds = %.lr.ph61
  %10 = zext nneg i32 %8 to i64
  %11 = zext nneg i32 %1 to i64
  %12 = sext i32 %7 to i64
  %13 = sext i32 %3 to i64
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv69 = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next70, %._crit_edge.us ]
  %14 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv69
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  br label %16

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

._crit_edge.us:                                   ; preds = %16
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next70, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge62, label %.lr.ph.us, !llvm.loop !13

._crit_edge62:                                    ; preds = %._crit_edge.us, %.lr.ph61, %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(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" }
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 = !{!"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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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