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

; 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 @_ZN4sptk5world7rftfsubEiPdiS1_(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = ashr i32 %20, 1
  store i32 %21, ptr %13, align 4, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = mul nsw i32 2, %22
  %24 = load i32, ptr %13, align 4, !tbaa !5
  %25 = sdiv i32 %23, %24
  store i32 %25, ptr %12, align 4, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %117, %4
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = load i32, ptr %13, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %30, label %120

30:                                               ; preds = %26
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = sub nsw i32 %31, %32
  store i32 %33, ptr %10, align 4, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !5
  %35 = load i32, ptr %11, align 4, !tbaa !5
  %36 = add nsw i32 %35, %34
  store i32 %36, ptr %11, align 4, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !9
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = sub nsw i32 %38, %39
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %37, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = fsub double 5.000000e-01, %43
  store double %44, ptr %14, align 8, !tbaa !11
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = load i32, ptr %11, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %45, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  store double %49, ptr %15, align 8, !tbaa !11
  %50 = load ptr, ptr %6, align 8, !tbaa !9
  %51 = load i32, ptr %9, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds double, ptr %50, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = fsub double %54, %59
  store double %60, ptr %16, align 8, !tbaa !11
  %61 = load ptr, ptr %6, align 8, !tbaa !9
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %61, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !11
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %67, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !11
  %73 = fadd double %66, %72
  store double %73, ptr %17, align 8, !tbaa !11
  %74 = load double, ptr %14, align 8, !tbaa !11
  %75 = load double, ptr %16, align 8, !tbaa !11
  %76 = load double, ptr %15, align 8, !tbaa !11
  %77 = load double, ptr %17, align 8, !tbaa !11
  %78 = fmul double %76, %77
  %79 = fneg double %78
  %80 = call double @llvm.fmuladd.f64(double %74, double %75, double %79)
  store double %80, ptr %18, align 8, !tbaa !11
  %81 = load double, ptr %14, align 8, !tbaa !11
  %82 = load double, ptr %17, align 8, !tbaa !11
  %83 = load double, ptr %15, align 8, !tbaa !11
  %84 = load double, ptr %16, align 8, !tbaa !11
  %85 = fmul double %83, %84
  %86 = call double @llvm.fmuladd.f64(double %81, double %82, double %85)
  store double %86, ptr %19, align 8, !tbaa !11
  %87 = load double, ptr %18, align 8, !tbaa !11
  %88 = load ptr, ptr %6, align 8, !tbaa !9
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %88, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !11
  %93 = fsub double %92, %87
  store double %93, ptr %91, align 8, !tbaa !11
  %94 = load double, ptr %19, align 8, !tbaa !11
  %95 = load ptr, ptr %6, align 8, !tbaa !9
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds double, ptr %95, i64 %98
  %100 = load double, ptr %99, align 8, !tbaa !11
  %101 = fsub double %100, %94
  store double %101, ptr %99, align 8, !tbaa !11
  %102 = load double, ptr %18, align 8, !tbaa !11
  %103 = load ptr, ptr %6, align 8, !tbaa !9
  %104 = load i32, ptr %10, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds double, ptr %103, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !11
  %108 = fadd double %107, %102
  store double %108, ptr %106, align 8, !tbaa !11
  %109 = load double, ptr %19, align 8, !tbaa !11
  %110 = load ptr, ptr %6, align 8, !tbaa !9
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = add nsw i32 %111, 1
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds double, ptr %110, i64 %113
  %115 = load double, ptr %114, align 8, !tbaa !11
  %116 = fsub double %115, %109
  store double %116, ptr %114, align 8, !tbaa !11
  br label %117

117:                                              ; preds = %30
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = add nsw i32 %118, 2
  store i32 %119, ptr %9, align 4, !tbaa !5
  br label %26, !llvm.loop !13

120:                                              ; preds = %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_ZN4sptk5world7rftfsubEiPdiS1_(i32 noundef %0, ptr nocapture noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = ashr i32 %0, 1
  %6 = icmp sgt i32 %5, 2
  br i1 %6, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %7 = shl nsw i32 %2, 1
  %8 = sdiv i32 %7, %5
  %9 = zext nneg i32 %0 to i64
  %10 = zext nneg i32 %5 to i64
  %11 = sext i32 %8 to i64
  %12 = sext i32 %2 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv45 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next46, %.lr.ph ]
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %13 = sub nsw i64 %9, %indvars.iv
  %indvars.iv.next46 = add nsw i64 %indvars.iv45, %11
  %14 = sub nsw i64 %12, %indvars.iv.next46
  %15 = getelementptr inbounds double, ptr %3, i64 %14
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fsub double 5.000000e-01, %16
  %18 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next46
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %21 = getelementptr inbounds double, ptr %1, i64 %13
  %22 = fneg double %19
  %23 = load <2 x double>, ptr %20, align 8, !tbaa !5
  %24 = load <2 x double>, ptr %21, align 8, !tbaa !5
  %25 = fsub <2 x double> %23, %24
  %26 = fadd <2 x double> %23, %24
  %27 = shufflevector <2 x double> %25, <2 x double> %26, <2 x i32> <i32 0, i32 3>
  %28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %29 = insertelement <2 x double> poison, double %22, i64 0
  %30 = insertelement <2 x double> %29, double %19, i64 1
  %31 = fmul <2 x double> %28, %30
  %32 = insertelement <2 x double> poison, double %17, i64 0
  %33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
  %34 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %27, <2 x double> %31)
  %35 = fsub <2 x double> %23, %34
  store <2 x double> %35, ptr %20, align 8, !tbaa !5
  %36 = load <2 x double>, ptr %21, align 8, !tbaa !5
  %37 = fadd <2 x double> %36, %34
  %38 = fsub <2 x double> %36, %34
  %39 = shufflevector <2 x double> %37, <2 x double> %38, <2 x i32> <i32 0, i32 3>
  store <2 x double> %39, ptr %21, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %40 = icmp ult i64 %indvars.iv.next, %10
  br i1 %40, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #1

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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass