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

%struct.flexframegenprops_s = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_flexframesync(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca %struct.flexframegenprops_s, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca [14 x i8], align 1
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca ptr, 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
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = udiv i64 %18, 128
  store i64 %19, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %20 = call i32 @flexframegenprops_init_default(ptr noundef %8)
  %21 = getelementptr inbounds %struct.flexframegenprops_s, ptr %8, i32 0, i32 0
  store i32 6, ptr %21, align 4, !tbaa !11
  %22 = getelementptr inbounds %struct.flexframegenprops_s, ptr %8, i32 0, i32 1
  store i32 1, ptr %22, align 4, !tbaa !14
  %23 = getelementptr inbounds %struct.flexframegenprops_s, ptr %8, i32 0, i32 2
  store i32 1, ptr %23, align 4, !tbaa !15
  %24 = getelementptr inbounds %struct.flexframegenprops_s, ptr %8, i32 0, i32 3
  store i32 40, ptr %24, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %25 = call ptr @flexframegen_create(ptr noundef %8)
  store ptr %25, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 8, ptr %10, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 14, ptr %11) #5
  %26 = load i32, ptr %10, align 4, !tbaa !17
  %27 = zext i32 %26 to i64
  %28 = call ptr @llvm.stacksave.p0()
  store ptr %28, ptr %12, align 8
  %29 = alloca i8, i64 %27, align 16
  store i64 %27, ptr %13, align 8
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds [14 x i8], ptr %11, i64 0, i64 0
  %32 = load i32, ptr %10, align 4, !tbaa !17
  %33 = call i32 @flexframegen_assemble(ptr noundef %30, ptr noundef %31, ptr noundef %29, i32 noundef %32)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = call i32 @flexframegen_getframelen(ptr noundef %34)
  store i32 %35, ptr %14, align 4, !tbaa !17
  %36 = load i32, ptr %14, align 4, !tbaa !17
  %37 = zext i32 %36 to i64
  %38 = alloca { float, float }, i64 %37, align 16
  store i64 %37, ptr %15, align 8
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i32, ptr %14, align 4, !tbaa !17
  %41 = call i32 @flexframegen_write_samples(ptr noundef %39, ptr noundef %38, i32 noundef %40)
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %65, %3
  %43 = load i64, ptr %7, align 8, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !17
  %45 = zext i32 %44 to i64
  %46 = icmp ult i64 %43, %45
  br i1 %46, label %47, label %68

47:                                               ; preds = %42
  %48 = call float (...) @randnf()
  %49 = call float (...) @randnf()
  %50 = fmul float 0.000000e+00, %49
  %51 = fmul float 1.000000e+00, %49
  %52 = fadd float %48, %50
  %53 = fmul float 0x3F947AE140000000, %52
  %54 = fmul float 0x3F947AE140000000, %51
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = getelementptr inbounds { float, float }, ptr %38, i64 %55
  %57 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 0
  %58 = load float, ptr %57, align 8
  %59 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 1
  %60 = load float, ptr %59, align 4
  %61 = fadd float %58, %53
  %62 = fadd float %60, %54
  %63 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 0
  %64 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 1
  store float %61, ptr %63, align 8
  store float %62, ptr %64, align 4
  br label %65

65:                                               ; preds = %47
  %66 = load i64, ptr %7, align 8, !tbaa !9
  %67 = add i64 %66, 1
  store i64 %67, ptr %7, align 8, !tbaa !9
  br label %42, !llvm.loop !18

68:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %69 = call ptr @flexframesync_create(ptr noundef null, ptr noundef null)
  store ptr %69, ptr %16, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i32 @getrusage(i32 noundef 0, ptr noundef %70) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %72

72:                                               ; preds = %81, %68
  %73 = load i64, ptr %7, align 8, !tbaa !9
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %74, align 8, !tbaa !9
  %76 = icmp ult i64 %73, %75
  br i1 %76, label %77, label %84

77:                                               ; preds = %72
  %78 = load ptr, ptr %16, align 8, !tbaa !5
  %79 = load i32, ptr %14, align 4, !tbaa !17
  %80 = call i32 @flexframesync_execute(ptr noundef %78, ptr noundef %38, i32 noundef %79)
  br label %81

81:                                               ; preds = %77
  %82 = load i64, ptr %7, align 8, !tbaa !9
  %83 = add i64 %82, 1
  store i64 %83, ptr %7, align 8, !tbaa !9
  br label %72, !llvm.loop !20

84:                                               ; preds = %72
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call i32 @getrusage(i32 noundef 0, ptr noundef %85) #5
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = call i32 @flexframegen_destroy(ptr noundef %87)
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  %90 = call i32 @flexframesync_destroy(ptr noundef %89)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %91 = load ptr, ptr %12, align 8
  call void @llvm.stackrestore.p0(ptr %91)
  call void @llvm.lifetime.end.p0(i64 14, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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

declare i32 @flexframegenprops_init_default(ptr noundef) #2

declare ptr @flexframegen_create(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

declare i32 @flexframegen_getframelen(ptr noundef) #2

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

declare float @randnf(...) #2

declare ptr @flexframesync_create(ptr noundef, ptr noundef) #2

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

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

declare i32 @flexframegen_destroy(ptr noundef) #2

declare i32 @flexframesync_destroy(ptr noundef) #2

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !13, i64 8}
!16 = !{!12, !13, i64 12}
!17 = !{!13, !13, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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

%struct.flexframegenprops_s = type { i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @benchmark_flexframesync(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.flexframegenprops_s, align 16
  %5 = alloca [14 x i8], align 1
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = lshr i64 %6, 7
  store i64 %7, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %8 = call i32 @flexframegenprops_init_default(ptr noundef nonnull %4) #5
  store <4 x i32> <i32 6, i32 1, i32 1, i32 40>, ptr %4, align 16, !tbaa !9
  %9 = call ptr @flexframegen_create(ptr noundef nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 14, ptr nonnull %5) #5
  %10 = call ptr @llvm.stacksave.p0()
  %11 = alloca [8 x i8], align 16
  %12 = call i32 @flexframegen_assemble(ptr noundef %9, ptr noundef nonnull %5, ptr noundef nonnull %11, i32 noundef 8) #5
  %13 = call i32 @flexframegen_getframelen(ptr noundef %9) #5
  %14 = zext i32 %13 to i64
  %15 = alloca { float, float }, i64 %14, align 16
  %16 = call i32 @flexframegen_write_samples(ptr noundef %9, ptr noundef nonnull %15, i32 noundef %13) #5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.021 = phi i64 [ %27, %.lr.ph ], [ 0, %3 ]
  %17 = call float (...) @randnf() #5
  %18 = call float (...) @randnf() #5
  %19 = fmul float %18, 0.000000e+00
  %20 = fadd float %17, %19
  %21 = getelementptr inbounds { float, float }, ptr %15, i64 %.021
  %22 = insertelement <2 x float> poison, float %20, i64 0
  %23 = insertelement <2 x float> %22, float %18, i64 1
  %24 = fmul <2 x float> %23, <float 0x3F947AE140000000, float 0x3F947AE140000000>
  %25 = load <2 x float>, ptr %21, align 8
  %26 = fadd <2 x float> %25, %24
  store <2 x float> %26, ptr %21, align 8
  %27 = add nuw nsw i64 %.021, 1
  %exitcond.not = icmp eq i64 %27, %14
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %3
  %28 = call ptr @flexframesync_create(ptr noundef null, ptr noundef null) #5
  %29 = call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %.not26 = icmp eq i64 %30, 0
  br i1 %.not26, label %._crit_edge25, label %.lr.ph24

.lr.ph24:                                         ; preds = %._crit_edge, %.lr.ph24
  %.122 = phi i64 [ %32, %.lr.ph24 ], [ 0, %._crit_edge ]
  %31 = call i32 @flexframesync_execute(ptr noundef %28, ptr noundef nonnull %15, i32 noundef %13) #5
  %32 = add nuw i64 %.122, 1
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %.lr.ph24, label %._crit_edge25, !llvm.loop !13

._crit_edge25:                                    ; preds = %.lr.ph24, %._crit_edge
  %35 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %36 = call i32 @flexframegen_destroy(ptr noundef %9) #5
  %37 = call i32 @flexframesync_destroy(ptr noundef %28) #5
  call void @llvm.stackrestore.p0(ptr %10)
  call void @llvm.lifetime.end.p0(i64 14, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  ret void
}

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

declare i32 @flexframegenprops_init_default(ptr noundef) local_unnamed_addr #2

declare ptr @flexframegen_create(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

declare i32 @flexframegen_assemble(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @flexframegen_getframelen(ptr noundef) local_unnamed_addr #2

declare i32 @flexframegen_write_samples(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare ptr @flexframesync_create(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @flexframesync_execute(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @flexframegen_destroy(ptr noundef) local_unnamed_addr #2

declare i32 @flexframesync_destroy(ptr noundef) local_unnamed_addr #2

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind willreturn }
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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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