; LLVM IR from kdrag0n/fxdsp :: external/kissfft (kiss_fftndr)

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

%struct.kiss_fftndr_state = type { i32, i32, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local ptr @kiss_fftndr_alloc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store i64 0, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i64 0, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store i64 0, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %21, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  store i32 %26, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sub nsw i32 %28, 1
  %30 = call i32 @prod(ptr noundef %27, i32 noundef %29)
  store i32 %30, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  store ptr null, ptr %19, align 8, !tbaa !5
  %31 = load i32, ptr %16, align 4, !tbaa !9
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = call ptr @kiss_fftr_alloc(i32 noundef %31, i32 noundef %32, ptr noundef null, ptr noundef %13)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = sub nsw i32 %35, 1
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = call ptr @kiss_fftnd_alloc(ptr noundef %34, i32 noundef %36, i32 noundef %37, ptr noundef null, ptr noundef %14)
  %39 = load i32, ptr %17, align 4, !tbaa !9
  %40 = mul nsw i32 2, %39
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = add nsw i32 %41, 2
  %43 = icmp slt i32 %40, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %5
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = add nsw i32 %45, 2
  br label %50

47:                                               ; preds = %5
  %48 = load i32, ptr %17, align 4, !tbaa !9
  %49 = mul nsw i32 2, %48
  br label %50

50:                                               ; preds = %47, %44
  %51 = phi i32 [ %46, %44 ], [ %49, %47 ]
  %52 = sext i32 %51 to i64
  %53 = mul i64 %52, 4
  %54 = load i32, ptr %17, align 4, !tbaa !9
  %55 = load i32, ptr %16, align 4, !tbaa !9
  %56 = add nsw i32 %55, 2
  %57 = mul nsw i32 %54, %56
  %58 = sext i32 %57 to i64
  %59 = mul i64 %58, 4
  %60 = add i64 %53, %59
  store i64 %60, ptr %15, align 8, !tbaa !11
  %61 = load i64, ptr %13, align 8, !tbaa !11
  %62 = add i64 32, %61
  %63 = load i64, ptr %14, align 8, !tbaa !11
  %64 = add i64 %62, %63
  %65 = load i64, ptr %15, align 8, !tbaa !11
  %66 = add i64 %64, %65
  store i64 %66, ptr %18, align 8, !tbaa !11
  %67 = load ptr, ptr %11, align 8, !tbaa !5
  %68 = icmp eq ptr %67, null
  br i1 %68, label %69, label %72

69:                                               ; preds = %50
  %70 = load i64, ptr %18, align 8, !tbaa !11
  %71 = call noalias ptr @malloc(i64 noundef %70) #6
  store ptr %71, ptr %19, align 8, !tbaa !5
  br label %82

72:                                               ; preds = %50
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = load i64, ptr %73, align 8, !tbaa !11
  %75 = load i64, ptr %18, align 8, !tbaa !11
  %76 = icmp uge i64 %74, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %72
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %78, ptr %19, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %77, %72
  %80 = load i64, ptr %18, align 8, !tbaa !11
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %80, ptr %81, align 8, !tbaa !11
  br label %82

82:                                               ; preds = %79, %69
  %83 = load ptr, ptr %19, align 8, !tbaa !5
  %84 = icmp eq ptr %83, null
  br i1 %84, label %85, label %86

85:                                               ; preds = %82
  store ptr null, ptr %6, align 8
  store i32 1, ptr %20, align 4
  br label %122

86:                                               ; preds = %82
  %87 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %87, ptr %12, align 8, !tbaa !5
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = load i64, ptr %18, align 8, !tbaa !11
  call void @llvm.memset.p0.i64(ptr align 8 %88, i8 0, i64 %89, i1 false)
  %90 = load ptr, ptr %19, align 8, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %90, i64 32
  store ptr %91, ptr %19, align 8, !tbaa !5
  %92 = load i32, ptr %16, align 4, !tbaa !9
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.kiss_fftndr_state, ptr %93, i32 0, i32 0
  store i32 %92, ptr %94, align 8, !tbaa !13
  %95 = load i32, ptr %17, align 4, !tbaa !9
  %96 = load ptr, ptr %12, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.kiss_fftndr_state, ptr %96, i32 0, i32 1
  store i32 %95, ptr %97, align 4, !tbaa !15
  %98 = load i32, ptr %16, align 4, !tbaa !9
  %99 = load i32, ptr %9, align 4, !tbaa !9
  %100 = load ptr, ptr %19, align 8, !tbaa !5
  %101 = call ptr @kiss_fftr_alloc(i32 noundef %98, i32 noundef %99, ptr noundef %100, ptr noundef %13)
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.kiss_fftndr_state, ptr %102, i32 0, i32 2
  store ptr %101, ptr %103, align 8, !tbaa !16
  %104 = load i64, ptr %13, align 8, !tbaa !11
  %105 = load ptr, ptr %19, align 8, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %105, i64 %104
  store ptr %106, ptr %19, align 8, !tbaa !5
  %107 = load ptr, ptr %7, align 8, !tbaa !5
  %108 = load i32, ptr %8, align 4, !tbaa !9
  %109 = sub nsw i32 %108, 1
  %110 = load i32, ptr %9, align 4, !tbaa !9
  %111 = load ptr, ptr %19, align 8, !tbaa !5
  %112 = call ptr @kiss_fftnd_alloc(ptr noundef %107, i32 noundef %109, i32 noundef %110, ptr noundef %111, ptr noundef %14)
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.kiss_fftndr_state, ptr %113, i32 0, i32 3
  store ptr %112, ptr %114, align 8, !tbaa !17
  %115 = load i64, ptr %14, align 8, !tbaa !11
  %116 = load ptr, ptr %19, align 8, !tbaa !5
  %117 = getelementptr inbounds i8, ptr %116, i64 %115
  store ptr %117, ptr %19, align 8, !tbaa !5
  %118 = load ptr, ptr %19, align 8, !tbaa !5
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.kiss_fftndr_state, ptr %119, i32 0, i32 4
  store ptr %118, ptr %120, align 8, !tbaa !18
  %121 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %121, ptr %6, align 8
  store i32 1, ptr %20, align 4
  br label %122

122:                                              ; preds = %86, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %123 = load ptr, ptr %6, align 8
  ret ptr %123
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @prod(ptr noundef, i32 noundef) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; 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 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 nounwind willreturn memory(argmem: write) }
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 = !{!"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, !10, i64 0}
!14 = !{!"kiss_fftndr_state", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!14, !10, i64 4}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{!14, !6, i64 24}


; 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 noundef ptr @kiss_fftndr_alloc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  store i64 0, ptr %7, align 8, !tbaa !5
  %8 = add nsw i32 %1, -1
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i32, ptr %0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = tail call i32 @prod(ptr noundef %0, i32 noundef %8)
  %13 = call ptr @kiss_fftr_alloc(i32 noundef %11, i32 noundef %2, ptr noundef null, ptr noundef nonnull %6) #6
  %14 = call ptr @kiss_fftnd_alloc(ptr noundef %0, i32 noundef %8, i32 noundef %2, ptr noundef null, ptr noundef nonnull %7) #6
  %15 = shl nsw i32 %12, 1
  %16 = add nsw i32 %11, 2
  %17 = call i32 @llvm.smax.i32(i32 %15, i32 %16)
  %18 = sext i32 %17 to i64
  %19 = mul nsw i32 %12, %16
  %20 = sext i32 %19 to i64
  %21 = add nsw i64 %18, %20
  %22 = shl nsw i64 %21, 2
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = add i64 %23, 32
  %25 = load i64, ptr %7, align 8, !tbaa !5
  %26 = add i64 %24, %25
  %27 = add i64 %26, %22
  %28 = icmp eq ptr %4, null
  br i1 %28, label %29, label %31

29:                                               ; preds = %5
  %30 = call noalias ptr @malloc(i64 noundef %27) #7
  br label %33

31:                                               ; preds = %5
  %32 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp ult i64 %32, %27
  store i64 %27, ptr %4, align 8, !tbaa !5
  br i1 %.not, label %.thread, label %33

33:                                               ; preds = %31, %29
  %.1 = phi ptr [ %30, %29 ], [ %3, %31 ]
  %34 = icmp eq ptr %.1, null
  br i1 %34, label %.thread, label %35

35:                                               ; preds = %33
  call void @llvm.memset.p0.i64(ptr nonnull align 8 %.1, i8 0, i64 %27, i1 false)
  %36 = getelementptr inbounds i8, ptr %.1, i64 32
  store i32 %11, ptr %.1, align 8, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %.1, i64 4
  store i32 %12, ptr %37, align 4, !tbaa !14
  %38 = call ptr @kiss_fftr_alloc(i32 noundef %11, i32 noundef %2, ptr noundef nonnull %36, ptr noundef nonnull %6) #6
  %39 = getelementptr inbounds i8, ptr %.1, i64 8
  store ptr %38, ptr %39, align 8, !tbaa !15
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %36, i64 %40
  %42 = call ptr @kiss_fftnd_alloc(ptr noundef nonnull %0, i32 noundef %8, i32 noundef %2, ptr noundef nonnull %41, ptr noundef nonnull %7) #6
  %43 = getelementptr inbounds i8, ptr %.1, i64 16
  store ptr %42, ptr %43, align 8, !tbaa !16
  %44 = load i64, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  %46 = getelementptr inbounds i8, ptr %.1, i64 24
  store ptr %45, ptr %46, align 8, !tbaa !17
  br label %.thread

.thread:                                          ; preds = %31, %33, %35
  %.046 = phi ptr [ %.1, %35 ], [ null, %33 ], [ null, %31 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  ret ptr %.046
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @prod(ptr noundef, i32 noundef) local_unnamed_addr #0

declare ptr @kiss_fftr_alloc(i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @kiss_fftnd_alloc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

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 = { mustprogress 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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long", !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, !10, i64 0}
!12 = !{!"kiss_fftndr_state", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 16, !13, i64 24}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !13, i64 16}
!17 = !{!12, !13, i64 24}


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