; 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 dso_local i32 @stb_vorbis_get_frame_float(ptr noundef, ptr noundef, ptr noundef) #1

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

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

24:                                               ; preds = %4
  %25 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %25, ptr %12, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %24, %4
  br label %27

27:                                               ; preds = %91, %26
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %92

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.stb_vorbis, ptr %32, i32 0, i32 69
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.stb_vorbis, ptr %35, i32 0, i32 68
  %37 = load i32, ptr %36, align 4, !tbaa !16
  %38 = sub nsw i32 %34, %37
  store i32 %38, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = add nsw i32 %39, %40
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = icmp sge i32 %41, %42
  br i1 %43, label %44, label %48

44:                                               ; preds = %31
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = sub nsw i32 %45, %46
  store i32 %47, ptr %13, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %44, %31
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %64

51:                                               ; preds = %48
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.stb_vorbis, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.stb_vorbis, ptr %57, i32 0, i32 37
  %59 = getelementptr inbounds [16 x ptr], ptr %58, i64 0, i64 0
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.stb_vorbis, ptr %60, i32 0, i32 68
  %62 = load i32, ptr %61, align 4, !tbaa !16
  %63 = load i32, ptr %13, align 4, !tbaa !9
  call void @convert_channels_short_interleaved(i32 noundef %52, ptr noundef %53, i32 noundef %56, ptr noundef %59, i32 noundef %62, i32 noundef %63)
  br label %64

64:                                               ; preds = %51, %48
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = mul nsw i32 %65, %66
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = sext i32 %67 to i64
  %70 = getelementptr inbounds i16, ptr %68, i64 %69
  store ptr %70, ptr %7, align 8, !tbaa !5
  %71 = load i32, ptr %13, align 4, !tbaa !9
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = add nsw i32 %72, %71
  store i32 %73, ptr %11, align 4, !tbaa !9
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.stb_vorbis, ptr %75, i32 0, i32 68
  %77 = load i32, ptr %76, align 4, !tbaa !16
  %78 = add nsw i32 %77, %74
  store i32 %78, ptr %76, align 4, !tbaa !16
  %79 = load i32, ptr %11, align 4, !tbaa !9
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = icmp eq i32 %79, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %64
  store i32 3, ptr %14, align 4
  br label %89

83:                                               ; preds = %64
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = call i32 @stb_vorbis_get_frame_float(ptr noundef %84, ptr noundef null, ptr noundef %9)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  store i32 3, ptr %14, align 4
  br label %89

88:                                               ; preds = %83
  store i32 0, ptr %14, align 4
  br label %89

89:                                               ; preds = %88, %87, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  %90 = load i32, ptr %14, align 4
  switch i32 %90, label %94 [
    i32 0, label %91
    i32 3, label %92
  ]

91:                                               ; preds = %89
  br label %27, !llvm.loop !17

92:                                               ; preds = %89, %27
  %93 = load i32, ptr %11, align 4, !tbaa !9
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  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 8, ptr %9) #2
  ret i32 %93

94:                                               ; preds = %89
  unreachable
}

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @stb_vorbis_get_samples_short_interleaved(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #2
  %6 = sdiv i32 %3, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = getelementptr inbounds i8, ptr %0, i64 1888
  %9 = getelementptr inbounds i8, ptr %0, i64 1884
  %10 = getelementptr inbounds i8, ptr %0, i64 880
  br label %11

11:                                               ; preds = %26, %4
  %.035 = phi ptr [ %2, %4 ], [ %29, %26 ]
  %.034 = phi i32 [ 0, %4 ], [ %23, %26 ]
  %12 = icmp slt i32 %.034, %6
  br i1 %12, label %13, label %.thread

13:                                               ; preds = %11
  %14 = load i32, ptr %8, align 8, !tbaa !5
  %15 = load i32, ptr %9, align 4, !tbaa !13
  %16 = sub nsw i32 %14, %15
  %17 = add nsw i32 %16, %.034
  %.not = icmp slt i32 %17, %6
  %18 = sub nsw i32 %6, %.034
  %spec.select = select i1 %.not, i32 %16, i32 %18
  %.not37 = icmp eq i32 %spec.select, 0
  br i1 %.not37, label %21, label %19

19:                                               ; preds = %13
  %20 = load i32, ptr %7, align 4, !tbaa !14
  call void @convert_channels_short_interleaved(i32 noundef %1, ptr noundef %.035, i32 noundef %20, ptr noundef nonnull %10, i32 noundef %15, i32 noundef %spec.select)
  %.pre = load i32, ptr %9, align 4, !tbaa !13
  br label %21

21:                                               ; preds = %19, %13
  %22 = phi i32 [ %.pre, %19 ], [ %15, %13 ]
  %23 = add nsw i32 %spec.select, %.034
  %24 = add nsw i32 %22, %spec.select
  store i32 %24, ptr %9, align 4, !tbaa !13
  %25 = icmp eq i32 %23, %6
  br i1 %25, label %.thread, label %26

26:                                               ; preds = %21
  %27 = mul nsw i32 %spec.select, %1
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i16, ptr %.035, i64 %28
  %30 = call i32 @stb_vorbis_get_frame_float(ptr noundef nonnull %0, ptr noundef null, ptr noundef nonnull %5)
  %.not38 = icmp eq i32 %30, 0
  br i1 %.not38, label %.thread, label %11

.thread:                                          ; preds = %26, %21, %11
  %.1 = phi i32 [ %.034, %11 ], [ %6, %21 ], [ %23, %26 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #2
  ret i32 %.1
}

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, !7, i64 1888}
!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 1884}
!14 = !{!6, !7, i64 4}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,ReassociatePass,SROAPass,SimplifyCFGPass