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

; 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_runbench(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 ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = zext i32 %16 to i64
  %18 = mul i64 %17, 8
  %19 = trunc i64 %18 to i32
  %20 = call ptr @fft_malloc(i32 noundef %19)
  store ptr %20, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = mul i64 %22, 8
  %24 = trunc i64 %23 to i32
  %25 = call ptr @fft_malloc(i32 noundef %24)
  store ptr %25, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = call ptr @fft_create_plan(i32 noundef %26, ptr noundef %27, ptr noundef %28, i32 noundef %29, i32 noundef %30)
  store ptr %31, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %48, %5
  %33 = load i64, ptr %15, align 8, !tbaa !11
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = icmp ult i64 %33, %35
  br i1 %36, label %37, label %51

37:                                               ; preds = %32
  %38 = call float (...) @randnf()
  %39 = call float (...) @randnf()
  %40 = fmul float %39, 0.000000e+00
  %41 = fmul float %39, 1.000000e+00
  %42 = fadd float %38, %40
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = load i64, ptr %15, align 8, !tbaa !11
  %45 = getelementptr inbounds { float, float }, ptr %43, i64 %44
  %46 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 1
  store float %42, ptr %46, align 4
  store float %41, ptr %47, align 4
  br label %48

48:                                               ; preds = %37
  %49 = load i64, ptr %15, align 8, !tbaa !11
  %50 = add i64 %49, 1
  store i64 %50, ptr %15, align 8, !tbaa !11
  br label %32, !llvm.loop !13

51:                                               ; preds = %32
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i64, ptr %54, align 8, !tbaa !11
  %56 = udiv i64 %55, %53
  store i64 %56, ptr %54, align 8, !tbaa !11
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i32 @getrusage(i32 noundef 0, ptr noundef %57) #4
  store i64 0, ptr %15, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %73, %51
  %60 = load i64, ptr %15, align 8, !tbaa !11
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %61, align 8, !tbaa !11
  %63 = icmp ult i64 %60, %62
  br i1 %63, label %64, label %76

64:                                               ; preds = %59
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = call i32 @fft_execute(ptr noundef %65)
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = call i32 @fft_execute(ptr noundef %67)
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = call i32 @fft_execute(ptr noundef %69)
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = call i32 @fft_execute(ptr noundef %71)
  br label %73

73:                                               ; preds = %64
  %74 = load i64, ptr %15, align 8, !tbaa !11
  %75 = add i64 %74, 1
  store i64 %75, ptr %15, align 8, !tbaa !11
  br label %59, !llvm.loop !15

76:                                               ; preds = %59
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = call i32 @getrusage(i32 noundef 0, ptr noundef %77) #4
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load i64, ptr %79, align 8, !tbaa !11
  %81 = mul i64 %80, 4
  store i64 %81, ptr %79, align 8, !tbaa !11
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = call i32 @fft_destroy_plan(ptr noundef %82)
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  call void @fft_free(ptr noundef %84)
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  call void @fft_free(ptr noundef %85)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

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

declare ptr @fft_malloc(i32 noundef) #2

declare ptr @fft_create_plan(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

declare float @randnf(...) #2

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

declare i32 @fft_execute(ptr noundef) #2

declare i32 @fft_destroy_plan(ptr noundef) #2

declare void @fft_free(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 memory(argmem: readwrite) }
attributes #2 = { "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 "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 }

!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 = 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: nounwind uwtable
define dso_local void @fft_runbench(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 = shl i32 %3, 3
  %8 = tail call ptr @fft_malloc(i32 noundef %7) #3
  %9 = tail call ptr @fft_malloc(i32 noundef %7) #3
  %10 = tail call ptr @fft_create_plan(i32 noundef %3, ptr noundef %8, ptr noundef %9, 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
  %.027 = phi i64 [ %17, %.lr.ph ], [ 0, %5 ]
  %11 = tail call float (...) @randnf() #3
  %12 = tail call float (...) @randnf() #3
  %13 = fmul float %12, 0.000000e+00
  %14 = fadd float %11, %13
  %15 = getelementptr inbounds { float, float }, ptr %8, i64 %.027
  %16 = getelementptr inbounds i8, ptr %15, i64 4
  store float %14, ptr %15, align 4
  store float %12, ptr %16, align 4
  %17 = add nuw nsw i64 %.027, 1
  %exitcond.not = icmp eq i64 %17, %6
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  %18 = load i64, ptr %2, align 8, !tbaa !7
  %19 = udiv i64 %18, %6
  store i64 %19, ptr %2, align 8, !tbaa !7
  %20 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %21 = load i64, ptr %2, align 8, !tbaa !7
  %.not32 = icmp eq i64 %21, 0
  br i1 %.not32, label %._crit_edge31, label %.lr.ph30

.lr.ph30:                                         ; preds = %._crit_edge, %.lr.ph30
  %.128 = phi i64 [ %26, %.lr.ph30 ], [ 0, %._crit_edge ]
  %22 = tail call i32 @fft_execute(ptr noundef %10) #3
  %23 = tail call i32 @fft_execute(ptr noundef %10) #3
  %24 = tail call i32 @fft_execute(ptr noundef %10) #3
  %25 = tail call i32 @fft_execute(ptr noundef %10) #3
  %26 = add nuw i64 %.128, 1
  %27 = load i64, ptr %2, align 8, !tbaa !7
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %.lr.ph30, label %._crit_edge31, !llvm.loop !11

._crit_edge31:                                    ; preds = %.lr.ph30, %._crit_edge
  %29 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %30 = load i64, ptr %2, align 8, !tbaa !7
  %31 = shl i64 %30, 2
  store i64 %31, ptr %2, align 8, !tbaa !7
  %32 = tail call i32 @fft_destroy_plan(ptr noundef %10) #3
  tail call void @fft_free(ptr noundef %8) #3
  tail call void @fft_free(ptr noundef %9) #3
  ret void
}

declare ptr @fft_malloc(i32 noundef) local_unnamed_addr #1

declare ptr @fft_create_plan(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

declare void @fft_free(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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}


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