; LLVM IR from VoidRune/Audio-engine :: src (minivorbis)

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @vorbis_bitrate_init(ptr noundef %0, ptr noundef %1) #3 {
  %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 %108

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 %108

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 i64
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.bitrate_manager_state, ptr %59, i32 0, i32 3
  store i64 %58, ptr %60, align 8, !tbaa !23
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.bitrate_manager_info, ptr %61, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !24
  %64 = sitofp i64 %63 to double
  %65 = fmul double 1.000000e+00, %64
  %66 = load i32, ptr %8, align 4, !tbaa !18
  %67 = sitofp i32 %66 to double
  %68 = fmul double %65, %67
  %69 = load i64, ptr %7, align 8, !tbaa !17
  %70 = sitofp i64 %69 to double
  %71 = fdiv double %68, %70
  %72 = call double @llvm.rint.f64(double %71)
  %73 = fptosi double %72 to i64
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.bitrate_manager_state, ptr %74, i32 0, i32 4
  store i64 %73, ptr %75, align 8, !tbaa !25
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.bitrate_manager_info, ptr %76, i32 0, i32 2
  %78 = load i64, ptr %77, align 8, !tbaa !26
  %79 = sitofp i64 %78 to double
  %80 = fmul double 1.000000e+00, %79
  %81 = load i32, ptr %8, align 4, !tbaa !18
  %82 = sitofp i32 %81 to double
  %83 = fmul double %80, %82
  %84 = load i64, ptr %7, align 8, !tbaa !17
  %85 = sitofp i64 %84 to double
  %86 = fdiv double %83, %85
  %87 = call double @llvm.rint.f64(double %86)
  %88 = fptosi double %87 to i64
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.bitrate_manager_state, ptr %89, i32 0, i32 5
  store i64 %88, ptr %90, align 8, !tbaa !27
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.bitrate_manager_state, ptr %91, i32 0, i32 7
  store double 7.000000e+00, ptr %92, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.bitrate_manager_info, ptr %93, i32 0, i32 3
  %95 = load i64, ptr %94, align 8, !tbaa !13
  %96 = sitofp i64 %95 to double
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.bitrate_manager_info, ptr %97, i32 0, i32 4
  %99 = load double, ptr %98, align 8, !tbaa !29
  %100 = fmul double %96, %99
  %101 = fptosi double %100 to i64
  store i64 %101, ptr %9, align 8, !tbaa !17
  %102 = load i64, ptr %9, align 8, !tbaa !17
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.bitrate_manager_state, ptr %103, i32 0, i32 2
  store i64 %102, ptr %104, align 8, !tbaa !30
  %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 1
  store i64 %105, ptr %107, 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 %108

108:                                              ; 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
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; 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 #2 {
  %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 %52

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 = load i64, ptr %9, align 8, !tbaa !20
  %20 = sitofp i64 %19 to double
  %21 = sitofp i32 %14 to double
  %22 = fmul double %21, %20
  %23 = sitofp i64 %11 to double
  %24 = fdiv double %22, %23
  %25 = tail call double @llvm.rint.f64(double %24)
  %26 = fptosi double %25 to i64
  %27 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 %26, ptr %27, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %4, i64 5448
  %29 = load i64, ptr %28, align 8, !tbaa !22
  %30 = sitofp i64 %29 to double
  %31 = fmul double %21, %30
  %32 = fdiv double %31, %23
  %33 = tail call double @llvm.rint.f64(double %32)
  %34 = fptosi double %33 to i64
  %35 = getelementptr inbounds i8, ptr %1, i64 32
  store i64 %34, ptr %35, align 8, !tbaa !23
  %36 = getelementptr inbounds i8, ptr %4, i64 5456
  %37 = load i64, ptr %36, align 8, !tbaa !24
  %38 = sitofp i64 %37 to double
  %39 = fmul double %21, %38
  %40 = fdiv double %39, %23
  %41 = tail call double @llvm.rint.f64(double %40)
  %42 = fptosi double %41 to i64
  %43 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 %42, ptr %43, align 8, !tbaa !25
  %44 = getelementptr inbounds i8, ptr %1, i64 56
  store double 7.000000e+00, ptr %44, align 8, !tbaa !26
  %45 = uitofp nneg i64 %6 to double
  %46 = getelementptr inbounds i8, ptr %4, i64 5472
  %47 = load double, ptr %46, align 8, !tbaa !27
  %48 = fmul double %47, %45
  %49 = fptosi double %48 to i64
  %50 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 %49, ptr %50, align 8, !tbaa !28
  %51 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %49, ptr %51, align 8, !tbaa !29
  br label %52

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

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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" }

!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 0}
!21 = !{!18, !10, i64 24}
!22 = !{!13, !10, i64 8}
!23 = !{!18, !10, i64 32}
!24 = !{!13, !10, i64 16}
!25 = !{!18, !10, i64 40}
!26 = !{!18, !14, i64 56}
!27 = !{!13, !14, i64 32}
!28 = !{!18, !10, i64 16}
!29 = !{!18, !10, i64 8}


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