; 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__.mWaveHammingWin = external hidden unnamed_addr constant [16 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 @mWaveHammingWin(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  br label %7

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #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 %4, align 4, !tbaa !13
  %41 = load i32, ptr %4, align 4, !tbaa !13
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %45

43:                                               ; preds = %39
  %44 = load i32, ptr %4, 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 30, ptr noundef @__FUNCTION__.mWaveHammingWin, ptr noundef @.str.1)
  br label %45

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

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %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 = %86, %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 %89

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %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 0xBFDD70A3E0000000, double %64, double 0x3FE147AE20000000)
  %66 = fptrunc double %65 to float
  store float %66, ptr %6, align 4, !tbaa !14
  %67 = load float, ptr %6, align 4, !tbaa !14
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.MWave, ptr %68, i32 0, i32 2
  %70 = getelementptr inbounds [32 x ptr], ptr %69, i64 0, i64 0
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = load i32, ptr %3, align 4, !tbaa !13
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %71, i64 %73
  store float %67, ptr %74, align 4, !tbaa !14
  %75 = load float, ptr %6, align 4, !tbaa !14
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MWave, ptr %76, i32 0, i32 2
  %78 = getelementptr inbounds [32 x ptr], ptr %77, i64 0, i64 0
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !13
  %81 = sub nsw i32 %80, 1
  %82 = load i32, ptr %3, align 4, !tbaa !13
  %83 = sub nsw i32 %81, %82
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds float, ptr %79, i64 %84
  store float %75, ptr %85, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %86

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

89:                                               ; preds = %51
  %90 = load i32, ptr %3, align 4, !tbaa !13
  %91 = mul nsw i32 360, %90
  %92 = sitofp i32 %91 to float
  %93 = load i32, ptr %5, align 4, !tbaa !13
  %94 = sitofp i32 %93 to float
  %95 = fdiv float %92, %94
  %96 = fpext float %95 to double
  %97 = call double @mCos(double noundef %96)
  %98 = call double @llvm.fmuladd.f64(double 0xBFDD70A3E0000000, double %97, double 0x3FE147AE20000000)
  %99 = fptrunc double %98 to float
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.MWave, ptr %100, i32 0, i32 2
  %102 = getelementptr inbounds [32 x ptr], ptr %101, i64 0, i64 0
  %103 = load ptr, ptr %102, align 8, !tbaa !5
  %104 = load i32, ptr %3, align 4, !tbaa !13
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds float, ptr %103, i64 %105
  store float %99, ptr %106, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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__.mWaveHammingWin = external hidden unnamed_addr constant [16 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 @mWaveHammingWin(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 30, ptr noundef nonnull @__FUNCTION__.mWaveHammingWin, 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
  %.pre35 = 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 0xBFDD70A3E0000000, double 0x3FE147AE20000000)
  %27 = fptrunc double %26 to float
  %28 = load ptr, ptr %17, align 8, !tbaa !11
  %29 = getelementptr inbounds float, ptr %28, i64 %indvars.iv
  store float %27, ptr %29, align 4, !tbaa !13
  %30 = xor i64 %indvars.iv, -1
  %31 = getelementptr float, ptr %28, i64 %18
  %32 = getelementptr float, ptr %31, i64 %30
  store float %27, ptr %32, 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 [ %.pre35, %.._crit_edge_crit_edge ], [ %16, %19 ]
  %.0.lcssa = phi i32 [ 0, %.._crit_edge_crit_edge ], [ %14, %19 ]
  %33 = mul nuw nsw i32 %.0.lcssa, 360
  %34 = uitofp nneg i32 %33 to float
  %35 = fdiv float %34, %.pre-phi
  %36 = fpext float %35 to double
  %37 = tail call double @mCos(double noundef %36) #3
  %38 = tail call double @llvm.fmuladd.f64(double %37, double 0xBFDD70A3E0000000, double 0x3FE147AE20000000)
  %39 = fptrunc double %38 to float
  %40 = getelementptr inbounds i8, ptr %0, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = zext nneg i32 %.0.lcssa to i64
  %43 = getelementptr inbounds float, ptr %41, i64 %42
  store float %39, ptr %43, 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