; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/modules/juce_audio_formats/codecs/oggvorbis (init)

; 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.vorbis_info = type { i32, i32, i64, i64, i64, i64, i64, ptr }
%struct.codec_setup_info = type { [2 x i64], i32, i32, i32, i32, i32, i32, [64 x ptr], [64 x i32], [64 x ptr], [64 x i32], [64 x ptr], [64 x i32], [64 x ptr], [256 x ptr], ptr, [4 x ptr], %struct.vorbis_info_psy_global, %struct.bitrate_manager_info, %struct.highlevel_encode_setup, i32 }
%struct.vorbis_info_psy_global = type { i32, [7 x float], [7 x float], float, float, float, [15 x i32], [2 x [15 x i32]], [15 x i32], [15 x i32], [2 x [15 x i32]] }
%struct.bitrate_manager_info = type { i64, i64, i64, i64, double, double }
%struct.highlevel_encode_setup = type { i32, ptr, double, double, float, i32, i64, i64, double, i64, i64, double, i32, i32, i32, double, double, i32, double, double, double, double, [4 x %struct.highlevel_byblocktype] }
%struct.highlevel_byblocktype = type { double, double, double, double }
%struct.bitrate_manager_state = type { i32, i64, i64, i64, i64, i64, i64, double, ptr, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @vorbis_bitrate_init(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.vorbis_info, ptr %10, i32 0, i32 7
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.codec_setup_info, ptr %13, i32 0, i32 18
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 80, i1 false)
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %111

18:                                               ; preds = %2
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.bitrate_manager_info, ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %23, label %111

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.vorbis_info, ptr %24, i32 0, i32 2
  %26 = load i64, ptr %25, align 8, !tbaa !16
  store i64 %26, ptr %7, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.codec_setup_info, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds [2 x i64], ptr %28, i64 0, i64 0
  %30 = load i64, ptr %29, align 8, !tbaa !17
  %31 = ashr i64 %30, 1
  %32 = trunc i64 %31 to i32
  store i32 %32, ptr %8, align 4, !tbaa !18
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.codec_setup_info, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds [2 x i64], ptr %34, i64 0, i64 1
  %36 = load i64, ptr %35, align 8, !tbaa !17
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.codec_setup_info, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds [2 x i64], ptr %38, i64 0, i64 0
  %40 = load i64, ptr %39, align 8, !tbaa !17
  %41 = sdiv i64 %36, %40
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.bitrate_manager_state, ptr %42, i32 0, i32 6
  store i64 %41, ptr %43, align 8, !tbaa !19
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bitrate_manager_state, ptr %44, i32 0, i32 0
  store i32 1, ptr %45, align 8, !tbaa !21
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.bitrate_manager_info, ptr %46, i32 0, i32 0
  %48 = load i64, ptr %47, align 8, !tbaa !22
  %49 = sitofp i64 %48 to double
  %50 = fmul double 1.000000e+00, %49
  %51 = load i32, ptr %8, align 4, !tbaa !18
  %52 = sitofp i32 %51 to double
  %53 = fmul double %50, %52
  %54 = load i64, ptr %7, align 8, !tbaa !17
  %55 = sitofp i64 %54 to double
  %56 = fdiv double %53, %55
  %57 = call double @llvm.rint.f64(double %56)
  %58 = fptosi double %57 to i32
  %59 = sext i32 %58 to i64
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.bitrate_manager_state, ptr %60, i32 0, i32 3
  store i64 %59, ptr %61, align 8, !tbaa !23
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.bitrate_manager_info, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !24
  %65 = sitofp i64 %64 to double
  %66 = fmul double 1.000000e+00, %65
  %67 = load i32, ptr %8, align 4, !tbaa !18
  %68 = sitofp i32 %67 to double
  %69 = fmul double %66, %68
  %70 = load i64, ptr %7, align 8, !tbaa !17
  %71 = sitofp i64 %70 to double
  %72 = fdiv double %69, %71
  %73 = call double @llvm.rint.f64(double %72)
  %74 = fptosi double %73 to i32
  %75 = sext i32 %74 to i64
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.bitrate_manager_state, ptr %76, i32 0, i32 4
  store i64 %75, ptr %77, align 8, !tbaa !25
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.bitrate_manager_info, ptr %78, i32 0, i32 2
  %80 = load i64, ptr %79, align 8, !tbaa !26
  %81 = sitofp i64 %80 to double
  %82 = fmul double 1.000000e+00, %81
  %83 = load i32, ptr %8, align 4, !tbaa !18
  %84 = sitofp i32 %83 to double
  %85 = fmul double %82, %84
  %86 = load i64, ptr %7, align 8, !tbaa !17
  %87 = sitofp i64 %86 to double
  %88 = fdiv double %85, %87
  %89 = call double @llvm.rint.f64(double %88)
  %90 = fptosi double %89 to i32
  %91 = sext i32 %90 to i64
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.bitrate_manager_state, ptr %92, i32 0, i32 5
  store i64 %91, ptr %93, align 8, !tbaa !27
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.bitrate_manager_state, ptr %94, i32 0, i32 7
  store double 7.000000e+00, ptr %95, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.bitrate_manager_info, ptr %96, i32 0, i32 3
  %98 = load i64, ptr %97, align 8, !tbaa !13
  %99 = sitofp i64 %98 to double
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.bitrate_manager_info, ptr %100, i32 0, i32 4
  %102 = load double, ptr %101, align 8, !tbaa !29
  %103 = fmul double %99, %102
  %104 = fptosi double %103 to i64
  store i64 %104, ptr %9, align 8, !tbaa !17
  %105 = load i64, ptr %9, align 8, !tbaa !17
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.bitrate_manager_state, ptr %106, i32 0, i32 2
  store i64 %105, ptr %107, align 8, !tbaa !30
  %108 = load i64, ptr %9, align 8, !tbaa !17
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.bitrate_manager_state, ptr %109, i32 0, i32 1
  store i64 %108, ptr %110, align 8, !tbaa !31
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %111

111:                                              ; preds = %23, %18, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

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

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

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

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 48}
!10 = !{!"vorbis_info", !11, i64 0, !11, i64 4, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !6, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 24}
!14 = !{!"bitrate_manager_info", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !15, i64 32, !15, i64 40}
!15 = !{!"double", !7, i64 0}
!16 = !{!10, !12, i64 8}
!17 = !{!12, !12, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!20, !12, i64 48}
!20 = !{!"bitrate_manager_state", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !15, i64 56, !6, i64 64, !11, i64 72}
!21 = !{!20, !11, i64 0}
!22 = !{!14, !12, i64 0}
!23 = !{!20, !12, i64 24}
!24 = !{!14, !12, i64 8}
!25 = !{!20, !12, i64 32}
!26 = !{!14, !12, i64 16}
!27 = !{!20, !12, i64 40}
!28 = !{!20, !15, i64 56}
!29 = !{!14, !15, i64 32}
!30 = !{!20, !12, i64 16}
!31 = !{!20, !12, i64 8}


; 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 nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @vorbis_bitrate_init(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(80) %1, i8 0, i64 80, i1 false)
  %5 = getelementptr inbounds i8, ptr %4, i64 5464
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %8, label %50

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %4, i64 5440
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = load i64, ptr %4, align 8, !tbaa !16
  %13 = lshr i64 %12, 1
  %14 = trunc i64 %13 to i32
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !16
  %17 = sdiv i64 %16, %12
  %18 = getelementptr inbounds i8, ptr %1, i64 48
  store i64 %17, ptr %18, align 8, !tbaa !17
  store i32 1, ptr %1, align 8, !tbaa !19
  %19 = sitofp i32 %14 to double
  %20 = sitofp i64 %11 to double
  %21 = getelementptr inbounds i8, ptr %1, i64 24
  %22 = load <2 x i64>, ptr %9, align 8, !tbaa !16
  %23 = sitofp <2 x i64> %22 to <2 x double>
  %24 = insertelement <2 x double> poison, double %19, i64 0
  %25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
  %26 = fmul <2 x double> %25, %23
  %27 = insertelement <2 x double> poison, double %20, i64 0
  %28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> zeroinitializer
  %29 = fdiv <2 x double> %26, %28
  %30 = tail call <2 x double> @llvm.rint.v2f64(<2 x double> %29)
  %31 = fptosi <2 x double> %30 to <2 x i32>
  %32 = sext <2 x i32> %31 to <2 x i64>
  store <2 x i64> %32, ptr %21, align 8, !tbaa !16
  %33 = getelementptr inbounds i8, ptr %4, i64 5456
  %34 = load i64, ptr %33, align 8, !tbaa !20
  %35 = sitofp i64 %34 to double
  %36 = fmul double %19, %35
  %37 = fdiv double %36, %20
  %38 = tail call double @llvm.rint.f64(double %37)
  %39 = fptosi double %38 to i32
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 %40, ptr %41, align 8, !tbaa !21
  %42 = getelementptr inbounds i8, ptr %1, i64 56
  store double 7.000000e+00, ptr %42, align 8, !tbaa !22
  %43 = uitofp nneg i64 %6 to double
  %44 = getelementptr inbounds i8, ptr %4, i64 5472
  %45 = load double, ptr %44, align 8, !tbaa !23
  %46 = fmul double %45, %43
  %47 = fptosi double %46 to i64
  %48 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 %47, ptr %48, align 8, !tbaa !24
  %49 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %47, ptr %49, align 8, !tbaa !25
  br label %50

50:                                               ; preds = %8, %2
  ret void
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.rint.v2f64(<2 x double>) #3

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 48}
!6 = !{!"vorbis_info", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !10, i64 24}
!13 = !{!"bitrate_manager_info", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !14, i64 32, !14, i64 40}
!14 = !{!"double", !8, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!10, !10, i64 0}
!17 = !{!18, !10, i64 48}
!18 = !{!"bitrate_manager_state", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !11, i64 64, !7, i64 72}
!19 = !{!18, !7, i64 0}
!20 = !{!13, !10, i64 16}
!21 = !{!18, !10, i64 40}
!22 = !{!18, !14, i64 56}
!23 = !{!13, !14, i64 32}
!24 = !{!18, !10, i64 16}
!25 = !{!18, !10, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass