; LLVM IR from reworks-org/galaxy :: deps/sfml_deps/vorbis-src/lib (vorbisenc)

; 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %13 = load i64, ptr %8, align 8, !tbaa !9
  %14 = icmp sle i64 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %4
  store i32 -131, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %56

16:                                               ; preds = %4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.vorbis_info, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.codec_setup_info, ptr %20, i32 0, i32 19
  store ptr %21, ptr %11, align 8, !tbaa !5
  %22 = load float, ptr %9, align 4, !tbaa !11
  %23 = fpext float %22 to double
  %24 = fadd double %23, 0x3E7AD7F29ABCAF48
  %25 = fptrunc double %24 to float
  store float %25, ptr %9, align 4, !tbaa !11
  %26 = load float, ptr %9, align 4, !tbaa !11
  %27 = fpext float %26 to double
  %28 = fcmp oge double %27, 1.000000e+00
  br i1 %28, label %29, label %30

29:                                               ; preds = %16
  store float 0x3FEFFF2E40000000, ptr %9, align 4, !tbaa !11
  br label %30

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

47:                                               ; preds = %30
  store i32 -130, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %56

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

56:                                               ; preds = %48, %47, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %57 = load i32, ptr %5, align 4
  ret i32 %57
}

; 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 -131, 1) i32 @vorbis_encode_setup_vbr(ptr noundef %0, i64 noundef %1, i64 noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = icmp slt i64 %2, 1
  br i1 %5, label %21, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = fpext float %3 to double
  %10 = fadd double %9, 0x3E7AD7F29ABCAF48
  %11 = fptrunc double %10 to float
  %12 = fcmp ult float %11, 1.000000e+00
  %.018 = select i1 %12, float %11, float 0x3FEFFF2E40000000
  %13 = getelementptr inbounds i8, ptr %8, i64 5520
  store float %.018, ptr %13, align 8, !tbaa !12
  %14 = fpext float %.018 to double
  %15 = getelementptr inbounds i8, ptr %8, i64 5504
  %16 = tail call ptr @get_setup_template(i64 noundef %1, i64 noundef %2, double noundef %14, i32 noundef 0, ptr noundef nonnull %15)
  %17 = getelementptr inbounds i8, ptr %8, i64 5496
  store ptr %16, ptr %17, align 8, !tbaa !16
  %.not = icmp eq ptr %16, null
  br i1 %.not, label %21, label %18

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

21:                                               ; preds = %6, %4, %18
  %.0 = phi i32 [ 0, %18 ], [ -131, %4 ], [ -130, %6 ]
  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