; 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] }
%struct.MHandle = type { i32, i32, ptr, ptr }
%struct.HandleWaveWithWindow = type { ptr, 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__.mWaveWindow = external hidden unnamed_addr constant [12 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
declare dso_local void @mWaveHammingWin(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @endWaveWithWindow(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @mWaveWindow(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  br label %10

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

13:                                               ; preds = %10
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = ptrtoint ptr %14 to i64
  %16 = icmp eq i64 %15, -1
  br i1 %16, label %17, label %18

17:                                               ; preds = %13, %10
  br label %42

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

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

29:                                               ; preds = %23
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.MWave, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = icmp sle i32 %32, 0
  br i1 %33, label %39, label %34

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

39:                                               ; preds = %34, %29, %23, %18
  %40 = phi i1 [ true, %29 ], [ true, %23 ], [ true, %18 ], [ %38, %34 ]
  %41 = zext i1 %40 to i32
  br label %42

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

46:                                               ; preds = %42
  %47 = load i32, ptr %7, align 4, !tbaa !13
  call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef %47, i32 noundef -1, ptr noundef @.str, i32 noundef 92, ptr noundef @__FUNCTION__.mWaveWindow, ptr noundef @.str.1)
  br label %48

48:                                               ; preds = %46, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call ptr @GetHandle(ptr noundef %50, i32 noundef 16, i32 noundef 1640510978, ptr noundef @endWaveWithWindow)
  store ptr %51, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.MHandle, ptr %52, i32 0, i32 3
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  store ptr %54, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.MHandle, ptr %55, i32 0, i32 1
  %57 = load volatile i32, ptr %56, align 4, !tbaa !16
  %58 = icmp eq i32 %57, 0
  br i1 %58, label %65, label %59

59:                                               ; preds = %49
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  %64 = icmp ne ptr %60, %63
  br i1 %64, label %65, label %95

65:                                               ; preds = %59, %49
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %66, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !19
  %69 = icmp eq ptr %68, null
  br i1 %69, label %70, label %77

70:                                               ; preds = %65
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.MWave, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !12
  %74 = call ptr @mWaveCreate(i32 noundef 1, i32 noundef %73, ptr noundef null)
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %75, i32 0, i32 1
  store ptr %74, ptr %76, align 8, !tbaa !19
  br label %84

77:                                               ; preds = %65
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MWave, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !12
  call void @mWaveRedefine(ptr noundef %80, i32 noundef 1, i32 noundef %83, ptr noundef null)
  br label %84

84:                                               ; preds = %77, %70
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = icmp eq ptr %85, null
  br i1 %86, label %87, label %88

87:                                               ; preds = %84
  store ptr @mWaveHammingWin, ptr %6, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %87, %84
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !19
  call void %89(ptr noundef %92)
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.MHandle, ptr %93, i32 0, i32 1
  store volatile i32 1, ptr %94, align 4, !tbaa !16
  br label %95

95:                                               ; preds = %88, %59
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.HandleWaveWithWindow, ptr %97, i32 0, i32 1
  %99 = load ptr, ptr %98, align 8, !tbaa !19
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mWaveMul(ptr noundef %96, ptr noundef %99, ptr noundef %100)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  ret void
}

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

declare ptr @mWaveCreate(i32 noundef, i32 noundef, ptr noundef) #1

declare void @mWaveRedefine(ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

declare void @mWaveMul(ptr noundef, ptr noundef, ptr noundef) #1

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, !6, i64 16}
!15 = !{!"MHandle", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!16 = !{!15, !11, i64 4}
!17 = !{!18, !6, i64 0}
!18 = !{!"HandleWaveWithWindow", !6, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 8}


; 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__.mWaveWindow = external hidden unnamed_addr constant [12 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
declare dso_local void @mWaveHammingWin(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @endWaveWithWindow(ptr noundef) #1

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

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

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

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

.critedge:                                        ; preds = %3, %3, %7, %4, %10
  tail call void (i32, i32, ptr, i32, ptr, ptr, ...) @m_Exception(i32 noundef 1, i32 noundef -1, ptr noundef nonnull @.str, i32 noundef 92, ptr noundef nonnull @__FUNCTION__.mWaveWindow, ptr noundef nonnull @.str.1) #2
  br label %14

14:                                               ; preds = %.critedge, %10
  %15 = tail call ptr @GetHandle(ptr noundef %0, i32 noundef 16, i32 noundef 1640510978, ptr noundef nonnull @endWaveWithWindow) #2
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %15, i64 4
  %19 = load volatile i32, ptr %18, align 4, !tbaa !14
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %23, label %21

21:                                               ; preds = %14
  %22 = load ptr, ptr %17, align 8, !tbaa !15
  %.not33 = icmp eq ptr %22, %2
  br i1 %.not33, label %35, label %23

23:                                               ; preds = %21, %14
  %24 = getelementptr inbounds i8, ptr %17, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = icmp eq ptr %25, null
  %27 = getelementptr inbounds i8, ptr %0, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !10
  br i1 %26, label %29, label %31

29:                                               ; preds = %23
  %30 = tail call ptr @mWaveCreate(i32 noundef 1, i32 noundef %28, ptr noundef null) #2
  store ptr %30, ptr %24, align 8, !tbaa !17
  br label %32

31:                                               ; preds = %23
  tail call void @mWaveRedefine(ptr noundef nonnull %25, i32 noundef 1, i32 noundef %28, ptr noundef null) #2
  %.pre = load ptr, ptr %24, align 8, !tbaa !17
  br label %32

32:                                               ; preds = %31, %29
  %33 = phi ptr [ %.pre, %31 ], [ %30, %29 ]
  %34 = icmp eq ptr %2, null
  %spec.store.select = select i1 %34, ptr @mWaveHammingWin, ptr %2
  tail call void %spec.store.select(ptr noundef %33) #2
  store volatile i32 1, ptr %18, align 4, !tbaa !14
  br label %35

35:                                               ; preds = %32, %21
  %36 = getelementptr inbounds i8, ptr %17, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  tail call void @mWaveMul(ptr noundef %0, ptr noundef %37, ptr noundef %1) #2
  ret void
}

declare ptr @GetHandle(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @mWaveCreate(i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

declare void @mWaveMul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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, !13, i64 16}
!12 = !{!"MHandle", !7, i64 0, !7, i64 4, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!12, !7, i64 4}
!15 = !{!16, !13, i64 0}
!16 = !{!"HandleWaveWithWindow", !13, i64 0, !13, i64 8}
!17 = !{!16, !13, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass