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

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

; 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
declare ptr @llvm.stacksave.p0() #1

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_gmskmodem_demodulate(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %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 float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca { float, float }, align 4
  %16 = alloca { float, float }, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 0x3FD3333340000000, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load float, ptr %9, align 4, !tbaa !11
  %20 = call ptr @gmskdem_create(i32 noundef %17, i32 noundef %18, float noundef %19)
  store ptr %20, ptr %10, align 8, !tbaa !5
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = call ptr @llvm.stacksave.p0()
  store ptr %23, ptr %11, align 8
  %24 = alloca { float, float }, i64 %22, align 16
  store i64 %22, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i64 0, ptr %14, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %52, %3
  %26 = load i64, ptr %14, align 8, !tbaa !13
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = icmp ult i64 %26, %28
  br i1 %29, label %30, label %55

30:                                               ; preds = %25
  %31 = call float (...) @randnf()
  %32 = call float (...) @randf()
  %33 = fpext float %32 to double
  %34 = fmul double 0.000000e+00, %33
  %35 = fmul double 0x401921FB54442D18, %33
  %36 = fptrunc double %34 to float
  %37 = fptrunc double %35 to float
  %38 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %39 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  store float %36, ptr %38, align 4
  store float %37, ptr %39, align 4
  %40 = load <2 x float>, ptr %15, align 4
  %41 = call <2 x float> @cexpf(<2 x float> noundef %40) #5
  store <2 x float> %41, ptr %16, align 4
  %42 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %43 = load float, ptr %42, align 4
  %44 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  %45 = load float, ptr %44, align 4
  %46 = fmul float %31, %43
  %47 = fmul float %31, %45
  %48 = load i64, ptr %14, align 8, !tbaa !13
  %49 = getelementptr inbounds { float, float }, ptr %24, i64 %48
  %50 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds { float, float }, ptr %49, i32 0, i32 1
  store float %46, ptr %50, align 8
  store float %47, ptr %51, align 4
  br label %52

52:                                               ; preds = %30
  %53 = load i64, ptr %14, align 8, !tbaa !13
  %54 = add i64 %53, 1
  store i64 %54, ptr %14, align 8, !tbaa !13
  br label %25, !llvm.loop !15

55:                                               ; preds = %25
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = call i32 @getrusage(i32 noundef 0, ptr noundef %56) #5
  store i64 0, ptr %14, align 8, !tbaa !13
  br label %58

58:                                               ; preds = %72, %55
  %59 = load i64, ptr %14, align 8, !tbaa !13
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i64, ptr %60, align 8, !tbaa !13
  %62 = icmp ult i64 %59, %61
  br i1 %62, label %63, label %75

63:                                               ; preds = %58
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = call i32 @gmskdem_demodulate(ptr noundef %64, ptr noundef %24, ptr noundef %13)
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = call i32 @gmskdem_demodulate(ptr noundef %66, ptr noundef %24, ptr noundef %13)
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = call i32 @gmskdem_demodulate(ptr noundef %68, ptr noundef %24, ptr noundef %13)
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = call i32 @gmskdem_demodulate(ptr noundef %70, ptr noundef %24, ptr noundef %13)
  br label %72

72:                                               ; preds = %63
  %73 = load i64, ptr %14, align 8, !tbaa !13
  %74 = add i64 %73, 1
  store i64 %74, ptr %14, align 8, !tbaa !13
  br label %58, !llvm.loop !17

75:                                               ; preds = %58
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call i32 @getrusage(i32 noundef 0, ptr noundef %76) #5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = load i64, ptr %78, align 8, !tbaa !13
  %80 = mul i64 %79, 4
  store i64 %80, ptr %78, align 8, !tbaa !13
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = call i32 @gmskdem_destroy(ptr noundef %81)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %83 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %83)
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

declare ptr @gmskdem_create(i32 noundef, i32 noundef, float noundef) #4

declare float @randnf(...) #4

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #2

declare float @randf(...) #4

declare i32 @gmskdem_demodulate(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @gmskdem_destroy(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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"="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 = { "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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_gmskmodem_demodulate(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  %5 = tail call ptr @gmskdem_create(i32 noundef 2, i32 noundef 3, float noundef 0x3FD3333340000000) #4
  %6 = alloca [2 x { float, float }], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  %7 = tail call float (...) @randnf() #4
  %8 = tail call float (...) @randf() #4
  %9 = fpext float %8 to double
  %10 = fmul double %9, 0x401921FB54442D18
  %11 = fmul float %8, 0.000000e+00
  %12 = fptrunc double %10 to float
  %.sroa.01.0.vec.insert = insertelement <2 x float> poison, float %11, i64 0
  %.sroa.01.4.vec.insert = insertelement <2 x float> %.sroa.01.0.vec.insert, float %12, i64 1
  %13 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert) #4
  %14 = tail call float (...) @randnf() #4
  %15 = tail call float (...) @randf() #4
  %16 = fpext float %15 to double
  %17 = fmul double %16, 0x401921FB54442D18
  %18 = fmul float %15, 0.000000e+00
  %19 = fptrunc double %17 to float
  %.sroa.01.0.vec.insert.1 = insertelement <2 x float> poison, float %18, i64 0
  %.sroa.01.4.vec.insert.1 = insertelement <2 x float> %.sroa.01.0.vec.insert.1, float %19, i64 1
  %20 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert.1) #4
  %21 = insertelement <4 x float> poison, float %7, i64 0
  %22 = insertelement <4 x float> %21, float %14, i64 1
  %23 = shufflevector <4 x float> %22, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
  %24 = shufflevector <2 x float> %13, <2 x float> %20, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %25 = fmul <4 x float> %23, %24
  store <4 x float> %25, ptr %6, align 16
  %26 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #4
  %27 = load i64, ptr %2, align 8, !tbaa !9
  %.not = icmp eq i64 %27, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.122 = phi i64 [ %32, %.lr.ph ], [ 0, %3 ]
  %28 = call i32 @gmskdem_demodulate(ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %4) #4
  %29 = call i32 @gmskdem_demodulate(ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %4) #4
  %30 = call i32 @gmskdem_demodulate(ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %4) #4
  %31 = call i32 @gmskdem_demodulate(ptr noundef %5, ptr noundef nonnull %6, ptr noundef nonnull %4) #4
  %32 = add nuw i64 %.122, 1
  %33 = load i64, ptr %2, align 8, !tbaa !9
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %3
  %35 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #4
  %36 = load i64, ptr %2, align 8, !tbaa !9
  %37 = shl i64 %36, 2
  store i64 %37, ptr %2, align 8, !tbaa !9
  %38 = call i32 @gmskdem_destroy(ptr noundef %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret void
}

declare ptr @gmskdem_create(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #3

declare float @randnf(...) local_unnamed_addr #3

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #1

declare float @randf(...) local_unnamed_addr #3

declare i32 @gmskdem_demodulate(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @gmskdem_destroy(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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