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

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

; 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: inlinehint nounwind uwtable
declare hidden i64 @decode_packed_entry_number(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @vorbis_book_decodevs_add(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca i64, 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
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.codebook, ptr %17, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = icmp sgt i64 %19, 0
  br i1 %20, label %21, label %122

21:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.codebook, ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = sdiv i64 %23, %26
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = mul i64 8, %30
  %32 = alloca i8, i64 %31, align 16
  store ptr %32, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = mul i64 8, %34
  %36 = alloca i8, i64 %35, align 16
  store ptr %36, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %74, %21
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %77

41:                                               ; preds = %37
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call i64 @decode_packed_entry_number(ptr noundef %42, ptr noundef %43)
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = load i32, ptr %13, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i64, ptr %45, i64 %47
  store i64 %44, ptr %48, align 8, !tbaa !15
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load i32, ptr %13, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i64, ptr %49, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !15
  %54 = icmp eq i64 %53, -1
  br i1 %54, label %55, label %56

55:                                               ; preds = %41
  store i64 -1, ptr %5, align 8
  store i32 1, ptr %16, align 4
  br label %119

56:                                               ; preds = %41
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.codebook, ptr %57, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = load i32, ptr %13, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds i64, ptr %60, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !15
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.codebook, ptr %65, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !14
  %68 = mul nsw i64 %64, %67
  %69 = getelementptr inbounds float, ptr %59, i64 %68
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i32, ptr %13, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds ptr, ptr %70, i64 %72
  store ptr %69, ptr %73, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %56
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %13, align 4, !tbaa !9
  br label %37, !llvm.loop !17

77:                                               ; preds = %37
  store i32 0, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %112, %77
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.codebook, ptr %81, i32 0, i32 0
  %83 = load i64, ptr %82, align 8, !tbaa !14
  %84 = icmp slt i64 %80, %83
  br i1 %84, label %85, label %118

85:                                               ; preds = %78
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %86

86:                                               ; preds = %108, %85
  %87 = load i32, ptr %14, align 4, !tbaa !9
  %88 = load i32, ptr %10, align 4, !tbaa !9
  %89 = icmp slt i32 %87, %88
  br i1 %89, label %90, label %111

90:                                               ; preds = %86
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds ptr, ptr %91, i64 %93
  %95 = load ptr, ptr %94, align 8, !tbaa !5
  %96 = load i32, ptr %13, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds float, ptr %95, i64 %97
  %99 = load float, ptr %98, align 4, !tbaa !19
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = load i32, ptr %15, align 4, !tbaa !9
  %102 = load i32, ptr %14, align 4, !tbaa !9
  %103 = add nsw i32 %101, %102
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds float, ptr %100, i64 %104
  %106 = load float, ptr %105, align 4, !tbaa !19
  %107 = fadd float %106, %99
  store float %107, ptr %105, align 4, !tbaa !19
  br label %108

108:                                              ; preds = %90
  %109 = load i32, ptr %14, align 4, !tbaa !9
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %14, align 4, !tbaa !9
  br label %86, !llvm.loop !21

111:                                              ; preds = %86
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %13, align 4, !tbaa !9
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %13, align 4, !tbaa !9
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = load i32, ptr %15, align 4, !tbaa !9
  %117 = add nsw i32 %116, %115
  store i32 %117, ptr %15, align 4, !tbaa !9
  br label %78, !llvm.loop !22

118:                                              ; preds = %78
  store i32 0, ptr %16, align 4
  br label %119

119:                                              ; preds = %118, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %120 = load i32, ptr %16, align 4
  switch i32 %120, label %125 [
    i32 0, label %121
    i32 1, label %123
  ]

121:                                              ; preds = %119
  br label %122

122:                                              ; preds = %121, %4
  store i64 0, ptr %5, align 8
  br label %123

123:                                              ; preds = %122, %119
  %124 = load i64, ptr %5, align 8
  ret i64 %124

125:                                              ; preds = %119
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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, !13, i64 16}
!12 = !{!"codebook", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !6, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}


; 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: inlinehint nounwind uwtable
declare hidden i64 @decode_packed_entry_number(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 -1, 1) i64 @vorbis_book_decodevs_add(ptr noundef %0, ptr nocapture noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %4
  %9 = sext i32 %3 to i64
  %10 = load i64, ptr %0, align 8, !tbaa !12
  %11 = sdiv i64 %9, %10
  %12 = trunc i64 %11 to i32
  %sext = shl i64 %11, 32
  %13 = ashr exact i64 %sext, 29
  %14 = alloca i8, i64 %13, align 16
  %.not45 = icmp slt i32 %12, 1
  br i1 %.not45, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  %wide.trip.count = and i64 %11, 2147483647
  br label %37

.preheader44:                                     ; preds = %40
  %16 = icmp slt i64 %42, 1
  %brmerge = or i1 %16, %.not45
  br i1 %brmerge, label %.thread, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.preheader44
  %17 = and i64 %11, 2147483647
  %xtraiter = and i64 %11, 1
  %18 = icmp eq i64 %wide.trip.count, 1
  %unroll_iter = sub nsw i64 %wide.trip.count, %xtraiter
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv65 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next66, %._crit_edge.us ]
  %indvars.iv63 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next64, %._crit_edge.us ]
  %invariant.gep = getelementptr inbounds float, ptr %1, i64 %indvars.iv63
  br i1 %18, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv58 = phi i64 [ %indvars.iv.next59.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %19 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv58
  %20 = load ptr, ptr %19, align 16, !tbaa !13
  %21 = getelementptr inbounds float, ptr %20, i64 %indvars.iv65
  %22 = load float, ptr %21, align 4, !tbaa !14
  %gep = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv58
  %23 = load float, ptr %gep, align 4, !tbaa !14
  %24 = fadd float %22, %23
  store float %24, ptr %gep, align 4, !tbaa !14
  %indvars.iv.next59 = or disjoint i64 %indvars.iv58, 1
  %25 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv.next59
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds float, ptr %26, i64 %indvars.iv65
  %28 = load float, ptr %27, align 4, !tbaa !14
  %gep.1 = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.next59
  %29 = load float, ptr %gep.1, align 4, !tbaa !14
  %30 = fadd float %28, %29
  store float %30, ptr %gep.1, align 4, !tbaa !14
  %indvars.iv.next59.1 = add nuw nsw i64 %indvars.iv58, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !16

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %indvars.iv58.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next59.1, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %31 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv58.unr
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = getelementptr inbounds float, ptr %32, i64 %indvars.iv65
  %34 = load float, ptr %33, align 4, !tbaa !14
  %gep.epil = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv58.unr
  %35 = load float, ptr %gep.epil, align 4, !tbaa !14
  %36 = fadd float %34, %35
  store float %36, ptr %gep.epil, align 4, !tbaa !14
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, %17
  %exitcond70.not = icmp eq i64 %indvars.iv.next66, %42
  br i1 %exitcond70.not, label %.thread, label %.preheader.us, !llvm.loop !18

37:                                               ; preds = %.lr.ph, %40
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %40 ]
  %38 = tail call i64 @decode_packed_entry_number(ptr noundef nonnull %0, ptr noundef %2)
  %39 = icmp eq i64 %38, -1
  br i1 %39, label %.thread, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr %15, align 8, !tbaa !19
  %42 = load i64, ptr %0, align 8, !tbaa !12
  %43 = mul nsw i64 %42, %38
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  store ptr %44, ptr %45, align 8, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader44, label %37, !llvm.loop !20

.thread:                                          ; preds = %37, %._crit_edge.us, %.preheader44, %8, %4
  %.139 = phi i64 [ 0, %.preheader44 ], [ 0, %4 ], [ 0, %8 ], [ 0, %._crit_edge.us ], [ -1, %37 ]
  ret i64 %.139
}

attributes #0 = { inlinehint 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 = { 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, !7, i64 16}
!6 = !{!"codebook", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!6, !10, i64 32}
!20 = distinct !{!20, !17}


; Effective O3 passes: ADCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass