; 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.vorbis_info_residue0 = type { i64, i64, i32, i32, i32, i32, [64 x i32], [512 x i32], [64 x i32], [64 x 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: nounwind uwtable
declare dso_local void @oggpack_write(ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ov_ilog(i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @res0_pack(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %8, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !11
  call void @oggpack_write(ptr noundef %9, i64 noundef %12, i32 noundef 24)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %14, i32 0, i32 1
  %16 = load i64, ptr %15, align 8, !tbaa !14
  call void @oggpack_write(ptr noundef %13, i64 noundef %16, i32 noundef 24)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !15
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  call void @oggpack_write(ptr noundef %17, i64 noundef %22, i32 noundef 24)
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = sub nsw i32 %26, 1
  %28 = sext i32 %27 to i64
  call void @oggpack_write(ptr noundef %23, i64 noundef %28, i32 noundef 6)
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = sext i32 %32 to i64
  call void @oggpack_write(ptr noundef %29, i64 noundef %33, i32 noundef 8)
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %87, %2
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %36, i32 0, i32 3
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = icmp slt i32 %35, %38
  br i1 %39, label %40, label %90

40:                                               ; preds = %34
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %41, i32 0, i32 6
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [64 x i32], ptr %42, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = call i32 @ov_ilog(i32 noundef %46)
  %48 = icmp sgt i32 %47, 3
  br i1 %48, label %49, label %68

49:                                               ; preds = %40
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %51, i32 0, i32 6
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [64 x i32], ptr %52, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  call void @oggpack_write(ptr noundef %50, i64 noundef %57, i32 noundef 3)
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  call void @oggpack_write(ptr noundef %58, i64 noundef 1, i32 noundef 1)
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %60, i32 0, i32 6
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [64 x i32], ptr %61, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !9
  %66 = ashr i32 %65, 3
  %67 = sext i32 %66 to i64
  call void @oggpack_write(ptr noundef %59, i64 noundef %67, i32 noundef 5)
  br label %77

68:                                               ; preds = %40
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %70, i32 0, i32 6
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [64 x i32], ptr %71, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  call void @oggpack_write(ptr noundef %69, i64 noundef %76, i32 noundef 4)
  br label %77

77:                                               ; preds = %68, %49
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %78, i32 0, i32 6
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [64 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = call i32 @icount(i32 noundef %83)
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = add nsw i32 %85, %84
  store i32 %86, ptr %7, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %77
  %88 = load i32, ptr %6, align 4, !tbaa !9
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %6, align 4, !tbaa !9
  br label %34, !llvm.loop !18

90:                                               ; preds = %34
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %104, %90
  %92 = load i32, ptr %6, align 4, !tbaa !9
  %93 = load i32, ptr %7, align 4, !tbaa !9
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %95, label %107

95:                                               ; preds = %91
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.vorbis_info_residue0, ptr %97, i32 0, i32 7
  %99 = load i32, ptr %6, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [512 x i32], ptr %98, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  call void @oggpack_write(ptr noundef %96, i64 noundef %103, i32 noundef 8)
  br label %104

104:                                              ; preds = %95
  %105 = load i32, ptr %6, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %6, align 4, !tbaa !9
  br label %91, !llvm.loop !20

107:                                              ; preds = %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @icount(i32 noundef) #1

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, !13, i64 0}
!12 = !{!"vorbis_info_residue0", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !7, i64 288, !7, i64 2336, !7, i64 2592}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 28}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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: nounwind uwtable
declare dso_local void @oggpack_write(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @ov_ilog(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @res0_pack(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = load i64, ptr %0, align 8, !tbaa !5
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %3, i32 noundef 24)
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !11
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %5, i32 noundef 24)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = add nsw i32 %7, -1
  %9 = sext i32 %8 to i64
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %9, i32 noundef 24)
  %10 = getelementptr inbounds i8, ptr %0, i64 20
  %11 = load i32, ptr %10, align 4, !tbaa !13
  %12 = add nsw i32 %11, -1
  %13 = sext i32 %12 to i64
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %13, i32 noundef 6)
  %14 = getelementptr inbounds i8, ptr %0, i64 28
  %15 = load i32, ptr %14, align 4, !tbaa !14
  %16 = sext i32 %15 to i64
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %16, i32 noundef 8)
  %17 = load i32, ptr %10, align 4, !tbaa !13
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  br label %22

.preheader:                                       ; preds = %34
  %20 = icmp sgt i32 %37, 0
  br i1 %20, label %.lr.ph38, label %._crit_edge

.lr.ph38:                                         ; preds = %.preheader
  %21 = getelementptr inbounds i8, ptr %0, i64 288
  %wide.trip.count = zext nneg i32 %37 to i64
  br label %41

22:                                               ; preds = %.lr.ph, %34
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %34 ]
  %.036 = phi i32 [ 0, %.lr.ph ], [ %37, %34 ]
  %23 = getelementptr inbounds [64 x i32], ptr %19, i64 0, i64 %indvars.iv
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = tail call i32 @ov_ilog(i32 noundef %24)
  %26 = icmp sgt i32 %25, 3
  %27 = load i32, ptr %23, align 4, !tbaa !15
  %28 = sext i32 %27 to i64
  br i1 %26, label %29, label %33

29:                                               ; preds = %22
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %28, i32 noundef 3)
  tail call void @oggpack_write(ptr noundef %1, i64 noundef 1, i32 noundef 1)
  %30 = load i32, ptr %23, align 4, !tbaa !15
  %31 = ashr i32 %30, 3
  %32 = sext i32 %31 to i64
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %32, i32 noundef 5)
  br label %34

33:                                               ; preds = %22
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %28, i32 noundef 4)
  br label %34

34:                                               ; preds = %33, %29
  %35 = load i32, ptr %23, align 4, !tbaa !15
  %36 = tail call i32 @icount(i32 noundef %35)
  %37 = add nsw i32 %36, %.036
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = load i32, ptr %10, align 4, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = icmp slt i64 %indvars.iv.next, %39
  br i1 %40, label %22, label %.preheader, !llvm.loop !16

41:                                               ; preds = %.lr.ph38, %41
  %indvars.iv40 = phi i64 [ 0, %.lr.ph38 ], [ %indvars.iv.next41, %41 ]
  %42 = getelementptr inbounds [512 x i32], ptr %21, i64 0, i64 %indvars.iv40
  %43 = load i32, ptr %42, align 4, !tbaa !15
  %44 = sext i32 %43 to i64
  tail call void @oggpack_write(ptr noundef %1, i64 noundef %44, i32 noundef 8)
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next41, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %41, !llvm.loop !18

._crit_edge:                                      ; preds = %41, %2, %.preheader
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @icount(i32 noundef) local_unnamed_addr #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" }

!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 0}
!6 = !{!"vorbis_info_residue0", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !8, i64 32, !8, i64 288, !8, i64 2336, !8, i64 2592}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !10, i64 20}
!14 = !{!6, !10, i64 28}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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