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

; 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.envelope_lookup = type { i32, i32, i32, float, %struct.mdct_lookup, ptr, [7 x %struct.envelope_band], ptr, i32, ptr, i64, i64, i64, i64 }
%struct.mdct_lookup = type { i32, i32, ptr, ptr, float }
%struct.envelope_band = type { i32, i32, ptr, float }

; 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
define dso_local void @_ve_envelope_shift(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.envelope_lookup, ptr %7, i32 0, i32 11
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.envelope_lookup, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = sext i32 %12 to i64
  %14 = sdiv i64 %9, %13
  %15 = add nsw i64 %14, 2
  %16 = trunc i64 %15 to i32
  store i32 %16, ptr %5, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.envelope_lookup, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %21 = sext i32 %20 to i64
  %22 = sdiv i64 %17, %21
  %23 = trunc i64 %22 to i32
  store i32 %23, ptr %6, align 4, !tbaa !17
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.envelope_lookup, ptr %24, i32 0, i32 9
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.envelope_lookup, ptr %27, i32 0, i32 9
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = load i32, ptr %6, align 4, !tbaa !17
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i32, ptr %29, i64 %31
  %33 = load i32, ptr %5, align 4, !tbaa !17
  %34 = load i32, ptr %6, align 4, !tbaa !17
  %35 = sub nsw i32 %33, %34
  %36 = sext i32 %35 to i64
  %37 = mul i64 %36, 4
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %26, ptr align 4 %32, i64 %37, i1 false)
  %38 = load i64, ptr %4, align 8, !tbaa !9
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.envelope_lookup, ptr %39, i32 0, i32 11
  %41 = load i64, ptr %40, align 8, !tbaa !11
  %42 = sub nsw i64 %41, %38
  store i64 %42, ptr %40, align 8, !tbaa !11
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.envelope_lookup, ptr %43, i32 0, i32 12
  %45 = load i64, ptr %44, align 8, !tbaa !19
  %46 = icmp sge i64 %45, 0
  br i1 %46, label %47, label %53

47:                                               ; preds = %2
  %48 = load i64, ptr %4, align 8, !tbaa !9
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.envelope_lookup, ptr %49, i32 0, i32 12
  %51 = load i64, ptr %50, align 8, !tbaa !19
  %52 = sub nsw i64 %51, %48
  store i64 %52, ptr %50, align 8, !tbaa !19
  br label %53

53:                                               ; preds = %47, %2
  %54 = load i64, ptr %4, align 8, !tbaa !9
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.envelope_lookup, ptr %55, i32 0, i32 13
  %57 = load i64, ptr %56, align 8, !tbaa !20
  %58 = sub nsw i64 %57, %54
  store i64 %58, ptr %56, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

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 nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 256}
!12 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 12, !15, i64 16, !6, i64 48, !7, i64 56, !6, i64 224, !13, i64 232, !6, i64 240, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !14, i64 24}
!16 = !{!12, !13, i64 8}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !6, i64 240}
!19 = !{!12, !10, i64 264}
!20 = !{!12, !10, i64 272}


; 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 nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ve_envelope_shift(ptr nocapture noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 256
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !14
  %7 = sext i32 %6 to i64
  %8 = sdiv i64 %4, %7
  %9 = add i64 %8, 2
  %10 = sdiv i64 %1, %7
  %11 = getelementptr inbounds i8, ptr %0, i64 240
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %sext = shl i64 %10, 32
  %13 = ashr exact i64 %sext, 30
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  %15 = sub i64 %9, %10
  %sext15 = shl i64 %15, 32
  %16 = ashr exact i64 %sext15, 30
  tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %12, ptr align 4 %14, i64 %16, i1 false)
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = sub nsw i64 %17, %1
  store i64 %18, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 264
  %20 = load i64, ptr %19, align 8, !tbaa !16
  %21 = icmp sgt i64 %20, -1
  br i1 %21, label %22, label %24

22:                                               ; preds = %2
  %23 = sub nsw i64 %20, %1
  store i64 %23, ptr %19, align 8, !tbaa !16
  br label %24

24:                                               ; preds = %22, %2
  %25 = getelementptr inbounds i8, ptr %0, i64 272
  %26 = load i64, ptr %25, align 8, !tbaa !17
  %27 = sub nsw i64 %26, %1
  store i64 %27, ptr %25, align 8, !tbaa !17
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: readwrite) }

!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, !13, i64 256}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !11, i64 16, !12, i64 48, !8, i64 56, !12, i64 224, !7, i64 232, !12, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4, !12, i64 8, !12, i64 16, !10, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !12, i64 240}
!16 = !{!6, !13, i64 264}
!17 = !{!6, !13, i64 272}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass