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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_encode_setup_vbr(ptr noundef %0, i64 noundef %1, i64 noundef %2, float noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.vorbis_info, ptr %13, i32 0, i32 7
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  store ptr %15, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.codec_setup_info, ptr %16, i32 0, i32 19
  store ptr %17, ptr %11, align 8, !tbaa !5
  %18 = load float, ptr %9, align 4, !tbaa !11
  %19 = fpext float %18 to double
  %20 = fadd double %19, 0x3E7AD7F29ABCAF48
  %21 = fptrunc double %20 to float
  store float %21, ptr %9, align 4, !tbaa !11
  %22 = load float, ptr %9, align 4, !tbaa !11
  %23 = fpext float %22 to double
  %24 = fcmp oge double %23, 1.000000e+00
  br i1 %24, label %25, label %26

25:                                               ; preds = %4
  store float 0x3FEFFF2E40000000, ptr %9, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %25, %4
  %27 = load float, ptr %9, align 4, !tbaa !11
  %28 = load ptr, ptr %11, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %28, i32 0, i32 4
  store float %27, ptr %29, align 8, !tbaa !16
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = load i64, ptr %8, align 8, !tbaa !9
  %32 = load float, ptr %9, align 4, !tbaa !11
  %33 = fpext float %32 to double
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %34, i32 0, i32 2
  %36 = call ptr @get_setup_template(i64 noundef %30, i64 noundef %31, double noundef %33, i32 noundef 0, ptr noundef %35)
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %37, i32 0, i32 1
  store ptr %36, ptr %38, align 8, !tbaa !19
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = icmp ne ptr %41, null
  br i1 %42, label %44, label %43

43:                                               ; preds = %26
  store i32 -130, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %52

44:                                               ; preds = %26
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !9
  %47 = load i64, ptr %8, align 8, !tbaa !9
  call void @vorbis_encode_setup_setting(ptr noundef %45, i64 noundef %46, i64 noundef %47)
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %48, i32 0, i32 5
  store i32 0, ptr %49, align 4, !tbaa !20
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %50, i32 0, i32 14
  store i32 1, ptr %51, align 8, !tbaa !21
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %52

52:                                               ; preds = %44, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %53 = load i32, ptr %5, align 4
  ret i32 %53
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_setup_template(i64 noundef, i64 noundef, double noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @vorbis_encode_setup_setting(ptr noundef, i64 noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 48}
!14 = !{!"vorbis_info", !15, i64 0, !15, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !12, i64 32}
!17 = !{!"highlevel_encode_setup", !15, i64 0, !6, i64 8, !18, i64 16, !18, i64 24, !12, i64 32, !15, i64 36, !10, i64 40, !10, i64 48, !18, i64 56, !10, i64 64, !10, i64 72, !18, i64 80, !15, i64 88, !15, i64 92, !15, i64 96, !18, i64 104, !18, i64 112, !15, i64 120, !18, i64 128, !18, i64 136, !18, i64 144, !18, i64 152, !7, i64 160}
!18 = !{!"double", !7, i64 0}
!19 = !{!17, !6, i64 8}
!20 = !{!17, !15, i64 36}
!21 = !{!17, !15, i64 96}


; 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 range(i32 -130, 1) i32 @vorbis_encode_setup_vbr(ptr noundef %0, i64 noundef %1, i64 noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = fpext float %3 to double
  %8 = fadd double %7, 0x3E7AD7F29ABCAF48
  %9 = fptrunc double %8 to float
  %10 = fcmp ult float %9, 1.000000e+00
  %.017 = select i1 %10, float %9, float 0x3FEFFF2E40000000
  %11 = getelementptr inbounds i8, ptr %6, i64 5520
  store float %.017, ptr %11, align 8, !tbaa !12
  %12 = fpext float %.017 to double
  %13 = getelementptr inbounds i8, ptr %6, i64 5504
  %14 = tail call ptr @get_setup_template(i64 noundef %1, i64 noundef %2, double noundef %12, i32 noundef 0, ptr noundef nonnull %13)
  %15 = getelementptr inbounds i8, ptr %6, i64 5496
  store ptr %14, ptr %15, align 8, !tbaa !16
  %.not = icmp eq ptr %14, null
  br i1 %.not, label %19, label %16

16:                                               ; preds = %4
  tail call void @vorbis_encode_setup_setting(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %2)
  %17 = getelementptr inbounds i8, ptr %6, i64 5524
  store i32 0, ptr %17, align 4, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %6, i64 5584
  store i32 1, ptr %18, align 8, !tbaa !18
  br label %19

19:                                               ; preds = %4, %16
  %.0 = phi i32 [ 0, %16 ], [ -130, %4 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden ptr @get_setup_template(i64 noundef, i64 noundef, double noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @vorbis_encode_setup_setting(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

!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, !15, i64 32}
!13 = !{!"highlevel_encode_setup", !7, i64 0, !11, i64 8, !14, i64 16, !14, i64 24, !15, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !14, i64 56, !10, i64 64, !10, i64 72, !14, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !14, i64 104, !14, i64 112, !7, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !8, i64 160}
!14 = !{!"double", !8, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = !{!13, !11, i64 8}
!17 = !{!13, !7, i64 36}
!18 = !{!13, !7, i64 96}


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