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

; 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 double @ov_time_total(ptr noundef, i32 noundef) #1

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

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

12:                                               ; preds = %1
  store double -1.310000e+02, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %77

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.OggVorbis_File, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !23
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %58

18:                                               ; preds = %13
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i64 @ov_pcm_total(ptr noundef %19, i32 noundef -1)
  store i64 %20, ptr %5, align 8, !tbaa !11
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call double @ov_time_total(ptr noundef %21, i32 noundef -1)
  store double %22, ptr %6, align 8, !tbaa !13
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.OggVorbis_File, ptr %23, i32 0, i32 5
  %25 = load i32, ptr %24, align 8, !tbaa !24
  %26 = sub nsw i32 %25, 1
  store i32 %26, ptr %4, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %54, %18
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = icmp sge i32 %28, 0
  br i1 %29, label %30, label %57

30:                                               ; preds = %27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.OggVorbis_File, ptr %31, i32 0, i32 9
  %33 = load ptr, ptr %32, align 8, !tbaa !25
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = mul nsw i32 %34, 2
  %36 = add nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i64, ptr %33, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = load i64, ptr %5, align 8, !tbaa !11
  %41 = sub nsw i64 %40, %39
  store i64 %41, ptr %5, align 8, !tbaa !11
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = call double @ov_time_total(ptr noundef %42, i32 noundef %43)
  %45 = load double, ptr %6, align 8, !tbaa !13
  %46 = fsub double %45, %44
  store double %46, ptr %6, align 8, !tbaa !13
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.OggVorbis_File, ptr %47, i32 0, i32 12
  %49 = load i64, ptr %48, align 8, !tbaa !26
  %50 = load i64, ptr %5, align 8, !tbaa !11
  %51 = icmp sge i64 %49, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %30
  br label %57

53:                                               ; preds = %30
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %4, align 4, !tbaa !9
  br label %27, !llvm.loop !27

57:                                               ; preds = %52, %27
  br label %58

58:                                               ; preds = %57, %13
  %59 = load double, ptr %6, align 8, !tbaa !13
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.OggVorbis_File, ptr %60, i32 0, i32 12
  %62 = load i64, ptr %61, align 8, !tbaa !26
  %63 = load i64, ptr %5, align 8, !tbaa !11
  %64 = sub nsw i64 %62, %63
  %65 = sitofp i64 %64 to double
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.OggVorbis_File, ptr %66, i32 0, i32 10
  %68 = load ptr, ptr %67, align 8, !tbaa !29
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds %struct.vorbis_info, ptr %68, i64 %70
  %72 = getelementptr inbounds %struct.vorbis_info, ptr %71, i32 0, i32 2
  %73 = load i64, ptr %72, align 8, !tbaa !30
  %74 = sitofp i64 %73 to double
  %75 = fdiv double %65, %74
  %76 = fadd double %59, %75
  store double %76, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %77

77:                                               ; preds = %58, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %78 = load double, ptr %2, align 8
  ret double %78
}

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 }

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !10, i64 128}
!16 = !{!"OggVorbis_File", !6, i64 0, !10, i64 8, !12, i64 16, !12, i64 24, !17, i64 32, !10, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !12, i64 120, !10, i64 128, !12, i64 136, !10, i64 144, !14, i64 152, !14, i64 160, !18, i64 168, !19, i64 576, !20, i64 720, !22, i64 912}
!17 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!18 = !{!"", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !7, i64 80, !10, i64 364, !10, i64 368, !10, i64 372, !12, i64 376, !12, i64 384, !12, i64 392, !12, i64 400}
!19 = !{!"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, !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}
!20 = !{!"vorbis_block", !6, i64 0, !21, i64 8, !12, i64 48, !12, i64 56, !12, i64 64, !10, i64 72, !10, i64 76, !10, 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}
!21 = !{!"", !12, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!22 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = !{!16, !10, i64 8}
!24 = !{!16, !10, i64 64}
!25 = !{!16, !6, i64 96}
!26 = !{!16, !12, i64 120}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!16, !6, i64 104}
!30 = !{!31, !12, i64 8}
!31 = !{!"vorbis_info", !10, i64 0, !10, i64 4, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, 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 double @ov_time_total(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

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

8:                                                ; preds = %5
  %9 = tail call i64 @ov_pcm_total(ptr noundef nonnull %0, i32 noundef -1)
  %10 = tail call double @ov_time_total(ptr noundef nonnull %0, i32 noundef -1)
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load i32, ptr %11, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 96
  %14 = getelementptr inbounds i8, ptr %0, i64 120
  %15 = zext i32 %12 to i64
  br label %16

16:                                               ; preds = %19, %8
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ %15, %8 ]
  %.020 = phi i64 [ %26, %19 ], [ %9, %8 ]
  %.0 = phi double [ %28, %19 ], [ %10, %8 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %17 = trunc nuw i64 %indvars.iv to i32
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %19, label %.loopexit.loopexit

19:                                               ; preds = %16
  %indvars = trunc i64 %indvars.iv.next to i32
  %20 = load ptr, ptr %13, align 8, !tbaa !21
  %21 = shl i64 %indvars.iv.next, 1
  %22 = and i64 %21, 4294967294
  %23 = or disjoint i64 %22, 1
  %24 = getelementptr inbounds i64, ptr %20, i64 %23
  %25 = load i64, ptr %24, align 8, !tbaa !22
  %26 = sub nsw i64 %.020, %25
  %27 = tail call double @ov_time_total(ptr noundef nonnull %0, i32 noundef %indvars)
  %28 = fsub double %.0, %27
  %29 = load i64, ptr %14, align 8, !tbaa !23
  %.not27 = icmp slt i64 %29, %26
  br i1 %.not27, label %16, label %.loopexit.loopexit, !llvm.loop !24

.loopexit.loopexit:                               ; preds = %19, %16
  %.121.ph = phi i64 [ %.020, %16 ], [ %26, %19 ]
  %.1.ph = phi double [ %.0, %16 ], [ %28, %19 ]
  %sext = shl i64 %indvars.iv.next, 32
  %30 = ashr exact i64 %sext, 32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %5
  %.123 = phi i64 [ 0, %5 ], [ %30, %.loopexit.loopexit ]
  %.121 = phi i64 [ 0, %5 ], [ %.121.ph, %.loopexit.loopexit ]
  %.1 = phi double [ 0.000000e+00, %5 ], [ %.1.ph, %.loopexit.loopexit ]
  %31 = getelementptr inbounds i8, ptr %0, i64 120
  %32 = load i64, ptr %31, align 8, !tbaa !23
  %33 = sub nsw i64 %32, %.121
  %34 = sitofp i64 %33 to double
  %35 = getelementptr inbounds i8, ptr %0, i64 104
  %36 = load ptr, ptr %35, align 8, !tbaa !26
  %37 = getelementptr inbounds %struct.vorbis_info, ptr %36, i64 %.123, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !27
  %39 = sitofp i64 %38 to double
  %40 = fdiv double %34, %39
  %41 = fadd double %.1, %40
  br label %42

42:                                               ; preds = %1, %.loopexit
  %.024 = phi double [ %41, %.loopexit ], [ -1.310000e+02, %1 ]
  ret double %.024
}

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

!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 = !{!6, !11, i64 120}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!6, !7, i64 104}
!27 = !{!28, !11, i64 8}
!28 = !{!"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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass