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

; 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
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.vorbis_info, ptr %18, i32 0, i32 7
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  store ptr %20, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %21 = load ptr, ptr %14, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.codec_setup_info, ptr %21, i32 0, i32 19
  store ptr %22, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %23 = load i64, ptr %12, align 8, !tbaa !9
  %24 = sitofp i64 %23 to double
  store double %24, ptr %16, align 8, !tbaa !14
  %25 = load i64, ptr %12, align 8, !tbaa !9
  %26 = sitofp i64 %25 to double
  %27 = fcmp ole double %26, 0.000000e+00
  br i1 %27, label %28, label %58

28:                                               ; preds = %6
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %30 = sitofp i64 %29 to double
  %31 = fcmp ogt double %30, 0.000000e+00
  br i1 %31, label %32, label %49

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

36:                                               ; preds = %32
  %37 = load i64, ptr %11, align 8, !tbaa !9
  %38 = load i64, ptr %13, align 8, !tbaa !9
  %39 = add nsw i64 %37, %38
  %40 = sitofp i64 %39 to double
  %41 = fmul double %40, 5.000000e-01
  %42 = fptosi double %41 to i64
  store i64 %42, ptr %12, align 8, !tbaa !9
  br label %48

43:                                               ; preds = %32
  %44 = load i64, ptr %11, align 8, !tbaa !9
  %45 = sitofp i64 %44 to double
  %46 = fmul double %45, 8.750000e-01
  %47 = fptosi double %46 to i64
  store i64 %47, ptr %12, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %43, %36
  br label %57

49:                                               ; preds = %28
  %50 = load i64, ptr %13, align 8, !tbaa !9
  %51 = sitofp i64 %50 to double
  %52 = fcmp ogt double %51, 0.000000e+00
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %54, ptr %12, align 8, !tbaa !9
  br label %56

55:                                               ; preds = %49
  store i32 -131, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %103

56:                                               ; preds = %53
  br label %57

57:                                               ; preds = %56, %48
  br label %58

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

76:                                               ; preds = %58
  store i32 -130, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %103

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

103:                                              ; preds = %77, %76, %55
  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
  %104 = load i32, ptr %7, align 4
  ret i32 %104
}

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 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = sitofp i64 %4 to double
  %10 = icmp slt i64 %4, 1
  br i1 %10, label %11, label %25

11:                                               ; preds = %6
  %12 = sitofp i64 %3 to double
  %13 = icmp sgt i64 %3, 0
  %14 = icmp sgt i64 %5, 0
  br i1 %13, label %15, label %24

15:                                               ; preds = %11
  br i1 %14, label %16, label %21

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

21:                                               ; preds = %15
  %22 = fmul double %12, 8.750000e-01
  %23 = fptosi double %22 to i64
  br label %25

24:                                               ; preds = %11
  br i1 %14, label %25, label %43

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

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

43:                                               ; preds = %25, %24, %32
  %.0 = phi i32 [ 0, %32 ], [ -131, %24 ], [ -130, %25 ]
  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