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

; 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.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 }
%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.vorbis_block_internal = type { ptr, float, i32, [15 x ptr] }
%struct.ogg_packet = type { ptr, i64, i64, i64, i64, i64 }

; 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 dso_local i32 @vorbis_bitrate_managed(ptr noundef) #1

declare i64 @oggpack_bytes(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_bitrate_flushpacket(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.vorbis_dsp_state, ptr %12, i32 0, i32 19
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %14, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.private_state, ptr %15, i32 0, i32 12
  store ptr %16, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bitrate_manager_state, ptr %17, i32 0, i32 8
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  store ptr %19, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 7, ptr %9, align 4, !tbaa !16
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %77

23:                                               ; preds = %2
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %74

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.vorbis_block, ptr %27, i32 0, i32 20
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  store ptr %29, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call i32 @vorbis_bitrate_managed(ptr noundef %30)
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %37

33:                                               ; preds = %26
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.bitrate_manager_state, ptr %34, i32 0, i32 9
  %36 = load i32, ptr %35, align 8, !tbaa !20
  store i32 %36, ptr %9, align 4, !tbaa !16
  br label %37

37:                                               ; preds = %33, %26
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.vorbis_block_internal, ptr %38, i32 0, i32 3
  %40 = load i32, ptr %9, align 4, !tbaa !16
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [15 x ptr], ptr %39, i64 0, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = call ptr @oggpack_get_buffer(ptr noundef %43)
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ogg_packet, ptr %45, i32 0, i32 0
  store ptr %44, ptr %46, align 8, !tbaa !21
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.vorbis_block_internal, ptr %47, i32 0, i32 3
  %49 = load i32, ptr %9, align 4, !tbaa !16
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [15 x ptr], ptr %48, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = call i64 @oggpack_bytes(ptr noundef %52)
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ogg_packet, ptr %54, i32 0, i32 1
  store i64 %53, ptr %55, align 8, !tbaa !23
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ogg_packet, ptr %56, i32 0, i32 2
  store i64 0, ptr %57, align 8, !tbaa !24
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.vorbis_block, ptr %58, i32 0, i32 7
  %60 = load i32, ptr %59, align 8, !tbaa !25
  %61 = sext i32 %60 to i64
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ogg_packet, ptr %62, i32 0, i32 3
  store i64 %61, ptr %63, align 8, !tbaa !26
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.vorbis_block, ptr %64, i32 0, i32 8
  %66 = load i64, ptr %65, align 8, !tbaa !27
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ogg_packet, ptr %67, i32 0, i32 4
  store i64 %66, ptr %68, align 8, !tbaa !28
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.vorbis_block, ptr %69, i32 0, i32 9
  %71 = load i64, ptr %70, align 8, !tbaa !29
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ogg_packet, ptr %72, i32 0, i32 5
  store i64 %71, ptr %73, align 8, !tbaa !30
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %74

74:                                               ; preds = %37, %23
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.bitrate_manager_state, ptr %75, i32 0, i32 8
  store ptr null, ptr %76, align 8, !tbaa !13
  store i32 1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %77

77:                                               ; preds = %74, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %78 = load i32, ptr %3, align 4
  ret i32 %78
}

declare ptr @oggpack_get_buffer(ptr 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 = { "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 }

!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 136}
!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 = !{!14, !6, i64 64}
!14 = !{!"bitrate_manager_state", !11, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !15, i64 56, !6, i64 64, !11, i64 72}
!15 = !{!"double", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !6, i64 184}
!18 = !{!"vorbis_block", !6, i64 0, !19, i64 8, !12, i64 48, !12, i64 56, !12, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !12, i64 88, !12, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !6, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !6, i64 184}
!19 = !{!"", !12, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!20 = !{!14, !11, i64 72}
!21 = !{!22, !6, i64 0}
!22 = !{!"", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!23 = !{!22, !12, i64 8}
!24 = !{!22, !12, i64 16}
!25 = !{!18, !11, i64 80}
!26 = !{!22, !12, i64 24}
!27 = !{!18, !12, i64 88}
!28 = !{!22, !12, i64 32}
!29 = !{!18, !12, i64 96}
!30 = !{!22, !12, i64 40}


; 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 dso_local i32 @vorbis_bitrate_managed(ptr noundef) local_unnamed_addr #0

declare i64 @oggpack_bytes(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @vorbis_bitrate_flushpacket(ptr nocapture noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 136
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 208
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %33, label %7

7:                                                ; preds = %2
  %.not25 = icmp eq ptr %1, null
  br i1 %.not25, label %32, label %8

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %6, i64 184
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = tail call i32 @vorbis_bitrate_managed(ptr noundef nonnull %6)
  %.not26 = icmp eq i32 %11, 0
  br i1 %.not26, label %16, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %4, i64 216
  %14 = load i32, ptr %13, align 8, !tbaa !18
  %15 = sext i32 %14 to i64
  br label %16

16:                                               ; preds = %12, %8
  %.022 = phi i64 [ %15, %12 ], [ 7, %8 ]
  %17 = getelementptr inbounds i8, ptr %10, i64 16
  %18 = getelementptr inbounds [15 x ptr], ptr %17, i64 0, i64 %.022
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = tail call ptr @oggpack_get_buffer(ptr noundef %19) #2
  store ptr %20, ptr %1, align 8, !tbaa !20
  %21 = load ptr, ptr %18, align 8, !tbaa !19
  %22 = tail call i64 @oggpack_bytes(ptr noundef %21) #2
  %23 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 %22, ptr %23, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 0, ptr %24, align 8, !tbaa !23
  %25 = getelementptr inbounds i8, ptr %6, i64 80
  %26 = load i32, ptr %25, align 8, !tbaa !24
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 %27, ptr %28, align 8, !tbaa !25
  %29 = getelementptr inbounds i8, ptr %6, i64 88
  %30 = getelementptr inbounds i8, ptr %1, i64 32
  %31 = load <2 x i64>, ptr %29, align 8, !tbaa !26
  store <2 x i64> %31, ptr %30, align 8, !tbaa !26
  br label %32

32:                                               ; preds = %16, %7
  store ptr null, ptr %5, align 8, !tbaa !12
  br label %33

33:                                               ; preds = %2, %32
  %.0 = phi i32 [ 1, %32 ], [ 0, %2 ]
  ret i32 %.0
}

declare ptr @oggpack_get_buffer(ptr noundef) local_unnamed_addr #1

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" }
attributes #1 = { "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, !10, i64 136}
!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 = !{!13, !10, i64 64}
!13 = !{!"bitrate_manager_state", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !14, i64 56, !10, i64 64, !7, i64 72}
!14 = !{!"double", !8, i64 0}
!15 = !{!16, !10, i64 184}
!16 = !{!"vorbis_block", !10, i64 0, !17, i64 8, !11, i64 48, !11, i64 56, !11, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !11, i64 88, !11, i64 96, !10, i64 104, !10, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !10, i64 144, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !10, i64 184}
!17 = !{!"", !11, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !11, i64 32}
!18 = !{!13, !7, i64 72}
!19 = !{!10, !10, i64 0}
!20 = !{!21, !10, i64 0}
!21 = !{!"", !10, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40}
!22 = !{!21, !11, i64 8}
!23 = !{!21, !11, i64 16}
!24 = !{!16, !7, i64 80}
!25 = !{!21, !11, i64 24}
!26 = !{!11, !11, i64 0}


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