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

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

; 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 nounwind uwtable
define dso_local void @_ZN4sptk5world7makeiptEiPi(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = getelementptr inbounds i32, ptr %11, i64 2
  store i32 0, ptr %12, align 4, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !9
  %14 = getelementptr inbounds i32, ptr %13, i64 3
  store i32 16, ptr %14, align 4, !tbaa !5
  store i32 2, ptr %7, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %15, ptr %6, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %57, %2
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = icmp sgt i32 %17, 32
  br i1 %18, label %19, label %60

19:                                               ; preds = %16
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = shl i32 %20, 1
  store i32 %21, ptr %8, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = shl i32 %22, 3
  store i32 %23, ptr %10, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %24, ptr %5, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %52, %19
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %55

29:                                               ; preds = %25
  %30 = load ptr, ptr %4, align 8, !tbaa !9
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = shl i32 %34, 2
  store i32 %35, ptr %9, align 4, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr %5, align 4, !tbaa !5
  %40 = add nsw i32 %38, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %37, i64 %41
  store i32 %36, ptr %42, align 4, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = load i32, ptr %10, align 4, !tbaa !5
  %45 = add nsw i32 %43, %44
  %46 = load ptr, ptr %4, align 8, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = add nsw i32 %47, %48
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i32, ptr %46, i64 %50
  store i32 %45, ptr %51, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %29
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !5
  br label %25, !llvm.loop !11

55:                                               ; preds = %25
  %56 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %56, ptr %7, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %55
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = ashr i32 %58, 2
  store i32 %59, ptr %6, align 4, !tbaa !5
  br label %16, !llvm.loop !13

60:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_ZN4sptk5world7makeiptEiPi(i32 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 12
  store i32 16, ptr %4, align 4, !tbaa !5
  %5 = icmp sgt i32 %0, 32
  br i1 %5, label %.lr.ph29, label %._crit_edge30

.lr.ph29:                                         ; preds = %2, %._crit_edge
  %.02227 = phi i32 [ %40, %._crit_edge ], [ %0, %2 ]
  %.02326 = phi i32 [ %6, %._crit_edge ], [ 2, %2 ]
  %6 = shl i32 %.02326, 1
  %7 = shl i32 %.02326, 4
  %8 = icmp slt i32 %.02326, %6
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph29
  %9 = sext i32 %.02326 to i64
  %10 = sext i32 %6 to i64
  %invariant.gep = getelementptr i32, ptr %1, i64 %9
  %invariant.gep32 = getelementptr i32, ptr %1, i64 %10
  %11 = sub nsw i64 %10, %9
  %min.iters.check = icmp ult i64 %11, 8
  br i1 %min.iters.check, label %.lr.ph.preheader38, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %12 = shl nsw i64 %10, 2
  %13 = shl nsw i64 %9, 2
  %14 = sub nsw i64 %12, %13
  %diff.check = icmp ult i64 %14, 32
  %diff.check34 = icmp ult i64 %13, 32
  %conflict.rdx = or i1 %diff.check, %diff.check34
  %diff.check35 = icmp ult i64 %12, 32
  %conflict.rdx36 = or i1 %conflict.rdx, %diff.check35
  br i1 %conflict.rdx36, label %.lr.ph.preheader38, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %11, -8
  %ind.end = add nsw i64 %n.vec, %9
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %7, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %9
  %15 = getelementptr inbounds i32, ptr %1, i64 %offset.idx
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %wide.load = load <4 x i32>, ptr %15, align 4, !tbaa !5
  %wide.load37 = load <4 x i32>, ptr %16, align 4, !tbaa !5
  %17 = shl <4 x i32> %wide.load, <i32 2, i32 2, i32 2, i32 2>
  %18 = shl <4 x i32> %wide.load37, <i32 2, i32 2, i32 2, i32 2>
  %19 = getelementptr i32, ptr %invariant.gep, i64 %offset.idx
  %20 = getelementptr i8, ptr %19, i64 16
  store <4 x i32> %17, ptr %19, align 4, !tbaa !5
  store <4 x i32> %18, ptr %20, align 4, !tbaa !5
  %21 = add nsw <4 x i32> %17, %broadcast.splat
  %22 = add nsw <4 x i32> %18, %broadcast.splat
  %23 = getelementptr i32, ptr %invariant.gep32, i64 %offset.idx
  %24 = getelementptr i8, ptr %23, i64 16
  store <4 x i32> %21, ptr %23, align 4, !tbaa !5
  store <4 x i32> %22, ptr %24, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %25 = icmp eq i64 %index.next, %n.vec
  br i1 %25, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %11, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader38

.lr.ph.preheader38:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ %9, %vector.memcheck ], [ %9, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %xtraiter = and i64 %indvars.iv.ph, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader38
  %26 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.ph
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = shl i32 %27, 2
  %gep.prol = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv.ph
  store i32 %28, ptr %gep.prol, align 4, !tbaa !5
  %29 = add nsw i32 %28, %7
  %gep33.prol = getelementptr i32, ptr %invariant.gep32, i64 %indvars.iv.ph
  store i32 %29, ptr %gep33.prol, align 4, !tbaa !5
  %indvars.iv.next.prol = add nsw i64 %indvars.iv.ph, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader38
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph.preheader38 ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %30 = add nsw i64 %10, -1
  %31 = icmp eq i64 %indvars.iv.ph, %30
  br i1 %31, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %32 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = shl i32 %33, 2
  %gep = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv
  store i32 %34, ptr %gep, align 4, !tbaa !5
  %35 = add nsw i32 %34, %7
  %gep33 = getelementptr i32, ptr %invariant.gep32, i64 %indvars.iv
  store i32 %35, ptr %gep33, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %36 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv.next
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = shl i32 %37, 2
  %gep.1 = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv.next
  store i32 %38, ptr %gep.1, align 4, !tbaa !5
  %39 = add nsw i32 %38, %7
  %gep33.1 = getelementptr i32, ptr %invariant.gep32, i64 %indvars.iv.next
  store i32 %39, ptr %gep33.1, align 4, !tbaa !5
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %10
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %.lr.ph29
  %40 = lshr i32 %.02227, 2
  %41 = icmp ugt i32 %.02227, 131
  br i1 %41, label %.lr.ph29, label %._crit_edge30, !llvm.loop !14

._crit_edge30:                                    ; preds = %._crit_edge, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass