; LLVM IR from Natrox/RaptorAudio :: RaptorAudio/src (stb_vorbis)

; 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.stb_vorbis = type { i32, i32, i32, i32, i32, ptr, i32, i32, ptr, ptr, ptr, i32, i8, i32, %struct.ProbedPage, %struct.ProbedPage, %struct.stb_vorbis_alloc, i32, i32, i32, i32, [2 x i32], i32, i32, i32, ptr, i32, [64 x i16], ptr, i32, [64 x i16], ptr, i32, ptr, i32, [64 x %struct.Mode], i32, [16 x ptr], [16 x ptr], [16 x ptr], i32, [16 x ptr], i32, i32, [2 x ptr], [2 x ptr], [2 x ptr], [2 x ptr], [2 x ptr], i32, i32, i32, [255 x i8], i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x %struct.CRCscan], i32, i32 }
%struct.ProbedPage = type { i32, i32, i32, i32, i32 }
%struct.stb_vorbis_alloc = type { ptr, i32 }
%struct.Mode = type { i8, i8, i16, i16 }
%struct.CRCscan = type { i32, i32, i32, i32, 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 hidden i32 @error(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @vorbis_decode_packet(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @vorbis_finish_frame(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @stb_vorbis_get_frame_float(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.stb_vorbis, ptr %13, i32 0, i32 12
  %15 = load i8, ptr %14, align 4, !tbaa !9
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 @error(ptr noundef %18, i32 noundef 2)
  store i32 %19, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %85

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 @vorbis_decode_packet(ptr noundef %21, ptr noundef %8, ptr noundef %10, ptr noundef %9)
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %29, label %24

24:                                               ; preds = %20
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.stb_vorbis, ptr %25, i32 0, i32 69
  store i32 0, ptr %26, align 8, !tbaa !14
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.stb_vorbis, ptr %27, i32 0, i32 68
  store i32 0, ptr %28, align 4, !tbaa !15
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %85

29:                                               ; preds = %20
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !16
  %32 = load i32, ptr %10, align 4, !tbaa !16
  %33 = load i32, ptr %9, align 4, !tbaa !16
  %34 = call i32 @vorbis_finish_frame(ptr noundef %30, i32 noundef %31, i32 noundef %32, i32 noundef %33)
  store i32 %34, ptr %8, align 4, !tbaa !16
  store i32 0, ptr %11, align 4, !tbaa !16
  br label %35

35:                                               ; preds = %56, %29
  %36 = load i32, ptr %11, align 4, !tbaa !16
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.stb_vorbis, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = icmp slt i32 %36, %39
  br i1 %40, label %41, label %59

41:                                               ; preds = %35
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.stb_vorbis, ptr %42, i32 0, i32 37
  %44 = load i32, ptr %11, align 4, !tbaa !16
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [16 x ptr], ptr %43, i64 0, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load i32, ptr %10, align 4, !tbaa !16
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %47, i64 %49
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.stb_vorbis, ptr %51, i32 0, i32 38
  %53 = load i32, ptr %11, align 4, !tbaa !16
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [16 x ptr], ptr %52, i64 0, i64 %54
  store ptr %50, ptr %55, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %41
  %57 = load i32, ptr %11, align 4, !tbaa !16
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %11, align 4, !tbaa !16
  br label %35, !llvm.loop !18

59:                                               ; preds = %35
  %60 = load i32, ptr %10, align 4, !tbaa !16
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.stb_vorbis, ptr %61, i32 0, i32 68
  store i32 %60, ptr %62, align 4, !tbaa !15
  %63 = load i32, ptr %10, align 4, !tbaa !16
  %64 = load i32, ptr %8, align 4, !tbaa !16
  %65 = add nsw i32 %63, %64
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.stb_vorbis, ptr %66, i32 0, i32 69
  store i32 %65, ptr %67, align 8, !tbaa !14
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %75

70:                                               ; preds = %59
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.stb_vorbis, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 4, !tbaa !17
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %73, ptr %74, align 4, !tbaa !16
  br label %75

75:                                               ; preds = %70, %59
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %83

78:                                               ; preds = %75
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.stb_vorbis, ptr %79, i32 0, i32 38
  %81 = getelementptr inbounds [16 x ptr], ptr %80, i64 0, i64 0
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %81, ptr %82, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %78, %75
  %84 = load i32, ptr %8, align 4, !tbaa !16
  store i32 %84, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %85

85:                                               ; preds = %83, %24, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %86 = load i32, ptr %4, align 4
  ret i32 %86
}

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, !7, i64 68}
!10 = !{!"stb_vorbis", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !7, i64 68, !11, i64 72, !12, i64 76, !12, i64 96, !13, i64 120, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !7, i64 152, !11, i64 160, !11, i64 164, !11, i64 168, !6, i64 176, !11, i64 184, !7, i64 188, !6, i64 320, !11, i64 328, !7, i64 332, !6, i64 464, !11, i64 472, !6, i64 480, !11, i64 488, !7, i64 492, !11, i64 876, !7, i64 880, !7, i64 1008, !7, i64 1136, !11, i64 1264, !7, i64 1272, !11, i64 1400, !11, i64 1404, !7, i64 1408, !7, i64 1424, !7, i64 1440, !7, i64 1456, !7, i64 1472, !11, i64 1488, !11, i64 1492, !11, i64 1496, !7, i64 1500, !7, i64 1755, !7, i64 1756, !7, i64 1757, !11, i64 1760, !11, i64 1764, !11, i64 1768, !11, i64 1772, !11, i64 1776, !11, i64 1780, !11, i64 1784, !11, i64 1788, !11, i64 1792, !11, i64 1796, !11, i64 1800, !7, i64 1804, !11, i64 1884, !11, i64 1888}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16}
!13 = !{!"", !6, i64 0, !11, i64 8}
!14 = !{!10, !11, i64 1888}
!15 = !{!10, !11, i64 1884}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @error(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @vorbis_decode_packet(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @vorbis_finish_frame(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @stb_vorbis_get_frame_float(ptr noundef %0, ptr noundef writeonly %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  %7 = getelementptr inbounds i8, ptr %0, i64 68
  %8 = load i8, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %3
  %10 = tail call i32 @error(ptr noundef nonnull %0, i32 noundef 2)
  br label %42

11:                                               ; preds = %3
  %12 = call i32 @vorbis_decode_packet(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef nonnull %6, ptr noundef nonnull %5)
  %.not24 = icmp eq i32 %12, 0
  br i1 %.not24, label %13, label %16

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 1888
  store i32 0, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %0, i64 1884
  store i32 0, ptr %15, align 4, !tbaa !14
  br label %42

16:                                               ; preds = %11
  %17 = load i32, ptr %4, align 4, !tbaa !15
  %18 = load i32, ptr %6, align 4, !tbaa !15
  %19 = load i32, ptr %5, align 4, !tbaa !15
  %20 = call i32 @vorbis_finish_frame(ptr noundef nonnull %0, i32 noundef %17, i32 noundef %18, i32 noundef %19)
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = load i32, ptr %21, align 4, !tbaa !16
  %23 = icmp sgt i32 %22, 0
  %.pre = load i32, ptr %6, align 4, !tbaa !15
  br i1 %23, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %16
  %24 = getelementptr inbounds i8, ptr %0, i64 880
  %25 = sext i32 %.pre to i64
  %26 = getelementptr inbounds i8, ptr %0, i64 1008
  %wide.trip.count = zext nneg i32 %22 to i64
  %min.iters.check = icmp eq i32 %22, 1
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %wide.trip.count, 2147483646
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %27 = getelementptr inbounds [16 x ptr], ptr %24, i64 0, i64 %index
  %wide.load = load <2 x ptr>, ptr %27, align 8, !tbaa !17
  %28 = getelementptr inbounds float, <2 x ptr> %wide.load, i64 %25
  %29 = getelementptr inbounds [16 x ptr], ptr %26, i64 0, i64 %index
  store <2 x ptr> %28, ptr %29, align 8, !tbaa !17
  %index.next = add nuw i64 %index, 2
  %30 = icmp eq i64 %index.next, %n.vec
  br i1 %30, label %middle.block, label %vector.body, !llvm.loop !18

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %31 = getelementptr inbounds [16 x ptr], ptr %24, i64 0, i64 %indvars.iv
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds float, ptr %32, i64 %25
  %34 = getelementptr inbounds [16 x ptr], ptr %26, i64 0, i64 %indvars.iv
  store ptr %33, ptr %34, align 8, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !22

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %16
  %35 = getelementptr inbounds i8, ptr %0, i64 1884
  store i32 %.pre, ptr %35, align 4, !tbaa !14
  %36 = add nsw i32 %.pre, %20
  %37 = getelementptr inbounds i8, ptr %0, i64 1888
  store i32 %36, ptr %37, align 8, !tbaa !13
  %.not25 = icmp eq ptr %1, null
  br i1 %.not25, label %39, label %38

38:                                               ; preds = %._crit_edge
  store i32 %22, ptr %1, align 4, !tbaa !15
  br label %39

39:                                               ; preds = %38, %._crit_edge
  %.not26 = icmp eq ptr %2, null
  br i1 %.not26, label %42, label %40

40:                                               ; preds = %39
  %41 = getelementptr inbounds i8, ptr %0, i64 1008
  store ptr %41, ptr %2, align 8, !tbaa !17
  br label %42

42:                                               ; preds = %39, %40, %13, %9
  %.021 = phi i32 [ %10, %9 ], [ 0, %13 ], [ %20, %40 ], [ %20, %39 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #2
  ret i32 %.021
}

attributes #0 = { mustprogress 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, !8, i64 68}
!6 = !{!"stb_vorbis", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !8, i64 68, !7, i64 72, !11, i64 76, !11, i64 96, !12, i64 120, !7, i64 136, !7, i64 140, !7, i64 144, !7, i64 148, !8, i64 152, !7, i64 160, !7, i64 164, !7, i64 168, !10, i64 176, !7, i64 184, !8, i64 188, !10, i64 320, !7, i64 328, !8, i64 332, !10, i64 464, !7, i64 472, !10, i64 480, !7, i64 488, !8, i64 492, !7, i64 876, !8, i64 880, !8, i64 1008, !8, i64 1136, !7, i64 1264, !8, i64 1272, !7, i64 1400, !7, i64 1404, !8, i64 1408, !8, i64 1424, !8, i64 1440, !8, i64 1456, !8, i64 1472, !7, i64 1488, !7, i64 1492, !7, i64 1496, !8, i64 1500, !8, i64 1755, !8, i64 1756, !8, i64 1757, !7, i64 1760, !7, i64 1764, !7, i64 1768, !7, i64 1772, !7, i64 1776, !7, i64 1780, !7, i64 1784, !7, i64 1788, !7, i64 1792, !7, i64 1796, !7, i64 1800, !8, i64 1804, !7, i64 1884, !7, i64 1888}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16}
!12 = !{!"", !10, i64 0, !7, i64 8}
!13 = !{!6, !7, i64 1888}
!14 = !{!6, !7, i64 1884}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 4}
!17 = !{!10, !10, i64 0}
!18 = distinct !{!18, !19, !20, !21}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!"llvm.loop.isvectorized", i32 1}
!21 = !{!"llvm.loop.unroll.runtime.disable"}
!22 = distinct !{!22, !19, !21, !20}


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