; LLVM IR from glotzerlab/hoomd-blue :: hoomd/extern (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: mustprogress 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 i32, align 4
  %12 = 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) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %13, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = and i32 %16, 1
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %38

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %20, ptr %10, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = icmp eq ptr %21, %22
  br i1 %23, label %24, label %37

24:                                               ; preds = %19
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %25, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !13
  %32 = sext i32 %31 to i64
  %33 = mul i64 8, %32
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %28, i64 %33, i1 false)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %34, i32 0, i32 4
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  store ptr %36, ptr %9, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %24, %19
  br label %42

38:                                               ; preds = %3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !12
  store ptr %41, ptr %10, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %38, %37
  store i32 0, ptr %8, align 4, !tbaa !14
  br label %43

43:                                               ; preds = %105, %42
  %44 = load i32, ptr %8, align 4, !tbaa !14
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = icmp slt i32 %44, %47
  br i1 %48, label %49, label %108

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %8, align 4, !tbaa !14
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !14
  store i32 %56, ptr %11, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %58, align 8, !tbaa !13
  %60 = load i32, ptr %11, align 4, !tbaa !14
  %61 = sdiv i32 %59, %60
  store i32 %61, ptr %12, align 4, !tbaa !14
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %62

62:                                               ; preds = %85, %49
  %63 = load i32, ptr %7, align 4, !tbaa !14
  %64 = load i32, ptr %12, align 4, !tbaa !14
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %66, label %88

66:                                               ; preds = %62
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  %70 = load i32, ptr %8, align 4, !tbaa !14
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !14
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %74, i64 %76
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !14
  %80 = load i32, ptr %11, align 4, !tbaa !14
  %81 = mul nsw i32 %79, %80
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %78, i64 %82
  %84 = load i32, ptr %12, align 4, !tbaa !14
  call void @kiss_fft_stride(ptr noundef %73, ptr noundef %77, ptr noundef %83, i32 noundef %84)
  br label %85

85:                                               ; preds = %66
  %86 = load i32, ptr %7, align 4, !tbaa !14
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %7, align 4, !tbaa !14
  br label %62, !llvm.loop !17

88:                                               ; preds = %62
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %90, i32 0, i32 4
  %92 = load ptr, ptr %91, align 8, !tbaa !12
  %93 = icmp eq ptr %89, %92
  br i1 %93, label %94, label %99

94:                                               ; preds = %88
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %95, ptr %10, align 8, !tbaa !5
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %96, i32 0, i32 4
  %98 = load ptr, ptr %97, align 8, !tbaa !12
  store ptr %98, ptr %9, align 8, !tbaa !5
  br label %104

99:                                               ; preds = %88
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.kiss_fftnd_state, ptr %100, i32 0, i32 4
  %102 = load ptr, ptr %101, align 8, !tbaa !12
  store ptr %102, ptr %10, align 8, !tbaa !5
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %103, ptr %9, align 8, !tbaa !5
  br label %104

104:                                              ; preds = %99, %94
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %105

105:                                              ; preds = %104
  %106 = load i32, ptr %8, align 4, !tbaa !14
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %8, align 4, !tbaa !14
  br label %43, !llvm.loop !19

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

; 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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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, !11, i64 4}
!10 = !{!"_ZTS16kiss_fftnd_state", !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 = !{!10, !11, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 8}
!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: mustprogress 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 %16, label %7

7:                                                ; preds = %3
  %8 = icmp eq ptr %1, %2
  br i1 %8, label %9, label %19

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load i32, ptr %0, align 8, !tbaa !12
  %13 = sext i32 %12 to i64
  %14 = shl nsw i64 %13, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %1, i64 %14, i1 false)
  %15 = load ptr, ptr %10, align 8, !tbaa !11
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %19

16:                                               ; preds = %3
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %7, %9, %16
  %20 = phi i32 [ %.pre, %9 ], [ %5, %7 ], [ %5, %16 ]
  %.035 = phi ptr [ %15, %9 ], [ %1, %7 ], [ %1, %16 ]
  %.034 = phi ptr [ %2, %9 ], [ %2, %7 ], [ %18, %16 ]
  %21 = icmp sgt i32 %20, 0
  br i1 %21, label %.lr.ph51, label %._crit_edge52

.lr.ph51:                                         ; preds = %19
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  br label %25

25:                                               ; preds = %.lr.ph51, %._crit_edge
  %26 = phi i32 [ %20, %.lr.ph51 ], [ %40, %._crit_edge ]
  %indvars.iv54 = phi i64 [ 0, %.lr.ph51 ], [ %indvars.iv.next55, %._crit_edge ]
  %.148 = phi ptr [ %.034, %.lr.ph51 ], [ %.45, %._crit_edge ]
  %.13647 = phi ptr [ %.035, %.lr.ph51 ], [ %., %._crit_edge ]
  %27 = load ptr, ptr %22, align 8, !tbaa !13
  %28 = getelementptr inbounds i32, ptr %27, i64 %indvars.iv54
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = load i32, ptr %0, align 8, !tbaa !12
  %31 = sdiv i32 %30, %29
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %25
  %33 = sext i32 %29 to i64
  %wide.trip.count = zext nneg i32 %31 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 ]
  %34 = load ptr, ptr %23, align 8, !tbaa !15
  %35 = getelementptr inbounds ptr, ptr %34, i64 %indvars.iv54
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.13647, i64 %indvars.iv
  %38 = mul nsw i64 %indvars.iv, %33
  %39 = getelementptr inbounds %struct.kiss_fft_cpx, ptr %.148, i64 %38
  tail call void @kiss_fft_stride(ptr noundef %36, ptr noundef %37, ptr noundef %39, i32 noundef %31)
  %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
  %.pre57 = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %25
  %40 = phi i32 [ %.pre57, %._crit_edge.loopexit ], [ %26, %25 ]
  %41 = load ptr, ptr %24, align 8, !tbaa !11
  %42 = icmp eq ptr %.148, %41
  %. = select i1 %42, ptr %41, ptr %2
  %.45 = select i1 %42, ptr %2, ptr %41
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %43 = sext i32 %40 to i64
  %44 = icmp slt i64 %indvars.iv.next55, %43
  br i1 %44, label %25, label %._crit_edge52, !llvm.loop !19

._crit_edge52:                                    ; preds = %._crit_edge, %19
  ret void
}

; Function Attrs: mustprogress 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) #1

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

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 = { mustprogress nocallback nofree 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" }

!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 = !{!"_ZTS16kiss_fftnd_state", !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++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!7, !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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass