; LLVM IR from suxiaojack/sapDecoder :: src (kiss_fft)

; 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_fft_state = type { i32, i32, [64 x i32], [1 x %struct.kiss_fft_cpx] }
%struct.kiss_fft_cpx = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local ptr @kiss_fft_alloc(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr null, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = mul i64 8, %16
  %18 = add i64 272, %17
  store i64 %18, ptr %10, align 8, !tbaa !11
  %19 = load ptr, ptr %8, align 8, !tbaa !9
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %4
  %22 = load i64, ptr %10, align 8, !tbaa !11
  %23 = call noalias ptr @malloc(i64 noundef %22) #6
  store ptr %23, ptr %9, align 8, !tbaa !9
  br label %37

24:                                               ; preds = %4
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %34

27:                                               ; preds = %24
  %28 = load ptr, ptr %8, align 8, !tbaa !9
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = load i64, ptr %10, align 8, !tbaa !11
  %31 = icmp uge i64 %29, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %27
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %33, ptr %9, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %32, %27, %24
  %35 = load i64, ptr %10, align 8, !tbaa !11
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  store i64 %35, ptr %36, align 8, !tbaa !11
  br label %37

37:                                               ; preds = %34, %21
  %38 = load ptr, ptr %9, align 8, !tbaa !9
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %97

40:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.kiss_fft_state, ptr %42, i32 0, i32 0
  store i32 %41, ptr %43, align 4, !tbaa !13
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.kiss_fft_state, ptr %45, i32 0, i32 1
  store i32 %44, ptr %46, align 4, !tbaa !15
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %89, %40
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %92

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0x400921FB54442D18, ptr %12, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = sitofp i32 %52 to double
  %54 = fmul double 0xC01921FB54442D18, %53
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = sitofp i32 %55 to double
  %57 = fdiv double %54, %56
  store double %57, ptr %13, align 8, !tbaa !16
  %58 = load ptr, ptr %9, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.kiss_fft_state, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !15
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %51
  %63 = load double, ptr %13, align 8, !tbaa !16
  %64 = fmul double %63, -1.000000e+00
  store double %64, ptr %13, align 8, !tbaa !16
  br label %65

65:                                               ; preds = %62, %51
  br label %66

66:                                               ; preds = %65
  %67 = load double, ptr %13, align 8, !tbaa !16
  %68 = call double @cos(double noundef %67) #5
  %69 = fptrunc double %68 to float
  %70 = load ptr, ptr %9, align 8, !tbaa !9
  %71 = getelementptr inbounds %struct.kiss_fft_state, ptr %70, i32 0, i32 3
  %72 = getelementptr inbounds [1 x %struct.kiss_fft_cpx], ptr %71, i64 0, i64 0
  %73 = load i32, ptr %11, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %72, i64 %74
  %76 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %75, i32 0, i32 0
  store float %69, ptr %76, align 4, !tbaa !18
  %77 = load double, ptr %13, align 8, !tbaa !16
  %78 = call double @sin(double noundef %77) #5
  %79 = fptrunc double %78 to float
  %80 = load ptr, ptr %9, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct.kiss_fft_state, ptr %80, i32 0, i32 3
  %82 = getelementptr inbounds [1 x %struct.kiss_fft_cpx], ptr %81, i64 0, i64 0
  %83 = load i32, ptr %11, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %82, i64 %84
  %86 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %85, i32 0, i32 1
  store float %79, ptr %86, align 4, !tbaa !21
  br label %87

87:                                               ; preds = %66
  br label %88

88:                                               ; preds = %87
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %11, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %11, align 4, !tbaa !5
  br label %47, !llvm.loop !22

92:                                               ; preds = %47
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = load ptr, ptr %9, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.kiss_fft_state, ptr %94, i32 0, i32 2
  %96 = getelementptr inbounds [64 x i32], ptr %95, i64 0, i64 0
  call void @_ZL9kf_factoriPi(i32 noundef %93, ptr noundef %96)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %97

97:                                               ; preds = %92, %37
  %98 = load ptr, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret ptr %98
}

; 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: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL9kf_factoriPi(i32 noundef, ptr noundef) #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 = { 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 = { 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 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 = !{!"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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS14kiss_fft_state", !6, i64 0, !6, i64 4, !7, i64 8, !7, i64 264}
!15 = !{!14, !6, i64 4}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!19, !20, i64 0}
!19 = !{!"_ZTS12kiss_fft_cpx", !20, i64 0, !20, i64 4}
!20 = !{!"float", !7, i64 0}
!21 = !{!19, !20, i64 4}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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

%struct.kiss_fft_cpx = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local ptr @kiss_fft_alloc(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = add nsw i32 %0, -1
  %6 = sext i32 %5 to i64
  %7 = shl nsw i64 %6, 3
  %8 = add nsw i64 %7, 272
  %9 = icmp eq ptr %3, null
  br i1 %9, label %10, label %12

10:                                               ; preds = %4
  %11 = tail call noalias ptr @malloc(i64 noundef %8) #3
  br label %16

12:                                               ; preds = %4
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %15, label %13

13:                                               ; preds = %12
  %14 = load i64, ptr %3, align 8, !tbaa !5
  %.not35 = icmp ult i64 %14, %8
  %spec.select = select i1 %.not35, ptr null, ptr %2
  br label %15

15:                                               ; preds = %13, %12
  %.029 = phi ptr [ null, %12 ], [ %spec.select, %13 ]
  store i64 %8, ptr %3, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %15, %10
  %.1 = phi ptr [ %11, %10 ], [ %.029, %15 ]
  %.not36 = icmp eq ptr %.1, null
  br i1 %.not36, label %36, label %17

17:                                               ; preds = %16
  store i32 %0, ptr %.1, align 4, !tbaa !9
  %18 = getelementptr inbounds i8, ptr %.1, i64 4
  store i32 %1, ptr %18, align 4, !tbaa !12
  %19 = icmp sgt i32 %0, 0
  br i1 %19, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %17
  %20 = uitofp nneg i32 %0 to double
  %21 = getelementptr inbounds i8, ptr %.1, i64 264
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %22

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  %24 = uitofp nneg i32 %23 to double
  %25 = fmul double %24, 0xC01921FB54442D18
  %26 = fdiv double %25, %20
  %27 = load i32, ptr %18, align 4, !tbaa !12
  %.not37 = icmp eq i32 %27, 0
  %28 = fneg double %26
  %.0 = select i1 %.not37, double %26, double %28
  %29 = tail call double @cos(double noundef %.0) #4
  %30 = fptrunc double %29 to float
  %31 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %21, i64 %indvars.iv
  store float %30, ptr %31, align 4, !tbaa !13
  %32 = tail call double @sin(double noundef %.0) #4
  %33 = fptrunc double %32 to float
  %34 = getelementptr inbounds i8, ptr %31, i64 4
  store float %33, ptr %34, align 4, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %22, !llvm.loop !17

._crit_edge:                                      ; preds = %22, %17
  %35 = getelementptr inbounds i8, ptr %.1, i64 8
  tail call void @_ZL9kf_factoriPi(i32 noundef %0, ptr noundef nonnull %35)
  br label %36

36:                                               ; preds = %._crit_edge, %16
  ret ptr %.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 #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #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 nofree nounwind willreturn memory(write) "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) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS14kiss_fft_state", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 264}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS12kiss_fft_cpx", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !15, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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