; LLVM IR from merpheus-dev/LavaEngine :: src/Utils/soloud/src/audiosource/wav (dr_impl)

; 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.drflac_streaminfo = type { i16, i16, i32, i32, i32, i8, i8, i64, [16 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z23drflac__read_streaminfoPFmPvS_mES_P17drflac_streaminfo(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %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 i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca [16 x i8], align 16
  %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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call noundef i64 %13(ptr noundef %14, ptr noundef %8, i64 noundef 4)
  %16 = icmp ne i64 %15, 4
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %99

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call noundef i64 %19(ptr noundef %20, ptr noundef %9, i64 noundef 6)
  %22 = icmp ne i64 %21, 6
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %99

24:                                               ; preds = %18
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef i64 %25(ptr noundef %26, ptr noundef %10, i64 noundef 8)
  %28 = icmp ne i64 %27, 8
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %99

30:                                               ; preds = %24
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %34 = call noundef i64 %31(ptr noundef %32, ptr noundef %33, i64 noundef 16)
  %35 = icmp ne i64 %34, 16
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %99

37:                                               ; preds = %30
  %38 = load i32, ptr %8, align 4, !tbaa !11
  %39 = call noundef i32 @_ZL18drflac__be2host_32j(i32 noundef %38)
  store i32 %39, ptr %8, align 4, !tbaa !11
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = call noundef i64 @_ZL18drflac__be2host_64m(i64 noundef %40)
  store i64 %41, ptr %9, align 8, !tbaa !9
  %42 = load i64, ptr %10, align 8, !tbaa !9
  %43 = call noundef i64 @_ZL18drflac__be2host_64m(i64 noundef %42)
  store i64 %43, ptr %10, align 8, !tbaa !9
  %44 = load i32, ptr %8, align 4, !tbaa !11
  %45 = and i32 %44, -65536
  %46 = lshr i32 %45, 16
  %47 = trunc i32 %46 to i16
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.drflac_streaminfo, ptr %48, i32 0, i32 0
  store i16 %47, ptr %49, align 8, !tbaa !13
  %50 = load i32, ptr %8, align 4, !tbaa !11
  %51 = and i32 %50, 65535
  %52 = trunc i32 %51 to i16
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.drflac_streaminfo, ptr %53, i32 0, i32 1
  store i16 %52, ptr %54, align 2, !tbaa !16
  %55 = load i64, ptr %9, align 8, !tbaa !9
  %56 = and i64 %55, -1099511627776
  %57 = lshr i64 %56, 40
  %58 = trunc i64 %57 to i32
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.drflac_streaminfo, ptr %59, i32 0, i32 2
  store i32 %58, ptr %60, align 4, !tbaa !17
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = and i64 %61, 1099511562240
  %63 = lshr i64 %62, 16
  %64 = trunc i64 %63 to i32
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.drflac_streaminfo, ptr %65, i32 0, i32 3
  store i32 %64, ptr %66, align 8, !tbaa !18
  %67 = load i64, ptr %10, align 8, !tbaa !9
  %68 = and i64 %67, -17592186044416
  %69 = lshr i64 %68, 44
  %70 = trunc i64 %69 to i32
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.drflac_streaminfo, ptr %71, i32 0, i32 4
  store i32 %70, ptr %72, align 4, !tbaa !19
  %73 = load i64, ptr %10, align 8, !tbaa !9
  %74 = and i64 %73, 15393162788864
  %75 = lshr i64 %74, 41
  %76 = trunc i64 %75 to i8
  %77 = zext i8 %76 to i32
  %78 = add nsw i32 %77, 1
  %79 = trunc i32 %78 to i8
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.drflac_streaminfo, ptr %80, i32 0, i32 5
  store i8 %79, ptr %81, align 8, !tbaa !20
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = and i64 %82, 2130303778816
  %84 = lshr i64 %83, 36
  %85 = trunc i64 %84 to i8
  %86 = zext i8 %85 to i32
  %87 = add nsw i32 %86, 1
  %88 = trunc i32 %87 to i8
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.drflac_streaminfo, ptr %89, i32 0, i32 6
  store i8 %88, ptr %90, align 1, !tbaa !21
  %91 = load i64, ptr %10, align 8, !tbaa !9
  %92 = and i64 %91, 68719476735
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.drflac_streaminfo, ptr %93, i32 0, i32 7
  store i64 %92, ptr %94, align 8, !tbaa !22
  %95 = load ptr, ptr %7, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.drflac_streaminfo, ptr %95, i32 0, i32 8
  %97 = getelementptr inbounds [16 x i8], ptr %96, i64 0, i64 0
  %98 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %97, ptr align 16 %98, i64 16, i1 false)
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %99

99:                                               ; preds = %37, %36, %29, %23, %17
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %100 = load i32, ptr %4, align 4
  ret i32 %100
}

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i32 @_ZL18drflac__be2host_32j(i32 noundef) #3

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i64 @_ZL18drflac__be2host_64m(i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { alwaysinline 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"_ZTS17drflac_streaminfo", !15, i64 0, !15, i64 2, !12, i64 4, !12, i64 8, !12, i64 12, !7, i64 16, !7, i64 17, !10, i64 24, !7, i64 32}
!15 = !{!"short", !7, i64 0}
!16 = !{!14, !15, i64 2}
!17 = !{!14, !12, i64 4}
!18 = !{!14, !12, i64 8}
!19 = !{!14, !12, i64 12}
!20 = !{!14, !7, i64 16}
!21 = !{!14, !7, i64 17}
!22 = !{!14, !10, i64 24}


; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z23drflac__read_streaminfoPFmPvS_mES_P17drflac_streaminfo(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %8 = call noundef i64 %0(ptr noundef %1, ptr noundef nonnull %4, i64 noundef 4)
  %.not = icmp eq i64 %8, 4
  br i1 %.not, label %9, label %51

9:                                                ; preds = %3
  %10 = call noundef i64 %0(ptr noundef %1, ptr noundef nonnull %5, i64 noundef 6)
  %.not17 = icmp eq i64 %10, 6
  br i1 %.not17, label %11, label %51

11:                                               ; preds = %9
  %12 = call noundef i64 %0(ptr noundef %1, ptr noundef nonnull %6, i64 noundef 8)
  %.not18 = icmp eq i64 %12, 8
  br i1 %.not18, label %13, label %51

13:                                               ; preds = %11
  %14 = call noundef i64 %0(ptr noundef %1, ptr noundef nonnull %7, i64 noundef 16)
  %.not19 = icmp eq i64 %14, 16
  br i1 %.not19, label %15, label %51

15:                                               ; preds = %13
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = call noundef i32 @_ZL18drflac__be2host_32j(i32 noundef %16)
  store i32 %17, ptr %4, align 4, !tbaa !9
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %19 = call noundef i64 @_ZL18drflac__be2host_64m(i64 noundef %18)
  store i64 %19, ptr %5, align 8, !tbaa !5
  %20 = load i64, ptr %6, align 8, !tbaa !5
  %21 = call noundef i64 @_ZL18drflac__be2host_64m(i64 noundef %20)
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = lshr i32 %22, 16
  %24 = trunc nuw i32 %23 to i16
  store i16 %24, ptr %2, align 8, !tbaa !11
  %25 = trunc i32 %22 to i16
  %26 = getelementptr inbounds i8, ptr %2, i64 2
  store i16 %25, ptr %26, align 2, !tbaa !14
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = lshr i64 %27, 40
  %29 = trunc nuw nsw i64 %28 to i32
  %30 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 %29, ptr %30, align 4, !tbaa !15
  %31 = lshr i64 %27, 16
  %32 = trunc i64 %31 to i32
  %33 = and i32 %32, 16777215
  %34 = getelementptr inbounds i8, ptr %2, i64 8
  store i32 %33, ptr %34, align 8, !tbaa !16
  %35 = lshr i64 %21, 44
  %36 = trunc nuw nsw i64 %35 to i32
  %37 = getelementptr inbounds i8, ptr %2, i64 12
  store i32 %36, ptr %37, align 4, !tbaa !17
  %38 = lshr i64 %21, 41
  %39 = trunc i64 %38 to i8
  %40 = and i8 %39, 7
  %41 = add nuw nsw i8 %40, 1
  %42 = getelementptr inbounds i8, ptr %2, i64 16
  store i8 %41, ptr %42, align 8, !tbaa !18
  %43 = lshr i64 %21, 36
  %44 = trunc i64 %43 to i8
  %45 = and i8 %44, 31
  %46 = add nuw nsw i8 %45, 1
  %47 = getelementptr inbounds i8, ptr %2, i64 17
  store i8 %46, ptr %47, align 1, !tbaa !19
  %48 = and i64 %21, 68719476735
  %49 = getelementptr inbounds i8, ptr %2, i64 24
  store i64 %48, ptr %49, align 8, !tbaa !20
  %50 = getelementptr inbounds i8, ptr %2, i64 32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %50, ptr noundef nonnull align 16 dereferenceable(16) %7, i64 16, i1 false)
  br label %51

51:                                               ; preds = %13, %11, %9, %3, %15
  %.0 = phi i32 [ 1, %15 ], [ 0, %3 ], [ 0, %9 ], [ 0, %11 ], [ 0, %13 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret i32 %.0
}

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i32 @_ZL18drflac__be2host_32j(i32 noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef i64 @_ZL18drflac__be2host_64m(i64 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { alwaysinline 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 #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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS17drflac_streaminfo", !13, i64 0, !13, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 17, !6, i64 24, !7, i64 32}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 2}
!15 = !{!12, !10, i64 4}
!16 = !{!12, !10, i64 8}
!17 = !{!12, !10, i64 12}
!18 = !{!12, !7, i64 16}
!19 = !{!12, !7, i64 17}
!20 = !{!12, !6, i64 24}


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