; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/wav (soloud_wavstream)

; 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_info = type { i32, i32, i32, i32, i32, i32 }
%"class.SoLoud::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }
%"class.SoLoud::WavStream" = type <{ %"class.SoLoud::AudioSource", i32, [4 x i8], ptr, ptr, ptr, i32, [4 x i8] }>

; 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

declare ptr @stb_vorbis_open_file(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

declare void @stb_vorbis_close(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6SoLoud9WavStream7loadoggEPNS_4FileE(ptr noundef nonnull align 8 dereferenceable(188) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.stb_vorbis_info, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 5
  %15 = load ptr, ptr %14, align 8
  call void %15(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call ptr @stb_vorbis_open_file(ptr noundef %16, i32 noundef 0, ptr noundef %6, ptr noundef null)
  store ptr %17, ptr %7, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %2
  store i32 3, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %42

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  call void @stb_vorbis_get_info(ptr dead_on_unwind writable sret(%struct.stb_vorbis_info) align 4 %9, ptr noundef %22)
  %23 = getelementptr inbounds %struct.stb_vorbis_info, ptr %9, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %11, i32 0, i32 4
  store i32 %24, ptr %25, align 4, !tbaa !14
  %26 = getelementptr inbounds %struct.stb_vorbis_info, ptr %9, i32 0, i32 1
  %27 = load i32, ptr %26, align 4, !tbaa !11
  %28 = icmp sgt i32 %27, 8
  br i1 %28, label %29, label %31

29:                                               ; preds = %21
  %30 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %11, i32 0, i32 4
  store i32 8, ptr %30, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %29, %21
  %32 = getelementptr inbounds %struct.stb_vorbis_info, ptr %9, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = uitofp i32 %33 to float
  %35 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %11, i32 0, i32 2
  store float %34, ptr %35, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i32 @stb_vorbis_stream_length_in_samples(ptr noundef %36)
  store i32 %37, ptr %10, align 4, !tbaa !20
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  call void @stb_vorbis_close(ptr noundef %38)
  %39 = getelementptr inbounds %"class.SoLoud::WavStream", ptr %11, i32 0, i32 1
  store i32 1, ptr %39, align 8, !tbaa !21
  %40 = load i32, ptr %10, align 4, !tbaa !20
  %41 = getelementptr inbounds %"class.SoLoud::WavStream", ptr %11, i32 0, i32 6
  store i32 %40, ptr %41, align 8, !tbaa !23
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  br label %42

42:                                               ; preds = %31, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %43 = load i32, ptr %3, align 4
  ret i32 %43
}

declare void @stb_vorbis_get_info(ptr dead_on_unwind writable sret(%struct.stb_vorbis_info) align 4, ptr noundef) #1

declare i32 @stb_vorbis_stream_length_in_samples(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { mustprogress 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 #3 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"_ZTS15stb_vorbis_info", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 20}
!15 = !{!"_ZTSN6SoLoud11AudioSourceE", !13, i64 8, !16, i64 12, !16, i64 16, !13, i64 20, !13, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !13, i64 40, !16, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !13, i64 136, !17, i64 144}
!16 = !{!"float", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!12, !13, i64 0}
!19 = !{!15, !16, i64 12}
!20 = !{!13, !13, i64 0}
!21 = !{!22, !13, i64 152}
!22 = !{!"_ZTSN6SoLoud9WavStreamE", !15, i64 0, !13, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !13, i64 184}
!23 = !{!22, !13, i64 184}


; 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"

%struct.stb_vorbis_info = type { i32, i32, i32, i32, i32, i32 }

; 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

declare ptr @stb_vorbis_open_file(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @stb_vorbis_close(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 4) i32 @_ZN6SoLoud9WavStream7loadoggEPNS_4FileE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(188) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca %struct.stb_vorbis_info, align 4
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 40
  %7 = load ptr, ptr %6, align 8
  tail call void %7(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %8 = call ptr @stb_vorbis_open_file(ptr noundef nonnull %1, i32 noundef 0, ptr noundef nonnull %3, ptr noundef null)
  %9 = icmp eq ptr %8, null
  br i1 %9, label %20, label %10

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  call void @stb_vorbis_get_info(ptr dead_on_unwind nonnull writable sret(%struct.stb_vorbis_info) align 4 %4, ptr noundef nonnull %8)
  %11 = getelementptr inbounds i8, ptr %4, i64 4
  %12 = load i32, ptr %11, align 4, !tbaa !8
  %13 = getelementptr inbounds i8, ptr %0, i64 20
  %spec.select = call i32 @llvm.smin.i32(i32 %12, i32 8)
  store i32 %spec.select, ptr %13, align 4, !tbaa !12
  %14 = load i32, ptr %4, align 4, !tbaa !17
  %15 = uitofp i32 %14 to float
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  store float %15, ptr %16, align 4, !tbaa !18
  %17 = call i32 @stb_vorbis_stream_length_in_samples(ptr noundef nonnull %8)
  call void @stb_vorbis_close(ptr noundef nonnull %8)
  %18 = getelementptr inbounds i8, ptr %0, i64 152
  store i32 1, ptr %18, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 184
  store i32 %17, ptr %19, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  br label %20

20:                                               ; preds = %2, %10
  %.0 = phi i32 [ 0, %10 ], [ 3, %2 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret i32 %.0
}

declare void @stb_vorbis_get_info(ptr dead_on_unwind writable sret(%struct.stb_vorbis_info) align 4, ptr noundef) local_unnamed_addr #1

declare i32 @stb_vorbis_stream_length_in_samples(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { mustprogress 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 4}
!9 = !{!"_ZTS15stb_vorbis_info", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!13, !10, i64 20}
!13 = !{!"_ZTSN6SoLoud11AudioSourceE", !10, i64 8, !14, i64 12, !14, i64 16, !10, i64 20, !10, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !10, i64 40, !14, i64 44, !11, i64 48, !15, i64 112, !15, i64 120, !15, i64 128, !10, i64 136, !16, i64 144}
!14 = !{!"float", !11, i64 0}
!15 = !{!"any pointer", !11, i64 0}
!16 = !{!"double", !11, i64 0}
!17 = !{!9, !10, i64 0}
!18 = !{!13, !14, i64 12}
!19 = !{!20, !10, i64 152}
!20 = !{!"_ZTSN6SoLoud9WavStreamE", !13, i64 0, !10, i64 152, !15, i64 160, !15, i64 168, !15, i64 176, !10, i64 184}
!21 = !{!20, !10, i64 184}


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