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

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

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

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

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

; Function Attrs: nounwind
declare float @sinf(float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_modulate_apsk(ptr noundef %0, i32 noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.modemcf_s, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp uge i32 %16, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %3
  %22 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 5, ptr noundef @.str.26, i32 noundef 99, ptr noundef @.str.28, ptr noundef @.str.2)
  store i32 %22, ptr %4, align 4
  br label %117

23:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.modemcf_s, ptr %24, i32 0, i32 8
  %26 = getelementptr inbounds %struct.anon.3, ptr %25, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %27, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = zext i8 %31 to i32
  store i32 %32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %64, %23
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.modemcf_s, ptr %35, i32 0, i32 8
  %37 = getelementptr inbounds %struct.anon.3, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = icmp ult i32 %34, %38
  br i1 %39, label %40, label %67

40:                                               ; preds = %33
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.modemcf_s, ptr %43, i32 0, i32 8
  %45 = getelementptr inbounds %struct.anon.3, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [8 x i32], ptr %45, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !13
  %50 = add i32 %42, %49
  %51 = icmp ult i32 %41, %50
  br i1 %51, label %52, label %54

52:                                               ; preds = %40
  %53 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %53, ptr %10, align 4, !tbaa !9
  br label %67

54:                                               ; preds = %40
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.modemcf_s, ptr %55, i32 0, i32 8
  %57 = getelementptr inbounds %struct.anon.3, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [8 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !13
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = add i32 %62, %61
  store i32 %63, ptr %11, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %54
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !9
  br label %33, !llvm.loop !14

67:                                               ; preds = %52, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = sub i32 %68, %69
  store i32 %70, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.modemcf_s, ptr %71, i32 0, i32 8
  %73 = getelementptr inbounds %struct.anon.3, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds [8 x i32], ptr %73, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !13
  store i32 %77, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.modemcf_s, ptr %78, i32 0, i32 8
  %80 = getelementptr inbounds %struct.anon.3, ptr %79, i32 0, i32 2
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds [8 x float], ptr %80, i64 0, i64 %82
  %84 = load float, ptr %83, align 4, !tbaa !13
  store float %84, ptr %14, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.modemcf_s, ptr %85, i32 0, i32 8
  %87 = getelementptr inbounds %struct.anon.3, ptr %86, i32 0, i32 4
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = zext i32 %88 to i64
  %90 = getelementptr inbounds [8 x float], ptr %87, i64 0, i64 %89
  %91 = load float, ptr %90, align 4, !tbaa !13
  %92 = fpext float %91 to double
  %93 = load i32, ptr %12, align 4, !tbaa !9
  %94 = uitofp i32 %93 to float
  %95 = fmul float %94, 2.000000e+00
  %96 = fpext float %95 to double
  %97 = fmul double %96, 0x400921FB54442D18
  %98 = load i32, ptr %13, align 4, !tbaa !9
  %99 = uitofp i32 %98 to float
  %100 = fpext float %99 to double
  %101 = fdiv double %97, %100
  %102 = fadd double %92, %101
  %103 = fptrunc double %102 to float
  store float %103, ptr %15, align 4, !tbaa !16
  %104 = load float, ptr %14, align 4, !tbaa !16
  %105 = load float, ptr %15, align 4, !tbaa !16
  %106 = call float @cosf(float noundef %105) #4
  %107 = load float, ptr %15, align 4, !tbaa !16
  %108 = call float @sinf(float noundef %107) #4
  %109 = fmul float 0.000000e+00, %108
  %110 = fmul float 1.000000e+00, %108
  %111 = fadd float %106, %109
  %112 = fmul float %104, %111
  %113 = fmul float %104, %110
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds { float, float }, ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds { float, float }, ptr %114, i32 0, i32 1
  store float %112, ptr %115, align 4
  store float %113, ptr %116, align 4
  store i32 0, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %117

117:                                              ; preds = %67, %21
  %118 = load i32, ptr %4, align 4
  ret i32 %118
}

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 "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"="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 }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"modemcf_s", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !6, i64 48, !10, i64 56, !7, i64 60, !7, i64 68, !7, i64 80, !6, i64 224, !6, i64 232, !6, i64 240, !10, i64 248}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}


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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_modulate_apsk(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp ugt i32 %5, %1
  br i1 %.not, label %8, label %6

6:                                                ; preds = %3
  %7 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 5, ptr noundef nonnull @.str.26, i32 noundef 99, ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.2) #3
  br label %51

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  %10 = getelementptr inbounds i8, ptr %0, i64 216
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = zext i32 %1 to i64
  %13 = getelementptr inbounds i8, ptr %11, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !11
  %15 = zext i8 %14 to i32
  %16 = getelementptr inbounds i8, ptr %0, i64 84
  %17 = load i32, ptr %9, align 8, !tbaa !11
  %.not40 = icmp eq i32 %17, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %8
  %wide.trip.count = zext i32 %17 to i64
  br label %.lr.ph

18:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %.lr.ph.preheader, %18
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %18 ]
  %.03134 = phi i32 [ 0, %.lr.ph.preheader ], [ %21, %18 ]
  %19 = getelementptr inbounds [8 x i32], ptr %16, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = add i32 %20, %.03134
  %22 = icmp ugt i32 %21, %15
  br i1 %22, label %._crit_edge, label %18

._crit_edge:                                      ; preds = %18, %.lr.ph, %8
  %.031.lcssa = phi i32 [ 0, %8 ], [ %.03134, %.lr.ph ], [ %21, %18 ]
  %.030 = phi i64 [ 0, %8 ], [ %indvars.iv, %.lr.ph ], [ 0, %18 ]
  %23 = sub nsw i32 %15, %.031.lcssa
  %24 = getelementptr inbounds [8 x i32], ptr %16, i64 0, i64 %.030
  %25 = load i32, ptr %24, align 4, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %0, i64 116
  %27 = getelementptr inbounds [8 x float], ptr %26, i64 0, i64 %.030
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %0, i64 180
  %30 = getelementptr inbounds [8 x float], ptr %29, i64 0, i64 %.030
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = fpext float %31 to double
  %33 = uitofp i32 %23 to float
  %34 = fmul float %33, 2.000000e+00
  %35 = fpext float %34 to double
  %36 = fmul double %35, 0x400921FB54442D18
  %37 = uitofp i32 %25 to float
  %38 = fpext float %37 to double
  %39 = fdiv double %36, %38
  %40 = fadd double %39, %32
  %41 = fptrunc double %40 to float
  %42 = tail call float @cosf(float noundef %41) #3
  %43 = tail call float @sinf(float noundef %41) #3
  %44 = fmul float %43, 0.000000e+00
  %45 = fadd float %42, %44
  %46 = insertelement <2 x float> poison, float %28, i64 0
  %47 = shufflevector <2 x float> %46, <2 x float> poison, <2 x i32> zeroinitializer
  %48 = insertelement <2 x float> poison, float %45, i64 0
  %49 = insertelement <2 x float> %48, float %43, i64 1
  %50 = fmul <2 x float> %47, %49
  store <2 x float> %50, ptr %2, align 4
  br label %51

51:                                               ; preds = %._crit_edge, %6
  %.0 = phi i32 [ %7, %6 ], [ 0, %._crit_edge ]
  ret i32 %.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 = { mustprogress nofree nounwind willreturn memory(write) "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, !7, i64 8}
!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 = !{!8, !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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