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

; 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_block = type { ptr, %struct.oggpack_buffer, i64, i64, i64, i32, i32, i32, i64, i64, ptr, ptr, i64, i64, i64, ptr, i64, i64, i64, i64, ptr }
%struct.oggpack_buffer = type { i64, i32, ptr, ptr, i64 }
%struct.alloc_chain = type { ptr, ptr }

; 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 ptr @_vorbis_block_alloc(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load i64, ptr %4, align 8, !tbaa !9
  %8 = add nsw i64 %7, 7
  %9 = and i64 %8, -8
  store i64 %9, ptr %4, align 8, !tbaa !9
  %10 = load i64, ptr %4, align 8, !tbaa !9
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.vorbis_block, ptr %11, i32 0, i32 12
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = add nsw i64 %10, %13
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.vorbis_block, ptr %15, i32 0, i32 13
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = icmp sgt i64 %14, %17
  br i1 %18, label %19, label %58

19:                                               ; preds = %2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.vorbis_block, ptr %20, i32 0, i32 11
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %46

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %25 = call noalias ptr @malloc(i64 noundef 16) #4
  store ptr %25, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.vorbis_block, ptr %26, i32 0, i32 12
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.vorbis_block, ptr %29, i32 0, i32 14
  %31 = load i64, ptr %30, align 8, !tbaa !17
  %32 = add nsw i64 %31, %28
  store i64 %32, ptr %30, align 8, !tbaa !17
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.vorbis_block, ptr %33, i32 0, i32 15
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.alloc_chain, ptr %36, i32 0, i32 1
  store ptr %35, ptr %37, align 8, !tbaa !19
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.vorbis_block, ptr %38, i32 0, i32 11
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.alloc_chain, ptr %41, i32 0, i32 0
  store ptr %40, ptr %42, align 8, !tbaa !21
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.vorbis_block, ptr %44, i32 0, i32 15
  store ptr %43, ptr %45, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %46

46:                                               ; preds = %24, %19
  %47 = load i64, ptr %4, align 8, !tbaa !9
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.vorbis_block, ptr %48, i32 0, i32 13
  store i64 %47, ptr %49, align 8, !tbaa !15
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.vorbis_block, ptr %50, i32 0, i32 13
  %52 = load i64, ptr %51, align 8, !tbaa !15
  %53 = call noalias ptr @malloc(i64 noundef %52) #4
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.vorbis_block, ptr %54, i32 0, i32 11
  store ptr %53, ptr %55, align 8, !tbaa !16
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.vorbis_block, ptr %56, i32 0, i32 12
  store i64 0, ptr %57, align 8, !tbaa !11
  br label %58

58:                                               ; preds = %46, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.vorbis_block, ptr %59, i32 0, i32 11
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.vorbis_block, ptr %62, i32 0, i32 12
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds i8, ptr %61, i64 %64
  store ptr %65, ptr %6, align 8, !tbaa !5
  %66 = load i64, ptr %4, align 8, !tbaa !9
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.vorbis_block, ptr %67, i32 0, i32 12
  %69 = load i64, ptr %68, align 8, !tbaa !11
  %70 = add nsw i64 %69, %66
  store i64 %70, ptr %68, align 8, !tbaa !11
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  ret ptr %71
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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 allocsize(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 #3 = { nounwind }
attributes #4 = { nounwind allocsize(0) }

!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, !10, i64 120}
!12 = !{!"vorbis_block", !6, i64 0, !13, i64 8, !10, i64 48, !10, i64 56, !10, i64 64, !14, i64 72, !14, i64 76, !14, i64 80, !10, i64 88, !10, i64 96, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !6, i64 144, !10, i64 152, !10, i64 160, !10, i64 168, !10, i64 176, !6, i64 184}
!13 = !{!"", !10, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !10, i64 32}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !10, i64 128}
!16 = !{!12, !6, i64 112}
!17 = !{!12, !10, i64 136}
!18 = !{!12, !6, i64 144}
!19 = !{!20, !6, i64 8}
!20 = !{!"alloc_chain", !6, i64 0, !6, i64 8}
!21 = !{!20, !6, i64 0}


; 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 nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local ptr @_vorbis_block_alloc(ptr nocapture noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = add nsw i64 %1, 7
  %4 = and i64 %3, -8
  %5 = getelementptr inbounds i8, ptr %0, i64 120
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = add nsw i64 %6, %4
  %8 = getelementptr inbounds i8, ptr %0, i64 128
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %10 = icmp sgt i64 %7, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  br i1 %10, label %13, label %._crit_edge

13:                                               ; preds = %2
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %22, label %14

14:                                               ; preds = %13
  %15 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #2
  %16 = getelementptr inbounds i8, ptr %0, i64 136
  %17 = load i64, ptr %16, align 8, !tbaa !15
  %18 = add nsw i64 %17, %6
  store i64 %18, ptr %16, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 144
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds i8, ptr %15, i64 8
  store ptr %20, ptr %21, align 8, !tbaa !17
  store ptr %12, ptr %15, align 8, !tbaa !19
  store ptr %15, ptr %19, align 8, !tbaa !16
  br label %22

22:                                               ; preds = %14, %13
  store i64 %4, ptr %8, align 8, !tbaa !13
  %23 = tail call noalias ptr @malloc(i64 noundef %4) #2
  store ptr %23, ptr %11, align 8, !tbaa !14
  br label %._crit_edge

._crit_edge:                                      ; preds = %2, %22
  %24 = phi i64 [ 0, %22 ], [ %6, %2 ]
  %25 = phi ptr [ %23, %22 ], [ %12, %2 ]
  %26 = getelementptr inbounds i8, ptr %25, i64 %24
  %27 = add nsw i64 %24, %4
  store i64 %27, ptr %5, align 8, !tbaa !5
  ret ptr %26
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0) }

!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 120}
!6 = !{!"vorbis_block", !7, i64 0, !10, i64 8, !11, i64 48, !11, i64 56, !11, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !11, i64 88, !11, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !7, i64 184}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !12, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !11, i64 128}
!14 = !{!6, !7, i64 112}
!15 = !{!6, !11, i64 136}
!16 = !{!6, !7, i64 144}
!17 = !{!18, !7, i64 8}
!18 = !{!"alloc_chain", !7, i64 0, !7, i64 8}
!19 = !{!18, !7, i64 0}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass