; 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.drwav = type { ptr, ptr, ptr, ptr, %struct.drwav_allocation_callbacks, i32, %struct.drwav_fmt, i32, i16, i16, i16, i64, i64, i64, i64, i64, i32, %struct.drwav_smpl, %struct.drwav__memory_stream, %struct.drwav__memory_stream_write, %struct.anon.1, %struct.anon.2, %struct.anon.3 }
%struct.drwav_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.drwav_fmt = type { i16, i16, i32, i32, i16, i16, i16, i16, i32, [16 x i8] }
%struct.drwav_smpl = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, [1 x %struct.drwav_smpl_loop] }
%struct.drwav_smpl_loop = type { i32, i32, i32, i32, i32, i32 }
%struct.drwav__memory_stream = type { ptr, i64, i64 }
%struct.drwav__memory_stream_write = type { ptr, ptr, i64, i64, i64 }
%struct.anon.1 = type { i64 }
%struct.anon.2 = type { i32, [2 x i16], [2 x i32], [4 x i32], i32, [2 x [2 x i32]] }
%struct.anon.3 = type { i32, [2 x i32], [2 x i32], [16 x i32], i32 }

@.str.16 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame = external hidden unnamed_addr constant [60 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [41 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
declare hidden noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef) #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL31drwav__is_compressed_format_tagt(i16 noundef zeroext) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local i32 @drwav_seek_to_pcm_frame(ptr noundef %0, i64 noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca [2048 x i16], align 16
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %23, label %18

18:                                               ; preds = %2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.drwav, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %18, %2
  store i32 0, ptr %3, align 4
  br label %222

24:                                               ; preds = %18
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.drwav, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !24
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store i32 0, ptr %3, align 4
  br label %222

30:                                               ; preds = %24
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.drwav, ptr %31, i32 0, i32 11
  %33 = load i64, ptr %32, align 8, !tbaa !25
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %30
  store i32 1, ptr %3, align 4
  br label %222

36:                                               ; preds = %30
  %37 = load i64, ptr %5, align 8, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.drwav, ptr %38, i32 0, i32 11
  %40 = load i64, ptr %39, align 8, !tbaa !25
  %41 = icmp uge i64 %37, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %36
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.drwav, ptr %43, i32 0, i32 11
  %45 = load i64, ptr %44, align 8, !tbaa !25
  %46 = sub i64 %45, 1
  store i64 %46, ptr %5, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %42, %36
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.drwav, ptr %48, i32 0, i32 10
  %50 = load i16, ptr %49, align 4, !tbaa !26
  %51 = call noundef i32 @_ZL31drwav__is_compressed_format_tagt(i16 noundef zeroext %50)
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %139

53:                                               ; preds = %47
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.drwav, ptr %55, i32 0, i32 20
  %57 = getelementptr inbounds %struct.anon.1, ptr %56, i32 0, i32 0
  %58 = load i64, ptr %57, align 8, !tbaa !27
  %59 = icmp ult i64 %54, %58
  br i1 %59, label %60, label %66

60:                                               ; preds = %53
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = call noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef %61)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 0, ptr %3, align 4
  br label %222

65:                                               ; preds = %60
  br label %66

66:                                               ; preds = %65, %53
  %67 = load i64, ptr %5, align 8, !tbaa !9
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.drwav, ptr %68, i32 0, i32 20
  %70 = getelementptr inbounds %struct.anon.1, ptr %69, i32 0, i32 0
  %71 = load i64, ptr %70, align 8, !tbaa !27
  %72 = icmp ugt i64 %67, %71
  br i1 %72, label %73, label %138

73:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %74 = load i64, ptr %5, align 8, !tbaa !9
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.drwav, ptr %75, i32 0, i32 20
  %77 = getelementptr inbounds %struct.anon.1, ptr %76, i32 0, i32 0
  %78 = load i64, ptr %77, align 8, !tbaa !27
  %79 = sub i64 %74, %78
  store i64 %79, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %7) #5
  br label %80

80:                                               ; preds = %133, %73
  %81 = load i64, ptr %6, align 8, !tbaa !9
  %82 = icmp ugt i64 %81, 0
  br i1 %82, label %83, label %134

83:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %84 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %84, ptr %9, align 8, !tbaa !9
  %85 = load i64, ptr %9, align 8, !tbaa !9
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.drwav, ptr %86, i32 0, i32 8
  %88 = load i16, ptr %87, align 8, !tbaa !28
  %89 = zext i16 %88 to i64
  %90 = udiv i64 2048, %89
  %91 = icmp ugt i64 %85, %90
  br i1 %91, label %92, label %98

92:                                               ; preds = %83
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.drwav, ptr %93, i32 0, i32 8
  %95 = load i16, ptr %94, align 8, !tbaa !28
  %96 = zext i16 %95 to i64
  %97 = udiv i64 2048, %96
  store i64 %97, ptr %9, align 8, !tbaa !9
  br label %98

98:                                               ; preds = %92, %83
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.drwav, ptr %99, i32 0, i32 10
  %101 = load i16, ptr %100, align 4, !tbaa !26
  %102 = zext i16 %101 to i32
  %103 = icmp eq i32 %102, 2
  br i1 %103, label %104, label %109

104:                                              ; preds = %98
  %105 = load ptr, ptr %4, align 8, !tbaa !5
  %106 = load i64, ptr %9, align 8, !tbaa !9
  %107 = getelementptr inbounds [2048 x i16], ptr %7, i64 0, i64 0
  %108 = call noundef i64 @_Z34drwav_read_pcm_frames_s16__msadpcmP5drwavmPs(ptr noundef %105, i64 noundef %106, ptr noundef %107)
  store i64 %108, ptr %8, align 8, !tbaa !9
  br label %122

109:                                              ; preds = %98
  %110 = load ptr, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.drwav, ptr %110, i32 0, i32 10
  %112 = load i16, ptr %111, align 4, !tbaa !26
  %113 = zext i16 %112 to i32
  %114 = icmp eq i32 %113, 17
  br i1 %114, label %115, label %120

115:                                              ; preds = %109
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = load i64, ptr %9, align 8, !tbaa !9
  %118 = getelementptr inbounds [2048 x i16], ptr %7, i64 0, i64 0
  %119 = call noundef i64 @_Z30drwav_read_pcm_frames_s16__imaP5drwavmPs(ptr noundef %116, i64 noundef %117, ptr noundef %118)
  store i64 %119, ptr %8, align 8, !tbaa !9
  br label %121

120:                                              ; preds = %109
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.16, i32 noundef 3000, ptr noundef @__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame) #6
  unreachable

121:                                              ; preds = %115
  br label %122

122:                                              ; preds = %121, %104
  %123 = load i64, ptr %8, align 8, !tbaa !9
  %124 = load i64, ptr %9, align 8, !tbaa !9
  %125 = icmp ne i64 %123, %124
  br i1 %125, label %126, label %127

126:                                              ; preds = %122
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %131

127:                                              ; preds = %122
  %128 = load i64, ptr %8, align 8, !tbaa !9
  %129 = load i64, ptr %6, align 8, !tbaa !9
  %130 = sub i64 %129, %128
  store i64 %130, ptr %6, align 8, !tbaa !9
  store i32 0, ptr %10, align 4
  br label %131

131:                                              ; preds = %127, %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %132 = load i32, ptr %10, align 4
  switch i32 %132, label %135 [
    i32 0, label %133
  ]

133:                                              ; preds = %131
  br label %80, !llvm.loop !29

134:                                              ; preds = %80
  store i32 0, ptr %10, align 4
  br label %135

135:                                              ; preds = %134, %131
  call void @llvm.lifetime.end.p0(i64 4096, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %136 = load i32, ptr %10, align 4
  switch i32 %136, label %224 [
    i32 0, label %137
    i32 1, label %222
  ]

137:                                              ; preds = %135
  br label %138

138:                                              ; preds = %137, %66
  br label %221

139:                                              ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.drwav, ptr %140, i32 0, i32 11
  %142 = load i64, ptr %141, align 8, !tbaa !25
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = call noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef %143)
  %145 = zext i32 %144 to i64
  %146 = mul i64 %142, %145
  store i64 %146, ptr %11, align 8, !tbaa !9
  %147 = load i64, ptr %11, align 8, !tbaa !9
  %148 = load ptr, ptr %4, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.drwav, ptr %148, i32 0, i32 14
  %150 = load i64, ptr %149, align 8, !tbaa !31
  %151 = icmp uge i64 %147, %150
  br i1 %151, label %152, label %153

152:                                              ; preds = %139
  br label %155

153:                                              ; preds = %139
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.16, i32 noundef 3017, ptr noundef @__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame) #6
  unreachable

154:                                              ; No predecessors!
  br label %155

155:                                              ; preds = %154, %152
  %156 = load i64, ptr %11, align 8, !tbaa !9
  %157 = load ptr, ptr %4, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.drwav, ptr %157, i32 0, i32 14
  %159 = load i64, ptr %158, align 8, !tbaa !31
  %160 = sub i64 %156, %159
  store i64 %160, ptr %12, align 8, !tbaa !9
  %161 = load i64, ptr %5, align 8, !tbaa !9
  %162 = load ptr, ptr %4, align 8, !tbaa !5
  %163 = call noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef %162)
  %164 = zext i32 %163 to i64
  %165 = mul i64 %161, %164
  store i64 %165, ptr %13, align 8, !tbaa !9
  %166 = load i64, ptr %12, align 8, !tbaa !9
  %167 = load i64, ptr %13, align 8, !tbaa !9
  %168 = icmp ult i64 %166, %167
  br i1 %168, label %169, label %173

169:                                              ; preds = %155
  %170 = load i64, ptr %13, align 8, !tbaa !9
  %171 = load i64, ptr %12, align 8, !tbaa !9
  %172 = sub i64 %170, %171
  store i64 %172, ptr %14, align 8, !tbaa !9
  br label %180

173:                                              ; preds = %155
  %174 = load ptr, ptr %4, align 8, !tbaa !5
  %175 = call noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef %174)
  %176 = icmp ne i32 %175, 0
  br i1 %176, label %178, label %177

177:                                              ; preds = %173
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %218

178:                                              ; preds = %173
  %179 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %179, ptr %14, align 8, !tbaa !9
  br label %180

180:                                              ; preds = %178, %169
  br label %181

181:                                              ; preds = %216, %180
  %182 = load i64, ptr %14, align 8, !tbaa !9
  %183 = icmp ugt i64 %182, 0
  br i1 %183, label %184, label %217

184:                                              ; preds = %181
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %185 = load i64, ptr %14, align 8, !tbaa !9
  %186 = icmp ugt i64 %185, 2147483647
  br i1 %186, label %187, label %188

187:                                              ; preds = %184
  br label %191

188:                                              ; preds = %184
  %189 = load i64, ptr %14, align 8, !tbaa !9
  %190 = trunc i64 %189 to i32
  br label %191

191:                                              ; preds = %188, %187
  %192 = phi i32 [ 2147483647, %187 ], [ %190, %188 ]
  store i32 %192, ptr %15, align 4, !tbaa !32
  %193 = load ptr, ptr %4, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.drwav, ptr %193, i32 0, i32 2
  %195 = load ptr, ptr %194, align 8, !tbaa !11
  %196 = load ptr, ptr %4, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.drwav, ptr %196, i32 0, i32 3
  %198 = load ptr, ptr %197, align 8, !tbaa !33
  %199 = load i32, ptr %15, align 4, !tbaa !32
  %200 = call noundef i32 %195(ptr noundef %198, i32 noundef %199, i32 noundef 1)
  %201 = icmp ne i32 %200, 0
  br i1 %201, label %203, label %202

202:                                              ; preds = %191
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %214

203:                                              ; preds = %191
  %204 = load i32, ptr %15, align 4, !tbaa !32
  %205 = sext i32 %204 to i64
  %206 = load ptr, ptr %4, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.drwav, ptr %206, i32 0, i32 14
  %208 = load i64, ptr %207, align 8, !tbaa !31
  %209 = sub i64 %208, %205
  store i64 %209, ptr %207, align 8, !tbaa !31
  %210 = load i32, ptr %15, align 4, !tbaa !32
  %211 = sext i32 %210 to i64
  %212 = load i64, ptr %14, align 8, !tbaa !9
  %213 = sub i64 %212, %211
  store i64 %213, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %10, align 4
  br label %214

214:                                              ; preds = %203, %202
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %215 = load i32, ptr %10, align 4
  switch i32 %215, label %218 [
    i32 0, label %216
  ]

216:                                              ; preds = %214
  br label %181, !llvm.loop !34

217:                                              ; preds = %181
  store i32 0, ptr %10, align 4
  br label %218

218:                                              ; preds = %217, %214, %177
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %219 = load i32, ptr %10, align 4
  switch i32 %219, label %224 [
    i32 0, label %220
    i32 1, label %222
  ]

220:                                              ; preds = %218
  br label %221

221:                                              ; preds = %220, %138
  store i32 1, ptr %3, align 4
  br label %222

222:                                              ; preds = %221, %218, %135, %64, %35, %29, %23
  %223 = load i32, ptr %3, align 4
  ret i32 %223

224:                                              ; preds = %218, %135
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z34drwav_read_pcm_frames_s16__msadpcmP5drwavmPs(ptr noundef, i64 noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z30drwav_read_pcm_frames_s16__imaP5drwavmPs(ptr noundef, i64 noundef, ptr noundef) #4

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 = { alwaysinline 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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, !6, i64 16}
!12 = !{!"_ZTS5drwav", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 64, !15, i64 68, !17, i64 108, !16, i64 112, !16, i64 114, !16, i64 116, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !10, i64 152, !17, i64 160, !18, i64 164, !19, i64 224, !20, i64 248, !21, i64 288, !22, i64 296, !23, i64 348}
!13 = !{!"_ZTS26drwav_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"_ZTS15drwav_container", !7, i64 0}
!15 = !{!"_ZTS9drwav_fmt", !16, i64 0, !16, i64 2, !17, i64 4, !17, i64 8, !16, i64 12, !16, i64 14, !16, i64 16, !16, i64 18, !17, i64 20, !7, i64 24}
!16 = !{!"short", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTS10drwav_smpl", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !17, i64 20, !17, i64 24, !17, i64 28, !17, i64 32, !7, i64 36}
!19 = !{!"_ZTS20drwav__memory_stream", !6, i64 0, !10, i64 8, !10, i64 16}
!20 = !{!"_ZTS26drwav__memory_stream_write", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!21 = !{!"_ZTSN5drwavUt_E", !10, i64 0}
!22 = !{!"_ZTSN5drwavUt0_E", !17, i64 0, !7, i64 4, !7, i64 8, !7, i64 16, !17, i64 32, !7, i64 36}
!23 = !{!"_ZTSN5drwavUt1_E", !17, i64 0, !7, i64 4, !7, i64 12, !7, i64 20, !17, i64 84}
!24 = !{!12, !6, i64 8}
!25 = !{!12, !10, i64 120}
!26 = !{!12, !16, i64 116}
!27 = !{!12, !10, i64 288}
!28 = !{!12, !16, i64 112}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!12, !10, i64 144}
!32 = !{!17, !17, i64 0}
!33 = !{!12, !6, i64 24}
!34 = distinct !{!34, !30}


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

@.str.16 = external hidden unnamed_addr constant [103 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame = external hidden unnamed_addr constant [60 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [41 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL31drwav__is_compressed_format_tagt(i16 noundef zeroext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @drwav_seek_to_pcm_frame(ptr noundef %0, i64 noundef %1) local_unnamed_addr #4 {
  %3 = alloca [2048 x i16], align 16
  %4 = icmp eq ptr %0, null
  br i1 %4, label %.thread97, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %.thread97, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !22
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %.thread97

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 120
  %14 = load i64, ptr %13, align 8, !tbaa !23
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %.thread97, label %16

16:                                               ; preds = %12
  %.not82 = icmp ugt i64 %14, %1
  %17 = add i64 %14, -1
  %spec.select = select i1 %.not82, i64 %1, i64 %17
  %18 = getelementptr inbounds i8, ptr %0, i64 116
  %19 = load i16, ptr %18, align 4, !tbaa !24
  %20 = tail call noundef i32 @_ZL31drwav__is_compressed_format_tagt(i16 noundef zeroext %19)
  %.not83 = icmp eq i32 %20, 0
  br i1 %.not83, label %47, label %21

21:                                               ; preds = %16
  %22 = getelementptr inbounds i8, ptr %0, i64 288
  %23 = load i64, ptr %22, align 8, !tbaa !25
  %24 = icmp ult i64 %spec.select, %23
  br i1 %24, label %25, label %27

25:                                               ; preds = %21
  %26 = tail call noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef nonnull %0)
  %.not88 = icmp eq i32 %26, 0
  br i1 %.not88, label %.thread97, label %._crit_edge

._crit_edge:                                      ; preds = %25
  %.pre = load i64, ptr %22, align 8, !tbaa !25
  br label %27

27:                                               ; preds = %._crit_edge, %21
  %28 = phi i64 [ %.pre, %._crit_edge ], [ %23, %21 ]
  %29 = icmp ugt i64 %spec.select, %28
  br i1 %29, label %30, label %.thread97

30:                                               ; preds = %27
  %31 = sub i64 %spec.select, %28
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %3) #6
  %32 = getelementptr inbounds i8, ptr %0, i64 112
  br label %33

33:                                               ; preds = %44, %30
  %.063 = phi i64 [ %31, %30 ], [ %45, %44 ]
  %.not89.not = icmp eq i64 %.063, 0
  br i1 %.not89.not, label %.thread, label %34

.thread:                                          ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #6
  br label %.thread97

34:                                               ; preds = %33
  %35 = load i16, ptr %32, align 8, !tbaa !26
  %36 = udiv i16 2048, %35
  %37 = zext nneg i16 %36 to i64
  %spec.select91 = call i64 @llvm.umin.i64(i64 %.063, i64 %37)
  %38 = load i16, ptr %18, align 4, !tbaa !24
  switch i16 %38, label %43 [
    i16 2, label %39
    i16 17, label %41
  ]

39:                                               ; preds = %34
  %40 = call noundef i64 @_Z34drwav_read_pcm_frames_s16__msadpcmP5drwavmPs(ptr noundef nonnull %0, i64 noundef %spec.select91, ptr noundef nonnull %3)
  br label %44

41:                                               ; preds = %34
  %42 = call noundef i64 @_Z30drwav_read_pcm_frames_s16__imaP5drwavmPs(ptr noundef nonnull %0, i64 noundef %spec.select91, ptr noundef nonnull %3)
  br label %44

43:                                               ; preds = %34
  call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.16, i32 noundef 3000, ptr noundef nonnull @__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame) #7
  unreachable

44:                                               ; preds = %41, %39
  %.065 = phi i64 [ %40, %39 ], [ %42, %41 ]
  %.not90 = icmp eq i64 %.065, %spec.select91
  %45 = sub i64 %.063, %.065
  br i1 %.not90, label %33, label %46, !llvm.loop !27

46:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #6
  br label %.thread97

47:                                               ; preds = %16
  %48 = load i64, ptr %13, align 8, !tbaa !23
  %49 = tail call noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef nonnull %0)
  %50 = zext i32 %49 to i64
  %51 = mul i64 %48, %50
  %52 = getelementptr inbounds i8, ptr %0, i64 144
  %53 = load i64, ptr %52, align 8, !tbaa !29
  %.not84 = icmp ult i64 %51, %53
  br i1 %.not84, label %54, label %55

54:                                               ; preds = %47
  tail call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.16, i32 noundef 3017, ptr noundef nonnull @__PRETTY_FUNCTION__.drwav_seek_to_pcm_frame) #7
  unreachable

55:                                               ; preds = %47
  %56 = sub i64 %51, %53
  %57 = tail call noundef i32 @_ZL29drwav_get_bytes_per_pcm_frameP5drwav(ptr noundef nonnull %0)
  %58 = zext i32 %57 to i64
  %59 = mul i64 %spec.select, %58
  %60 = icmp ult i64 %56, %59
  br i1 %60, label %61, label %63

61:                                               ; preds = %55
  %62 = sub i64 %59, %56
  br label %65

63:                                               ; preds = %55
  %64 = tail call noundef i32 @_Z29drwav_seek_to_first_pcm_frameP5drwav(ptr noundef nonnull %0)
  %.not85 = icmp eq i32 %64, 0
  br i1 %.not85, label %.thread97, label %65

65:                                               ; preds = %63, %61
  %.059 = phi i64 [ %62, %61 ], [ %59, %63 ]
  %.not86100 = icmp eq i64 %.059, 0
  br i1 %.not86100, label %.thread97, label %.lr.ph

.lr.ph:                                           ; preds = %65
  %66 = getelementptr inbounds i8, ptr %0, i64 24
  br label %67

67:                                               ; preds = %.lr.ph, %73
  %.160101 = phi i64 [ %.059, %.lr.ph ], [ %76, %73 ]
  %68 = tail call i64 @llvm.umin.i64(i64 %.160101, i64 2147483647)
  %69 = trunc nuw nsw i64 %68 to i32
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load ptr, ptr %66, align 8, !tbaa !30
  %72 = tail call noundef i32 %70(ptr noundef %71, i32 noundef %69, i32 noundef 1)
  %.not87.not = icmp eq i32 %72, 0
  br i1 %.not87.not, label %.thread97, label %73

73:                                               ; preds = %67
  %74 = load i64, ptr %52, align 8, !tbaa !29
  %75 = sub i64 %74, %68
  store i64 %75, ptr %52, align 8, !tbaa !29
  %76 = sub i64 %.160101, %68
  %.not86 = icmp eq i64 %76, 0
  br i1 %.not86, label %.thread97, label %67, !llvm.loop !31

.thread97:                                        ; preds = %73, %67, %65, %63, %27, %.thread, %46, %25, %12, %9, %2, %5
  %.6 = phi i32 [ 0, %46 ], [ 0, %5 ], [ 0, %2 ], [ 0, %9 ], [ 1, %12 ], [ 0, %25 ], [ 1, %.thread ], [ 1, %27 ], [ 0, %63 ], [ 1, %65 ], [ 1, %73 ], [ 0, %67 ]
  ret i32 %.6
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z34drwav_read_pcm_frames_s16__msadpcmP5drwavmPs(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z30drwav_read_pcm_frames_s16__imaP5drwavmPs(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

attributes #0 = { mustprogress 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 = { alwaysinline 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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { 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, !7, i64 16}
!6 = !{!"_ZTS5drwav", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 64, !12, i64 68, !14, i64 108, !13, i64 112, !13, i64 114, !13, i64 116, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !14, i64 160, !16, i64 164, !17, i64 224, !18, i64 248, !19, i64 288, !20, i64 296, !21, i64 348}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS26drwav_allocation_callbacks", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!11 = !{!"_ZTS15drwav_container", !8, i64 0}
!12 = !{!"_ZTS9drwav_fmt", !13, i64 0, !13, i64 2, !14, i64 4, !14, i64 8, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18, !14, i64 20, !8, i64 24}
!13 = !{!"short", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTS10drwav_smpl", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !8, i64 36}
!17 = !{!"_ZTS20drwav__memory_stream", !7, i64 0, !15, i64 8, !15, i64 16}
!18 = !{!"_ZTS26drwav__memory_stream_write", !7, i64 0, !7, i64 8, !15, i64 16, !15, i64 24, !15, i64 32}
!19 = !{!"_ZTSN5drwavUt_E", !15, i64 0}
!20 = !{!"_ZTSN5drwavUt0_E", !14, i64 0, !8, i64 4, !8, i64 8, !8, i64 16, !14, i64 32, !8, i64 36}
!21 = !{!"_ZTSN5drwavUt1_E", !14, i64 0, !8, i64 4, !8, i64 12, !8, i64 20, !14, i64 84}
!22 = !{!6, !7, i64 8}
!23 = !{!6, !15, i64 120}
!24 = !{!6, !13, i64 116}
!25 = !{!6, !15, i64 288}
!26 = !{!6, !13, i64 112}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!6, !15, i64 144}
!30 = !{!6, !7, i64 24}
!31 = distinct !{!31, !28}


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