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

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

declare i32 @vorbis_block_clear(ptr noundef) #0

declare void @vorbis_dsp_clear(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ov_halfrate(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.OggVorbis_File, ptr %9, i32 0, i32 10
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %70

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.OggVorbis_File, ptr %15, i32 0, i32 13
  %17 = load i32, ptr %16, align 8, !tbaa !21
  %18 = icmp sgt i32 %17, 3
  br i1 %18, label %19, label %41

19:                                               ; preds = %14
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.OggVorbis_File, ptr %20, i32 0, i32 19
  call void @vorbis_dsp_clear(ptr noundef %21)
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.OggVorbis_File, ptr %22, i32 0, i32 20
  %24 = call i32 @vorbis_block_clear(ptr noundef %23)
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.OggVorbis_File, ptr %25, i32 0, i32 13
  store i32 3, ptr %26, align 8, !tbaa !21
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.OggVorbis_File, ptr %27, i32 0, i32 12
  %29 = load i64, ptr %28, align 8, !tbaa !22
  %30 = icmp sge i64 %29, 0
  br i1 %30, label %31, label %40

31:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.OggVorbis_File, ptr %32, i32 0, i32 12
  %34 = load i64, ptr %33, align 8, !tbaa !22
  store i64 %34, ptr %8, align 8, !tbaa !23
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.OggVorbis_File, ptr %35, i32 0, i32 12
  store i64 -1, ptr %36, align 8, !tbaa !22
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i64, ptr %8, align 8, !tbaa !23
  %39 = call i32 @ov_pcm_seek(ptr noundef %37, i64 noundef %38)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %40

40:                                               ; preds = %31, %19
  br label %41

41:                                               ; preds = %40, %14
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %66, %41
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.OggVorbis_File, ptr %44, i32 0, i32 5
  %46 = load i32, ptr %45, align 8, !tbaa !24
  %47 = icmp slt i32 %43, %46
  br i1 %47, label %48, label %69

48:                                               ; preds = %42
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.OggVorbis_File, ptr %49, i32 0, i32 10
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %struct.vorbis_info, ptr %51, i64 %53
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = call i32 @vorbis_synthesis_halfrate(ptr noundef %54, i32 noundef %55)
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %58, label %65

58:                                               ; preds = %48
  %59 = load i32, ptr %5, align 4, !tbaa !9
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call i32 @ov_halfrate(ptr noundef %62, i32 noundef 0)
  br label %64

64:                                               ; preds = %61, %58
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %70

65:                                               ; preds = %48
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !9
  br label %42, !llvm.loop !25

69:                                               ; preds = %42
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %70

70:                                               ; preds = %69, %64, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %71 = load i32, ptr %3, align 4
  ret i32 %71
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @ov_pcm_seek(ptr noundef, i64 noundef) #2

declare i32 @vorbis_synthesis_halfrate(ptr noundef, i32 noundef) #0

attributes #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 nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 104}
!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 = !{!12, !10, i64 128}
!22 = !{!12, !13, i64 120}
!23 = !{!13, !13, i64 0}
!24 = !{!12, !10, i64 64}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; 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"

%struct.vorbis_info = type { i32, i32, i64, i64, i64, i64, i64, ptr }

declare i32 @vorbis_block_clear(ptr noundef) local_unnamed_addr #0

declare void @vorbis_dsp_clear(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -131, 1) i32 @ov_halfrate(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 104
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %ov_halfrate.exit, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  %8 = load i32, ptr %7, align 8, !tbaa !19
  %9 = icmp sgt i32 %8, 3
  br i1 %9, label %10, label %19

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 576
  tail call void @vorbis_dsp_clear(ptr noundef nonnull %11) #2
  %12 = getelementptr inbounds i8, ptr %0, i64 720
  %13 = tail call i32 @vorbis_block_clear(ptr noundef nonnull %12) #2
  store i32 3, ptr %7, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  %15 = load i64, ptr %14, align 8, !tbaa !20
  %16 = icmp sgt i64 %15, -1
  br i1 %16, label %17, label %19

17:                                               ; preds = %10
  store i64 -1, ptr %14, align 8, !tbaa !20
  %18 = tail call i32 @ov_pcm_seek(ptr noundef nonnull %0, i64 noundef %15)
  br label %19

19:                                               ; preds = %10, %17, %6
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  %21 = load i32, ptr %20, align 8, !tbaa !21
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %ov_halfrate.exit

23:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr %20, align 8, !tbaa !21
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %ov_halfrate.exit, !llvm.loop !22

.lr.ph:                                           ; preds = %19, %23
  %indvars.iv = phi i64 [ %indvars.iv.next, %23 ], [ 0, %19 ]
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.vorbis_info, ptr %27, i64 %indvars.iv
  %29 = tail call i32 @vorbis_synthesis_halfrate(ptr noundef %28, i32 noundef %1) #2
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %23, label %30

30:                                               ; preds = %.lr.ph
  %.not20 = icmp eq i32 %1, 0
  br i1 %.not20, label %ov_halfrate.exit, label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = icmp eq ptr %32, null
  br i1 %33, label %ov_halfrate.exit, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %7, align 8, !tbaa !19
  %36 = icmp sgt i32 %35, 3
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = getelementptr inbounds i8, ptr %0, i64 576
  tail call void @vorbis_dsp_clear(ptr noundef nonnull %38) #2
  %39 = getelementptr inbounds i8, ptr %0, i64 720
  %40 = tail call i32 @vorbis_block_clear(ptr noundef nonnull %39) #2
  store i32 3, ptr %7, align 8, !tbaa !19
  %41 = getelementptr inbounds i8, ptr %0, i64 120
  %42 = load i64, ptr %41, align 8, !tbaa !20
  %43 = icmp sgt i64 %42, -1
  br i1 %43, label %44, label %46

44:                                               ; preds = %37
  store i64 -1, ptr %41, align 8, !tbaa !20
  %45 = tail call i32 @ov_pcm_seek(ptr noundef nonnull %0, i64 noundef %42)
  br label %46

46:                                               ; preds = %44, %37, %34
  %47 = load i32, ptr %20, align 8, !tbaa !21
  %48 = icmp sgt i32 %47, 0
  br i1 %48, label %.lr.ph25, label %ov_halfrate.exit

49:                                               ; preds = %.lr.ph25
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %50 = load i32, ptr %20, align 8, !tbaa !21
  %51 = sext i32 %50 to i64
  %52 = icmp slt i64 %indvars.iv.next30, %51
  br i1 %52, label %.lr.ph25, label %ov_halfrate.exit, !llvm.loop !22

.lr.ph25:                                         ; preds = %46, %49
  %indvars.iv29 = phi i64 [ %indvars.iv.next30, %49 ], [ 0, %46 ]
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.vorbis_info, ptr %53, i64 %indvars.iv29
  %55 = tail call i32 @vorbis_synthesis_halfrate(ptr noundef %54, i32 noundef 0) #2
  %.not.i = icmp eq i32 %55, 0
  br i1 %.not.i, label %49, label %ov_halfrate.exit

ov_halfrate.exit:                                 ; preds = %23, %.lr.ph25, %49, %19, %46, %31, %30, %2
  %.0 = phi i32 [ -131, %2 ], [ -131, %30 ], [ -131, %31 ], [ -131, %46 ], [ 0, %19 ], [ -131, %49 ], [ -131, %.lr.ph25 ], [ 0, %23 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @ov_pcm_seek(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @vorbis_synthesis_halfrate(ptr noundef, i32 noundef) local_unnamed_addr #0

attributes #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 = { 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, !7, i64 104}
!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, !10, i64 128}
!20 = !{!6, !11, i64 120}
!21 = !{!6, !10, i64 64}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InlinerPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass