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

; 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.modemcf_s = type { i32, i32, i32, [8 x float], ptr, i32, { float, float }, { float, float }, %union.anon, ptr, ptr, ptr, i32 }
%union.anon = type { %struct.anon.3 }
%struct.anon.3 = type { i32, [8 x i32], [8 x float], [8 x float], [8 x float], ptr }
%struct.anon.0 = type { float, float, float }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @modemcf_create_dpsk(i32 noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %7 = call noalias ptr @malloc(i64 noundef 256) #6
  store ptr %7, ptr %4, align 8, !tbaa !9
  %8 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %8, label %33 [
    i32 1, label %9
    i32 2, label %12
    i32 3, label %15
    i32 4, label %18
    i32 5, label %21
    i32 6, label %24
    i32 7, label %27
    i32 8, label %30
  ]

9:                                                ; preds = %1
  %10 = load ptr, ptr %4, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.modemcf_s, ptr %10, i32 0, i32 0
  store i32 9, ptr %11, align 8, !tbaa !11
  br label %35

12:                                               ; preds = %1
  %13 = load ptr, ptr %4, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.modemcf_s, ptr %13, i32 0, i32 0
  store i32 10, ptr %14, align 8, !tbaa !11
  br label %35

15:                                               ; preds = %1
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.modemcf_s, ptr %16, i32 0, i32 0
  store i32 11, ptr %17, align 8, !tbaa !11
  br label %35

18:                                               ; preds = %1
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.modemcf_s, ptr %19, i32 0, i32 0
  store i32 12, ptr %20, align 8, !tbaa !11
  br label %35

21:                                               ; preds = %1
  %22 = load ptr, ptr %4, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.modemcf_s, ptr %22, i32 0, i32 0
  store i32 13, ptr %23, align 8, !tbaa !11
  br label %35

24:                                               ; preds = %1
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.modemcf_s, ptr %25, i32 0, i32 0
  store i32 14, ptr %26, align 8, !tbaa !11
  br label %35

27:                                               ; preds = %1
  %28 = load ptr, ptr %4, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.modemcf_s, ptr %28, i32 0, i32 0
  store i32 15, ptr %29, align 8, !tbaa !11
  br label %35

30:                                               ; preds = %1
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.modemcf_s, ptr %31, i32 0, i32 0
  store i32 16, ptr %32, align 8, !tbaa !11
  br label %35

33:                                               ; preds = %1
  %34 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.17, i32 noundef 42, ptr noundef @.str.18, ptr noundef @.str.2)
  store ptr %34, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %95

35:                                               ; preds = %30, %27, %24, %21, %18, %15, %12, %9
  %36 = load ptr, ptr %4, align 8, !tbaa !9
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = call i32 @modemcf_init(ptr noundef %36, i32 noundef %37)
  %39 = load ptr, ptr %4, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.modemcf_s, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = uitofp i32 %41 to float
  %43 = fpext float %42 to double
  %44 = fdiv double 0x400921FB54442D18, %43
  %45 = fptrunc double %44 to float
  %46 = load ptr, ptr %4, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.modemcf_s, ptr %46, i32 0, i32 8
  %48 = getelementptr inbounds %struct.anon.0, ptr %47, i32 0, i32 2
  store float %45, ptr %48, align 8, !tbaa !14
  %49 = load ptr, ptr %4, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.modemcf_s, ptr %49, i32 0, i32 8
  %51 = getelementptr inbounds %struct.anon.0, ptr %50, i32 0, i32 1
  store float 0.000000e+00, ptr %51, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %72, %35
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.modemcf_s, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !15
  %57 = icmp ult i32 %53, %56
  br i1 %57, label %58, label %75

58:                                               ; preds = %52
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = shl i32 1, %59
  %61 = sitofp i32 %60 to float
  %62 = load ptr, ptr %4, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.modemcf_s, ptr %62, i32 0, i32 8
  %64 = getelementptr inbounds %struct.anon.0, ptr %63, i32 0, i32 2
  %65 = load float, ptr %64, align 8, !tbaa !14
  %66 = fmul float %61, %65
  %67 = load ptr, ptr %4, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.modemcf_s, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds [8 x float], ptr %68, i64 0, i64 %70
  store float %66, ptr %71, align 4, !tbaa !16
  br label %72

72:                                               ; preds = %58
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = add i32 %73, 1
  store i32 %74, ptr %6, align 4, !tbaa !5
  br label %52, !llvm.loop !18

75:                                               ; preds = %52
  %76 = load ptr, ptr %4, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.modemcf_s, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 8, !tbaa !13
  %79 = uitofp i32 %78 to float
  %80 = fdiv float 1.000000e+00, %79
  %81 = fsub float 1.000000e+00, %80
  %82 = fpext float %81 to double
  %83 = fmul double 0x400921FB54442D18, %82
  %84 = fptrunc double %83 to float
  %85 = load ptr, ptr %4, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct.modemcf_s, ptr %85, i32 0, i32 8
  %87 = getelementptr inbounds %struct.anon.0, ptr %86, i32 0, i32 0
  store float %84, ptr %87, align 8, !tbaa !14
  %88 = load ptr, ptr %4, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.modemcf_s, ptr %88, i32 0, i32 9
  store ptr @modemcf_modulate_dpsk, ptr %89, align 8, !tbaa !20
  %90 = load ptr, ptr %4, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.modemcf_s, ptr %90, i32 0, i32 10
  store ptr @modemcf_demodulate_dpsk, ptr %91, align 8, !tbaa !21
  %92 = load ptr, ptr %4, align 8, !tbaa !9
  %93 = call i32 @modemcf_reset(ptr noundef %92)
  %94 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %94, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %95

95:                                               ; preds = %75, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %96 = load ptr, ptr %2, align 8
  ret ptr %96
}

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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

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

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

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

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

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"modemcf_s", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !10, i64 48, !6, i64 56, !7, i64 60, !7, i64 68, !7, i64 80, !10, i64 224, !10, i64 232, !10, i64 240, !6, i64 248}
!13 = !{!12, !6, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!12, !6, i64 4}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!12, !10, i64 224}
!21 = !{!12, !10, i64 232}


; 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.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @modemcf_create_dpsk(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call noalias dereferenceable_or_null(256) ptr @malloc(i64 noundef 256) #4
  %switch.tableidx = add i32 %0, -1
  %3 = icmp ult i32 %switch.tableidx, 8
  br i1 %3, label %switch.lookup, label %4

4:                                                ; preds = %1
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.17, i32 noundef 42, ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2) #5
  br label %47

switch.lookup:                                    ; preds = %1
  %switch.offset = add nuw nsw i32 %0, 8
  store i32 %switch.offset, ptr %2, align 8, !tbaa !5
  %6 = tail call i32 @modemcf_init(ptr noundef nonnull %2, i32 noundef %0)
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = uitofp i32 %8 to float
  %10 = fpext float %9 to double
  %11 = fdiv double 0x400921FB54442D18, %10
  %12 = fptrunc double %11 to float
  %13 = getelementptr inbounds i8, ptr %2, i64 80
  %14 = getelementptr inbounds i8, ptr %2, i64 88
  store float %12, ptr %14, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %2, i64 84
  store float 0.000000e+00, ptr %15, align 4, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !13
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %switch.lookup
  %18 = getelementptr inbounds i8, ptr %2, i64 12
  %wide.trip.count = zext i32 %17 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %19 = icmp eq i32 %17, 1
  br i1 %19, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

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

20:                                               ; preds = %20, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %20 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %20 ]
  %21 = trunc nuw i64 %indvars.iv to i32
  %22 = shl nuw i32 1, %21
  %23 = uitofp nneg i32 %22 to float
  %24 = load float, ptr %14, align 8, !tbaa !12
  %25 = fmul float %24, %23
  %26 = getelementptr inbounds [8 x float], ptr %18, i64 0, i64 %indvars.iv
  store float %25, ptr %26, align 4, !tbaa !14
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %27 = trunc nuw i64 %indvars.iv.next to i32
  %28 = shl nuw i32 1, %27
  %29 = sitofp i32 %28 to float
  %30 = load float, ptr %14, align 8, !tbaa !12
  %31 = fmul float %30, %29
  %32 = getelementptr inbounds [8 x float], ptr %18, i64 0, i64 %indvars.iv.next
  store float %31, ptr %32, align 4, !tbaa !14
  %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 %20, !llvm.loop !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %20, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %20 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %33 = trunc nuw i64 %indvars.iv.unr to i32
  %34 = shl nuw i32 1, %33
  %35 = sitofp i32 %34 to float
  %36 = load float, ptr %14, align 8, !tbaa !12
  %37 = fmul float %36, %35
  %38 = getelementptr inbounds [8 x float], ptr %18, i64 0, i64 %indvars.iv.unr
  store float %37, ptr %38, align 4, !tbaa !14
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %switch.lookup
  %39 = fdiv float 1.000000e+00, %9
  %40 = fsub float 1.000000e+00, %39
  %41 = fpext float %40 to double
  %42 = fmul double %41, 0x400921FB54442D18
  %43 = fptrunc double %42 to float
  store float %43, ptr %13, align 8, !tbaa !12
  %44 = getelementptr inbounds i8, ptr %2, i64 224
  store ptr @modemcf_modulate_dpsk, ptr %44, align 8, !tbaa !18
  %45 = getelementptr inbounds i8, ptr %2, i64 232
  store ptr @modemcf_demodulate_dpsk, ptr %45, align 8, !tbaa !19
  %46 = tail call i32 @modemcf_reset(ptr noundef nonnull %2)
  br label %47

47:                                               ; preds = %._crit_edge, %4
  %.027 = phi ptr [ %5, %4 ], [ %2, %._crit_edge ]
  ret ptr %.027
}

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

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

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

; 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

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

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

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 allocsize(0) }
attributes #5 = { 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 = !{!"modemcf_s", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !10, i64 48, !7, i64 56, !8, i64 60, !8, i64 68, !8, i64 80, !10, i64 224, !10, i64 232, !10, i64 240, !7, i64 248}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!8, !8, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 224}
!19 = !{!6, !10, i64 232}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass