; 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 @makect(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
  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
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds i32, ptr %11, i64 1
  store i32 %10, ptr %12, align 4, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp sgt i32 %13, 1
  br i1 %14, label %15, label %66

15:                                               ; preds = %3
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = ashr i32 %16, 1
  store i32 %17, ptr %7, align 4, !tbaa !5
  %18 = call double @atan(double noundef 1.000000e+00) #3
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = sitofp i32 %19 to double
  %21 = fdiv double %18, %20
  store double %21, ptr %9, align 8, !tbaa !11
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = getelementptr inbounds double, ptr %22, i64 0
  store double 5.000000e-01, ptr %23, align 8, !tbaa !11
  %24 = load double, ptr %9, align 8, !tbaa !11
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = sitofp i32 %25 to double
  %27 = fmul double %24, %26
  %28 = call double @cos(double noundef %27) #3
  %29 = fmul double 5.000000e-01, %28
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds double, ptr %30, i64 %32
  store double %29, ptr %33, align 8, !tbaa !11
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %62, %15
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = icmp sle i32 %35, %37
  br i1 %38, label %39, label %65

39:                                               ; preds = %34
  %40 = load double, ptr %9, align 8, !tbaa !11
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = sitofp i32 %41 to double
  %43 = fmul double %40, %42
  %44 = call double @cos(double noundef %43) #3
  %45 = fmul double 5.000000e-01, %44
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %46, i64 %48
  store double %45, ptr %49, align 8, !tbaa !11
  %50 = load double, ptr %9, align 8, !tbaa !11
  %51 = load i32, ptr %8, align 4, !tbaa !5
  %52 = sitofp i32 %51 to double
  %53 = fmul double %50, %52
  %54 = call double @sin(double noundef %53) #3
  %55 = fmul double 5.000000e-01, %54
  %56 = load ptr, ptr %6, align 8, !tbaa !9
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = sub nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds double, ptr %56, i64 %60
  store double %55, ptr %61, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %39
  %63 = load i32, ptr %8, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %8, align 4, !tbaa !5
  br label %34, !llvm.loop !13

65:                                               ; preds = %34
  br label %66

66:                                               ; preds = %65, %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: 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

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

6:                                                ; preds = %3
  %7 = lshr i32 %0, 1
  %8 = uitofp nneg i32 %7 to double
  %9 = fdiv double 0x3FE921FB54442D18, %8
  store double 5.000000e-01, ptr %2, align 8, !tbaa !9
  %10 = fmul double %9, %8
  %11 = tail call double @cos(double noundef %10) #2
  %12 = fmul double %11, 5.000000e-01
  %13 = zext nneg i32 %7 to i64
  %14 = getelementptr inbounds double, ptr %2, i64 %13
  store double %12, ptr %14, align 8, !tbaa !9
  %.not.not22 = icmp ugt i32 %0, 3
  br i1 %.not.not22, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %6
  %15 = zext nneg i32 %0 to i64
  %16 = add nsw i64 %13, -1
  %xtraiter = and i64 %16, 1
  %17 = icmp eq i32 %7, 2
  br i1 %17, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %16, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.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 = fmul double %21, 5.000000e-01
  %23 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %22, ptr %23, align 8, !tbaa !9
  %24 = tail call double @sin(double noundef %20) #2
  %25 = fmul double %24, 5.000000e-01
  %26 = sub nsw i64 %15, %indvars.iv
  %27 = getelementptr inbounds double, ptr %2, i64 %26
  store double %25, ptr %27, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = trunc nuw nsw i64 %indvars.iv.next to i32
  %29 = uitofp nneg i32 %28 to double
  %30 = fmul double %9, %29
  %31 = tail call double @cos(double noundef %30) #2
  %32 = fmul double %31, 5.000000e-01
  %33 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next
  store double %32, ptr %33, align 8, !tbaa !9
  %34 = tail call double @sin(double noundef %30) #2
  %35 = fmul double %34, 5.000000e-01
  %36 = sub nsw i64 %15, %indvars.iv.next
  %37 = getelementptr inbounds double, ptr %2, i64 %36
  store double %35, ptr %37, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.loopexit.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

.loopexit.loopexit.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.loopexit, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.loopexit.loopexit.unr-lcssa
  %38 = trunc nuw nsw i64 %indvars.iv.unr to i32
  %39 = uitofp nneg i32 %38 to double
  %40 = fmul double %9, %39
  %41 = tail call double @cos(double noundef %40) #2
  %42 = fmul double %41, 5.000000e-01
  %43 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.unr
  store double %42, ptr %43, align 8, !tbaa !9
  %44 = tail call double @sin(double noundef %40) #2
  %45 = fmul double %44, 5.000000e-01
  %46 = sub nsw i64 %15, %indvars.iv.unr
  %47 = getelementptr inbounds double, ptr %2, i64 %46
  store double %45, ptr %47, align 8, !tbaa !9
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph.epil, %.loopexit.loopexit.unr-lcssa, %6, %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

attributes #0 = { nofree nounwind memory(write) 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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass