; LLVM IR from T-Troll/alienfx-tools :: alienfx-gui/kiss_fft/tools (kiss_fftnd)

; 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_fftnd_state = type { i32, i32, ptr, ptr, ptr }
%struct.kiss_fft_cpx = type { float, float }

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

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

; Function Attrs: nounwind uwtable
define dso_local void @kiss_fftnd(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %15, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %16, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = and i32 %18, 1
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %3
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %22, ptr %11, align 8, !tbaa !5
  br label %27

23:                                               ; preds = %3
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  store ptr %26, ptr %11, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %23, %21
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %28

28:                                               ; preds = %90, %27
  %29 = load i32, ptr %8, align 4, !tbaa !13
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %93

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = load i32, ptr %8, align 4, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !13
  store i32 %41, ptr %12, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !15
  %45 = load i32, ptr %12, align 4, !tbaa !13
  %46 = sdiv i32 %44, %45
  store i32 %46, ptr %13, align 4, !tbaa !13
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %47

47:                                               ; preds = %70, %34
  %48 = load i32, ptr %7, align 4, !tbaa !13
  %49 = load i32, ptr %13, align 4, !tbaa !13
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %73

51:                                               ; preds = %47
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !16
  %55 = load i32, ptr %8, align 4, !tbaa !13
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %54, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !13
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %59, i64 %61
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !13
  %65 = load i32, ptr %12, align 4, !tbaa !13
  %66 = mul nsw i32 %64, %65
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %63, i64 %67
  %69 = load i32, ptr %13, align 4, !tbaa !13
  call void @kiss_fft_stride(ptr noundef %58, ptr noundef %62, ptr noundef %68, i32 noundef %69)
  br label %70

70:                                               ; preds = %51
  %71 = load i32, ptr %7, align 4, !tbaa !13
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !13
  br label %47, !llvm.loop !17

73:                                               ; preds = %47
  %74 = load ptr, ptr %11, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !12
  %78 = icmp eq ptr %74, %77
  br i1 %78, label %79, label %84

79:                                               ; preds = %73
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %80, ptr %11, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !12
  store ptr %83, ptr %10, align 8, !tbaa !5
  br label %89

84:                                               ; preds = %73
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %85, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !12
  store ptr %87, ptr %11, align 8, !tbaa !5
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %88, ptr %10, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %84, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %8, align 4, !tbaa !13
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %8, align 4, !tbaa !13
  br label %28, !llvm.loop !19

93:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

declare void @kiss_fft_stride(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

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

!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, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 24}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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: nounwind uwtable
define dso_local void @kiss_fftnd(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = and i32 %5, 1
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %10

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %3, %7
  %.029 = phi ptr [ %9, %7 ], [ %2, %3 ]
  %11 = icmp sgt i32 %5, 0
  br i1 %11, label %.lr.ph41, label %._crit_edge42

.lr.ph41:                                         ; preds = %10
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  br label %15

15:                                               ; preds = %.lr.ph41, %._crit_edge
  %16 = phi i32 [ %5, %.lr.ph41 ], [ %30, %._crit_edge ]
  %indvars.iv44 = phi i64 [ 0, %.lr.ph41 ], [ %indvars.iv.next45, %._crit_edge ]
  %.138 = phi ptr [ %.029, %.lr.ph41 ], [ %.35, %._crit_edge ]
  %.03037 = phi ptr [ %1, %.lr.ph41 ], [ %., %._crit_edge ]
  %17 = load ptr, ptr %12, align 8, !tbaa !12
  %18 = getelementptr inbounds i32, ptr %17, i64 %indvars.iv44
  %19 = load i32, ptr %18, align 4, !tbaa !13
  %20 = load i32, ptr %0, align 8, !tbaa !14
  %21 = sdiv i32 %20, %19
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %15
  %23 = sext i32 %19 to i64
  %wide.trip.count = zext nneg i32 %21 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %24 = load ptr, ptr %13, align 8, !tbaa !15
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv44
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.03037, i64 %indvars.iv
  %28 = mul nsw i64 %indvars.iv, %23
  %29 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.138, i64 %28
  tail call void @kiss_fft_stride(ptr noundef %26, ptr noundef %27, ptr noundef %29, i32 noundef %21) #2
  %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.loopexit, label %.lr.ph, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %15
  %30 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %16, %15 ]
  %31 = load ptr, ptr %14, align 8, !tbaa !11
  %32 = icmp eq ptr %.138, %31
  %. = select i1 %32, ptr %31, ptr %2
  %.35 = select i1 %32, ptr %2, ptr %31
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %33 = sext i32 %30 to i64
  %34 = icmp slt i64 %indvars.iv.next45, %33
  br i1 %34, label %15, label %._crit_edge42, !llvm.loop !19

._crit_edge42:                                    ; preds = %._crit_edge, %10
  ret void
}

declare void @kiss_fft_stride(ptr noundef, ptr noundef, ptr noundef, i32 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 = { 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, !7, i64 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !10, i64 16}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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