; LLVM IR from jgaeddert/liquid-dsp :: src/fec/bench (interleaver_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: nounwind uwtable
define dso_local void @interleaver_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = uitofp i32 %14 to float
  %16 = call float @logf(float noundef %15) #6
  %17 = fpext float %16 to double
  %18 = call double @llvm.fmuladd.f64(double 0x3FE6A7EF9DB22D0E, double %17, double -8.830000e-01)
  %19 = fptrunc double %18 to float
  %20 = call float @expf(float noundef %19) #6, !tbaa !9
  %21 = fmul float 0x3FE6666660000000, %20
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = uitofp i64 %23 to float
  %25 = fdiv float %24, %21
  %26 = fptoui float %25 to i64
  store i64 %26, ptr %22, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = call ptr @interleaver_create(i32 noundef %27)
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = call i32 @interleaver_set_depth(ptr noundef %29, i32 noundef 4)
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = zext i32 %31 to i64
  %33 = call ptr @llvm.stacksave.p0()
  store ptr %33, ptr %10, align 8
  %34 = alloca i8, i64 %32, align 16
  store i64 %32, ptr %11, align 8
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = alloca i8, i64 %36, align 16
  store i64 %36, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %49, %4
  %39 = load i64, ptr %13, align 8, !tbaa !11
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = icmp ult i64 %39, %41
  br i1 %42, label %43, label %52

43:                                               ; preds = %38
  %44 = call i32 @rand() #6
  %45 = and i32 %44, 255
  %46 = trunc i32 %45 to i8
  %47 = load i64, ptr %13, align 8, !tbaa !11
  %48 = getelementptr inbounds i8, ptr %34, i64 %47
  store i8 %46, ptr %48, align 1, !tbaa !13
  br label %49

49:                                               ; preds = %43
  %50 = load i64, ptr %13, align 8, !tbaa !11
  %51 = add i64 %50, 1
  store i64 %51, ptr %13, align 8, !tbaa !11
  br label %38, !llvm.loop !14

52:                                               ; preds = %38
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call i32 @getrusage(i32 noundef 0, ptr noundef %53) #6
  store i64 0, ptr %13, align 8, !tbaa !11
  br label %55

55:                                               ; preds = %69, %52
  %56 = load i64, ptr %13, align 8, !tbaa !11
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = load i64, ptr %57, align 8, !tbaa !11
  %59 = icmp ult i64 %56, %58
  br i1 %59, label %60, label %72

60:                                               ; preds = %55
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = call i32 @interleaver_encode(ptr noundef %61, ptr noundef %34, ptr noundef %37)
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = call i32 @interleaver_encode(ptr noundef %63, ptr noundef %34, ptr noundef %37)
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = call i32 @interleaver_encode(ptr noundef %65, ptr noundef %34, ptr noundef %37)
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = call i32 @interleaver_encode(ptr noundef %67, ptr noundef %34, ptr noundef %37)
  br label %69

69:                                               ; preds = %60
  %70 = load i64, ptr %13, align 8, !tbaa !11
  %71 = add i64 %70, 1
  store i64 %71, ptr %13, align 8, !tbaa !11
  br label %55, !llvm.loop !16

72:                                               ; preds = %55
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = call i32 @getrusage(i32 noundef 0, ptr noundef %73) #6
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = load i64, ptr %75, align 8, !tbaa !11
  %77 = mul i64 %76, 4
  store i64 %77, ptr %75, align 8, !tbaa !11
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = call i32 @interleaver_destroy(ptr noundef %78)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %80 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %80)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret void
}

; Function Attrs: nounwind
declare float @expf(float noundef) #1

; Function Attrs: nounwind
declare float @logf(float noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

declare ptr @interleaver_create(i32 noundef) #4

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

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

; Function Attrs: nounwind
declare i32 @rand() #1

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

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

declare i32 @interleaver_destroy(ptr noundef) #4

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

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

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


; 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: nounwind uwtable
define dso_local void @interleaver_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = uitofp i32 %3 to float
  %6 = tail call float @logf(float noundef %5) #5
  %7 = fpext float %6 to double
  %8 = tail call double @llvm.fmuladd.f64(double %7, double 0x3FE6A7EF9DB22D0E, double -8.830000e-01)
  %9 = fptrunc double %8 to float
  %10 = tail call float @expf(float noundef %9) #5, !tbaa !5
  %11 = fmul float %10, 0x3FE6666660000000
  %12 = load i64, ptr %2, align 8, !tbaa !9
  %13 = uitofp i64 %12 to float
  %14 = fdiv float %13, %11
  %15 = fptoui float %14 to i64
  store i64 %15, ptr %2, align 8, !tbaa !9
  %16 = tail call ptr @interleaver_create(i32 noundef %3) #5
  %17 = tail call i32 @interleaver_set_depth(ptr noundef %16, i32 noundef 4) #5
  %18 = zext i32 %3 to i64
  %19 = alloca i8, i64 %18, align 16
  %20 = alloca i8, i64 %18, align 16
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.021 = phi i64 [ %24, %.lr.ph ], [ 0, %4 ]
  %21 = tail call i32 @rand() #5
  %22 = trunc i32 %21 to i8
  %23 = getelementptr inbounds i8, ptr %19, i64 %.021
  store i8 %22, ptr %23, align 1, !tbaa !11
  %24 = add nuw nsw i64 %.021, 1
  %exitcond.not = icmp eq i64 %24, %18
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %4
  %25 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %26 = load i64, ptr %2, align 8, !tbaa !9
  %.not26 = icmp eq i64 %26, 0
  br i1 %.not26, label %._crit_edge25, label %.lr.ph24

.lr.ph24:                                         ; preds = %._crit_edge, %.lr.ph24
  %.122 = phi i64 [ %31, %.lr.ph24 ], [ 0, %._crit_edge ]
  %27 = call i32 @interleaver_encode(ptr noundef %16, ptr noundef nonnull %19, ptr noundef nonnull %20) #5
  %28 = call i32 @interleaver_encode(ptr noundef %16, ptr noundef nonnull %19, ptr noundef nonnull %20) #5
  %29 = call i32 @interleaver_encode(ptr noundef %16, ptr noundef nonnull %19, ptr noundef nonnull %20) #5
  %30 = call i32 @interleaver_encode(ptr noundef %16, ptr noundef nonnull %19, ptr noundef nonnull %20) #5
  %31 = add nuw i64 %.122, 1
  %32 = load i64, ptr %2, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %.lr.ph24, label %._crit_edge25, !llvm.loop !14

._crit_edge25:                                    ; preds = %.lr.ph24, %._crit_edge
  %34 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %35 = load i64, ptr %2, align 8, !tbaa !9
  %36 = shl i64 %35, 2
  store i64 %36, ptr %2, align 8, !tbaa !9
  %37 = call i32 @interleaver_destroy(ptr noundef %16) #5
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare ptr @interleaver_create(i32 noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #4

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

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

declare i32 @interleaver_destroy(ptr noundef) local_unnamed_addr #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 nofree nounwind willreturn memory(write) "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 "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 = !{!"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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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