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

; 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: mustprogress uwtable
declare dso_local noundef i32 @_Z50drflac_ogg__read_page_header_after_capture_patternPFmPvS_mES_P22drflac_ogg_page_headerPjS4_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z28drflac_ogg__read_page_headerPFmPvS_mES_P22drflac_ogg_page_headerPjS4_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca [4 x i8], align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %15, align 4, !tbaa !9
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %19 = call noundef i64 %16(ptr noundef %17, ptr noundef %18, i64 noundef 4)
  %20 = icmp ne i64 %19, 4
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  store i32 -128, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %70

22:                                               ; preds = %5
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = add i32 %24, 4
  store i32 %25, ptr %23, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %69, %47, %22
  %27 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %28 = call noundef i32 @_ZL30drflac_ogg__is_capture_patternPh(ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %49

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 1605413199, ptr %31, align 4, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = call noundef i32 @_Z50drflac_ogg__read_page_header_after_capture_patternPFmPvS_mES_P22drflac_ogg_page_headerPjS4_(ptr noundef %32, ptr noundef %33, ptr noundef %34, ptr noundef %35, ptr noundef %36)
  store i32 %37, ptr %14, align 4, !tbaa !9
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %30
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %47

41:                                               ; preds = %30
  %42 = load i32, ptr %14, align 4, !tbaa !9
  %43 = icmp eq i32 %42, -129
  br i1 %43, label %44, label %45

44:                                               ; preds = %41
  store i32 3, ptr %13, align 4
  br label %47, !llvm.loop !11

45:                                               ; preds = %41
  %46 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %46, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %47

47:                                               ; preds = %45, %44, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %48 = load i32, ptr %13, align 4
  switch i32 %48, label %70 [
    i32 3, label %26
  ]

49:                                               ; preds = %26
  %50 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  %51 = load i8, ptr %50, align 1, !tbaa !13
  %52 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  store i8 %51, ptr %52, align 1, !tbaa !13
  %53 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  %54 = load i8, ptr %53, align 1, !tbaa !13
  %55 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  store i8 %54, ptr %55, align 1, !tbaa !13
  %56 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  %57 = load i8, ptr %56, align 1, !tbaa !13
  %58 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  store i8 %57, ptr %58, align 1, !tbaa !13
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  %62 = call noundef i64 %59(ptr noundef %60, ptr noundef %61, i64 noundef 1)
  %63 = icmp ne i64 %62, 1
  br i1 %63, label %64, label %65

64:                                               ; preds = %49
  store i32 -128, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %70

65:                                               ; preds = %49
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = add i32 %67, 1
  store i32 %68, ptr %66, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %65
  br label %26, !llvm.loop !11

70:                                               ; preds = %64, %47, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %71 = load i32, ptr %6, align 4
  ret i32 %71
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, 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: 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: mustprogress uwtable
declare dso_local noundef i32 @_Z50drflac_ogg__read_page_header_after_capture_patternPFmPvS_mES_P22drflac_ogg_page_headerPjS4_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

8:                                                ; preds = %5
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = add i32 %9, 4
  store i32 %10, ptr %3, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 1
  %12 = getelementptr inbounds i8, ptr %6, i64 2
  %13 = getelementptr inbounds i8, ptr %6, i64 3
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %8
  %14 = call noundef i32 @_ZL30drflac_ogg__is_capture_patternPh(ptr noundef nonnull %6)
  %.not19 = icmp eq i32 %14, 0
  br i1 %.not19, label %17, label %15

15:                                               ; preds = %.backedge
  store i32 1605413199, ptr %4, align 4, !tbaa !5
  %16 = call noundef i32 @_Z50drflac_ogg__read_page_header_after_capture_patternPFmPvS_mES_P22drflac_ogg_page_headerPjS4_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %cond = icmp eq i32 %16, -129
  br i1 %cond, label %.backedge.backedge, label %.thread

17:                                               ; preds = %.backedge
  %18 = load i8, ptr %11, align 1, !tbaa !9
  store i8 %18, ptr %6, align 1, !tbaa !9
  %19 = load i8, ptr %12, align 1, !tbaa !9
  store i8 %19, ptr %11, align 1, !tbaa !9
  %20 = load i8, ptr %13, align 1, !tbaa !9
  store i8 %20, ptr %12, align 1, !tbaa !9
  %21 = call noundef i64 %0(ptr noundef %1, ptr noundef nonnull %13, i64 noundef 1)
  %.not20 = icmp eq i64 %21, 1
  br i1 %.not20, label %22, label %.thread

22:                                               ; preds = %17
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = add i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !5
  br label %.backedge.backedge

.backedge.backedge:                               ; preds = %22, %15
  br label %.backedge, !llvm.loop !10

.thread:                                          ; preds = %15, %17, %5
  %.2 = phi i32 [ -128, %5 ], [ %16, %15 ], [ -128, %17 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  ret i32 %.2
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass