; LLVM IR from clangen/musikcube :: src/plugins/supereqdsp/supereq/Equ.ll (Z4rfftiiPf)

; 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"

@_ZZ4rfftiiPfE6ipsize = external hidden global i32, align 4
@_ZZ4rfftiiPfE5wsize = external hidden global i32, align 4
@_ZZ4rfftiiPfE2ip = external hidden global ptr, align 8
@_ZZ4rfftiiPfE1w = external hidden global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4rfftiiPf(i32 noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %10 = load i32, ptr %4, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %15

12:                                               ; preds = %3
  %13 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  call void @free(ptr noundef %13) #6
  store ptr null, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  store i32 0, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !5
  %14 = load ptr, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !9
  call void @free(ptr noundef %14) #6
  store ptr null, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !9
  store i32 0, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !5
  store i32 1, ptr %9, align 4
  br label %54

15:                                               ; preds = %3
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = shl i32 1, %16
  store i32 %17, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sdiv i32 %18, 2
  %20 = call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %19)
  %21 = fadd double 2.000000e+00, %20
  %22 = fptosi double %21 to i32
  store i32 %22, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = load i32, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !5
  %25 = icmp sgt i32 %23, %24
  br i1 %25, label %26, label %35

26:                                               ; preds = %15
  %27 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %27, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !5
  %28 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  %29 = load i32, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = mul i64 4, %30
  %32 = call ptr @realloc(ptr noundef %28, i64 noundef %31) #7
  store ptr %32, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  %33 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  %34 = getelementptr inbounds i32, ptr %33, i64 0
  store i32 0, ptr %34, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %26, %15
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sdiv i32 %36, 2
  store i32 %37, ptr %8, align 4, !tbaa !5
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = load i32, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !5
  %40 = icmp sgt i32 %38, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %35
  %42 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %42, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !5
  %43 = load ptr, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !9
  %44 = load i32, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = mul i64 4, %45
  %47 = call ptr @realloc(ptr noundef %43, i64 noundef %46) #7
  store ptr %47, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %41, %35
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !9
  %53 = load ptr, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !9
  call void @rdft(i32 noundef %49, i32 noundef %50, ptr noundef %51, ptr noundef %52, ptr noundef %53)
  store i32 0, ptr %9, align 4
  br label %54

54:                                               ; preds = %48, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  %55 = load i32, ptr %9, align 4
  switch i32 %55, label %57 [
    i32 0, label %56
    i32 1, label %56
  ]

56:                                               ; preds = %54, %54
  ret void

57:                                               ; preds = %54
  unreachable
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) #3

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #4

declare void @rdft(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #5

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

attributes #0 = { mustprogress 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 = { 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 = { inlinehint mustprogress 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 #4 = { nounwind allocsize(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 #5 = { "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(1) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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"

@_ZZ4rfftiiPfE6ipsize = external hidden local_unnamed_addr global i32, align 4
@_ZZ4rfftiiPfE5wsize = external hidden local_unnamed_addr global i32, align 4
@_ZZ4rfftiiPfE2ip = external hidden local_unnamed_addr global ptr, align 8
@_ZZ4rfftiiPfE1w = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4rfftiiPf(i32 noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq i32 %0, 0
  br i1 %4, label %5, label %8

5:                                                ; preds = %3
  %6 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !5
  tail call void @free(ptr noundef %6) #5
  store ptr null, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !5
  store i32 0, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !9
  %7 = load ptr, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !5
  tail call void @free(ptr noundef %7) #5
  store ptr null, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !5
  store i32 0, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !9
  br label %31

8:                                                ; preds = %3
  %9 = shl nuw i32 1, %0
  %10 = sdiv i32 %9, 2
  %11 = tail call noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef %10)
  %12 = fadd double %11, 2.000000e+00
  %13 = fptosi double %12 to i32
  %14 = load i32, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !9
  %15 = icmp slt i32 %14, %13
  br i1 %15, label %16, label %21

16:                                               ; preds = %8
  store i32 %13, ptr @_ZZ4rfftiiPfE6ipsize, align 4, !tbaa !9
  %17 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !5
  %18 = sext i32 %13 to i64
  %19 = shl nsw i64 %18, 2
  %20 = tail call ptr @realloc(ptr noundef %17, i64 noundef %19) #6
  store ptr %20, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !5
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %16, %8
  %22 = load i32, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !9
  %23 = icmp sgt i32 %10, %22
  %.pre = load ptr, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !5
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  store i32 %10, ptr @_ZZ4rfftiiPfE5wsize, align 4, !tbaa !9
  %25 = sext i32 %10 to i64
  %26 = shl nsw i64 %25, 2
  %27 = tail call ptr @realloc(ptr noundef %.pre, i64 noundef %26) #6
  store ptr %27, ptr @_ZZ4rfftiiPfE1w, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %24, %21
  %29 = phi ptr [ %27, %24 ], [ %.pre, %21 ]
  %30 = load ptr, ptr @_ZZ4rfftiiPfE2ip, align 8, !tbaa !5
  tail call void @rdft(i32 noundef %9, i32 noundef %1, ptr noundef %2, ptr noundef %30, ptr noundef %29)
  br label %31

31:                                               ; preds = %28, %5
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIiEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #3

declare void @rdft(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress 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 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 #2 = { inlinehint mustprogress 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 #3 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) 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 #4 = { "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(1) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass