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

; 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.gmskdem_s = type { i32, i32, float, i32, ptr, ptr, { float, float }, i32 }

@.str = external hidden unnamed_addr constant [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @gmskdem_create(i32 noundef %0, i32 noundef %1, float noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !5
  %10 = icmp ult i32 %9, 2
  br i1 %10, label %11, label %13

11:                                               ; preds = %3
  %12 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 75, ptr noundef @.str.1)
  store ptr %12, ptr %4, align 8
  br label %81

13:                                               ; preds = %3
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = icmp ult i32 %14, 1
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 77, ptr noundef @.str.2)
  store ptr %17, ptr %4, align 8
  br label %81

18:                                               ; preds = %13
  %19 = load float, ptr %7, align 4, !tbaa !9
  %20 = fcmp ole float %19, 0.000000e+00
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = load float, ptr %7, align 4, !tbaa !9
  %23 = fcmp oge float %22, 1.000000e+00
  br i1 %23, label %24, label %26

24:                                               ; preds = %21, %18
  %25 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str, i32 noundef 79, ptr noundef @.str.3)
  store ptr %25, ptr %4, align 8
  br label %81

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %27 = call noalias ptr @malloc(i64 noundef 48) #5
  store ptr %27, ptr %8, align 8, !tbaa !11
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct.gmskdem_s, ptr %29, i32 0, i32 0
  store i32 %28, ptr %30, align 8, !tbaa !13
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.gmskdem_s, ptr %32, i32 0, i32 1
  store i32 %31, ptr %33, align 4, !tbaa !15
  %34 = load float, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !11
  %36 = getelementptr inbounds %struct.gmskdem_s, ptr %35, i32 0, i32 2
  store float %34, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr %8, align 8, !tbaa !11
  %38 = getelementptr inbounds %struct.gmskdem_s, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = mul i32 2, %39
  %41 = load ptr, ptr %8, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.gmskdem_s, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !15
  %44 = mul i32 %40, %43
  %45 = add i32 %44, 1
  %46 = load ptr, ptr %8, align 8, !tbaa !11
  %47 = getelementptr inbounds %struct.gmskdem_s, ptr %46, i32 0, i32 3
  store i32 %45, ptr %47, align 4, !tbaa !17
  %48 = load ptr, ptr %8, align 8, !tbaa !11
  %49 = getelementptr inbounds %struct.gmskdem_s, ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = zext i32 %50 to i64
  %52 = mul i64 %51, 4
  %53 = call noalias ptr @malloc(i64 noundef %52) #5
  %54 = load ptr, ptr %8, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct.gmskdem_s, ptr %54, i32 0, i32 4
  store ptr %53, ptr %55, align 8, !tbaa !18
  %56 = load ptr, ptr %8, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.gmskdem_s, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !13
  %59 = load ptr, ptr %8, align 8, !tbaa !11
  %60 = getelementptr inbounds %struct.gmskdem_s, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !15
  %62 = load ptr, ptr %8, align 8, !tbaa !11
  %63 = getelementptr inbounds %struct.gmskdem_s, ptr %62, i32 0, i32 2
  %64 = load float, ptr %63, align 8, !tbaa !16
  %65 = load ptr, ptr %8, align 8, !tbaa !11
  %66 = getelementptr inbounds %struct.gmskdem_s, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !18
  %68 = call i32 @liquid_firdes_gmskrx(i32 noundef %58, i32 noundef %61, float noundef %64, float noundef 0.000000e+00, ptr noundef %67)
  %69 = load ptr, ptr %8, align 8, !tbaa !11
  %70 = getelementptr inbounds %struct.gmskdem_s, ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = load ptr, ptr %8, align 8, !tbaa !11
  %73 = getelementptr inbounds %struct.gmskdem_s, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !17
  %75 = call ptr @firfilt_rrrf_create(ptr noundef %71, i32 noundef %74)
  %76 = load ptr, ptr %8, align 8, !tbaa !11
  %77 = getelementptr inbounds %struct.gmskdem_s, ptr %76, i32 0, i32 5
  store ptr %75, ptr %77, align 8, !tbaa !19
  %78 = load ptr, ptr %8, align 8, !tbaa !11
  %79 = call i32 @gmskdem_reset(ptr noundef %78)
  %80 = load ptr, ptr %8, align 8, !tbaa !11
  store ptr %80, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %81

81:                                               ; preds = %26, %24, %16, %11
  %82 = load ptr, ptr %4, align 8
  ret ptr %82
}

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 i32 @liquid_firdes_gmskrx(i32 noundef, i32 noundef, float noundef, float noundef, ptr noundef) #1

declare ptr @firfilt_rrrf_create(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @gmskdem_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 }
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, !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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"gmskdem_s", !6, i64 0, !6, i64 4, !10, i64 8, !6, i64 12, !12, i64 16, !12, i64 24, !7, i64 32, !6, i64 40}
!15 = !{!14, !6, i64 4}
!16 = !{!14, !10, i64 8}
!17 = !{!14, !6, i64 12}
!18 = !{!14, !12, i64 16}
!19 = !{!14, !12, i64 24}


; 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 [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [58 x i8], align 1

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

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

7:                                                ; preds = %3
  %8 = icmp eq i32 %1, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %7
  %10 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 77, ptr noundef nonnull @.str.2) #3
  br label %32

11:                                               ; preds = %7
  %12 = fcmp ole float %2, 0.000000e+00
  %13 = fcmp oge float %2, 1.000000e+00
  %or.cond = or i1 %12, %13
  br i1 %or.cond, label %14, label %16

14:                                               ; preds = %11
  %15 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str, i32 noundef 79, ptr noundef nonnull @.str.3) #3
  br label %32

16:                                               ; preds = %11
  %17 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #4
  store i32 %0, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 4
  store i32 %1, ptr %18, align 4, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %17, i64 8
  store float %2, ptr %19, align 8, !tbaa !13
  %20 = shl i32 %0, 1
  %21 = mul i32 %20, %1
  %22 = or disjoint i32 %21, 1
  %23 = getelementptr inbounds i8, ptr %17, i64 12
  store i32 %22, ptr %23, align 4, !tbaa !14
  %24 = zext i32 %22 to i64
  %25 = shl nuw nsw i64 %24, 2
  %26 = tail call noalias ptr @malloc(i64 noundef %25) #4
  %27 = getelementptr inbounds i8, ptr %17, i64 16
  store ptr %26, ptr %27, align 8, !tbaa !15
  %28 = tail call i32 @liquid_firdes_gmskrx(i32 noundef %0, i32 noundef %1, float noundef %2, float noundef 0.000000e+00, ptr noundef %26) #3
  %29 = tail call ptr @firfilt_rrrf_create(ptr noundef %26, i32 noundef %22) #3
  %30 = getelementptr inbounds i8, ptr %17, i64 24
  store ptr %29, ptr %30, align 8, !tbaa !16
  %31 = tail call i32 @gmskdem_reset(ptr noundef nonnull %17)
  br label %32

32:                                               ; preds = %16, %14, %9, %5
  %.0 = phi ptr [ %6, %5 ], [ %10, %9 ], [ %15, %14 ], [ %17, %16 ]
  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 i32 @liquid_firdes_gmskrx(i32 noundef, i32 noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #1

declare ptr @firfilt_rrrf_create(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @gmskdem_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 }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"gmskdem_s", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12, !11, i64 16, !11, i64 24, !8, i64 32, !7, i64 40}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !7, i64 12}
!15 = !{!6, !11, i64 16}
!16 = !{!6, !11, i64 24}


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