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

; 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.spgramcf_s = type { i32, i32, i32, i32, float, float, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i64, i64, float, float }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [81 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @spgramcf_copy(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.8, i32 noundef 177, ptr noundef @.str.4, ptr noundef @.str.2)
  store ptr %9, ptr %2, align 8
  br label %106

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %11 = call noalias ptr @malloc(i64 noundef 128) #6
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memmove.p0.p0.i64(ptr align 8 %12, ptr align 8 %13, i64 128, i1 false)
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.spgramcf_s, ptr %14, i32 0, i32 7
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = call ptr @windowcf_copy(ptr noundef %16)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.spgramcf_s, ptr %18, i32 0, i32 7
  store ptr %17, ptr %19, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.spgramcf_s, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = zext i32 %22 to i64
  %24 = mul i64 %23, 8
  %25 = call noalias ptr @malloc(i64 noundef %24) #6
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.spgramcf_s, ptr %26, i32 0, i32 8
  store ptr %25, ptr %27, align 8, !tbaa !15
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.spgramcf_s, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = zext i32 %30 to i64
  %32 = mul i64 %31, 8
  %33 = call noalias ptr @malloc(i64 noundef %32) #6
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.spgramcf_s, ptr %34, i32 0, i32 9
  store ptr %33, ptr %35, align 8, !tbaa !16
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.spgramcf_s, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !14
  %39 = zext i32 %38 to i64
  %40 = mul i64 %39, 4
  %41 = call noalias ptr @malloc(i64 noundef %40) #6
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.spgramcf_s, ptr %42, i32 0, i32 12
  store ptr %41, ptr %43, align 8, !tbaa !17
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.spgramcf_s, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !14
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.spgramcf_s, ptr %47, i32 0, i32 8
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.spgramcf_s, ptr %50, i32 0, i32 9
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = call ptr @fft_create_plan(i32 noundef %46, ptr noundef %49, ptr noundef %52, i32 noundef 1, i32 noundef 0)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.spgramcf_s, ptr %54, i32 0, i32 11
  store ptr %53, ptr %55, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !19
  br label %56

56:                                               ; preds = %71, %10
  %57 = load i32, ptr %5, align 4, !tbaa !19
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.spgramcf_s, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !14
  %61 = icmp ult i32 %57, %60
  br i1 %61, label %62, label %74

62:                                               ; preds = %56
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.spgramcf_s, ptr %63, i32 0, i32 8
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = load i32, ptr %5, align 4, !tbaa !19
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds { float, float }, ptr %65, i64 %67
  %69 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 1
  store float 0.000000e+00, ptr %69, align 4
  store float 0.000000e+00, ptr %70, align 4
  br label %71

71:                                               ; preds = %62
  %72 = load i32, ptr %5, align 4, !tbaa !19
  %73 = add i32 %72, 1
  store i32 %73, ptr %5, align 4, !tbaa !19
  br label %56, !llvm.loop !20

74:                                               ; preds = %56
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.spgramcf_s, ptr %75, i32 0, i32 12
  %77 = load ptr, ptr %76, align 8, !tbaa !17
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.spgramcf_s, ptr %78, i32 0, i32 12
  %80 = load ptr, ptr %79, align 8, !tbaa !17
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.spgramcf_s, ptr %81, i32 0, i32 0
  %83 = load i32, ptr %82, align 8, !tbaa !14
  %84 = zext i32 %83 to i64
  %85 = mul i64 %84, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %77, ptr align 4 %80, i64 %85, i1 false)
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.spgramcf_s, ptr %86, i32 0, i32 2
  %88 = load i32, ptr %87, align 8, !tbaa !22
  %89 = zext i32 %88 to i64
  %90 = mul i64 %89, 4
  %91 = call noalias ptr @malloc(i64 noundef %90) #6
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.spgramcf_s, ptr %92, i32 0, i32 10
  store ptr %91, ptr %93, align 8, !tbaa !23
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.spgramcf_s, ptr %94, i32 0, i32 10
  %96 = load ptr, ptr %95, align 8, !tbaa !23
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.spgramcf_s, ptr %97, i32 0, i32 10
  %99 = load ptr, ptr %98, align 8, !tbaa !23
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.spgramcf_s, ptr %100, i32 0, i32 2
  %102 = load i32, ptr %101, align 8, !tbaa !22
  %103 = zext i32 %102 to i64
  %104 = mul i64 %103, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %96, ptr align 4 %99, i64 %104, i1 false)
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %105, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %106

106:                                              ; preds = %74, %8
  %107 = load ptr, ptr %2, align 8
  ret ptr %107
}

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

declare ptr @windowcf_copy(ptr noundef) #0

attributes #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 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !6, i64 32}
!10 = !{!"spgramcf_s", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !12, i64 120, !12, i64 124}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !6, i64 40}
!16 = !{!10, !6, i64 48}
!17 = !{!10, !6, i64 72}
!18 = !{!10, !6, i64 64}
!19 = !{!11, !11, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !11, i64 8}
!23 = !{!10, !6, i64 56}


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

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [81 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @spgramcf_copy(ptr noundef readonly %0) local_unnamed_addr #3 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %5

3:                                                ; preds = %1
  %4 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.8, i32 noundef 177, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.2) #6
  br label %33

5:                                                ; preds = %1
  %6 = tail call noalias dereferenceable_or_null(128) ptr @malloc(i64 noundef 128) #7
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %6, ptr noundef nonnull align 8 dereferenceable(128) %0, i64 128, i1 false)
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call ptr @windowcf_copy(ptr noundef %8) #6
  %10 = getelementptr inbounds i8, ptr %6, i64 32
  store ptr %9, ptr %10, align 8, !tbaa !5
  %11 = load i32, ptr %6, align 8, !tbaa !13
  %12 = zext i32 %11 to i64
  %13 = shl nuw nsw i64 %12, 3
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #7
  %15 = getelementptr inbounds i8, ptr %6, i64 40
  store ptr %14, ptr %15, align 8, !tbaa !14
  %16 = tail call noalias ptr @malloc(i64 noundef %13) #7
  %17 = getelementptr inbounds i8, ptr %6, i64 48
  store ptr %16, ptr %17, align 8, !tbaa !15
  %18 = shl nuw nsw i64 %12, 2
  %19 = tail call noalias ptr @malloc(i64 noundef %18) #7
  %20 = getelementptr inbounds i8, ptr %6, i64 72
  store ptr %19, ptr %20, align 8, !tbaa !16
  %21 = tail call ptr @fft_create_plan(i32 noundef %11, ptr noundef %14, ptr noundef %16, i32 noundef 1, i32 noundef 0) #6
  %22 = getelementptr inbounds i8, ptr %6, i64 64
  store ptr %21, ptr %22, align 8, !tbaa !17
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  tail call void @llvm.memset.p0.i64(ptr align 4 %14, i8 0, i64 %13, i1 false)
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %5
  %23 = getelementptr inbounds i8, ptr %0, i64 72
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %19, ptr align 4 %24, i64 %18, i1 false)
  %25 = getelementptr inbounds i8, ptr %6, i64 8
  %26 = load i32, ptr %25, align 8, !tbaa !18
  %27 = zext i32 %26 to i64
  %28 = shl nuw nsw i64 %27, 2
  %29 = tail call noalias ptr @malloc(i64 noundef %28) #7
  %30 = getelementptr inbounds i8, ptr %6, i64 56
  store ptr %29, ptr %30, align 8, !tbaa !19
  %31 = getelementptr inbounds i8, ptr %0, i64 56
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %29, ptr align 4 %32, i64 %28, i1 false)
  br label %33

33:                                               ; preds = %._crit_edge, %3
  %.029 = phi ptr [ %4, %3 ], [ %6, %._crit_edge ]
  ret ptr %.029
}

declare ptr @fft_create_plan(i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare ptr @windowcf_copy(ptr noundef) local_unnamed_addr #0

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

attributes #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 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 32}
!6 = !{!"spgramcf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !7, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !10, i64 120, !10, i64 124}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !11, i64 40}
!15 = !{!6, !11, i64 48}
!16 = !{!6, !11, i64 72}
!17 = !{!6, !11, i64 64}
!18 = !{!6, !7, i64 8}
!19 = !{!6, !11, i64 56}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass