; 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 @oggpack_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 %48

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 = ashr i32 %20, %23
  %25 = and i32 %24, 1
  %26 = sext i32 %25 to i64
  store i64 %26, ptr %4, align 8, !tbaa !17
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.oggpack_buffer, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 8, !tbaa !16
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.oggpack_buffer, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = icmp sgt i32 %33, 7
  br i1 %34, label %35, label %46

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

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

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

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

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 @oggpack_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 %20

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 = lshr i32 %9, %11
  %13 = and i32 %12, 1
  %14 = zext nneg i32 %13 to i64
  %15 = add nsw i32 %11, 1
  store i32 %15, ptr %10, align 8, !tbaa !15
  %16 = icmp sgt i32 %11, 6
  br i1 %16, label %17, label %22

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

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

22:                                               ; preds = %6, %17, %20
  %.0 = phi i64 [ -1, %20 ], [ %14, %17 ], [ %14, %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