; 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: nounwind uwtable
define dso_local void @makewt(i32 noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  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 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds i32, ptr %13, i64 0
  store i32 %12, ptr %14, align 4, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds i32, ptr %15, i64 1
  store i32 1, ptr %16, align 4, !tbaa !5
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 2
  br i1 %18, label %19, label %99

19:                                               ; preds = %3
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = ashr i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !5
  %22 = call double @atan(double noundef 1.000000e+00) #3
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %22, %24
  store double %25, ptr %9, align 8, !tbaa !11
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %26, i64 0
  store double 1.000000e+00, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = getelementptr inbounds double, ptr %28, i64 1
  store double 0.000000e+00, ptr %29, align 8, !tbaa !11
  %30 = load double, ptr %9, align 8, !tbaa !11
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fmul double %30, %32
  %34 = call double @cos(double noundef %33) #3
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  store double %34, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %44, i64 %47
  store double %43, ptr %48, align 8, !tbaa !11
  store i32 2, ptr %8, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %91, %19
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = load i32, ptr %7, align 4, !tbaa !5
  %52 = sub nsw i32 %51, 2
  %53 = icmp sle i32 %50, %52
  br i1 %53, label %54, label %94

54:                                               ; preds = %49
  %55 = load double, ptr %9, align 8, !tbaa !11
  %56 = load i32, ptr %8, align 4, !tbaa !5
  %57 = sitofp i32 %56 to double
  %58 = fmul double %55, %57
  %59 = call double @cos(double noundef %58) #3
  store double %59, ptr %10, align 8, !tbaa !11
  %60 = load double, ptr %9, align 8, !tbaa !11
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = sitofp i32 %61 to double
  %63 = fmul double %60, %62
  %64 = call double @sin(double noundef %63) #3
  store double %64, ptr %11, align 8, !tbaa !11
  %65 = load double, ptr %10, align 8, !tbaa !11
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  %67 = load i32, ptr %8, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  store double %65, ptr %69, align 8, !tbaa !11
  %70 = load double, ptr %11, align 8, !tbaa !11
  %71 = load ptr, ptr %6, align 8, !tbaa !9
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds double, ptr %71, i64 %74
  store double %70, ptr %75, align 8, !tbaa !11
  %76 = load double, ptr %11, align 8, !tbaa !11
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = sub nsw i32 %78, %79
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %77, i64 %81
  store double %76, ptr %82, align 8, !tbaa !11
  %83 = load double, ptr %10, align 8, !tbaa !11
  %84 = load ptr, ptr %6, align 8, !tbaa !9
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = sub nsw i32 %85, %86
  %88 = add nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %84, i64 %89
  store double %83, ptr %90, align 8, !tbaa !11
  br label %91

91:                                               ; preds = %54
  %92 = load i32, ptr %8, align 4, !tbaa !5
  %93 = add nsw i32 %92, 2
  store i32 %93, ptr %8, align 4, !tbaa !5
  br label %49, !llvm.loop !13

94:                                               ; preds = %49
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = load ptr, ptr %5, align 8, !tbaa !9
  %97 = getelementptr inbounds i32, ptr %96, i64 2
  %98 = load ptr, ptr %6, align 8, !tbaa !9
  call void @bitrv2(i32 noundef %95, ptr noundef %97, ptr noundef %98)
  br label %99

99:                                               ; preds = %94, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #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: nounwind
declare double @atan(double noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @bitrv2(i32 noundef, ptr noundef, ptr noundef) #1

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 = { 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 = { 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: nounwind uwtable
define dso_local void @makewt(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  store i32 %0, ptr %1, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 1, ptr %4, align 4, !tbaa !5
  %5 = icmp sgt i32 %0, 2
  br i1 %5, label %6, label %30

6:                                                ; preds = %3
  %7 = lshr i32 %0, 1
  %8 = uitofp nneg i32 %7 to double
  %9 = fdiv double 0x3FE921FB54442D18, %8
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %2, align 8, !tbaa !9
  %10 = fmul double %9, %8
  %11 = tail call double @cos(double noundef %10) #2
  %12 = zext nneg i32 %7 to i64
  %13 = getelementptr inbounds double, ptr %2, i64 %12
  store double %11, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  store double %11, ptr %14, align 8, !tbaa !9
  %.not40 = icmp ult i32 %0, 8
  br i1 %.not40, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %6
  %15 = add nsw i32 %7, -2
  %16 = zext nneg i32 %0 to i64
  %17 = sext i32 %15 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  %19 = uitofp nneg i32 %18 to double
  %20 = fmul double %9, %19
  %21 = tail call double @cos(double noundef %20) #2
  %22 = tail call double @sin(double noundef %20) #2
  %23 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %21, ptr %23, align 8, !tbaa !9
  %24 = or disjoint i64 %indvars.iv, 1
  %25 = getelementptr inbounds double, ptr %2, i64 %24
  store double %22, ptr %25, align 8, !tbaa !9
  %26 = sub nsw i64 %16, %indvars.iv
  %27 = getelementptr inbounds double, ptr %2, i64 %26
  store double %22, ptr %27, align 8, !tbaa !9
  %28 = getelementptr i8, ptr %27, i64 8
  store double %21, ptr %28, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %.not = icmp sgt i64 %indvars.iv.next, %17
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %6
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  tail call void @bitrv2(i32 noundef %0, ptr noundef nonnull %29, ptr noundef nonnull %2)
  br label %30

30:                                               ; preds = %._crit_edge, %3
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

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

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 nofree nounwind willreturn memory(write) "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 = { 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 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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