; 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.38 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

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

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

declare i32 @printf(ptr noundef, ...) #0

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

16:                                               ; preds = %2
  %17 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.37, i32 noundef 34, ptr noundef @.str.38, ptr noundef @.str.2)
  store ptr %17, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %65

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = call ptr @modemcf_create_arb(i32 noundef %19)
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !9
  %24 = call i32 @modemcf_arb_init(ptr noundef %21, ptr noundef %22, i32 noundef %23)
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.modemcf_s, ptr %25, i32 0, i32 2
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.39, i32 noundef %27)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %60, %18
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.modemcf_s, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = icmp ult i32 %30, %33
  br i1 %34, label %35, label %63

35:                                               ; preds = %29
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.modemcf_s, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds { float, float }, ptr %39, i64 %41
  %43 = getelementptr inbounds { float, float }, ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 4
  %45 = getelementptr inbounds { float, float }, ptr %42, i32 0, i32 1
  %46 = load float, ptr %45, align 4
  %47 = fpext float %44 to double
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.modemcf_s, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds { float, float }, ptr %50, i64 %52
  %54 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 0
  %55 = load float, ptr %54, align 4
  %56 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 1
  %57 = load float, ptr %56, align 4
  %58 = fpext float %57 to double
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.40, i32 noundef %36, double noundef %47, double noundef %58)
  br label %60

60:                                               ; preds = %35
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %9, align 4, !tbaa !9
  br label %29, !llvm.loop !14

63:                                               ; preds = %29
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %64, ptr %3, align 8
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %65

65:                                               ; preds = %63, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %66 = load ptr, ptr %3, align 8
  ret ptr %66
}

declare i32 @liquid_nextpow2(i32 noundef) #0

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!12, !6, i64 48}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; 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.38 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @modemcf_create_arbitrary(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call i32 @liquid_nextpow2(i32 noundef %1) #3
  %4 = shl nuw i32 1, %3
  %.not = icmp eq i32 %4, %1
  br i1 %.not, label %7, label %5

5:                                                ; preds = %2
  %6 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.37, i32 noundef 34, ptr noundef nonnull @.str.38, ptr noundef nonnull @.str.2) #3
  br label %.loopexit

7:                                                ; preds = %2
  %8 = tail call ptr @modemcf_create_arb(i32 noundef %3)
  %9 = tail call i32 @modemcf_arb_init(ptr noundef %8, ptr noundef %0, i32 noundef %1)
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.39, i32 noundef %11)
  %13 = load i32, ptr %10, align 8, !tbaa !5
  %.not20 = icmp eq i32 %13, 0
  br i1 %.not20, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %14 = getelementptr inbounds i8, ptr %8, i64 48
  br label %15

15:                                               ; preds = %.lr.ph, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %16 = load ptr, ptr %14, align 8, !tbaa !11
  %17 = getelementptr inbounds { float, float }, ptr %16, i64 %indvars.iv
  %18 = load float, ptr %17, align 4
  %19 = getelementptr inbounds i8, ptr %17, i64 4
  %20 = fpext float %18 to double
  %21 = load float, ptr %19, align 4
  %22 = fpext float %21 to double
  %23 = trunc nuw i64 %indvars.iv to i32
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.40, i32 noundef %23, double noundef %20, double noundef %22)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr %10, align 8, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = icmp ult i64 %indvars.iv.next, %26
  br i1 %27, label %15, label %.loopexit, !llvm.loop !12

.loopexit:                                        ; preds = %15, %7, %5
  %.017 = phi ptr [ %6, %5 ], [ %8, %7 ], [ %8, %15 ]
  ret ptr %.017
}

declare i32 @liquid_nextpow2(i32 noundef) local_unnamed_addr #0

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

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 = { 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 = { 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 #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 = !{!6, !10, i64 48}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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