; LLVM IR from jingweizhanghuai/Morn :: src/wave (morn_wave_preprocess)

; 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.MWave = type { i32, i32, [32 x ptr] }

@.str = external hidden unnamed_addr constant [87 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mWaveBlackmanWin = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare double @mCos(double noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @mWaveBlackmanWin(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  br label %7

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %14, label %10

10:                                               ; preds = %7
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = ptrtoint ptr %11 to i64
  %13 = icmp eq i64 %12, -1
  br i1 %13, label %14, label %15

14:                                               ; preds = %10, %7
  br label %39

15:                                               ; preds = %10
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.MWave, ptr %16, i32 0, i32 2
  %18 = getelementptr inbounds [32 x ptr], ptr %17, i64 0, i64 0
  %19 = icmp eq ptr %18, null
  br i1 %19, label %36, label %20

20:                                               ; preds = %15
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.MWave, ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds [32 x ptr], ptr %22, i64 0, i64 0
  %24 = ptrtoint ptr %23 to i64
  %25 = icmp eq i64 %24, -1
  br i1 %25, label %36, label %26

26:                                               ; preds = %20
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MWave, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = icmp sle i32 %29, 0
  br i1 %30, label %36, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.MWave, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !12
  %35 = icmp sle i32 %34, 0
  br label %36

36:                                               ; preds = %31, %26, %20, %15
  %37 = phi i1 [ true, %26 ], [ true, %20 ], [ true, %15 ], [ %35, %31 ]
  %38 = zext i1 %37 to i32
  br label %39

39:                                               ; preds = %36, %14
  %40 = phi i32 [ 1, %14 ], [ %38, %36 ]
  store i32 %40, ptr %6, align 4, !tbaa !13
  %41 = load i32, ptr %6, align 4, !tbaa !13
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = load i32, ptr %6, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %44, i32 noundef -1, ptr noundef @.str, i32 noundef 65, ptr noundef @__FUNCTION__.mWaveBlackmanWin, ptr noundef @.str.1)
  br label %45

45:                                               ; preds = %43, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.MWave, ptr %48, i32 0, i32 1
  %50 = load i32, ptr %49, align 4, !tbaa !12
  store i32 %50, ptr %5, align 4, !tbaa !13
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %51

51:                                               ; preds = %95, %47
  %52 = load i32, ptr %3, align 4, !tbaa !13
  %53 = load i32, ptr %5, align 4, !tbaa !13
  %54 = sdiv i32 %53, 2
  %55 = icmp slt i32 %52, %54
  br i1 %55, label %56, label %98

56:                                               ; preds = %51
  %57 = load i32, ptr %3, align 4, !tbaa !13
  %58 = mul nsw i32 360, %57
  %59 = sitofp i32 %58 to float
  %60 = load i32, ptr %5, align 4, !tbaa !13
  %61 = sitofp i32 %60 to float
  %62 = fdiv float %59, %61
  %63 = fpext float %62 to double
  %64 = call double @mCos(double noundef %63)
  %65 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %64, double 0x3FDAE147A0000000)
  %66 = load i32, ptr %3, align 4, !tbaa !13
  %67 = sitofp i32 %66 to float
  %68 = fmul float 7.200000e+02, %67
  %69 = load i32, ptr %5, align 4, !tbaa !13
  %70 = sitofp i32 %69 to float
  %71 = fdiv float %68, %70
  %72 = fpext float %71 to double
  %73 = call double @mCos(double noundef %72)
  %74 = call double @llvm.fmuladd.f64(double 0x3FB47AE140000000, double %73, double %65)
  %75 = fptrunc double %74 to float
  store float %75, ptr %4, align 4, !tbaa !14
  %76 = load float, ptr %4, align 4, !tbaa !14
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.MWave, ptr %77, i32 0, i32 2
  %79 = getelementptr inbounds [32 x ptr], ptr %78, i64 0, i64 0
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = load i32, ptr %3, align 4, !tbaa !13
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds float, ptr %80, i64 %82
  store float %76, ptr %83, align 4, !tbaa !14
  %84 = load float, ptr %4, align 4, !tbaa !14
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.MWave, ptr %85, i32 0, i32 2
  %87 = getelementptr inbounds [32 x ptr], ptr %86, i64 0, i64 0
  %88 = load ptr, ptr %87, align 8, !tbaa !5
  %89 = load i32, ptr %5, align 4, !tbaa !13
  %90 = sub nsw i32 %89, 1
  %91 = load i32, ptr %3, align 4, !tbaa !13
  %92 = sub nsw i32 %90, %91
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds float, ptr %88, i64 %93
  store float %84, ptr %94, align 4, !tbaa !14
  br label %95

95:                                               ; preds = %56
  %96 = load i32, ptr %3, align 4, !tbaa !13
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %3, align 4, !tbaa !13
  br label %51, !llvm.loop !16

98:                                               ; preds = %51
  %99 = load i32, ptr %3, align 4, !tbaa !13
  %100 = mul nsw i32 360, %99
  %101 = sitofp i32 %100 to float
  %102 = load i32, ptr %5, align 4, !tbaa !13
  %103 = sitofp i32 %102 to float
  %104 = fdiv float %101, %103
  %105 = fpext float %104 to double
  %106 = call double @mCos(double noundef %105)
  %107 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %106, double 0x3FDAE147A0000000)
  %108 = load i32, ptr %3, align 4, !tbaa !13
  %109 = sitofp i32 %108 to float
  %110 = fmul float 7.200000e+02, %109
  %111 = load i32, ptr %5, align 4, !tbaa !13
  %112 = sitofp i32 %111 to float
  %113 = fdiv float %110, %112
  %114 = fpext float %113 to double
  %115 = call double @mCos(double noundef %114)
  %116 = call double @llvm.fmuladd.f64(double 0x3FB47AE140000000, double %115, double %107)
  %117 = fptrunc double %116 to float
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.MWave, ptr %118, i32 0, i32 2
  %120 = getelementptr inbounds [32 x ptr], ptr %119, i64 0, i64 0
  %121 = load ptr, ptr %120, align 8, !tbaa !5
  %122 = load i32, ptr %3, align 4, !tbaa !13
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds float, ptr %121, i64 %123
  store float %117, ptr %124, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"MWave", !11, i64 0, !11, i64 4, !7, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

@.str = external hidden unnamed_addr constant [87 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [14 x i8], align 1
@__FUNCTION__.mWaveBlackmanWin = external hidden unnamed_addr constant [17 x i8], align 1

declare void @m_Exception(i32 noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

declare double @mCos(double noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @mWaveBlackmanWin(ptr noundef %0) local_unnamed_addr #2 {
  %magicptr = ptrtoint ptr %0 to i64
  switch i64 %magicptr, label %2 [
    i64 -1, label %.critedge
    i64 0, label %.critedge
  ]

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = icmp eq ptr %3, inttoptr (i64 -1 to ptr)
  br i1 %4, label %.critedge, label %5

5:                                                ; preds = %2
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = icmp slt i32 %6, 1
  br i1 %7, label %.critedge, label %8

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !10
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %.critedge

.critedge:                                        ; preds = %1, %1, %5, %2, %8
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 65, ptr noundef nonnull @__FUNCTION__.mWaveBlackmanWin, ptr noundef nonnull @.str.1) #3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !10
  br label %12

12:                                               ; preds = %.critedge, %8
  %13 = phi i32 [ %.pre, %.critedge ], [ %10, %8 ]
  %14 = sdiv i32 %13, 2
  %15 = icmp sgt i32 %13, 1
  br i1 %15, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %12
  %.pre39 = sitofp i32 %13 to float
  br label %._crit_edge

.lr.ph:                                           ; preds = %12
  %16 = uitofp nneg i32 %13 to float
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = zext nneg i32 %13 to i64
  %wide.trip.count = zext nneg i32 %14 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %20 = trunc i64 %indvars.iv to i32
  %21 = mul i32 %20, 360
  %22 = uitofp nneg i32 %21 to float
  %23 = fdiv float %22, %16
  %24 = fpext float %23 to double
  %25 = tail call double @mCos(double noundef %24) #3
  %26 = tail call double @llvm.fmuladd.f64(double %25, double -5.000000e-01, double 0x3FDAE147A0000000)
  %27 = trunc nuw nsw i64 %indvars.iv to i32
  %28 = uitofp nneg i32 %27 to float
  %29 = fmul float %28, 7.200000e+02
  %30 = fdiv float %29, %16
  %31 = fpext float %30 to double
  %32 = tail call double @mCos(double noundef %31) #3
  %33 = tail call double @llvm.fmuladd.f64(double %32, double 0x3FB47AE140000000, double %26)
  %34 = fptrunc double %33 to float
  %35 = load ptr, ptr %17, align 8, !tbaa !11
  %36 = getelementptr inbounds float, ptr %35, i64 %indvars.iv
  store float %34, ptr %36, align 4, !tbaa !13
  %37 = xor i64 %indvars.iv, -1
  %38 = getelementptr float, ptr %35, i64 %18
  %39 = getelementptr float, ptr %38, i64 %37
  store float %34, ptr %39, align 4, !tbaa !13
  %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, label %19, !llvm.loop !15

._crit_edge:                                      ; preds = %19, %.._crit_edge_crit_edge
  %.pre-phi = phi float [ %.pre39, %.._crit_edge_crit_edge ], [ %16, %19 ]
  %.0.lcssa = phi i32 [ 0, %.._crit_edge_crit_edge ], [ %14, %19 ]
  %40 = mul nuw nsw i32 %.0.lcssa, 360
  %41 = uitofp nneg i32 %40 to float
  %42 = fdiv float %41, %.pre-phi
  %43 = fpext float %42 to double
  %44 = tail call double @mCos(double noundef %43) #3
  %45 = tail call double @llvm.fmuladd.f64(double %44, double -5.000000e-01, double 0x3FDAE147A0000000)
  %46 = uitofp nneg i32 %.0.lcssa to float
  %47 = fmul float %46, 7.200000e+02
  %48 = fdiv float %47, %.pre-phi
  %49 = fpext float %48 to double
  %50 = tail call double @mCos(double noundef %49) #3
  %51 = tail call double @llvm.fmuladd.f64(double %50, double 0x3FB47AE140000000, double %45)
  %52 = fptrunc double %51 to float
  %53 = getelementptr inbounds i8, ptr %0, i64 8
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = zext nneg i32 %.0.lcssa to i64
  %56 = getelementptr inbounds float, ptr %54, i64 %55
  store float %52, ptr %56, align 4, !tbaa !13
  ret void
}

attributes #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 nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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, !7, i64 0}
!6 = !{!"MWave", !7, i64 0, !7, i64 4, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass