; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/ay/sndrender.ll (ZN9SNDRENDERC2ER9SNDBUFFER)

; 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.SNDRENDER = type { ptr, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%class.SNDBUFFER = type <{ ptr, i32, i32, i32, [4 x i8] }>

@_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready = external hidden global i8, align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9SNDRENDER11set_timingsEjj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9init_diffv() #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9SNDRENDERC2ER9SNDBUFFER(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 0
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %7, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %class.SNDBUFFER, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %11, ptr %8, align 8, !tbaa !12
  %12 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 6
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %class.SNDBUFFER, ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !14
  store i32 %15, ptr %12, align 8, !tbaa !15
  %16 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 7
  store i32 0, ptr %16, align 4, !tbaa !16
  %17 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 8
  store i32 0, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 9
  store i32 0, ptr %18, align 4, !tbaa !18
  %19 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 10
  store i32 0, ptr %19, align 8, !tbaa !19
  %20 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 11
  store i32 0, ptr %20, align 4, !tbaa !20
  %21 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 12
  store i32 0, ptr %21, align 8, !tbaa !21
  %22 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 1
  store i32 0, ptr %22, align 8, !tbaa !22
  %23 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 2
  store i32 0, ptr %23, align 4, !tbaa !23
  %24 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 13
  store i32 0, ptr %24, align 4, !tbaa !24
  %25 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 14
  store i32 0, ptr %25, align 8, !tbaa !25
  %26 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 15
  store i32 0, ptr %26, align 4, !tbaa !26
  %27 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 16
  store i32 0, ptr %27, align 8, !tbaa !27
  %28 = getelementptr inbounds %class.SNDRENDER, ptr %5, i32 0, i32 17
  store i32 0, ptr %28, align 4, !tbaa !28
  call void @_ZN9SNDRENDER11set_timingsEjj(ptr noundef nonnull align 8 dereferenceable(80) %5, i32 noundef 3500000, i32 noundef 44100)
  %29 = load i8, ptr @_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready, align 1, !tbaa !29
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %2
  call void @_Z9init_diffv()
  store i8 1, ptr @_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready, align 1, !tbaa !29
  br label %32

32:                                               ; preds = %31, %2
  ret void
}

attributes #0 = { 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" }

!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 0}
!10 = !{!"_ZTS9SNDBUFFER", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"_ZTS9SNDRENDER", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76}
!14 = !{!10, !11, i64 8}
!15 = !{!13, !11, i64 32}
!16 = !{!13, !11, i64 36}
!17 = !{!13, !11, i64 40}
!18 = !{!13, !11, i64 44}
!19 = !{!13, !11, i64 48}
!20 = !{!13, !11, i64 52}
!21 = !{!13, !11, i64 56}
!22 = !{!13, !11, i64 8}
!23 = !{!13, !11, i64 12}
!24 = !{!13, !11, i64 60}
!25 = !{!13, !11, i64 64}
!26 = !{!13, !11, i64 68}
!27 = !{!13, !11, i64 72}
!28 = !{!13, !11, i64 76}
!29 = !{!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"

@_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9SNDRENDER11set_timingsEjj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9init_diffv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9SNDRENDERC2ER9SNDBUFFER(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(20) %1) unnamed_addr #0 align 2 {
  store ptr %1, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load ptr, ptr %1, align 8, !tbaa !9
  store ptr %4, ptr %3, align 8, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !14
  store i32 %7, ptr %5, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %0, i64 36
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %10, align 4, !tbaa !17
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(44) %8, i8 0, i64 44, i1 false)
  tail call void @_ZN9SNDRENDER11set_timingsEjj(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef 3500000, i32 noundef 44100)
  %11 = load i8, ptr @_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready, align 1, !tbaa !18
  %.not = icmp eq i8 %11, 0
  br i1 %.not, label %12, label %13

12:                                               ; preds = %2
  tail call void @_Z9init_diffv()
  store i8 1, ptr @_ZZN9SNDRENDERC1ER9SNDBUFFERE10diff_ready, align 1, !tbaa !18
  br label %13

13:                                               ; preds = %12, %2
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 0}
!10 = !{!"_ZTS9SNDBUFFER", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"_ZTS9SNDRENDER", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76}
!14 = !{!10, !11, i64 8}
!15 = !{!13, !11, i64 32}
!16 = !{!13, !11, i64 8}
!17 = !{!13, !11, i64 12}
!18 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass