; LLVM IR from jgaeddert/liquid-dsp :: src/fft/bench (spgramcf_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 @spgramcf_runbench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = add i32 1, %17
  %19 = call i32 @liquid_nextpow2(i32 noundef %18)
  %20 = zext i32 %19 to i64
  %21 = mul i64 %16, %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = udiv i64 %21, %23
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %24, ptr %25, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = call ptr @spgramcf_create_default(i32 noundef %26)
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 2400, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = mul i64 %29, 8
  %31 = call noalias ptr @malloc(i64 noundef %30) #7
  store ptr %31, ptr %12, align 8, !tbaa !5
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %48, %4
  %33 = load i64, ptr %10, align 8, !tbaa !11
  %34 = load i32, ptr %11, 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 %12, align 8, !tbaa !5
  %44 = load i64, ptr %10, 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 %10, align 8, !tbaa !11
  %50 = add i64 %49, 1
  store i64 %50, ptr %10, align 8, !tbaa !11
  br label %32, !llvm.loop !13

51:                                               ; preds = %32
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = call ptr @llvm.stacksave.p0()
  store ptr %54, ptr %13, align 8
  %55 = alloca float, i64 %53, align 16
  store i64 %53, ptr %14, align 8
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i32 @getrusage(i32 noundef 0, ptr noundef %56) #6
  store i64 0, ptr %10, align 8, !tbaa !11
  br label %58

58:                                               ; preds = %76, %51
  %59 = load i64, ptr %10, align 8, !tbaa !11
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load i64, ptr %60, align 8, !tbaa !11
  %62 = icmp ult i64 %59, %61
  br i1 %62, label %63, label %79

63:                                               ; preds = %58
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = call i32 @spgramcf_write(ptr noundef %64, ptr noundef %65, i32 noundef %66)
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = call i32 @spgramcf_get_psd(ptr noundef %68, ptr noundef %55)
  %70 = getelementptr inbounds float, ptr %55, i64 0
  %71 = load float, ptr %70, align 16, !tbaa !15
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds { float, float }, ptr %72, i64 0
  %74 = getelementptr inbounds { float, float }, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds { float, float }, ptr %73, i32 0, i32 1
  store float %71, ptr %74, align 4
  store float 0.000000e+00, ptr %75, align 4
  br label %76

76:                                               ; preds = %63
  %77 = load i64, ptr %10, align 8, !tbaa !11
  %78 = add i64 %77, 1
  store i64 %78, ptr %10, align 8, !tbaa !11
  br label %58, !llvm.loop !17

79:                                               ; preds = %58
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call i32 @getrusage(i32 noundef 0, ptr noundef %80) #6
  %82 = load i32, ptr %11, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = load i64, ptr %84, align 8, !tbaa !11
  %86 = mul i64 %85, %83
  store i64 %86, ptr %84, align 8, !tbaa !11
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %87) #6
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  %89 = call i32 @spgramcf_destroy(ptr noundef %88)
  %90 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %90)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret void
}

declare i32 @liquid_nextpow2(i32 noundef) #1

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

declare ptr @spgramcf_create_default(i32 noundef) #1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare float @randnf(...) #1

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

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

declare i32 @spgramcf_write(ptr noundef, ptr noundef, i32 noundef) #1

declare i32 @spgramcf_get_psd(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

declare i32 @spgramcf_destroy(ptr noundef) #1

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(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 #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !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 @spgramcf_runbench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = add i32 %3, 1
  %7 = tail call i32 @liquid_nextpow2(i32 noundef %6) #5
  %8 = zext i32 %7 to i64
  %9 = mul i64 %5, %8
  %10 = zext i32 %3 to i64
  %11 = udiv i64 %9, %10
  store i64 %11, ptr %2, align 8, !tbaa !5
  %12 = tail call ptr @spgramcf_create_default(i32 noundef %3) #5
  %13 = tail call noalias dereferenceable_or_null(19200) ptr @malloc(i64 noundef 19200) #6
  br label %14

14:                                               ; preds = %4, %14
  %.026 = phi i64 [ 0, %4 ], [ %21, %14 ]
  %15 = tail call float (...) @randnf() #5
  %16 = tail call float (...) @randnf() #5
  %17 = fmul float %16, 0.000000e+00
  %18 = fadd float %15, %17
  %19 = getelementptr inbounds { float, float }, ptr %13, i64 %.026
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  store float %18, ptr %19, align 4
  store float %16, ptr %20, align 4
  %21 = add nuw nsw i64 %.026, 1
  %exitcond.not = icmp eq i64 %21, 2400
  br i1 %exitcond.not, label %22, label %14, !llvm.loop !9

22:                                               ; preds = %14
  %23 = alloca float, i64 %10, align 16
  %24 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %25, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %22
  %26 = getelementptr inbounds i8, ptr %13, i64 4
  br label %27

27:                                               ; preds = %.lr.ph, %27
  %.127 = phi i64 [ 0, %.lr.ph ], [ %31, %27 ]
  %28 = call i32 @spgramcf_write(ptr noundef %12, ptr noundef nonnull %13, i32 noundef 2400) #5
  %29 = call i32 @spgramcf_get_psd(ptr noundef %12, ptr noundef nonnull %23) #5
  %30 = load float, ptr %23, align 16, !tbaa !11
  store float %30, ptr %13, align 4
  store float 0.000000e+00, ptr %26, align 4
  %31 = add nuw i64 %.127, 1
  %32 = load i64, ptr %2, align 8, !tbaa !5
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %27, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %27, %22
  %34 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = mul i64 %35, 2400
  store i64 %36, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef nonnull %13) #5
  %37 = call i32 @spgramcf_destroy(ptr noundef %12) #5
  ret void
}

declare i32 @liquid_nextpow2(i32 noundef) local_unnamed_addr #1

declare ptr @spgramcf_create_default(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

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

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

declare i32 @spgramcf_destroy(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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"long", !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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !10}


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