; LLVM IR from jgaeddert/liquid-dsp :: src/fec/bench (packetizer_decode_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 @packetizer_decode_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %23 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %23, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = load i32, ptr %13, align 4, !tbaa !9
  %27 = load i32, ptr %14, align 4, !tbaa !9
  %28 = call i32 @packetizer_compute_enc_msg_len(i32 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  store i32 %28, ptr %16, align 4, !tbaa !9
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = load i64, ptr %29, align 8, !tbaa !11
  %31 = mul i64 %30, 1000
  store i64 %31, ptr %29, align 8, !tbaa !11
  %32 = load i32, ptr %15, align 4, !tbaa !9
  %33 = uitofp i32 %32 to double
  %34 = call double @llvm.fmuladd.f64(double 1.612500e+00, double %33, double 2.210000e+02)
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = uitofp i64 %36 to double
  %38 = fdiv double %37, %34
  %39 = fptoui double %38 to i64
  store i64 %39, ptr %35, align 8, !tbaa !11
  %40 = load i32, ptr %16, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = call ptr @llvm.stacksave.p0()
  store ptr %42, ptr %17, align 8
  %43 = alloca i8, i64 %41, align 16
  store i64 %41, ptr %18, align 8
  %44 = load i32, ptr %15, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = alloca i8, i64 %45, align 16
  store i64 %45, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store i64 0, ptr %20, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %58, %7
  %48 = load i64, ptr %20, align 8, !tbaa !11
  %49 = load i32, ptr %16, align 4, !tbaa !9
  %50 = zext i32 %49 to i64
  %51 = icmp ult i64 %48, %50
  br i1 %51, label %52, label %61

52:                                               ; preds = %47
  %53 = call i32 @rand() #6
  %54 = and i32 %53, 255
  %55 = trunc i32 %54 to i8
  %56 = load i64, ptr %20, align 8, !tbaa !11
  %57 = getelementptr inbounds i8, ptr %43, i64 %56
  store i8 %55, ptr %57, align 1, !tbaa !13
  br label %58

58:                                               ; preds = %52
  %59 = load i64, ptr %20, align 8, !tbaa !11
  %60 = add i64 %59, 1
  store i64 %60, ptr %20, align 8, !tbaa !11
  br label %47, !llvm.loop !14

61:                                               ; preds = %47
  store i64 0, ptr %20, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %70, %61
  %63 = load i64, ptr %20, align 8, !tbaa !11
  %64 = load i32, ptr %15, align 4, !tbaa !9
  %65 = zext i32 %64 to i64
  %66 = icmp ult i64 %63, %65
  br i1 %66, label %67, label %73

67:                                               ; preds = %62
  %68 = load i64, ptr %20, align 8, !tbaa !11
  %69 = getelementptr inbounds i8, ptr %46, i64 %68
  store i8 0, ptr %69, align 1, !tbaa !13
  br label %70

70:                                               ; preds = %67
  %71 = load i64, ptr %20, align 8, !tbaa !11
  %72 = add i64 %71, 1
  store i64 %72, ptr %20, align 8, !tbaa !11
  br label %62, !llvm.loop !16

73:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %74 = load i32, ptr %15, align 4, !tbaa !9
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = load i32, ptr %13, align 4, !tbaa !9
  %77 = load i32, ptr %14, align 4, !tbaa !9
  %78 = call ptr @packetizer_create(i32 noundef %74, i32 noundef %75, i32 noundef %76, i32 noundef %77)
  store ptr %78, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  store i32 0, ptr %22, align 4, !tbaa !9
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = call i32 @getrusage(i32 noundef 0, ptr noundef %79) #6
  store i64 0, ptr %20, align 8, !tbaa !11
  br label %81

81:                                               ; preds = %112, %73
  %82 = load i64, ptr %20, align 8, !tbaa !11
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load i64, ptr %83, align 8, !tbaa !11
  %85 = icmp ult i64 %82, %84
  br i1 %85, label %86, label %115

86:                                               ; preds = %81
  %87 = load ptr, ptr %21, align 8, !tbaa !5
  %88 = call i32 @packetizer_decode(ptr noundef %87, ptr noundef %43, ptr noundef %46)
  %89 = load i32, ptr %22, align 4, !tbaa !9
  %90 = or i32 %89, %88
  store i32 %90, ptr %22, align 4, !tbaa !9
  %91 = load ptr, ptr %21, align 8, !tbaa !5
  %92 = call i32 @packetizer_decode(ptr noundef %91, ptr noundef %43, ptr noundef %46)
  %93 = load i32, ptr %22, align 4, !tbaa !9
  %94 = or i32 %93, %92
  store i32 %94, ptr %22, align 4, !tbaa !9
  %95 = load ptr, ptr %21, align 8, !tbaa !5
  %96 = call i32 @packetizer_decode(ptr noundef %95, ptr noundef %43, ptr noundef %46)
  %97 = load i32, ptr %22, align 4, !tbaa !9
  %98 = or i32 %97, %96
  store i32 %98, ptr %22, align 4, !tbaa !9
  %99 = load ptr, ptr %21, align 8, !tbaa !5
  %100 = call i32 @packetizer_decode(ptr noundef %99, ptr noundef %43, ptr noundef %46)
  %101 = load i32, ptr %22, align 4, !tbaa !9
  %102 = or i32 %101, %100
  store i32 %102, ptr %22, align 4, !tbaa !9
  %103 = load i32, ptr %22, align 4, !tbaa !9
  %104 = icmp ne i32 %103, 0
  %105 = zext i1 %104 to i64
  %106 = select i1 %104, i32 1, i32 0
  %107 = getelementptr inbounds i8, ptr %43, i64 0
  %108 = load i8, ptr %107, align 16, !tbaa !13
  %109 = zext i8 %108 to i32
  %110 = xor i32 %109, %106
  %111 = trunc i32 %110 to i8
  store i8 %111, ptr %107, align 16, !tbaa !13
  br label %112

112:                                              ; preds = %86
  %113 = load i64, ptr %20, align 8, !tbaa !11
  %114 = add i64 %113, 1
  store i64 %114, ptr %20, align 8, !tbaa !11
  br label %81, !llvm.loop !17

115:                                              ; preds = %81
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = call i32 @getrusage(i32 noundef 0, ptr noundef %116) #6
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = load i64, ptr %118, align 8, !tbaa !11
  %120 = mul i64 %119, 4
  store i64 %120, ptr %118, align 8, !tbaa !11
  %121 = load ptr, ptr %21, align 8, !tbaa !5
  %122 = call i32 @packetizer_destroy(ptr noundef %121)
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  %123 = load ptr, ptr %17, align 8
  call void @llvm.stackrestore.p0(ptr %123)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  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 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

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

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

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

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

declare i32 @packetizer_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) #4

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 speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { 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 #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}
!17 = distinct !{!17, !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 @packetizer_decode_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = tail call i32 @packetizer_compute_enc_msg_len(i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #5
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = mul i64 %9, 1000
  %11 = uitofp i32 %3 to double
  %12 = tail call double @llvm.fmuladd.f64(double %11, double 1.612500e+00, double 2.210000e+02)
  %13 = uitofp i64 %10 to double
  %14 = fdiv double %13, %12
  %15 = fptoui double %14 to i64
  store i64 %15, ptr %2, align 8, !tbaa !5
  %16 = zext i32 %8 to i64
  %17 = alloca i8, i64 %16, align 16
  %18 = zext i32 %3 to i64
  %19 = alloca i8, i64 %18, align 16
  %.not47 = icmp eq i32 %8, 0
  br i1 %.not47, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %7
  %.not48 = icmp eq i32 %3, 0
  br i1 %.not48, label %._crit_edge, label %.lr.ph41.preheader

.lr.ph41.preheader:                               ; preds = %.preheader
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %19, i8 0, i64 %18, i1 false), !tbaa !9
  br label %._crit_edge

.lr.ph:                                           ; preds = %7, %.lr.ph
  %.03839 = phi i64 [ %23, %.lr.ph ], [ 0, %7 ]
  %20 = tail call i32 @rand() #5
  %21 = trunc i32 %20 to i8
  %22 = getelementptr inbounds i8, ptr %17, i64 %.03839
  store i8 %21, ptr %22, align 1, !tbaa !9
  %23 = add nuw nsw i64 %.03839, 1
  %exitcond.not = icmp eq i64 %23, %16
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph41.preheader, %.preheader
  %24 = tail call ptr @packetizer_create(i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #5
  %25 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %.not49 = icmp eq i64 %26, 0
  br i1 %.not49, label %._crit_edge46, label %.lr.ph45

.lr.ph45:                                         ; preds = %._crit_edge, %.lr.ph45
  %.043 = phi i32 [ %34, %.lr.ph45 ], [ 0, %._crit_edge ]
  %.242 = phi i64 [ %38, %.lr.ph45 ], [ 0, %._crit_edge ]
  %27 = call i32 @packetizer_decode(ptr noundef %24, ptr noundef nonnull %17, ptr noundef nonnull %19) #5
  %28 = or i32 %27, %.043
  %29 = call i32 @packetizer_decode(ptr noundef %24, ptr noundef nonnull %17, ptr noundef nonnull %19) #5
  %30 = or i32 %28, %29
  %31 = call i32 @packetizer_decode(ptr noundef %24, ptr noundef nonnull %17, ptr noundef nonnull %19) #5
  %32 = or i32 %30, %31
  %33 = call i32 @packetizer_decode(ptr noundef %24, ptr noundef nonnull %17, ptr noundef nonnull %19) #5
  %34 = or i32 %32, %33
  %.not = icmp ne i32 %34, 0
  %35 = load i8, ptr %17, align 16, !tbaa !9
  %36 = zext i1 %.not to i8
  %37 = xor i8 %35, %36
  store i8 %37, ptr %17, align 16, !tbaa !9
  %38 = add nuw i64 %.242, 1
  %39 = load i64, ptr %2, align 8, !tbaa !5
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %.lr.ph45, label %._crit_edge46, !llvm.loop !12

._crit_edge46:                                    ; preds = %.lr.ph45, %._crit_edge
  %41 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %42 = load i64, ptr %2, align 8, !tbaa !5
  %43 = shl i64 %42, 2
  store i64 %43, ptr %2, align 8, !tbaa !5
  %44 = call i32 @packetizer_destroy(ptr noundef %24) #5
  ret void
}

declare i32 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 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

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

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

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

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

declare i32 @packetizer_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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