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

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_encode_setup_managed(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store i64 %2, ptr %10, align 8, !tbaa !9
  store i64 %3, ptr %11, align 8, !tbaa !9
  store i64 %4, ptr %12, align 8, !tbaa !9
  store i64 %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %18 = load i64, ptr %10, align 8, !tbaa !9
  %19 = icmp sle i64 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %6
  store i32 -131, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %107

21:                                               ; preds = %6
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.vorbis_info, ptr %22, i32 0, i32 7
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store ptr %24, ptr %14, align 8, !tbaa !5
  %25 = load ptr, ptr %14, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.codec_setup_info, ptr %25, i32 0, i32 19
  store ptr %26, ptr %15, align 8, !tbaa !5
  %27 = load i64, ptr %12, align 8, !tbaa !9
  %28 = sitofp i64 %27 to double
  store double %28, ptr %16, align 8, !tbaa !14
  %29 = load i64, ptr %12, align 8, !tbaa !9
  %30 = sitofp i64 %29 to double
  %31 = fcmp ole double %30, 0.000000e+00
  br i1 %31, label %32, label %62

32:                                               ; preds = %21
  %33 = load i64, ptr %11, align 8, !tbaa !9
  %34 = sitofp i64 %33 to double
  %35 = fcmp ogt double %34, 0.000000e+00
  br i1 %35, label %36, label %53

36:                                               ; preds = %32
  %37 = load i64, ptr %13, align 8, !tbaa !9
  %38 = sitofp i64 %37 to double
  %39 = fcmp ogt double %38, 0.000000e+00
  br i1 %39, label %40, label %47

40:                                               ; preds = %36
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = load i64, ptr %13, align 8, !tbaa !9
  %43 = add nsw i64 %41, %42
  %44 = sitofp i64 %43 to double
  %45 = fmul double %44, 5.000000e-01
  %46 = fptosi double %45 to i64
  store i64 %46, ptr %12, align 8, !tbaa !9
  br label %52

47:                                               ; preds = %36
  %48 = load i64, ptr %11, align 8, !tbaa !9
  %49 = sitofp i64 %48 to double
  %50 = fmul double %49, 8.750000e-01
  %51 = fptosi double %50 to i64
  store i64 %51, ptr %12, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %47, %40
  br label %61

53:                                               ; preds = %32
  %54 = load i64, ptr %13, align 8, !tbaa !9
  %55 = sitofp i64 %54 to double
  %56 = fcmp ogt double %55, 0.000000e+00
  br i1 %56, label %57, label %59

57:                                               ; preds = %53
  %58 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %58, ptr %12, align 8, !tbaa !9
  br label %60

59:                                               ; preds = %53
  store i32 -131, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %107

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60, %52
  br label %62

62:                                               ; preds = %61, %21
  %63 = load i64, ptr %12, align 8, !tbaa !9
  %64 = sitofp i64 %63 to float
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %65, i32 0, i32 4
  store float %64, ptr %66, align 8, !tbaa !16
  %67 = load i64, ptr %9, align 8, !tbaa !9
  %68 = load i64, ptr %10, align 8, !tbaa !9
  %69 = load i64, ptr %12, align 8, !tbaa !9
  %70 = sitofp i64 %69 to double
  %71 = load ptr, ptr %15, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %71, i32 0, i32 2
  %73 = call ptr @get_setup_template(i64 noundef %67, i64 noundef %68, double noundef %70, i32 noundef 1, ptr noundef %72)
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %74, i32 0, i32 1
  store ptr %73, ptr %75, align 8, !tbaa !19
  %76 = load ptr, ptr %15, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  %79 = icmp ne ptr %78, null
  br i1 %79, label %81, label %80

80:                                               ; preds = %62
  store i32 -130, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %107

81:                                               ; preds = %62
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = load i64, ptr %9, align 8, !tbaa !9
  %84 = load i64, ptr %10, align 8, !tbaa !9
  call void @vorbis_encode_setup_setting(ptr noundef %82, i64 noundef %83, i64 noundef %84)
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %85, i32 0, i32 14
  store i32 1, ptr %86, align 8, !tbaa !20
  %87 = load ptr, ptr %15, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %87, i32 0, i32 5
  store i32 1, ptr %88, align 4, !tbaa !21
  %89 = load i64, ptr %13, align 8, !tbaa !9
  %90 = load ptr, ptr %15, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %90, i32 0, i32 6
  store i64 %89, ptr %91, align 8, !tbaa !22
  %92 = load i64, ptr %11, align 8, !tbaa !9
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %93, i32 0, i32 9
  store i64 %92, ptr %94, align 8, !tbaa !23
  %95 = load double, ptr %16, align 8, !tbaa !14
  %96 = fptosi double %95 to i64
  %97 = load ptr, ptr %15, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %97, i32 0, i32 7
  store i64 %96, ptr %98, align 8, !tbaa !24
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %99, i32 0, i32 8
  store double 1.500000e+00, ptr %100, align 8, !tbaa !25
  %101 = load i64, ptr %12, align 8, !tbaa !9
  %102 = mul nsw i64 %101, 2
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %103, i32 0, i32 10
  store i64 %102, ptr %104, align 8, !tbaa !26
  %105 = load ptr, ptr %15, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.highlevel_encode_setup, ptr %105, i32 0, i32 11
  store double 1.000000e-01, ptr %106, align 8, !tbaa !27
  store i32 0, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %107

107:                                              ; preds = %81, %80, %59, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  %108 = load i32, ptr %7, align 4
  ret i32 %108
}

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, !6, i64 48}
!12 = !{!"vorbis_info", !13, i64 0, !13, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!17, !18, i64 32}
!17 = !{!"highlevel_encode_setup", !13, i64 0, !6, i64 8, !15, i64 16, !15, i64 24, !18, i64 32, !13, i64 36, !10, i64 40, !10, i64 48, !15, i64 56, !10, i64 64, !10, i64 72, !15, i64 80, !13, i64 88, !13, i64 92, !13, i64 96, !15, i64 104, !15, i64 112, !13, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !7, i64 160}
!18 = !{!"float", !7, i64 0}
!19 = !{!17, !6, i64 8}
!20 = !{!17, !13, i64 96}
!21 = !{!17, !13, i64 36}
!22 = !{!17, !10, i64 40}
!23 = !{!17, !10, i64 64}
!24 = !{!17, !10, i64 48}
!25 = !{!17, !15, i64 56}
!26 = !{!17, !10, i64 72}
!27 = !{!17, !15, i64 80}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -131, 1) i32 @vorbis_encode_setup_managed(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = icmp slt i64 %2, 1
  br i1 %7, label %45, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = sitofp i64 %4 to double
  %12 = icmp slt i64 %4, 1
  br i1 %12, label %13, label %27

13:                                               ; preds = %8
  %14 = sitofp i64 %3 to double
  %15 = icmp sgt i64 %3, 0
  %16 = icmp sgt i64 %5, 0
  br i1 %15, label %17, label %26

17:                                               ; preds = %13
  br i1 %16, label %18, label %23

18:                                               ; preds = %17
  %19 = add nuw nsw i64 %5, %3
  %20 = uitofp nneg i64 %19 to double
  %21 = fmul double %20, 5.000000e-01
  %22 = fptosi double %21 to i64
  br label %27

23:                                               ; preds = %17
  %24 = fmul double %14, 8.750000e-01
  %25 = fptosi double %24 to i64
  br label %27

26:                                               ; preds = %13
  br i1 %16, label %27, label %45

27:                                               ; preds = %26, %23, %18, %8
  %.035 = phi i64 [ %22, %18 ], [ %25, %23 ], [ %4, %8 ], [ %5, %26 ]
  %28 = sitofp i64 %.035 to float
  %29 = getelementptr inbounds i8, ptr %10, i64 5520
  store float %28, ptr %29, align 8, !tbaa !12
  %30 = sitofp i64 %.035 to double
  %31 = getelementptr inbounds i8, ptr %10, i64 5504
  %32 = tail call ptr @get_setup_template(i64 noundef %1, i64 noundef %2, double noundef %30, i32 noundef 1, ptr noundef nonnull %31)
  %33 = getelementptr inbounds i8, ptr %10, i64 5496
  store ptr %32, ptr %33, align 8, !tbaa !16
  %.not = icmp eq ptr %32, null
  br i1 %.not, label %45, label %34

34:                                               ; preds = %27
  tail call void @vorbis_encode_setup_setting(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %2)
  %35 = getelementptr inbounds i8, ptr %10, i64 5584
  store i32 1, ptr %35, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %10, i64 5524
  store i32 1, ptr %36, align 4, !tbaa !18
  %37 = getelementptr inbounds i8, ptr %10, i64 5528
  store i64 %5, ptr %37, align 8, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %10, i64 5552
  store i64 %3, ptr %38, align 8, !tbaa !20
  %39 = fptosi double %11 to i64
  %40 = getelementptr inbounds i8, ptr %10, i64 5536
  store i64 %39, ptr %40, align 8, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %10, i64 5544
  store double 1.500000e+00, ptr %41, align 8, !tbaa !22
  %42 = shl nsw i64 %.035, 1
  %43 = getelementptr inbounds i8, ptr %10, i64 5560
  store i64 %42, ptr %43, align 8, !tbaa !23
  %44 = getelementptr inbounds i8, ptr %10, i64 5568
  store double 1.000000e-01, ptr %44, align 8, !tbaa !24
  br label %45

45:                                               ; preds = %27, %26, %6, %34
  %.0 = phi i32 [ 0, %34 ], [ -131, %6 ], [ -131, %26 ], [ -130, %27 ]
  ret i32 %.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 96}
!18 = !{!13, !7, i64 36}
!19 = !{!13, !10, i64 40}
!20 = !{!13, !10, i64 64}
!21 = !{!13, !10, i64 48}
!22 = !{!13, !14, i64 56}
!23 = !{!13, !10, i64 72}
!24 = !{!13, !14, i64 80}


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