; LLVM IR from jgaeddert/liquid-dsp :: src/framing/bench (gmskframesync_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

declare float @randnf(...) #2

declare ptr @gmskframesync_create_set(i32 noundef, i32 noundef, float noundef, ptr noundef, ptr noundef) #2

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

declare i32 @gmskframesync_execute(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @gmskframesync_destroy(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_gmskframesync_noise(ptr noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  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
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = udiv i64 %13, 2000
  store i64 %14, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %15 = call ptr @gmskframesync_create_set(i32 noundef 2, i32 noundef 3, float noundef 5.000000e-01, ptr noundef null, ptr noundef null)
  store ptr %15, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1024, ptr %9, align 4, !tbaa !11
  %16 = load i32, ptr %9, align 4, !tbaa !11
  %17 = zext i32 %16 to i64
  %18 = call ptr @llvm.stacksave.p0()
  store ptr %18, ptr %10, align 8
  %19 = alloca { float, float }, i64 %17, align 16
  store i64 %17, ptr %11, align 8
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %43, %3
  %21 = load i64, ptr %7, align 8, !tbaa !9
  %22 = load i32, ptr %9, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = icmp ult i64 %21, %23
  br i1 %24, label %25, label %46

25:                                               ; preds = %20
  %26 = call float (...) @randnf()
  %27 = call float (...) @randnf()
  %28 = fmul float %27, 0.000000e+00
  %29 = fmul float %27, 1.000000e+00
  %30 = fadd float %26, %28
  %31 = fmul float 0x3F847AE140000000, %30
  %32 = fmul float 0x3F847AE140000000, %29
  %33 = fpext float %31 to double
  %34 = fpext float %32 to double
  %35 = fmul double %33, 0x3FE6A09E667F3BCD
  %36 = fmul double %34, 0x3FE6A09E667F3BCD
  %37 = fptrunc double %35 to float
  %38 = fptrunc double %36 to float
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = getelementptr inbounds { float, float }, ptr %19, i64 %39
  %41 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 1
  store float %37, ptr %41, align 8
  store float %38, ptr %42, align 4
  br label %43

43:                                               ; preds = %25
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %7, align 8, !tbaa !9
  br label %20, !llvm.loop !13

46:                                               ; preds = %20
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = call i32 @getrusage(i32 noundef 0, ptr noundef %47) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %58, %46
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp ult i64 %50, %52
  br i1 %53, label %54, label %61

54:                                               ; preds = %49
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !11
  %57 = call i32 @gmskframesync_execute(ptr noundef %55, ptr noundef %19, i32 noundef %56)
  br label %58

58:                                               ; preds = %54
  %59 = load i64, ptr %7, align 8, !tbaa !9
  %60 = add i64 %59, 1
  store i64 %60, ptr %7, align 8, !tbaa !9
  br label %49, !llvm.loop !15

61:                                               ; preds = %49
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call i32 @getrusage(i32 noundef 0, ptr noundef %62) #5
  %64 = load i32, ptr %9, align 4, !tbaa !11
  %65 = zext i32 %64 to i64
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = mul i64 %67, %65
  store i64 %68, ptr %66, align 8, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call i32 @gmskframesync_destroy(ptr noundef %69)
  %71 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %71)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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


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

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

declare ptr @gmskframesync_create_set(i32 noundef, i32 noundef, float noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

declare i32 @gmskframesync_execute(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @gmskframesync_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_gmskframesync_noise(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #2 {
  %4 = load i64, ptr %2, align 8, !tbaa !5
  %5 = udiv i64 %4, 2000
  store i64 %5, ptr %2, align 8, !tbaa !5
  %6 = tail call ptr @gmskframesync_create_set(i32 noundef 2, i32 noundef 3, float noundef 5.000000e-01, ptr noundef null, ptr noundef null) #3
  %7 = alloca [1024 x { float, float }], align 16
  br label %8

8:                                                ; preds = %3, %8
  %.016 = phi i64 [ 0, %3 ], [ %20, %8 ]
  %9 = tail call float (...) @randnf() #3
  %10 = tail call float (...) @randnf() #3
  %11 = fmul float %10, 0.000000e+00
  %12 = fadd float %9, %11
  %13 = getelementptr inbounds { float, float }, ptr %7, i64 %.016
  %14 = insertelement <2 x float> poison, float %12, i64 0
  %15 = insertelement <2 x float> %14, float %10, i64 1
  %16 = fmul <2 x float> %15, <float 0x3F847AE140000000, float 0x3F847AE140000000>
  %17 = fpext <2 x float> %16 to <2 x double>
  %18 = fmul <2 x double> %17, <double 0x3FE6A09E667F3BCD, double 0x3FE6A09E667F3BCD>
  %19 = fptrunc <2 x double> %18 to <2 x float>
  store <2 x float> %19, ptr %13, align 8
  %20 = add nuw nsw i64 %.016, 1
  %exitcond.not = icmp eq i64 %20, 1024
  br i1 %exitcond.not, label %21, label %8, !llvm.loop !9

21:                                               ; preds = %8
  %22 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #3
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %23, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %21, %.lr.ph
  %.117 = phi i64 [ %25, %.lr.ph ], [ 0, %21 ]
  %24 = call i32 @gmskframesync_execute(ptr noundef %6, ptr noundef nonnull %7, i32 noundef 1024) #3
  %25 = add nuw i64 %.117, 1
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %21
  %28 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #3
  %29 = load i64, ptr %2, align 8, !tbaa !5
  %30 = shl i64 %29, 10
  store i64 %30, ptr %2, align 8, !tbaa !5
  %31 = call i32 @gmskframesync_destroy(ptr noundef %6) #3
  ret void
}

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 "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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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