; 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.drmp3 = type { %struct.drmp3dec, %struct.drmp3dec_frame_info, i32, i32, ptr, ptr, ptr, %struct.drmp3_allocation_callbacks, i32, i32, i32, i32, [9216 x i8], i64, i64, %struct.drmp3_src, ptr, i32, i64, i64, ptr, i8, %struct.anon.0 }
%struct.drmp3dec = type { [2 x [288 x float]], [960 x float], i32, i32, [4 x i8], [511 x i8] }
%struct.drmp3dec_frame_info = type { i32, i32, i32, i32, i32 }
%struct.drmp3_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.drmp3_src = type { %struct.drmp3_src_config, ptr, ptr, [256 x float], %struct.drmp3_src_cache, %union.anon }
%struct.drmp3_src_config = type { i32, i32, i32, i32, i32 }
%struct.drmp3_src_cache = type { ptr, [1024 x float], i32, i32 }
%union.anon = type { %struct.anon }
%struct.anon = type { double, i8 }
%struct.anon.0 = type { ptr, i64, i64 }
%struct.drmp3_seek_point = type { i64, i64, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._Z29drmp3_find_closest_seek_pointP5drmp3mPj = external hidden unnamed_addr constant [82 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z29drmp3_find_closest_seek_pointP5drmp3mPj(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  br label %15

13:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 3405, ptr noundef @__PRETTY_FUNCTION__._Z29drmp3_find_closest_seek_pointP5drmp3mPj) #4
  unreachable

14:                                               ; No predecessors!
  br label %15

15:                                               ; preds = %14, %12
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %16, align 4, !tbaa !11
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.drmp3, ptr %18, i32 0, i32 16
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds %struct.drmp3_seek_point, ptr %20, i64 0
  %22 = getelementptr inbounds %struct.drmp3_seek_point, ptr %21, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !23
  %24 = icmp ult i64 %17, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %15
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %52

26:                                               ; preds = %15
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %48, %26
  %28 = load i32, ptr %8, align 4, !tbaa !11
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.drmp3, ptr %29, i32 0, i32 17
  %31 = load i32, ptr %30, align 8, !tbaa !26
  %32 = icmp ult i32 %28, %31
  br i1 %32, label %33, label %51

33:                                               ; preds = %27
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.drmp3, ptr %34, i32 0, i32 16
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load i32, ptr %8, align 4, !tbaa !11
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds %struct.drmp3_seek_point, ptr %36, i64 %38
  %40 = getelementptr inbounds %struct.drmp3_seek_point, ptr %39, i32 0, i32 1
  %41 = load i64, ptr %40, align 8, !tbaa !23
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = icmp ugt i64 %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %33
  br label %51

45:                                               ; preds = %33
  %46 = load i32, ptr %8, align 4, !tbaa !11
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %46, ptr %47, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %45
  %49 = load i32, ptr %8, align 4, !tbaa !11
  %50 = add i32 %49, 1
  store i32 %50, ptr %8, align 4, !tbaa !11
  br label %27, !llvm.loop !27

51:                                               ; preds = %44, %27
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %52

52:                                               ; preds = %51, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %53 = load i32, ptr %4, align 4
  ret i32 %53
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 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 #3 = { nounwind }
attributes #4 = { noreturn 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, !6, i64 21192}
!14 = !{!"_ZTS5drmp3", !15, i64 0, !16, i64 6668, !12, i64 6688, !12, i64 6692, !6, i64 6696, !6, i64 6704, !6, i64 6712, !17, i64 6720, !12, i64 6752, !12, i64 6756, !12, i64 6760, !12, i64 6764, !7, i64 6768, !10, i64 15984, !10, i64 15992, !18, i64 16000, !6, i64 21192, !12, i64 21200, !10, i64 21208, !10, i64 21216, !6, i64 21224, !12, i64 21232, !22, i64 21240}
!15 = !{!"_ZTS8drmp3dec", !7, i64 0, !7, i64 2304, !12, i64 6144, !12, i64 6148, !7, i64 6152, !7, i64 6156}
!16 = !{!"_ZTS19drmp3dec_frame_info", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16}
!17 = !{!"_ZTS26drmp3_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTS9drmp3_src", !19, i64 0, !6, i64 24, !6, i64 32, !7, i64 40, !21, i64 1064, !7, i64 5176}
!19 = !{!"_ZTS16drmp3_src_config", !12, i64 0, !12, i64 4, !12, i64 8, !20, i64 12, !12, i64 16}
!20 = !{!"_ZTS19drmp3_src_algorithm", !7, i64 0}
!21 = !{!"_ZTS15drmp3_src_cache", !6, i64 0, !7, i64 8, !12, i64 4104, !12, i64 4108}
!22 = !{!"_ZTSN5drmp3Ut_E", !6, i64 0, !10, i64 8, !10, i64 16}
!23 = !{!24, !10, i64 8}
!24 = !{!"_ZTS16drmp3_seek_point", !10, i64 0, !10, i64 8, !25, i64 16, !25, i64 18}
!25 = !{!"short", !7, i64 0}
!26 = !{!14, !12, i64 21200}
!27 = distinct !{!27, !28}
!28 = !{!"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"

%struct.drmp3_seek_point = type { i64, i64, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._Z29drmp3_find_closest_seek_pointP5drmp3mPj = external hidden unnamed_addr constant [82 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z29drmp3_find_closest_seek_pointP5drmp3mPj(ptr nocapture noundef readonly %0, i64 noundef %1, ptr noundef writeonly %2) local_unnamed_addr #1 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 3405, ptr noundef nonnull @__PRETTY_FUNCTION__._Z29drmp3_find_closest_seek_pointP5drmp3mPj) #2
  unreachable

5:                                                ; preds = %3
  store i32 0, ptr %2, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 21192
  %7 = load ptr, ptr %6, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !21
  %10 = icmp ugt i64 %9, %1
  br i1 %10, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 21200
  %12 = load i32, ptr %11, align 8, !tbaa !24
  %.not17 = icmp eq i32 %12, 0
  br i1 %.not17, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %16
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 0, %.preheader ]
  %13 = getelementptr inbounds %struct.drmp3_seek_point, ptr %7, i64 %indvars.iv, i32 1
  %14 = load i64, ptr %13, align 8, !tbaa !21
  %15 = icmp ugt i64 %14, %1
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %.lr.ph
  %17 = trunc nuw i64 %indvars.iv to i32
  store i32 %17, ptr %2, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr %11, align 8, !tbaa !24
  %19 = zext i32 %18 to i64
  %20 = icmp ult i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %.loopexit, !llvm.loop !25

.loopexit:                                        ; preds = %.lr.ph, %16, %.preheader, %5
  %.012 = phi i32 [ 0, %5 ], [ 1, %.preheader ], [ 1, %16 ], [ 1, %.lr.ph ]
  ret i32 %.012
}

attributes #0 = { noreturn 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 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 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 21192}
!10 = !{!"_ZTS5drmp3", !11, i64 0, !12, i64 6668, !6, i64 6688, !6, i64 6692, !13, i64 6696, !13, i64 6704, !13, i64 6712, !14, i64 6720, !6, i64 6752, !6, i64 6756, !6, i64 6760, !6, i64 6764, !7, i64 6768, !15, i64 15984, !15, i64 15992, !16, i64 16000, !13, i64 21192, !6, i64 21200, !15, i64 21208, !15, i64 21216, !13, i64 21224, !6, i64 21232, !20, i64 21240}
!11 = !{!"_ZTS8drmp3dec", !7, i64 0, !7, i64 2304, !6, i64 6144, !6, i64 6148, !7, i64 6152, !7, i64 6156}
!12 = !{!"_ZTS19drmp3dec_frame_info", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"_ZTS26drmp3_allocation_callbacks", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS9drmp3_src", !17, i64 0, !13, i64 24, !13, i64 32, !7, i64 40, !19, i64 1064, !7, i64 5176}
!17 = !{!"_ZTS16drmp3_src_config", !6, i64 0, !6, i64 4, !6, i64 8, !18, i64 12, !6, i64 16}
!18 = !{!"_ZTS19drmp3_src_algorithm", !7, i64 0}
!19 = !{!"_ZTS15drmp3_src_cache", !13, i64 0, !7, i64 8, !6, i64 4104, !6, i64 4108}
!20 = !{!"_ZTSN5drmp3Ut_E", !13, i64 0, !15, i64 8, !15, i64 16}
!21 = !{!22, !15, i64 8}
!22 = !{!"_ZTS16drmp3_seek_point", !15, i64 0, !15, i64 8, !23, i64 16, !23, i64 18}
!23 = !{!"short", !7, i64 0}
!24 = !{!10, !6, i64 21200}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass