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

; 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_dsp_state = type { i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, ptr }
%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.private_state = type { ptr, [2 x i32], [2 x ptr], [2 x %struct.drft_lookup], i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.bitrate_manager_state, i64 }
%struct.drft_lookup = type { i32, ptr, ptr }
%struct.bitrate_manager_state = type { i32, i64, i64, i64, i64, i64, i64, double, ptr, i32 }

; 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_synthesis_restart(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %11, i32 0, i32 19
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = icmp ne ptr %13, null
  br i1 %14, label %16, label %15

15:                                               ; preds = %1
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %62

16:                                               ; preds = %1
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %62

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.vorbis_info, ptr %21, i32 0, i32 7
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  store ptr %23, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  store i32 -1, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %62

27:                                               ; preds = %20
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.codec_setup_info, ptr %28, i32 0, i32 20
  %30 = load i32, ptr %29, align 8, !tbaa !16
  store i32 %30, ptr %6, align 4, !tbaa !23
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.codec_setup_info, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds [2 x i64], ptr %32, i64 0, i64 1
  %34 = load i64, ptr %33, align 8, !tbaa !24
  %35 = load i32, ptr %6, align 4, !tbaa !23
  %36 = add nsw i32 %35, 1
  %37 = zext i32 %36 to i64
  %38 = ashr i64 %34, %37
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %39, i32 0, i32 12
  store i64 %38, ptr %40, align 8, !tbaa !25
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %41, i32 0, i32 12
  %43 = load i64, ptr %42, align 8, !tbaa !25
  %44 = load i32, ptr %6, align 4, !tbaa !23
  %45 = zext i32 %44 to i64
  %46 = ashr i64 %43, %45
  %47 = trunc i64 %46 to i32
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %48, i32 0, i32 5
  store i32 %47, ptr %49, align 4, !tbaa !26
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %50, i32 0, i32 6
  store i32 -1, ptr %51, align 8, !tbaa !27
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %52, i32 0, i32 13
  store i64 -1, ptr %53, align 8, !tbaa !28
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %54, i32 0, i32 14
  store i64 -1, ptr %55, align 8, !tbaa !29
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %56, i32 0, i32 8
  store i32 0, ptr %57, align 8, !tbaa !30
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %58, i32 0, i32 19
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = getelementptr inbounds %struct.private_state, ptr %60, i32 0, i32 13
  store i64 -1, ptr %61, align 8, !tbaa !31
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %62

62:                                               ; preds = %27, %26, %19, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %63 = load i32, ptr %2, align 4
  ret i32 %63
}

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, !6, i64 8}
!10 = !{!"vorbis_dsp_state", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !12, i64 128, !6, i64 136}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !6, i64 136}
!14 = !{!15, !6, i64 48}
!15 = !{!"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}
!16 = !{!17, !11, i64 5776}
!17 = !{!"codec_setup_info", !7, i64 0, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !7, i64 552, !7, i64 808, !7, i64 1320, !7, i64 1576, !7, i64 2088, !7, i64 2344, !7, i64 2856, !6, i64 4904, !7, i64 4912, !18, i64 4944, !20, i64 5440, !22, i64 5488, !11, i64 5776}
!18 = !{!"", !11, i64 0, !7, i64 4, !7, i64 32, !19, i64 60, !19, i64 64, !19, i64 68, !7, i64 72, !7, i64 132, !7, i64 252, !7, i64 312, !7, i64 372}
!19 = !{!"float", !7, i64 0}
!20 = !{!"bitrate_manager_info", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !21, i64 32, !21, i64 40}
!21 = !{!"double", !7, i64 0}
!22 = !{!"highlevel_encode_setup", !11, i64 0, !6, i64 8, !21, i64 16, !21, i64 24, !19, i64 32, !11, i64 36, !12, i64 40, !12, i64 48, !21, i64 56, !12, i64 64, !12, i64 72, !21, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !21, i64 104, !21, i64 112, !11, i64 120, !21, i64 128, !21, i64 136, !21, i64 144, !21, i64 152, !7, i64 160}
!23 = !{!11, !11, i64 0}
!24 = !{!12, !12, i64 0}
!25 = !{!10, !12, i64 80}
!26 = !{!10, !11, i64 36}
!27 = !{!10, !11, i64 40}
!28 = !{!10, !12, i64 88}
!29 = !{!10, !12, i64 96}
!30 = !{!10, !11, i64 48}
!31 = !{!32, !12, i64 224}
!32 = !{!"private_state", !6, i64 0, !7, i64 8, !7, i64 16, !7, i64 32, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !33, i64 144, !12, i64 224}
!33 = !{!"bitrate_manager_state", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !21, i64 56, !6, i64 64, !11, i64 72}


; 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 nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local range(i32 -1, 1) i32 @vorbis_synthesis_restart(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  %5 = load ptr, ptr %4, align 8, !tbaa !12
  %.not = icmp eq ptr %5, null
  %.not19 = icmp eq ptr %3, null
  %or.cond = select i1 %.not, i1 true, i1 %.not19
  br i1 %or.cond, label %26, label %6

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %3, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %.not20 = icmp eq ptr %8, null
  br i1 %.not20, label %26, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %8, i64 5776
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !22
  %14 = add nsw i32 %11, 1
  %15 = zext nneg i32 %14 to i64
  %16 = ashr i64 %13, %15
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  store i64 %16, ptr %17, align 8, !tbaa !23
  %18 = zext nneg i32 %11 to i64
  %19 = ashr i64 %16, %18
  %20 = trunc i64 %19 to i32
  %21 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 %20, ptr %21, align 4, !tbaa !24
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 -1, ptr %22, align 8, !tbaa !25
  %23 = getelementptr inbounds i8, ptr %0, i64 88
  %24 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %23, i8 -1, i64 16, i1 false)
  store i32 0, ptr %24, align 8, !tbaa !26
  %25 = getelementptr inbounds i8, ptr %5, i64 224
  store i64 -1, ptr %25, align 8, !tbaa !27
  br label %26

26:                                               ; preds = %6, %1, %9
  %.0 = phi i32 [ 0, %9 ], [ -1, %1 ], [ -1, %6 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

!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, !10, i64 8}
!6 = !{!"vorbis_dsp_state", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !10, i64 136}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 136}
!13 = !{!14, !10, i64 48}
!14 = !{!"vorbis_info", !7, i64 0, !7, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !10, i64 48}
!15 = !{!16, !7, i64 5776}
!16 = !{!"codec_setup_info", !8, i64 0, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !8, i64 40, !8, i64 552, !8, i64 808, !8, i64 1320, !8, i64 1576, !8, i64 2088, !8, i64 2344, !8, i64 2856, !10, i64 4904, !8, i64 4912, !17, i64 4944, !19, i64 5440, !21, i64 5488, !7, i64 5776}
!17 = !{!"", !7, i64 0, !8, i64 4, !8, i64 32, !18, i64 60, !18, i64 64, !18, i64 68, !8, i64 72, !8, i64 132, !8, i64 252, !8, i64 312, !8, i64 372}
!18 = !{!"float", !8, i64 0}
!19 = !{!"bitrate_manager_info", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !20, i64 32, !20, i64 40}
!20 = !{!"double", !8, i64 0}
!21 = !{!"highlevel_encode_setup", !7, i64 0, !10, i64 8, !20, i64 16, !20, i64 24, !18, i64 32, !7, i64 36, !11, i64 40, !11, i64 48, !20, i64 56, !11, i64 64, !11, i64 72, !20, i64 80, !7, i64 88, !7, i64 92, !7, i64 96, !20, i64 104, !20, i64 112, !7, i64 120, !20, i64 128, !20, i64 136, !20, i64 144, !20, i64 152, !8, i64 160}
!22 = !{!11, !11, i64 0}
!23 = !{!6, !11, i64 80}
!24 = !{!6, !7, i64 36}
!25 = !{!6, !7, i64 40}
!26 = !{!6, !7, i64 48}
!27 = !{!28, !11, i64 224}
!28 = !{!"private_state", !10, i64 0, !8, i64 8, !8, i64 16, !8, i64 32, !7, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !29, i64 144, !11, i64 224}
!29 = !{!"bitrate_manager_state", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !20, i64 56, !10, i64 64, !7, i64 72}


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