; LLVM IR from sp-nitech/SPTK :: third_party/WORLD/fft_world.ll (ZN4sptk5world19fft_plan_dft_r2c_1dEiPdPA2_dj)

; 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.sptk::world::fft_plan" = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4sptk5world6makewtEiPiPd(i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk5world6makectEiPiPd(i32 noundef, ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk5world19fft_plan_dft_r2c_1dEiPdPA2_dj(ptr dead_on_unwind noalias writable sret(%"struct.sptk::world::fft_plan") align 8 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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
  store i32 %4, ptr %9, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 72, i1 false)
  %10 = load i32, ptr %6, align 4, !tbaa !5
  %11 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 0
  store i32 %10, ptr %11, align 8, !tbaa !11
  %12 = load ptr, ptr %7, align 8, !tbaa !9
  %13 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 4
  store ptr %12, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 3
  store ptr null, ptr %14, align 8, !tbaa !14
  %15 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 6
  store ptr null, ptr %15, align 8, !tbaa !15
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 5
  store ptr %16, ptr %17, align 8, !tbaa !16
  %18 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 1
  store i32 1, ptr %18, align 4, !tbaa !17
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 2
  store i32 %19, ptr %20, align 8, !tbaa !18
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %22, i64 8)
  %24 = extractvalue { i64, i1 } %23, 1
  %25 = extractvalue { i64, i1 } %23, 0
  %26 = select i1 %24, i64 -1, i64 %25
  %27 = call noalias noundef nonnull ptr @_Znam(i64 noundef %26) #5
  %28 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 7
  store ptr %27, ptr %28, align 8, !tbaa !19
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %30, i64 4)
  %32 = extractvalue { i64, i1 } %31, 1
  %33 = extractvalue { i64, i1 } %31, 0
  %34 = select i1 %32, i64 -1, i64 %33
  %35 = call noalias noundef nonnull ptr @_Znam(i64 noundef %34) #5
  %36 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 8
  store ptr %35, ptr %36, align 8, !tbaa !20
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = mul nsw i32 %37, 5
  %39 = sdiv i32 %38, 4
  %40 = sext i32 %39 to i64
  %41 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %40, i64 8)
  %42 = extractvalue { i64, i1 } %41, 1
  %43 = extractvalue { i64, i1 } %41, 0
  %44 = select i1 %42, i64 -1, i64 %43
  %45 = call noalias noundef nonnull ptr @_Znam(i64 noundef %44) #5
  %46 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 9
  store ptr %45, ptr %46, align 8, !tbaa !21
  %47 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 8
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = getelementptr inbounds i32, ptr %48, i64 0
  store i32 0, ptr %49, align 4, !tbaa !5
  %50 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !11
  %52 = ashr i32 %51, 2
  %53 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 8
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 9
  %56 = load ptr, ptr %55, align 8, !tbaa !21
  call void @_ZN4sptk5world6makewtEiPiPd(i32 noundef %52, ptr noundef %54, ptr noundef %56)
  %57 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !11
  %59 = ashr i32 %58, 2
  %60 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 8
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 9
  %63 = load ptr, ptr %62, align 8, !tbaa !21
  %64 = getelementptr inbounds %"struct.sptk::world::fft_plan", ptr %0, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !11
  %66 = ashr i32 %65, 2
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %63, i64 %67
  call void @_ZN4sptk5world6makectEiPiPd(i32 noundef %59, ptr noundef %61, ptr noundef %68)
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nobuiltin 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 = { 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 #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 = { builtin 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, !6, i64 0}
!12 = !{!"_ZTSN4sptk5world8fft_planE", !6, i64 0, !6, i64 4, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !10, i64 16}
!15 = !{!12, !10, i64 40}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !6, i64 4}
!18 = !{!12, !6, i64 8}
!19 = !{!12, !10, i64 48}
!20 = !{!12, !10, i64 56}
!21 = !{!12, !10, i64 64}


; 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.sptk::world::fft_plan" = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4sptk5world6makewtEiPiPd(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4sptk5world6makectEiPiPd(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4sptk5world19fft_plan_dft_r2c_1dEiPdPA2_dj(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.sptk::world::fft_plan") align 8 %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 0, ptr %6, align 8
  store i32 %1, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %2, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %8, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr null, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %3, ptr %10, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1, ptr %11, align 4, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %4, ptr %12, align 8, !tbaa !16
  %13 = sext i32 %1 to i64
  %14 = icmp slt i32 %1, 0
  %15 = shl nsw i64 %13, 3
  %16 = select i1 %14, i64 -1, i64 %15
  %17 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %16) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  store ptr %17, ptr %18, align 8, !tbaa !17
  %19 = shl nsw i64 %13, 2
  %20 = select i1 %14, i64 -1, i64 %19
  %21 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %20) #3
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %21, ptr %22, align 8, !tbaa !18
  %23 = mul nsw i32 %1, 5
  %24 = sdiv i32 %23, 4
  %25 = sext i32 %24 to i64
  %26 = shl nsw i64 %25, 3
  %27 = select i1 %14, i64 -1, i64 %26
  %28 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %27) #3
  %29 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %28, ptr %29, align 8, !tbaa !19
  store i32 0, ptr %21, align 4, !tbaa !20
  %30 = ashr i32 %1, 2
  tail call void @_ZN4sptk5world6makewtEiPiPd(i32 noundef %30, ptr noundef nonnull %21, ptr noundef nonnull %28)
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds double, ptr %28, i64 %31
  tail call void @_ZN4sptk5world6makectEiPiPd(i32 noundef %30, ptr noundef nonnull %21, ptr noundef nonnull %32)
  ret void
}

attributes #0 = { nobuiltin 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 #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 = { 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 #3 = { builtin 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, !7, i64 0}
!6 = !{!"_ZTSN4sptk5world8fft_planE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64}
!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, !10, i64 16}
!13 = !{!6, !10, i64 40}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !10, i64 48}
!18 = !{!6, !10, i64 56}
!19 = !{!6, !10, i64 64}
!20 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass