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

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

%"class.SoLoud::Wav" = type <{ %"class.SoLoud::AudioSource", ptr, i32, [4 x i8] }>
%"class.SoLoud::AudioSource" = type { ptr, i32, float, float, i32, i32, float, float, float, i32, float, [8 x ptr], ptr, ptr, ptr, i32, double }

; 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadwavEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadoggEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadmp3EPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav8loadflacEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6SoLoud3Wav15testAndLoadFileEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %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 i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"class.SoLoud::Wav", ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  call void @_ZdaPv(ptr noundef %10) #4
  br label %13

13:                                               ; preds = %12, %2
  %14 = getelementptr inbounds %"class.SoLoud::Wav", ptr %8, i32 0, i32 1
  store ptr null, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.SoLoud::Wav", ptr %8, i32 0, i32 2
  store i32 0, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds %"class.SoLoud::AudioSource", ptr %8, i32 0, i32 4
  store i32 1, ptr %16, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef i32 @_ZN6SoLoud4File6read32Ev(ptr noundef nonnull align 8 dereferenceable(8) %17)
  store i32 %18, ptr %6, align 4, !tbaa !17
  %19 = load i32, ptr %6, align 4, !tbaa !17
  %20 = icmp eq i32 %19, 1399285583
  br i1 %20, label %21, label %24

21:                                               ; preds = %13
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef i32 @_ZN6SoLoud3Wav7loadoggEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %8, ptr noundef %22)
  store i32 %23, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

24:                                               ; preds = %13
  %25 = load i32, ptr %6, align 4, !tbaa !17
  %26 = icmp eq i32 %25, 1179011410
  br i1 %26, label %27, label %30

27:                                               ; preds = %24
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef i32 @_ZN6SoLoud3Wav7loadwavEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %8, ptr noundef %28)
  store i32 %29, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

30:                                               ; preds = %24
  %31 = load i32, ptr %6, align 4, !tbaa !17
  %32 = icmp eq i32 %31, 1130450022
  br i1 %32, label %33, label %36

33:                                               ; preds = %30
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call noundef i32 @_ZN6SoLoud3Wav8loadflacEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %8, ptr noundef %34)
  store i32 %35, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

36:                                               ; preds = %30
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = call noundef i32 @_ZN6SoLoud3Wav7loadmp3EPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %8, ptr noundef %37)
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

41:                                               ; preds = %36
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  store i32 3, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

45:                                               ; preds = %44, %40, %33, %27, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %46 = load i32, ptr %3, align 4
  ret i32 %46
}

declare noundef i32 @_ZN6SoLoud4File6read32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin nounwind "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 = { "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 #4 = { builtin nounwind }
attributes #5 = { 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, !6, i64 152}
!10 = !{!"_ZTSN6SoLoud3WavE", !11, i64 0, !6, i64 152, !12, i64 160}
!11 = !{!"_ZTSN6SoLoud11AudioSourceE", !12, i64 8, !13, i64 12, !13, i64 16, !12, i64 20, !12, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !12, i64 40, !13, i64 44, !7, i64 48, !6, i64 112, !6, i64 120, !6, i64 128, !12, i64 136, !14, i64 144}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!10, !12, i64 160}
!16 = !{!11, !12, i64 20}
!17 = !{!12, !12, 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: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadwavEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadoggEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav7loadmp3EPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6SoLoud3Wav8loadflacEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6SoLoud3Wav15testAndLoadFileEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 152
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void @_ZdaPv(ptr noundef nonnull %4) #3
  br label %7

7:                                                ; preds = %6, %2
  store ptr null, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 160
  store i32 0, ptr %8, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 20
  store i32 1, ptr %9, align 4, !tbaa !15
  %10 = tail call noundef i32 @_ZN6SoLoud4File6read32Ev(ptr noundef nonnull align 8 dereferenceable(8) %1)
  switch i32 %10, label %17 [
    i32 1399285583, label %11
    i32 1179011410, label %13
    i32 1130450022, label %15
  ]

11:                                               ; preds = %7
  %12 = tail call noundef i32 @_ZN6SoLoud3Wav7loadoggEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull %1)
  br label %20

13:                                               ; preds = %7
  %14 = tail call noundef i32 @_ZN6SoLoud3Wav7loadwavEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull %1)
  br label %20

15:                                               ; preds = %7
  %16 = tail call noundef i32 @_ZN6SoLoud3Wav8loadflacEPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull %1)
  br label %20

17:                                               ; preds = %7
  %18 = tail call noundef i32 @_ZN6SoLoud3Wav7loadmp3EPNS_10MemoryFileE(ptr noundef nonnull align 8 dereferenceable(164) %0, ptr noundef nonnull %1)
  %19 = icmp eq i32 %18, 0
  %. = select i1 %19, i32 0, i32 3
  br label %20

20:                                               ; preds = %17, %15, %13, %11
  %.0 = phi i32 [ %12, %11 ], [ %14, %13 ], [ %16, %15 ], [ %., %17 ]
  ret i32 %.0
}

declare noundef i32 @_ZN6SoLoud4File6read32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

attributes #0 = { nobuiltin nounwind "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 #1 = { 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 #2 = { "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 = { builtin 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, !12, i64 152}
!6 = !{!"_ZTSN6SoLoud3WavE", !7, i64 0, !12, i64 152, !8, i64 160}
!7 = !{!"_ZTSN6SoLoud11AudioSourceE", !8, i64 8, !11, i64 12, !11, i64 16, !8, i64 20, !8, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !11, i64 44, !9, i64 48, !12, i64 112, !12, i64 120, !12, i64 128, !8, i64 136, !13, i64 144}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"double", !9, i64 0}
!14 = !{!6, !8, i64 160}
!15 = !{!7, !8, i64 20}


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