; LLVM IR from zsiciarz/aquila :: lib/ooura (fft4g)

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

19:                                               ; preds = %3
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = ashr i32 %20, 1
  store i32 %21, ptr %8, align 4, !tbaa !5
  %22 = call double @atan(double noundef 1.000000e+00) #3
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = sitofp i32 %23 to double
  %25 = fdiv double %22, %24
  store double %25, ptr %9, align 8, !tbaa !11
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %26, i64 0
  store double 1.000000e+00, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = getelementptr inbounds double, ptr %28, i64 1
  store double 0.000000e+00, ptr %29, align 8, !tbaa !11
  %30 = load double, ptr %9, align 8, !tbaa !11
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = sitofp i32 %31 to double
  %33 = fmul double %30, %32
  %34 = call double @cos(double noundef %33) #3
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = load i32, ptr %8, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds double, ptr %35, i64 %37
  store double %34, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds double, ptr %39, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !11
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = load i32, ptr %8, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds double, ptr %44, i64 %47
  store double %43, ptr %48, align 8, !tbaa !11
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = icmp sgt i32 %49, 2
  br i1 %50, label %51, label %101

51:                                               ; preds = %19
  store i32 2, ptr %7, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %93, %51
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = load i32, ptr %8, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %56, label %96

56:                                               ; preds = %52
  %57 = load double, ptr %9, align 8, !tbaa !11
  %58 = load i32, ptr %7, align 4, !tbaa !5
  %59 = sitofp i32 %58 to double
  %60 = fmul double %57, %59
  %61 = call double @cos(double noundef %60) #3
  store double %61, ptr %10, align 8, !tbaa !11
  %62 = load double, ptr %9, align 8, !tbaa !11
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = sitofp i32 %63 to double
  %65 = fmul double %62, %64
  %66 = call double @sin(double noundef %65) #3
  store double %66, ptr %11, align 8, !tbaa !11
  %67 = load double, ptr %10, align 8, !tbaa !11
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  store double %67, ptr %71, align 8, !tbaa !11
  %72 = load double, ptr %11, align 8, !tbaa !11
  %73 = load ptr, ptr %6, align 8, !tbaa !9
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds double, ptr %73, i64 %76
  store double %72, ptr %77, align 8, !tbaa !11
  %78 = load double, ptr %11, align 8, !tbaa !11
  %79 = load ptr, ptr %6, align 8, !tbaa !9
  %80 = load i32, ptr %4, align 4, !tbaa !5
  %81 = load i32, ptr %7, align 4, !tbaa !5
  %82 = sub nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds double, ptr %79, i64 %83
  store double %78, ptr %84, align 8, !tbaa !11
  %85 = load double, ptr %10, align 8, !tbaa !11
  %86 = load ptr, ptr %6, align 8, !tbaa !9
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = sub nsw i32 %87, %88
  %90 = add nsw i32 %89, 1
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds double, ptr %86, i64 %91
  store double %85, ptr %92, align 8, !tbaa !11
  br label %93

93:                                               ; preds = %56
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = add nsw i32 %94, 2
  store i32 %95, ptr %7, align 4, !tbaa !5
  br label %52, !llvm.loop !13

96:                                               ; preds = %52
  %97 = load i32, ptr %4, align 4, !tbaa !5
  %98 = load ptr, ptr %5, align 8, !tbaa !9
  %99 = getelementptr inbounds i32, ptr %98, i64 2
  %100 = load ptr, ptr %6, align 8, !tbaa !9
  call void @bitrv2(i32 noundef %97, ptr noundef %99, ptr noundef %100)
  br label %101

101:                                              ; preds = %96, %19
  br label %102

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

; Function Attrs: nounwind uwtable
declare dso_local void @bitrv2(i32 noundef, ptr noundef, ptr noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare double @atan(double noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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 = { 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/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: nounwind uwtable
define dso_local void @makewt(i32 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  store i32 %0, ptr %1, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 4
  store i32 1, ptr %4, align 4, !tbaa !5
  %5 = icmp sgt i32 %0, 2
  br i1 %5, label %6, label %30

6:                                                ; preds = %3
  %7 = lshr i32 %0, 1
  %8 = uitofp nneg i32 %7 to double
  %9 = fdiv double 0x3FE921FB54442D18, %8
  store <2 x double> <double 1.000000e+00, double 0.000000e+00>, ptr %2, align 8, !tbaa !9
  %10 = fmul double %9, %8
  %11 = tail call double @cos(double noundef %10) #2
  %12 = zext nneg i32 %7 to i64
  %13 = getelementptr inbounds double, ptr %2, i64 %12
  store double %11, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %13, i64 8
  store double %11, ptr %14, align 8, !tbaa !9
  %15 = icmp ugt i32 %0, 5
  br i1 %15, label %.lr.ph.preheader, label %30

.lr.ph.preheader:                                 ; preds = %6
  %16 = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 2, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %17 = trunc nuw nsw i64 %indvars.iv to i32
  %18 = uitofp nneg i32 %17 to double
  %19 = fmul double %9, %18
  %20 = tail call double @cos(double noundef %19) #2
  %21 = tail call double @sin(double noundef %19) #2
  %22 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  store double %20, ptr %22, align 8, !tbaa !9
  %23 = or disjoint i64 %indvars.iv, 1
  %24 = getelementptr inbounds double, ptr %2, i64 %23
  store double %21, ptr %24, align 8, !tbaa !9
  %25 = sub nsw i64 %16, %indvars.iv
  %26 = getelementptr inbounds double, ptr %2, i64 %25
  store double %21, ptr %26, align 8, !tbaa !9
  %27 = getelementptr i8, ptr %26, i64 8
  store double %20, ptr %27, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %28 = icmp ult i64 %indvars.iv.next, %12
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  tail call void @bitrv2(i32 noundef %0, ptr noundef nonnull %29, ptr noundef nonnull %2)
  br label %30

30:                                               ; preds = %6, %._crit_edge, %3
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @bitrv2(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass