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

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

; 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 @ov_pcm_seek(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local double @ov_time_total(ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

16:                                               ; preds = %2
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.OggVorbis_File, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !23
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 -138, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

23:                                               ; preds = %17
  %24 = load double, ptr %5, align 8, !tbaa !9
  %25 = fcmp olt double %24, 0.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

27:                                               ; preds = %23
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %62, %27
  %29 = load i32, ptr %6, align 4, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.OggVorbis_File, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 8, !tbaa !24
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %34, label %65

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !11
  %37 = call double @ov_time_total(ptr noundef %35, i32 noundef %36)
  store double %37, ptr %10, align 8, !tbaa !9
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = load double, ptr %8, align 8, !tbaa !9
  %40 = load double, ptr %10, align 8, !tbaa !9
  %41 = fadd double %39, %40
  %42 = fcmp olt double %38, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  store i32 2, ptr %9, align 4
  br label %59

44:                                               ; preds = %34
  %45 = load double, ptr %10, align 8, !tbaa !9
  %46 = load double, ptr %8, align 8, !tbaa !9
  %47 = fadd double %46, %45
  store double %47, ptr %8, align 8, !tbaa !9
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.OggVorbis_File, ptr %48, i32 0, i32 9
  %50 = load ptr, ptr %49, align 8, !tbaa !25
  %51 = load i32, ptr %6, align 4, !tbaa !11
  %52 = mul nsw i32 %51, 2
  %53 = add nsw i32 %52, 1
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds i64, ptr %50, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !13
  %57 = load i64, ptr %7, align 8, !tbaa !13
  %58 = add nsw i64 %57, %56
  store i64 %58, ptr %7, align 8, !tbaa !13
  store i32 0, ptr %9, align 4
  br label %59

59:                                               ; preds = %44, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %60 = load i32, ptr %9, align 4
  switch i32 %60, label %94 [
    i32 0, label %61
    i32 2, label %65
  ]

61:                                               ; preds = %59
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %6, align 4, !tbaa !11
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %6, align 4, !tbaa !11
  br label %28, !llvm.loop !26

65:                                               ; preds = %59, %28
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.OggVorbis_File, ptr %67, i32 0, i32 5
  %69 = load i32, ptr %68, align 8, !tbaa !24
  %70 = icmp eq i32 %66, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %65
  store i32 -131, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %92

72:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %73 = load i64, ptr %7, align 8, !tbaa !13
  %74 = sitofp i64 %73 to double
  %75 = load double, ptr %5, align 8, !tbaa !9
  %76 = load double, ptr %8, align 8, !tbaa !9
  %77 = fsub double %75, %76
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.OggVorbis_File, ptr %78, i32 0, i32 10
  %80 = load ptr, ptr %79, align 8, !tbaa !28
  %81 = load i32, ptr %6, align 4, !tbaa !11
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds %struct.vorbis_info, ptr %80, i64 %82
  %84 = getelementptr inbounds %struct.vorbis_info, ptr %83, i32 0, i32 2
  %85 = load i64, ptr %84, align 8, !tbaa !29
  %86 = sitofp i64 %85 to double
  %87 = call double @llvm.fmuladd.f64(double %77, double %86, double %74)
  %88 = fptosi double %87 to i64
  store i64 %88, ptr %11, align 8, !tbaa !13
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = load i64, ptr %11, align 8, !tbaa !13
  %91 = call i32 @ov_pcm_seek(ptr noundef %89, i64 noundef %90)
  store i32 %91, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %92

92:                                               ; preds = %72, %71, %26, %22, %16
  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 4, ptr %6) #3
  %93 = load i32, ptr %3, align 4
  ret i32 %93

94:                                               ; preds = %59
  unreachable
}

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


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

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

; Function Attrs: nounwind uwtable
declare dso_local double @ov_time_total(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ov_time_seek(ptr noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 128
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp slt i32 %4, 2
  br i1 %5, label %43, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !19
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %43, label %9

9:                                                ; preds = %6
  %10 = fcmp olt double %1, 0.000000e+00
  br i1 %10, label %43, label %.preheader

.preheader:                                       ; preds = %9
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load i32, ptr %11, align 8, !tbaa !20
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %14 = getelementptr inbounds i8, ptr %0, i64 96
  br label %15

15:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %.02841 = phi double [ 0.000000e+00, %.lr.ph ], [ %18, %20 ]
  %.02940 = phi i64 [ 0, %.lr.ph ], [ %26, %20 ]
  %16 = trunc nuw nsw i64 %indvars.iv to i32
  %17 = tail call double @ov_time_total(ptr noundef nonnull %0, i32 noundef %16)
  %18 = fadd double %.02841, %17
  %19 = fcmp ogt double %18, %1
  %.pre.pre = load i32, ptr %11, align 8, !tbaa !20
  br i1 %19, label %._crit_edge.loopexit, label %20

20:                                               ; preds = %15
  %21 = load ptr, ptr %14, align 8, !tbaa !21
  %22 = shl nuw nsw i64 %indvars.iv, 1
  %23 = or disjoint i64 %22, 1
  %24 = getelementptr inbounds i64, ptr %21, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !22
  %26 = add nsw i64 %25, %.02940
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = sext i32 %.pre.pre to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %15, label %._crit_edge.loopexit.split.loop.exit50, !llvm.loop !23

._crit_edge.loopexit.split.loop.exit50:           ; preds = %20
  %indvars.le = trunc i64 %indvars.iv.next to i32
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %15, %._crit_edge.loopexit.split.loop.exit50
  %.029.lcssa.ph = phi i64 [ %26, %._crit_edge.loopexit.split.loop.exit50 ], [ %.02940, %15 ]
  %.028.lcssa.ph = phi double [ %18, %._crit_edge.loopexit.split.loop.exit50 ], [ %.02841, %15 ]
  %.026.lcssa.ph = phi i32 [ %indvars.le, %._crit_edge.loopexit.split.loop.exit50 ], [ %16, %15 ]
  %29 = sitofp i64 %.029.lcssa.ph to double
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %30 = phi i32 [ %12, %.preheader ], [ %.pre.pre, %._crit_edge.loopexit ]
  %.029.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %29, %._crit_edge.loopexit ]
  %.028.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %.028.lcssa.ph, %._crit_edge.loopexit ]
  %.026.lcssa = phi i32 [ 0, %.preheader ], [ %.026.lcssa.ph, %._crit_edge.loopexit ]
  %31 = icmp eq i32 %.026.lcssa, %30
  br i1 %31, label %43, label %32

32:                                               ; preds = %._crit_edge
  %33 = fsub double %1, %.028.lcssa
  %34 = getelementptr inbounds i8, ptr %0, i64 104
  %35 = load ptr, ptr %34, align 8, !tbaa !25
  %36 = zext nneg i32 %.026.lcssa to i64
  %37 = getelementptr inbounds %struct.vorbis_info, ptr %35, i64 %36, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !26
  %39 = sitofp i64 %38 to double
  %40 = tail call double @llvm.fmuladd.f64(double %33, double %39, double %.029.lcssa)
  %41 = fptosi double %40 to i64
  %42 = tail call i32 @ov_pcm_seek(ptr noundef nonnull %0, i64 noundef %41)
  br label %43

43:                                               ; preds = %._crit_edge, %9, %6, %2, %32
  %.0 = phi i32 [ %42, %32 ], [ -131, %2 ], [ -138, %6 ], [ -131, %9 ], [ -131, %._crit_edge ]
  ret i32 %.0
}

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 8}
!20 = !{!6, !10, i64 64}
!21 = !{!6, !7, i64 96}
!22 = !{!11, !11, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !7, i64 104}
!26 = !{!27, !11, i64 8}
!27 = !{!"vorbis_info", !10, i64 0, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !7, i64 48}


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