; LLVM IR from jgaeddert/liquid-dsp :: src/fft/bench (fft_r2r_benchmark)

; 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: nounwind uwtable
define dso_local void @fft_r2r_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = call ptr @llvm.stacksave.p0()
  store ptr %19, ptr %11, align 8
  %20 = alloca float, i64 %18, align 16
  store i64 %18, ptr %12, align 8
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = alloca float, i64 %22, align 16
  store i64 %22, ptr %13, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %24 = load i32, ptr %9, align 4, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = load i32, ptr %14, align 4, !tbaa !9
  %27 = call ptr @fft_create_plan_r2r_1d(i32 noundef %24, ptr noundef %20, ptr noundef %23, i32 noundef %25, i32 noundef %26)
  store ptr %27, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store i64 0, ptr %16, align 8, !tbaa !11
  br label %28

28:                                               ; preds = %37, %5
  %29 = load i64, ptr %16, align 8, !tbaa !11
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = icmp ult i64 %29, %31
  br i1 %32, label %33, label %40

33:                                               ; preds = %28
  %34 = call float (...) @randnf()
  %35 = load i64, ptr %16, align 8, !tbaa !11
  %36 = getelementptr inbounds float, ptr %20, i64 %35
  store float %34, ptr %36, align 4, !tbaa !13
  br label %37

37:                                               ; preds = %33
  %38 = load i64, ptr %16, align 8, !tbaa !11
  %39 = add i64 %38, 1
  store i64 %39, ptr %16, align 8, !tbaa !11
  br label %28, !llvm.loop !15

40:                                               ; preds = %28
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = mul i32 %41, %42
  %44 = zext i32 %43 to i64
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = udiv i64 %46, %44
  store i64 %47, ptr %45, align 8, !tbaa !11
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load i64, ptr %48, align 8, !tbaa !11
  %50 = mul i64 %49, 10
  store i64 %50, ptr %48, align 8, !tbaa !11
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %51, align 8, !tbaa !11
  %53 = add i64 %52, 1
  store i64 %53, ptr %51, align 8, !tbaa !11
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call i32 @getrusage(i32 noundef 0, ptr noundef %54) #5
  store i64 0, ptr %16, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %70, %40
  %57 = load i64, ptr %16, align 8, !tbaa !11
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load i64, ptr %58, align 8, !tbaa !11
  %60 = icmp ult i64 %57, %59
  br i1 %60, label %61, label %73

61:                                               ; preds = %56
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  %63 = call i32 @fft_execute(ptr noundef %62)
  %64 = load ptr, ptr %15, align 8, !tbaa !5
  %65 = call i32 @fft_execute(ptr noundef %64)
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = call i32 @fft_execute(ptr noundef %66)
  %68 = load ptr, ptr %15, align 8, !tbaa !5
  %69 = call i32 @fft_execute(ptr noundef %68)
  br label %70

70:                                               ; preds = %61
  %71 = load i64, ptr %16, align 8, !tbaa !11
  %72 = add i64 %71, 1
  store i64 %72, ptr %16, align 8, !tbaa !11
  br label %56, !llvm.loop !17

73:                                               ; preds = %56
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call i32 @getrusage(i32 noundef 0, ptr noundef %74) #5
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = load i64, ptr %76, align 8, !tbaa !11
  %78 = mul i64 %77, 4
  store i64 %78, ptr %76, align 8, !tbaa !11
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = call i32 @fft_destroy_plan(ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %81 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %81)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

declare ptr @fft_create_plan_r2r_1d(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #3

declare float @randnf(...) #3

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #4

declare i32 @fft_execute(ptr noundef) #3

declare i32 @fft_destroy_plan(ptr noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

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 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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 @fft_r2r_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = zext i32 %3 to i64
  %7 = alloca float, i64 %6, align 16
  %8 = alloca float, i64 %6, align 16
  %9 = call ptr @fft_create_plan_r2r_1d(i32 noundef %3, ptr noundef nonnull %7, ptr noundef nonnull %8, i32 noundef %4, i32 noundef 0) #3
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.025 = phi i64 [ %12, %.lr.ph ], [ 0, %5 ]
  %10 = call float (...) @randnf() #3
  %11 = getelementptr inbounds float, ptr %7, i64 %.025
  store float %10, ptr %11, align 4, !tbaa !5
  %12 = add nuw nsw i64 %.025, 1
  %exitcond.not = icmp eq i64 %12, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %5
  %13 = mul i32 %3, %3
  %14 = zext i32 %13 to i64
  %15 = load i64, ptr %2, align 8, !tbaa !11
  %16 = udiv i64 %15, %14
  %17 = mul i64 %16, 10
  %18 = or disjoint i64 %17, 1
  store i64 %18, ptr %2, align 8, !tbaa !11
  %19 = call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %20 = load i64, ptr %2, align 8, !tbaa !11
  %.not30 = icmp eq i64 %20, 0
  br i1 %.not30, label %._crit_edge29, label %.lr.ph28

.lr.ph28:                                         ; preds = %._crit_edge, %.lr.ph28
  %.126 = phi i64 [ %25, %.lr.ph28 ], [ 0, %._crit_edge ]
  %21 = call i32 @fft_execute(ptr noundef %9) #3
  %22 = call i32 @fft_execute(ptr noundef %9) #3
  %23 = call i32 @fft_execute(ptr noundef %9) #3
  %24 = call i32 @fft_execute(ptr noundef %9) #3
  %25 = add nuw i64 %.126, 1
  %26 = load i64, ptr %2, align 8, !tbaa !11
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph28, label %._crit_edge29, !llvm.loop !13

._crit_edge29:                                    ; preds = %.lr.ph28, %._crit_edge
  %28 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %29 = load i64, ptr %2, align 8, !tbaa !11
  %30 = shl i64 %29, 2
  store i64 %30, ptr %2, align 8, !tbaa !11
  %31 = call i32 @fft_destroy_plan(ptr noundef %9) #3
  ret void
}

declare ptr @fft_create_plan_r2r_1d(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare float @randnf(...) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @fft_execute(ptr noundef) local_unnamed_addr #1

declare i32 @fft_destroy_plan(ptr noundef) local_unnamed_addr #1

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 = { "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !10}


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