; 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__.mWaveFejerWin = external hidden unnamed_addr constant [14 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

; Function Attrs: nounwind uwtable
define dso_local void @mWaveFejerWin(ptr noundef %0) #2 {
  %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
  %7 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  br label %8

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

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

15:                                               ; preds = %11, %8
  br label %40

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

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

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

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

37:                                               ; preds = %32, %27, %21, %16
  %38 = phi i1 [ true, %27 ], [ true, %21 ], [ true, %16 ], [ %36, %32 ]
  %39 = zext i1 %38 to i32
  br label %40

40:                                               ; preds = %37, %15
  %41 = phi i32 [ 1, %15 ], [ %39, %37 ]
  store i32 %41, ptr %4, align 4, !tbaa !13
  %42 = load i32, ptr %4, align 4, !tbaa !13
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %40
  %45 = load i32, ptr %4, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %45, i32 noundef -1, ptr noundef @.str, i32 noundef 45, ptr noundef @__FUNCTION__.mWaveFejerWin, ptr noundef @.str.1)
  br label %46

46:                                               ; preds = %44, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MWave, ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !12
  store i32 %51, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store float 0.000000e+00, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %52 = load i32, ptr %5, align 4, !tbaa !13
  %53 = sitofp i32 %52 to float
  %54 = fdiv float 2.000000e+00, %53
  store float %54, ptr %7, align 4, !tbaa !14
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %55

55:                                               ; preds = %83, %48
  %56 = load i32, ptr %3, align 4, !tbaa !13
  %57 = load i32, ptr %5, align 4, !tbaa !13
  %58 = sdiv i32 %57, 2
  %59 = icmp slt i32 %56, %58
  br i1 %59, label %60, label %86

60:                                               ; preds = %55
  %61 = load float, ptr %6, align 4, !tbaa !14
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.MWave, ptr %62, i32 0, i32 2
  %64 = getelementptr inbounds [32 x ptr], ptr %63, i64 0, i64 0
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %3, align 4, !tbaa !13
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  store float %61, ptr %68, align 4, !tbaa !14
  %69 = load float, ptr %6, align 4, !tbaa !14
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.MWave, ptr %70, i32 0, i32 2
  %72 = getelementptr inbounds [32 x ptr], ptr %71, i64 0, i64 0
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load i32, ptr %5, align 4, !tbaa !13
  %75 = sub nsw i32 %74, 1
  %76 = load i32, ptr %3, align 4, !tbaa !13
  %77 = sub nsw i32 %75, %76
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %73, i64 %78
  store float %69, ptr %79, align 4, !tbaa !14
  %80 = load float, ptr %6, align 4, !tbaa !14
  %81 = load float, ptr %7, align 4, !tbaa !14
  %82 = fadd float %80, %81
  store float %82, ptr %6, align 4, !tbaa !14
  br label %83

83:                                               ; preds = %60
  %84 = load i32, ptr %3, align 4, !tbaa !13
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %3, align 4, !tbaa !13
  br label %55, !llvm.loop !16

86:                                               ; preds = %55
  %87 = load i32, ptr %5, align 4, !tbaa !13
  %88 = srem i32 %87, 2
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %99

90:                                               ; preds = %86
  %91 = load float, ptr %6, align 4, !tbaa !14
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.MWave, ptr %92, i32 0, i32 2
  %94 = getelementptr inbounds [32 x ptr], ptr %93, i64 0, i64 0
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  %96 = load i32, ptr %3, align 4, !tbaa !13
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds float, ptr %95, i64 %97
  store float %91, ptr %98, align 4, !tbaa !14
  br label %99

99:                                               ; preds = %90, %86
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  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 = { 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, !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__.mWaveFejerWin = external hidden unnamed_addr constant [14 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @mWaveFejerWin(ptr noundef %0) local_unnamed_addr #1 {
  %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 45, ptr noundef nonnull @__FUNCTION__.mWaveFejerWin, ptr noundef nonnull @.str.1) #2
  %.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 = sitofp i32 %13 to float
  %15 = fdiv float 2.000000e+00, %14
  %16 = sdiv i32 %13, 2
  %17 = icmp sgt i32 %13, 1
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %12
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = zext nneg i32 %13 to i64
  %wide.trip.count = zext nneg i32 %16 to i64
  %21 = getelementptr float, ptr %19, i64 %20
  %xtraiter = and i64 %wide.trip.count, 1
  %22 = and i32 %13, 2147483646
  %23 = icmp eq i32 %22, 2
  br i1 %23, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 1073741822
  br label %24

24:                                               ; preds = %24, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %24 ]
  %.03236 = phi float [ 0.000000e+00, %.lr.ph.new ], [ %32, %24 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %24 ]
  %25 = getelementptr inbounds float, ptr %19, i64 %indvars.iv
  store float %.03236, ptr %25, align 4, !tbaa !13
  %26 = xor i64 %indvars.iv, -1
  %27 = getelementptr float, ptr %21, i64 %26
  store float %.03236, ptr %27, align 4, !tbaa !13
  %28 = fadd float %15, %.03236
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %29 = getelementptr inbounds float, ptr %19, i64 %indvars.iv.next
  store float %28, ptr %29, align 4, !tbaa !13
  %30 = xor i64 %indvars.iv, -2
  %31 = getelementptr float, ptr %21, i64 %30
  store float %28, ptr %31, align 4, !tbaa !13
  %32 = fadd float %15, %28
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %24, !llvm.loop !15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %24, %.lr.ph
  %.lcssa.ph = phi float [ poison, %.lr.ph ], [ %32, %24 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %24 ]
  %.03236.unr = phi float [ 0.000000e+00, %.lr.ph ], [ %32, %24 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %33 = getelementptr inbounds float, ptr %19, i64 %indvars.iv.unr
  store float %.03236.unr, ptr %33, align 4, !tbaa !13
  %34 = xor i64 %indvars.iv.unr, -1
  %35 = getelementptr float, ptr %21, i64 %34
  store float %.03236.unr, ptr %35, align 4, !tbaa !13
  %36 = fadd float %15, %.03236.unr
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %._crit_edge.loopexit.unr-lcssa, %._crit_edge.loopexit.epilog-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %36, %._crit_edge.loopexit.epilog-lcssa ]
  %37 = zext nneg i32 %16 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %12
  %.032.lcssa = phi float [ 0.000000e+00, %12 ], [ %.lcssa, %._crit_edge.loopexit ]
  %.0.lcssa = phi i64 [ 0, %12 ], [ %37, %._crit_edge.loopexit ]
  %38 = and i32 %13, 1
  %.not35 = icmp eq i32 %38, 0
  br i1 %.not35, label %43, label %39

39:                                               ; preds = %._crit_edge
  %40 = getelementptr inbounds i8, ptr %0, i64 8
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = getelementptr inbounds float, ptr %41, i64 %.0.lcssa
  store float %.032.lcssa, ptr %42, align 4, !tbaa !13
  br label %43

43:                                               ; preds = %39, %._crit_edge
  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 = { 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, !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,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass