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

; 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.OggVorbis_File = type { ptr, i32, i64, i64, %struct.ogg_sync_state, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i32, i64, i32, double, double, %struct.ogg_stream_state, %struct.vorbis_dsp_state, %struct.vorbis_block, %struct.ov_callbacks }
%struct.ogg_sync_state = type { ptr, i32, i32, i32, i32, i32, i32 }
%struct.ogg_stream_state = type { ptr, i64, i64, i64, ptr, ptr, i64, i64, i64, i64, [282 x i8], i32, i32, i32, i64, i64, i64, i64 }
%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_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.ov_callbacks = type { ptr, ptr, 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

declare i32 @vorbis_synthesis_halfrate_p(ptr noundef) #1

declare i32 @vorbis_synthesis_pcmout(ptr noundef, ptr noundef) #1

declare i32 @vorbis_synthesis_read(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @_fetch_and_process_packet(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @ov_read_float(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #2 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.OggVorbis_File, ptr %15, i32 0, i32 13
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp slt i32 %17, 2
  br i1 %18, label %19, label %20

19:                                               ; preds = %4
  store i64 -131, ptr %5, align 8
  br label %94

20:                                               ; preds = %4
  br label %21

21:                                               ; preds = %93, %20
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.OggVorbis_File, ptr %22, i32 0, i32 13
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i32 %24, 4
  br i1 %25, label %26, label %78

26:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.OggVorbis_File, ptr %27, i32 0, i32 19
  %29 = call i32 @vorbis_synthesis_pcmout(ptr noundef %28, ptr noundef %10)
  %30 = sext i32 %29 to i64
  store i64 %30, ptr %11, align 8, !tbaa !21
  %31 = load i64, ptr %11, align 8, !tbaa !21
  %32 = icmp ne i64 %31, 0
  br i1 %32, label %33, label %74

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.OggVorbis_File, ptr %34, i32 0, i32 10
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = call i32 @vorbis_synthesis_halfrate_p(ptr noundef %36)
  store i32 %37, ptr %12, align 4, !tbaa !9
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %43

40:                                               ; preds = %33
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %41, ptr %42, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %40, %33
  %44 = load i64, ptr %11, align 8, !tbaa !21
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = icmp sgt i64 %44, %46
  br i1 %47, label %48, label %51

48:                                               ; preds = %43
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  store i64 %50, ptr %11, align 8, !tbaa !21
  br label %51

51:                                               ; preds = %48, %43
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.OggVorbis_File, ptr %52, i32 0, i32 19
  %54 = load i64, ptr %11, align 8, !tbaa !21
  %55 = trunc i64 %54 to i32
  %56 = call i32 @vorbis_synthesis_read(ptr noundef %53, i32 noundef %55)
  %57 = load i64, ptr %11, align 8, !tbaa !21
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = shl i64 %57, %59
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.OggVorbis_File, ptr %61, i32 0, i32 12
  %63 = load i64, ptr %62, align 8, !tbaa !23
  %64 = add nsw i64 %63, %60
  store i64 %64, ptr %62, align 8, !tbaa !23
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %72

67:                                               ; preds = %51
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.OggVorbis_File, ptr %68, i32 0, i32 15
  %70 = load i32, ptr %69, align 8, !tbaa !24
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %70, ptr %71, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %67, %51
  %73 = load i64, ptr %11, align 8, !tbaa !21
  store i64 %73, ptr %5, align 8
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %75

74:                                               ; preds = %26
  store i32 0, ptr %13, align 4
  br label %75

75:                                               ; preds = %74, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %76 = load i32, ptr %13, align 4
  switch i32 %76, label %96 [
    i32 0, label %77
    i32 1, label %94
  ]

77:                                               ; preds = %75
  br label %78

78:                                               ; preds = %77, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = call i32 @_fetch_and_process_packet(ptr noundef %79, ptr noundef null, i32 noundef 1, i32 noundef 1)
  store i32 %80, ptr %14, align 4, !tbaa !9
  %81 = load i32, ptr %14, align 4, !tbaa !9
  %82 = icmp eq i32 %81, -2
  br i1 %82, label %83, label %84

83:                                               ; preds = %78
  store i64 0, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %91

84:                                               ; preds = %78
  %85 = load i32, ptr %14, align 4, !tbaa !9
  %86 = icmp sle i32 %85, 0
  br i1 %86, label %87, label %90

87:                                               ; preds = %84
  %88 = load i32, ptr %14, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  store i64 %89, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %91

90:                                               ; preds = %84
  store i32 0, ptr %13, align 4
  br label %91

91:                                               ; preds = %90, %87, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %92 = load i32, ptr %13, align 4
  switch i32 %92, label %96 [
    i32 0, label %93
    i32 1, label %94
  ]

93:                                               ; preds = %91
  br label %21

94:                                               ; preds = %91, %75, %19
  %95 = load i64, ptr %5, align 8
  ret i64 %95

96:                                               ; preds = %91, %75
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 128}
!12 = !{!"OggVorbis_File", !6, i64 0, !10, i64 8, !13, i64 16, !13, i64 24, !14, i64 32, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !13, i64 120, !10, i64 128, !13, i64 136, !10, i64 144, !15, i64 152, !15, i64 160, !16, i64 168, !17, i64 576, !18, i64 720, !20, i64 912}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!15 = !{!"double", !7, i64 0}
!16 = !{!"", !6, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !6, i64 32, !6, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !7, i64 80, !10, i64 364, !10, i64 368, !10, i64 372, !13, i64 376, !13, i64 384, !13, i64 392, !13, i64 400}
!17 = !{!"vorbis_dsp_state", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !6, i64 136}
!18 = !{!"vorbis_block", !6, i64 0, !19, i64 8, !13, i64 48, !13, i64 56, !13, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !13, i64 88, !13, i64 96, !6, i64 104, !6, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !6, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !6, i64 184}
!19 = !{!"", !13, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !13, i64 32}
!20 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!13, !13, i64 0}
!22 = !{!12, !6, i64 104}
!23 = !{!12, !13, i64 120}
!24 = !{!12, !10, i64 144}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @vorbis_synthesis_halfrate_p(ptr noundef) local_unnamed_addr #1

declare i32 @vorbis_synthesis_pcmout(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @vorbis_synthesis_read(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @_fetch_and_process_packet(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @ov_read_float(ptr noundef %0, ptr noundef writeonly %1, i32 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %8 = icmp slt i32 %7, 2
  br i1 %8, label %.thread41, label %.preheader

.preheader:                                       ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 576
  br label %10

thread-pre-split:                                 ; preds = %35
  %.pr = load i32, ptr %6, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %.preheader, %thread-pre-split
  %11 = phi i32 [ %.pr, %thread-pre-split ], [ %7, %.preheader ]
  %12 = icmp eq i32 %11, 4
  br i1 %12, label %13, label %32

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %14 = call i32 @vorbis_synthesis_pcmout(ptr noundef nonnull %9, ptr noundef nonnull %5) #4
  %.not.not = icmp eq i32 %14, 0
  br i1 %.not.not, label %31, label %15

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = load ptr, ptr %16, align 8, !tbaa !19
  %18 = call i32 @vorbis_synthesis_halfrate_p(ptr noundef %17) #4
  %.not33 = icmp eq ptr %1, null
  br i1 %.not33, label %21, label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr %5, align 8, !tbaa !20
  store ptr %20, ptr %1, align 8, !tbaa !20
  br label %21

21:                                               ; preds = %19, %15
  %spec.select = call i32 @llvm.smin.i32(i32 %14, i32 %2)
  %.027 = sext i32 %spec.select to i64
  %22 = call i32 @vorbis_synthesis_read(ptr noundef nonnull %9, i32 noundef %spec.select) #4
  %23 = zext nneg i32 %18 to i64
  %24 = shl i64 %.027, %23
  %25 = getelementptr inbounds i8, ptr %0, i64 120
  %26 = load i64, ptr %25, align 8, !tbaa !21
  %27 = add nsw i64 %26, %24
  store i64 %27, ptr %25, align 8, !tbaa !21
  %.not34 = icmp eq ptr %3, null
  br i1 %.not34, label %.thread, label %28

28:                                               ; preds = %21
  %29 = getelementptr inbounds i8, ptr %0, i64 144
  %30 = load i32, ptr %29, align 8, !tbaa !22
  store i32 %30, ptr %3, align 4, !tbaa !23
  br label %.thread

.thread:                                          ; preds = %21, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %.thread41

31:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %32

32:                                               ; preds = %31, %10
  %33 = call i32 @_fetch_and_process_packet(ptr noundef nonnull %0, ptr noundef null, i32 noundef 1, i32 noundef 1)
  %34 = icmp eq i32 %33, -2
  br i1 %34, label %.thread41, label %35

35:                                               ; preds = %32
  %36 = icmp sgt i32 %33, 0
  br i1 %36, label %thread-pre-split, label %.thread41.loopexit.split.loop.exit

.thread41.loopexit.split.loop.exit:               ; preds = %35
  %37 = sext i32 %33 to i64
  br label %.thread41

.thread41:                                        ; preds = %32, %.thread41.loopexit.split.loop.exit, %.thread, %4
  %.4 = phi i64 [ -131, %4 ], [ %.027, %.thread ], [ %37, %.thread41.loopexit.split.loop.exit ], [ 0, %32 ]
  ret i64 %.4
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 128}
!6 = !{!"OggVorbis_File", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !10, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !11, i64 120, !10, i64 128, !11, i64 136, !10, i64 144, !13, i64 152, !13, i64 160, !14, i64 168, !15, i64 576, !16, i64 720, !18, i64 912}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!"double", !8, i64 0}
!14 = !{!"", !7, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !8, i64 80, !10, i64 364, !10, i64 368, !10, i64 372, !11, i64 376, !11, i64 384, !11, i64 392, !11, i64 400}
!15 = !{!"vorbis_dsp_state", !10, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, 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, !7, i64 136}
!16 = !{!"vorbis_block", !7, i64 0, !17, i64 8, !11, i64 48, !11, i64 56, !11, i64 64, !10, i64 72, !10, i64 76, !10, 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}
!17 = !{!"", !11, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!18 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!6, !7, i64 104}
!20 = !{!7, !7, i64 0}
!21 = !{!6, !11, i64 120}
!22 = !{!6, !10, i64 144}
!23 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass