; 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 }

@.str = external hidden unnamed_addr constant [79 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @ampmodem_create(float noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store float %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %9 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %9, label %11 [
    i32 0, label %10
    i32 1, label %10
    i32 2, label %10
  ]

10:                                               ; preds = %3, %3, %3
  br label %14

11:                                               ; preds = %3
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 77, ptr noundef @.str.1, i32 noundef %12)
  store ptr %13, ptr %4, align 8
  br label %90

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %15 = call noalias ptr @malloc(i64 noundef 64) #6
  store ptr %15, ptr %8, align 8, !tbaa !11
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %8, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.ampmodem_s, ptr %17, i32 0, i32 1
  store i32 %16, ptr %18, align 4, !tbaa !13
  %19 = load float, ptr %5, align 4, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.ampmodem_s, ptr %20, i32 0, i32 0
  store float %19, ptr %21, align 8, !tbaa !15
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  %24 = zext i1 %23 to i32
  %25 = load ptr, ptr %8, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.ampmodem_s, ptr %25, i32 0, i32 2
  store i32 %24, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %8, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.ampmodem_s, ptr %27, i32 0, i32 3
  store i32 25, ptr %28, align 4, !tbaa !17
  %29 = call ptr @nco_crcf_create(i32 noundef 0)
  %30 = load ptr, ptr %8, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.ampmodem_s, ptr %30, i32 0, i32 4
  store ptr %29, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %8, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.ampmodem_s, ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  %35 = call i32 @nco_crcf_pll_set_bandwidth(ptr noundef %34, float noundef 0x3F50624DE0000000)
  %36 = load ptr, ptr %8, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct.ampmodem_s, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 4, !tbaa !17
  %39 = call ptr @firfilt_rrrf_create_dc_blocker(i32 noundef %38, float noundef 2.000000e+01)
  %40 = load ptr, ptr %8, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.ampmodem_s, ptr %40, i32 0, i32 5
  store ptr %39, ptr %41, align 8, !tbaa !19
  %42 = load ptr, ptr %8, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct.ampmodem_s, ptr %42, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !17
  %45 = call ptr @firhilbf_create(i32 noundef %44, float noundef 6.000000e+01)
  %46 = load ptr, ptr %8, align 8, !tbaa !11
  %47 = getelementptr inbounds %struct.ampmodem_s, ptr %46, i32 0, i32 6
  store ptr %45, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %8, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.ampmodem_s, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = mul i32 2, %50
  %52 = add i32 %51, 1
  %53 = call ptr @firfilt_crcf_create_kaiser(i32 noundef %52, float noundef 0x3F847AE140000000, float noundef 4.000000e+01, float noundef 0.000000e+00)
  %54 = load ptr, ptr %8, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.ampmodem_s, ptr %54, i32 0, i32 7
  store ptr %53, ptr %55, align 8, !tbaa !21
  %56 = load ptr, ptr %8, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.ampmodem_s, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !17
  %59 = call ptr @wdelaycf_create(i32 noundef %58)
  %60 = load ptr, ptr %8, align 8, !tbaa !11
  %61 = getelementptr inbounds %struct.ampmodem_s, ptr %60, i32 0, i32 8
  store ptr %59, ptr %61, align 8, !tbaa !22
  %62 = load ptr, ptr %8, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.ampmodem_s, ptr %62, i32 0, i32 9
  store ptr null, ptr %63, align 8, !tbaa !23
  %64 = load ptr, ptr %8, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct.ampmodem_s, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !13
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %77

68:                                               ; preds = %14
  %69 = load ptr, ptr %8, align 8, !tbaa !11
  %70 = getelementptr inbounds %struct.ampmodem_s, ptr %69, i32 0, i32 2
  %71 = load i32, ptr %70, align 8, !tbaa !16
  %72 = icmp ne i32 %71, 0
  %73 = zext i1 %72 to i64
  %74 = select i1 %72, ptr @ampmodem_demod_dsb_pll_costas, ptr @ampmodem_demod_dsb_pll_carrier
  %75 = load ptr, ptr %8, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct.ampmodem_s, ptr %75, i32 0, i32 9
  store ptr %74, ptr %76, align 8, !tbaa !23
  br label %86

77:                                               ; preds = %14
  %78 = load ptr, ptr %8, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.ampmodem_s, ptr %78, i32 0, i32 2
  %80 = load i32, ptr %79, align 8, !tbaa !16
  %81 = icmp ne i32 %80, 0
  %82 = zext i1 %81 to i64
  %83 = select i1 %81, ptr @ampmodem_demod_ssb, ptr @ampmodem_demod_ssb_pll_carrier
  %84 = load ptr, ptr %8, align 8, !tbaa !11
  %85 = getelementptr inbounds %struct.ampmodem_s, ptr %84, i32 0, i32 9
  store ptr %83, ptr %85, align 8, !tbaa !23
  br label %86

86:                                               ; preds = %77, %68
  %87 = load ptr, ptr %8, align 8, !tbaa !11
  %88 = call i32 @ampmodem_reset(ptr noundef %87)
  %89 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %89, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %90

90:                                               ; preds = %86, %11
  %91 = load ptr, ptr %4, align 8
  ret ptr %91
}

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare ptr @nco_crcf_create(i32 noundef) #1

declare i32 @nco_crcf_pll_set_bandwidth(ptr noundef, float noundef) #1

declare ptr @firfilt_rrrf_create_dc_blocker(i32 noundef, float noundef) #1

declare ptr @firhilbf_create(i32 noundef, float noundef) #1

declare ptr @firfilt_crcf_create_kaiser(i32 noundef, float noundef, float noundef, float noundef) #1

declare ptr @wdelaycf_create(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_dsb_pll_costas(ptr noundef, <2 x float> noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_dsb_pll_carrier(ptr noundef, <2 x float> noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_ssb(ptr noundef, <2 x float> noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_ssb_pll_carrier(ptr noundef, <2 x float> noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_reset(ptr noundef) #0

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

attributes #0 = { 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 #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 willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(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 uwtable "min-legal-vector-width"="64" "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 4}
!14 = !{!"ampmodem_s", !6, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56}
!15 = !{!14, !6, i64 0}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !10, i64 12}
!18 = !{!14, !12, i64 16}
!19 = !{!14, !12, i64 24}
!20 = !{!14, !12, i64 32}
!21 = !{!14, !12, i64 40}
!22 = !{!14, !12, i64 48}
!23 = !{!14, !12, i64 56}


; 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 [79 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @ampmodem_create(float noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %switch = icmp ult i32 %1, 3
  br i1 %switch, label %6, label %4

4:                                                ; preds = %3
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 77, ptr noundef nonnull @.str.1, i32 noundef %1) #4
  br label %29

6:                                                ; preds = %3
  %7 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #5
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 %1, ptr %8, align 4, !tbaa !5
  store float %0, ptr %7, align 8, !tbaa !12
  %9 = icmp ne i32 %2, 0
  %10 = zext i1 %9 to i32
  %11 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %10, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %7, i64 12
  store i32 25, ptr %12, align 4, !tbaa !14
  %13 = tail call ptr @nco_crcf_create(i32 noundef 0) #4
  %14 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %13, ptr %14, align 8, !tbaa !15
  %15 = tail call i32 @nco_crcf_pll_set_bandwidth(ptr noundef %13, float noundef 0x3F50624DE0000000) #4
  %16 = tail call ptr @firfilt_rrrf_create_dc_blocker(i32 noundef 25, float noundef 2.000000e+01) #4
  %17 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %16, ptr %17, align 8, !tbaa !16
  %18 = tail call ptr @firhilbf_create(i32 noundef 25, float noundef 6.000000e+01) #4
  %19 = getelementptr inbounds i8, ptr %7, i64 32
  store ptr %18, ptr %19, align 8, !tbaa !17
  %20 = tail call ptr @firfilt_crcf_create_kaiser(i32 noundef 51, float noundef 0x3F847AE140000000, float noundef 4.000000e+01, float noundef 0.000000e+00) #4
  %21 = getelementptr inbounds i8, ptr %7, i64 40
  store ptr %20, ptr %21, align 8, !tbaa !18
  %22 = tail call ptr @wdelaycf_create(i32 noundef 25) #4
  %23 = getelementptr inbounds i8, ptr %7, i64 48
  store ptr %22, ptr %23, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %7, i64 56
  %25 = icmp eq i32 %1, 0
  %26 = select i1 %9, ptr @ampmodem_demod_ssb, ptr @ampmodem_demod_ssb_pll_carrier
  %27 = select i1 %9, ptr @ampmodem_demod_dsb_pll_costas, ptr @ampmodem_demod_dsb_pll_carrier
  %storemerge = select i1 %25, ptr %27, ptr %26
  store ptr %storemerge, ptr %24, align 8, !tbaa !20
  %28 = tail call i32 @ampmodem_reset(ptr noundef nonnull %7)
  br label %29

29:                                               ; preds = %6, %4
  %.0 = phi ptr [ %5, %4 ], [ %7, %6 ]
  ret ptr %.0
}

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

declare ptr @nco_crcf_create(i32 noundef) local_unnamed_addr #1

declare i32 @nco_crcf_pll_set_bandwidth(ptr noundef, float noundef) local_unnamed_addr #1

declare ptr @firfilt_rrrf_create_dc_blocker(i32 noundef, float noundef) local_unnamed_addr #1

declare ptr @firhilbf_create(i32 noundef, float noundef) local_unnamed_addr #1

declare ptr @firfilt_crcf_create_kaiser(i32 noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

declare ptr @wdelaycf_create(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_dsb_pll_costas(ptr noundef, <2 x float> noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_dsb_pll_carrier(ptr noundef, <2 x float> noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_ssb(ptr noundef, <2 x float> noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_demod_ssb_pll_carrier(ptr noundef, <2 x float> noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @ampmodem_reset(ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 uwtable "min-legal-vector-width"="64" "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 }
attributes #5 = { nounwind allocsize(0) }

!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, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !11, i64 16}
!16 = !{!6, !11, i64 24}
!17 = !{!6, !11, i64 32}
!18 = !{!6, !11, i64 40}
!19 = !{!6, !11, i64 48}
!20 = !{!6, !11, i64 56}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass