; 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.37 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [46 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 uwtable
declare dso_local i32 @modemcf_arb_balance_iq(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @modemcf_arb_scale(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_arb_init_file(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call noalias ptr @fopen(ptr noundef %12, ptr noundef @.str.44)
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef @.str.37, i32 noundef 220, ptr noundef @.str.45, ptr noundef @.str.2)
  store i32 %17, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %70

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %53, %18
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.modemcf_s, ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp ult i32 %20, %23
  br i1 %24, label %25, label %56

25:                                               ; preds = %19
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call i32 @feof(ptr noundef %26) #5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef @.str.37, i32 noundef 227, ptr noundef @.str.46, ptr noundef @.str.2, ptr noundef %30)
  store i32 %31, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

32:                                               ; preds = %25
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %33, ptr noundef @.str.47, ptr noundef %10, ptr noundef %11)
  store i32 %34, ptr %9, align 4, !tbaa !9
  %35 = load float, ptr %10, align 4, !tbaa !13
  %36 = load float, ptr %11, align 4, !tbaa !13
  %37 = fmul float 0.000000e+00, %36
  %38 = fmul float 1.000000e+00, %36
  %39 = fadd float %35, %37
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.modemcf_s, ptr %40, i32 0, i32 4
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds { float, float }, ptr %42, i64 %44
  %46 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 1
  store float %39, ptr %46, align 4
  store float %38, ptr %47, align 4
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = icmp ult i32 %48, 2
  br i1 %49, label %50, label %52

50:                                               ; preds = %32
  %51 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef @.str.37, i32 noundef 234, ptr noundef @.str.48, ptr noundef @.str.2)
  store i32 %51, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

52:                                               ; preds = %32
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = add i32 %54, 1
  store i32 %55, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !16

56:                                               ; preds = %19
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = call i32 @fclose(ptr noundef %57)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.modemcf_s, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !18
  %62 = icmp eq i32 %61, 52
  br i1 %62, label %63, label %66

63:                                               ; preds = %56
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @modemcf_arb_balance_iq(ptr noundef %64)
  br label %66

66:                                               ; preds = %63, %56
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = call i32 @modemcf_arb_scale(ptr noundef %67)
  store i32 %68, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %69

69:                                               ; preds = %66, %50, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %70

70:                                               ; preds = %69, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %71 = load i32, ptr %3, align 4
  ret i32 %71
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #4

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

declare i32 @fclose(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 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 "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 }

!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 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !6, i64 48}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !10, 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.37 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [46 x i8], align 1

; 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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_arb_init_file(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.44)
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %9

7:                                                ; preds = %2
  %8 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef nonnull @.str.37, i32 noundef 220, ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.2) #5
  br label %41

9:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %.not18 = icmp eq i32 %11, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  br label %17

13:                                               ; preds = %21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr %10, align 8, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = icmp ult i64 %indvars.iv.next, %15
  br i1 %16, label %17, label %._crit_edge, !llvm.loop !11

17:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %18 = call i32 @feof(ptr noundef nonnull %5) #5
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %21, label %19

19:                                               ; preds = %17
  %20 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef nonnull @.str.37, i32 noundef 227, ptr noundef nonnull @.str.46, ptr noundef nonnull @.str.2, ptr noundef %1) #5
  br label %40

21:                                               ; preds = %17
  %22 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.47, ptr noundef nonnull %3, ptr noundef nonnull %4) #5
  %23 = load float, ptr %3, align 4, !tbaa !13
  %24 = load float, ptr %4, align 4, !tbaa !13
  %25 = fmul float %24, 0.000000e+00
  %26 = fadd float %23, %25
  %27 = load ptr, ptr %12, align 8, !tbaa !15
  %28 = getelementptr inbounds { float, float }, ptr %27, i64 %indvars.iv
  %29 = getelementptr inbounds i8, ptr %28, i64 4
  store float %26, ptr %28, align 4
  store float %24, ptr %29, align 4
  %30 = icmp ult i32 %22, 2
  br i1 %30, label %31, label %13

31:                                               ; preds = %21
  %32 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 10, ptr noundef nonnull @.str.37, i32 noundef 234, ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.2) #5
  br label %40

._crit_edge:                                      ; preds = %13, %9
  %33 = call i32 @fclose(ptr noundef nonnull %5)
  %34 = load i32, ptr %0, align 8, !tbaa !16
  %35 = icmp eq i32 %34, 52
  br i1 %35, label %36, label %38

36:                                               ; preds = %._crit_edge
  %37 = call i32 @modemcf_arb_balance_iq(ptr noundef nonnull %0)
  br label %38

38:                                               ; preds = %36, %._crit_edge
  %39 = call i32 @modemcf_arb_scale(ptr noundef nonnull %0)
  br label %40

40:                                               ; preds = %38, %31, %19
  %.0 = phi i32 [ %20, %19 ], [ %32, %31 ], [ %39, %38 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  br label %41

41:                                               ; preds = %40, %7
  %.1 = phi i32 [ %8, %7 ], [ %.0, %40 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

attributes #0 = { mustprogress 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 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 = { nofree 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 #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 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = !{!6, !10, i64 48}
!16 = !{!6, !7, i64 0}


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