; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (ampmodem)

; 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.ampmodem_s = type { float, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }

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

; 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 i32 @ampmodem_modulate(ptr noundef %0, float noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %8 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float 0.000000e+00, ptr %8, align 4
  store float 0.000000e+00, ptr %9, align 4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ampmodem_s, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !11
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %18

14:                                               ; preds = %3
  %15 = load float, ptr %5, align 4, !tbaa !9
  %16 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %17 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %15, ptr %16, align 4
  store float 0.000000e+00, ptr %17, align 4
  br label %37

18:                                               ; preds = %3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ampmodem_s, ptr %19, i32 0, i32 6
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = load float, ptr %5, align 4, !tbaa !9
  %23 = call i32 @firhilbf_r2c_execute(ptr noundef %21, float noundef %22, ptr noundef %7)
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ampmodem_s, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !11
  %27 = icmp eq i32 %26, 2
  br i1 %27, label %28, label %36

28:                                               ; preds = %18
  %29 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %32 = load float, ptr %31, align 4
  %33 = fneg float %32
  %34 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %35 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %30, ptr %34, align 4
  store float %33, ptr %35, align 4
  br label %36

36:                                               ; preds = %28, %18
  br label %37

37:                                               ; preds = %36, %14
  %38 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %39 = load float, ptr %38, align 4
  %40 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %41 = load float, ptr %40, align 4
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ampmodem_s, ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 8, !tbaa !15
  %45 = fmul float %39, %44
  %46 = fmul float %41, %44
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ampmodem_s, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = icmp ne i32 %49, 0
  %51 = zext i1 %50 to i64
  %52 = select i1 %50, float 0.000000e+00, float 1.000000e+00
  %53 = fadd float %45, %52
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 1
  store float %53, ptr %55, align 4
  store float %46, ptr %56, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

declare i32 @firhilbf_r2c_execute(ptr noundef, float noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"ampmodem_s", !10, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 32}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !13, 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"

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

; Function Attrs: mustprogress 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 noundef i32 @ampmodem_modulate(ptr nocapture noundef readonly %0, float noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca { float, float }, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store <2 x float> zeroinitializer, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %3
  store float %1, ptr %4, align 8
  br label %18

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %4, i64 4
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = call i32 @firhilbf_r2c_execute(ptr noundef %12, float noundef %1, ptr noundef nonnull %4) #3
  %14 = load i32, ptr %5, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 2
  %.pre = load float, ptr %10, align 4
  br i1 %15, label %16, label %18

16:                                               ; preds = %9
  %17 = fneg float %.pre
  br label %18

18:                                               ; preds = %9, %16, %8
  %19 = phi float [ %.pre, %9 ], [ %17, %16 ], [ 0.000000e+00, %8 ]
  %20 = load float, ptr %4, align 8
  %21 = load float, ptr %0, align 8, !tbaa !13
  %22 = fmul float %20, %21
  %23 = fmul float %19, %21
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %.not = icmp eq i32 %25, 0
  %26 = select i1 %.not, float 1.000000e+00, float 0.000000e+00
  %27 = fadd float %22, %26
  %28 = getelementptr inbounds i8, ptr %2, i64 4
  store float %27, ptr %2, align 4
  store float %23, ptr %28, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

declare i32 @firhilbf_r2c_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 4}
!6 = !{!"ampmodem_s", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 8}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass