; LLVM IR from T-Troll/alienfx-tools :: alienfx-gui/kiss_fft/kiss_fft.ll (Z7kf_workP12kiss_fft_cpxPKS_iiPiPK14kiss_fft_state)

; 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_cpx = type { float, float }

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

22:                                               ; preds = %56, %6
  %23 = load i32, ptr %15, align 4, !tbaa !9
  %24 = load i32, ptr %14, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %59

26:                                               ; preds = %22
  %27 = load i32, ptr %13, align 4, !tbaa !9
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %35

29:                                               ; preds = %26
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %15, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %31, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %30, i64 8, i1 false), !tbaa.struct !11
  br label %49

35:                                               ; preds = %26
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i32, ptr %13, align 4, !tbaa !9
  %38 = load i32, ptr %15, align 4, !tbaa !9
  %39 = mul nsw i32 %37, %38
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %36, i64 %40
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = mul nsw i32 %43, %44
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_Z7kf_workP12kiss_fft_cpxPKS_iiPiPK14kiss_fft_state(ptr noundef %41, ptr noundef %42, i32 noundef %45, i32 noundef %46, ptr noundef %47, ptr noundef %48)
  br label %49

49:                                               ; preds = %35, %29
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = mul nsw i32 %50, %51
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = sext i32 %52 to i64
  %55 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %53, i64 %54
  store ptr %55, ptr %8, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %49
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %15, align 4, !tbaa !9
  br label %22, !llvm.loop !14

59:                                               ; preds = %22
  %60 = load i32, ptr %14, align 4, !tbaa !9
  switch i32 %60, label %81 [
    i32 2, label %61
    i32 3, label %66
    i32 4, label %71
    i32 5, label %76
  ]

61:                                               ; preds = %59
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZL8kf_bfly2P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %62, i32 noundef %63, ptr noundef %64, i32 noundef %65)
  br label %87

66:                                               ; preds = %59
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZL8kf_bfly3P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %67, i32 noundef %68, ptr noundef %69, i32 noundef %70)
  br label %87

71:                                               ; preds = %59
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZL8kf_bfly4P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %72, i32 noundef %73, ptr noundef %74, i32 noundef %75)
  br label %87

76:                                               ; preds = %59
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = load i32, ptr %13, align 4, !tbaa !9
  call void @_ZL8kf_bfly5P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %77, i32 noundef %78, ptr noundef %79, i32 noundef %80)
  br label %87

81:                                               ; preds = %59
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load i32, ptr %9, align 4, !tbaa !9
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = load i32, ptr %14, align 4, !tbaa !9
  call void @_ZL15kf_bfly_genericP12kiss_fft_cpxiPK14kiss_fft_stateii(ptr noundef %82, i32 noundef %83, ptr noundef %84, i32 noundef %85, i32 noundef %86)
  br label %87

87:                                               ; preds = %81, %76, %71, %66, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret void
}

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

; 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) #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8kf_bfly2P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8kf_bfly3P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8kf_bfly4P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8kf_bfly5P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL15kf_bfly_genericP12kiss_fft_cpxiPK14kiss_fft_stateii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef) #3

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

!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}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 void @_Z7kf_workP12kiss_fft_cpxPKS_iiPiPK14kiss_fft_state(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef readonly %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = getelementptr inbounds i8, ptr %4, i64 4
  %8 = load i32, ptr %4, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  %10 = load i32, ptr %7, align 4, !tbaa !5
  %11 = icmp sgt i32 %8, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %6
  %12 = icmp eq i32 %10, 1
  %13 = mul nsw i32 %8, %2
  %14 = mul nsw i32 %3, %2
  %15 = sext i32 %14 to i64
  br i1 %12, label %.lr.ph.split.us.preheader, label %.lr.ph.split.preheader

.lr.ph.split.preheader:                           ; preds = %.lr.ph
  %16 = sext i32 %10 to i64
  %wide.trip.count = zext nneg i32 %8 to i64
  br label %.lr.ph.split

.lr.ph.split.us.preheader:                        ; preds = %.lr.ph
  %wide.trip.count52 = zext nneg i32 %8 to i64
  %xtraiter = and i64 %wide.trip.count52, 3
  %17 = icmp ult i32 %8, 4
  br i1 %17, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.split.us.preheader.new

.lr.ph.split.us.preheader.new:                    ; preds = %.lr.ph.split.us.preheader
  %unroll_iter = and i64 %wide.trip.count52, 2147483644
  br label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph.split.us, %.lr.ph.split.us.preheader.new
  %indvars.iv49 = phi i64 [ 0, %.lr.ph.split.us.preheader.new ], [ %indvars.iv.next50.3, %.lr.ph.split.us ]
  %.04245.us = phi ptr [ %1, %.lr.ph.split.us.preheader.new ], [ %29, %.lr.ph.split.us ]
  %niter = phi i64 [ 0, %.lr.ph.split.us.preheader.new ], [ %niter.next.3, %.lr.ph.split.us ]
  %18 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %indvars.iv49
  %19 = load i64, ptr %.04245.us, align 4
  store i64 %19, ptr %18, align 4
  %20 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.04245.us, i64 %15
  %indvars.iv.next50 = or disjoint i64 %indvars.iv49, 1
  %21 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %indvars.iv.next50
  %22 = load i64, ptr %20, align 4
  store i64 %22, ptr %21, align 4
  %23 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %20, i64 %15
  %indvars.iv.next50.1 = or disjoint i64 %indvars.iv49, 2
  %24 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %indvars.iv.next50.1
  %25 = load i64, ptr %23, align 4
  store i64 %25, ptr %24, align 4
  %26 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %23, i64 %15
  %indvars.iv.next50.2 = or disjoint i64 %indvars.iv49, 3
  %27 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %indvars.iv.next50.2
  %28 = load i64, ptr %26, align 4
  store i64 %28, ptr %27, align 4
  %29 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %26, i64 %15
  %indvars.iv.next50.3 = add nuw nsw i64 %indvars.iv49, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.split.us, !llvm.loop !9

.lr.ph.split:                                     ; preds = %.lr.ph.split.preheader, %.lr.ph.split
  %indvars.iv = phi i64 [ 0, %.lr.ph.split.preheader ], [ %indvars.iv.next, %.lr.ph.split ]
  %.04245 = phi ptr [ %1, %.lr.ph.split.preheader ], [ %32, %.lr.ph.split ]
  %30 = mul nsw i64 %indvars.iv, %16
  %31 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %30
  tail call void @_Z7kf_workP12kiss_fft_cpxPKS_iiPiPK14kiss_fft_state(ptr noundef %31, ptr noundef %.04245, i32 noundef %13, i32 noundef %3, ptr noundef nonnull %9, ptr noundef %5)
  %32 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.04245, i64 %15
  %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 %.lr.ph.split, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph.split.us, %.lr.ph.split.us.preheader
  %indvars.iv49.unr = phi i64 [ 0, %.lr.ph.split.us.preheader ], [ %indvars.iv.next50.3, %.lr.ph.split.us ]
  %.04245.us.unr = phi ptr [ %1, %.lr.ph.split.us.preheader ], [ %29, %.lr.ph.split.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.split.us.epil

.lr.ph.split.us.epil:                             ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.split.us.epil
  %indvars.iv49.epil = phi i64 [ %indvars.iv.next50.epil, %.lr.ph.split.us.epil ], [ %indvars.iv49.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.04245.us.epil = phi ptr [ %35, %.lr.ph.split.us.epil ], [ %.04245.us.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.split.us.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %33 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %0, i64 %indvars.iv49.epil
  %34 = load i64, ptr %.04245.us.epil, align 4
  store i64 %34, ptr %33, align 4
  %35 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.04245.us.epil, i64 %15
  %indvars.iv.next50.epil = add nuw nsw i64 %indvars.iv49.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.split.us.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph.split, %._crit_edge.loopexit.unr-lcssa, %.lr.ph.split.us.epil, %6
  switch i32 %8, label %40 [
    i32 2, label %36
    i32 3, label %37
    i32 4, label %38
    i32 5, label %39
  ]

36:                                               ; preds = %._crit_edge
  tail call void @_ZL8kf_bfly2P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %0, i32 noundef %2, ptr noundef %5, i32 noundef %10)
  br label %41

37:                                               ; preds = %._crit_edge
  tail call void @_ZL8kf_bfly3P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %0, i32 noundef %2, ptr noundef %5, i32 noundef %10)
  br label %41

38:                                               ; preds = %._crit_edge
  tail call void @_ZL8kf_bfly4P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %0, i32 noundef %2, ptr noundef %5, i32 noundef %10)
  br label %41

39:                                               ; preds = %._crit_edge
  tail call void @_ZL8kf_bfly5P12kiss_fft_cpxiPK14kiss_fft_statei(ptr noundef %0, i32 noundef %2, ptr noundef %5, i32 noundef %10)
  br label %41

40:                                               ; preds = %._crit_edge
  tail call void @_ZL15kf_bfly_genericP12kiss_fft_cpxiPK14kiss_fft_stateii(ptr noundef %0, i32 noundef %2, ptr noundef %5, i32 noundef %10, i32 noundef %8)
  br label %41

41:                                               ; preds = %40, %39, %38, %37, %36
  ret void
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL15kf_bfly_genericP12kiss_fft_cpxiPK14kiss_fft_stateii(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass