; LLVM IR from VoidRune/Audio-engine :: src (minivorbis)

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local float @_float32_unpack(i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @vorbis_book_init_encode(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 96, i1 false)
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.codebook, ptr %7, i32 0, i32 3
  store ptr %6, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.static_codebook, ptr %9, i32 0, i32 1
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.codebook, ptr %12, i32 0, i32 1
  store i64 %11, ptr %13, align 8, !tbaa !15
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.static_codebook, ptr %14, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.codebook, ptr %17, i32 0, i32 2
  store i64 %16, ptr %18, align 8, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.static_codebook, ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !17
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.codebook, ptr %22, i32 0, i32 0
  store i64 %21, ptr %23, align 8, !tbaa !18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.static_codebook, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !19
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.static_codebook, ptr %27, i32 0, i32 1
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = call ptr @_make_words(ptr noundef %26, i64 noundef %29, i64 noundef 0)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.codebook, ptr %31, i32 0, i32 5
  store ptr %30, ptr %32, align 8, !tbaa !20
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i64 @_book_maptype1_quantvals(ptr noundef %33)
  %35 = trunc i64 %34 to i32
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.codebook, ptr %36, i32 0, i32 11
  store i32 %35, ptr %37, align 8, !tbaa !21
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.static_codebook, ptr %38, i32 0, i32 4
  %40 = load i64, ptr %39, align 8, !tbaa !22
  %41 = call float @_float32_unpack(i64 noundef %40)
  %42 = fpext float %41 to double
  %43 = call double @llvm.rint.f64(double %42)
  %44 = fptosi double %43 to i32
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.codebook, ptr %45, i32 0, i32 12
  store i32 %44, ptr %46, align 4, !tbaa !23
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.static_codebook, ptr %47, i32 0, i32 5
  %49 = load i64, ptr %48, align 8, !tbaa !24
  %50 = call float @_float32_unpack(i64 noundef %49)
  %51 = fpext float %50 to double
  %52 = call double @llvm.rint.f64(double %51)
  %53 = fptosi double %52 to i32
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.codebook, ptr %54, i32 0, i32 13
  store i32 %53, ptr %55, align 8, !tbaa !25
  ret i32 0
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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, !6, i64 24}
!10 = !{!"codebook", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !11, i64 8}
!14 = !{!"static_codebook", !11, i64 0, !11, i64 8, !6, i64 16, !12, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 52, !6, i64 56, !12, i64 64}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !11, i64 16}
!17 = !{!14, !11, i64 0}
!18 = !{!10, !11, i64 0}
!19 = !{!14, !6, i64 16}
!20 = !{!10, !6, i64 40}
!21 = !{!10, !12, i64 80}
!22 = !{!14, !11, i64 32}
!23 = !{!10, !12, i64 84}
!24 = !{!14, !11, i64 40}
!25 = !{!10, !12, i64 88}


; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; Function Attrs: nounwind uwtable
declare dso_local float @_float32_unpack(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @vorbis_book_init_encode(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #1 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(96) %0, i8 0, i64 96, i1 false)
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %5, ptr %6, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %5, ptr %7, align 8, !tbaa !15
  %8 = load i64, ptr %1, align 8, !tbaa !16
  store i64 %8, ptr %0, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !18
  %11 = tail call ptr @_make_words(ptr noundef %10, i64 noundef %5, i64 noundef 0)
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %11, ptr %12, align 8, !tbaa !19
  %13 = tail call i64 @_book_maptype1_quantvals(ptr noundef nonnull %1)
  %14 = trunc i64 %13 to i32
  %15 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 %14, ptr %15, align 8, !tbaa !20
  %16 = getelementptr inbounds i8, ptr %1, i64 32
  %17 = load i64, ptr %16, align 8, !tbaa !21
  %18 = tail call float @_float32_unpack(i64 noundef %17)
  %19 = tail call float @llvm.rint.f32(float %18)
  %20 = fptosi float %19 to i32
  %21 = getelementptr inbounds i8, ptr %0, i64 84
  store i32 %20, ptr %21, align 4, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %1, i64 40
  %23 = load i64, ptr %22, align 8, !tbaa !23
  %24 = tail call float @_float32_unpack(i64 noundef %23)
  %25 = tail call float @llvm.rint.f32(float %24)
  %26 = fptosi float %25 to i32
  %27 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 %26, ptr %27, align 8, !tbaa !24
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.rint.f32(float) #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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) }

!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 24}
!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 = !{!13, !7, i64 8}
!13 = !{!"static_codebook", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !7, i64 32, !7, i64 40, !11, i64 48, !11, i64 52, !10, i64 56, !11, i64 64}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 16}
!16 = !{!13, !7, i64 0}
!17 = !{!6, !7, i64 0}
!18 = !{!13, !10, i64 16}
!19 = !{!6, !10, i64 40}
!20 = !{!6, !11, i64 80}
!21 = !{!13, !7, i64 32}
!22 = !{!6, !11, i64 84}
!23 = !{!13, !7, i64 40}
!24 = !{!6, !11, i64 88}


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