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

; 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 i64 @oggpackB_read1(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.oggpack_buffer, ptr %6, i32 0, i32 0
  %8 = load i64, ptr %7, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.oggpack_buffer, ptr %9, i32 0, i32 4
  %11 = load i64, ptr %10, align 8, !tbaa !13
  %12 = icmp sge i64 %8, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  br label %49

14:                                               ; preds = %1
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.oggpack_buffer, ptr %15, i32 0, i32 3
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %17, i64 0
  %19 = load i8, ptr %18, align 1, !tbaa !15
  %20 = zext i8 %19 to i32
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.oggpack_buffer, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !16
  %24 = sub nsw i32 7, %23
  %25 = ashr i32 %20, %24
  %26 = and i32 %25, 1
  %27 = sext i32 %26 to i64
  store i64 %27, ptr %4, align 8, !tbaa !17
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.oggpack_buffer, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 8, !tbaa !16
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %29, align 8, !tbaa !16
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.oggpack_buffer, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = icmp sgt i32 %34, 7
  br i1 %35, label %36, label %47

36:                                               ; preds = %14
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.oggpack_buffer, ptr %37, i32 0, i32 1
  store i32 0, ptr %38, align 8, !tbaa !16
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.oggpack_buffer, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %41, i32 1
  store ptr %42, ptr %40, align 8, !tbaa !14
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.oggpack_buffer, ptr %43, i32 0, i32 0
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = add nsw i64 %45, 1
  store i64 %46, ptr %44, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %36, %14
  %48 = load i64, ptr %4, align 8, !tbaa !17
  store i64 %48, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %59

49:                                               ; preds = %13
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.oggpack_buffer, ptr %50, i32 0, i32 3
  store ptr null, ptr %51, align 8, !tbaa !14
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.oggpack_buffer, ptr %52, i32 0, i32 4
  %54 = load i64, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.oggpack_buffer, ptr %55, i32 0, i32 0
  store i64 %54, ptr %56, align 8, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.oggpack_buffer, ptr %57, i32 0, i32 1
  store i32 1, ptr %58, align 8, !tbaa !16
  store i64 -1, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %59

59:                                               ; preds = %49, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %60 = load i64, ptr %2, align 8
  ret i64 %60
}

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, !11, i64 0}
!10 = !{!"", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !6, i64 24}
!15 = !{!7, !7, i64 0}
!16 = !{!10, !12, i64 8}
!17 = !{!11, !11, i64 0}


; 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(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local range(i64 -1, 2) i64 @oggpackB_read1(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load i64, ptr %3, align 8, !tbaa !12
  %.not = icmp slt i64 %2, %4
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  br i1 %.not, label %6, label %21

6:                                                ; preds = %1
  %7 = load ptr, ptr %5, align 8, !tbaa !13
  %8 = load i8, ptr %7, align 1, !tbaa !14
  %9 = zext i8 %8 to i32
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !15
  %12 = sub nsw i32 7, %11
  %13 = lshr i32 %9, %12
  %14 = and i32 %13, 1
  %15 = zext nneg i32 %14 to i64
  %16 = add nsw i32 %11, 1
  store i32 %16, ptr %10, align 8, !tbaa !15
  %17 = icmp sgt i32 %11, 6
  br i1 %17, label %18, label %23

18:                                               ; preds = %6
  store i32 0, ptr %10, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %7, i64 1
  store ptr %19, ptr %5, align 8, !tbaa !13
  %20 = add nsw i64 %2, 1
  store i64 %20, ptr %0, align 8, !tbaa !5
  br label %23

21:                                               ; preds = %1
  store ptr null, ptr %5, align 8, !tbaa !13
  store i64 %4, ptr %0, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 1, ptr %22, align 8, !tbaa !15
  br label %23

23:                                               ; preds = %6, %18, %21
  %.0 = phi i64 [ -1, %21 ], [ %15, %18 ], [ %15, %6 ]
  ret i64 %.0
}

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

!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 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !7, i64 32}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !11, i64 24}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !10, i64 8}


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