; LLVM IR from awawa-dev/HyperHDR :: sources/base/SoundCaptureResult.ll (ZN18SoundCaptureResult9ResetDataEv)

; 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.ColorRgb = type { i8, i8, i8 }
%class.SoundCaptureResult = type { i32, i8, i32, [8 x i32], [8 x i32], [8 x i32], [8 x i8], [8 x i8], [8 x i8], [8 x %struct.ColorRgb], i32, %struct.ColorRgb, i32, i32, i32, %struct.MovingTarget, %struct.MovingTarget }
%struct.MovingTarget = type { %struct.ColorRgb, %struct.ColorRgb, %struct.ColorRgb, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; 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
define dso_local void @_ZN18SoundCaptureResult9ResetDataEv(ptr noundef nonnull align 4 dereferenceable(296) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %struct.ColorRgb, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 1
  store i8 0, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 0
  store i32 0, ptr %7, align 4, !tbaa !15
  %8 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 12
  store i32 0, ptr %8, align 4, !tbaa !16
  %9 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 13
  store i32 0, ptr %9, align 4, !tbaa !17
  %10 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 2
  store i32 0, ptr %10, align 4, !tbaa !18
  %11 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 3
  %12 = getelementptr inbounds [8 x i32], ptr %11, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %12, i8 0, i64 32, i1 false)
  %13 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 4
  %14 = getelementptr inbounds [8 x i32], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %14, i8 0, i64 32, i1 false)
  %15 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 6
  %16 = getelementptr inbounds [8 x i8], ptr %15, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %16, i8 0, i64 8, i1 false)
  %17 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 8
  %18 = getelementptr inbounds [8 x i8], ptr %17, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %18, i8 0, i64 8, i1 false)
  %19 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 5
  %20 = getelementptr inbounds [8 x i32], ptr %19, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %20, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !19
  br label %21

21:                                               ; preds = %30, %1
  %22 = load i32, ptr %3, align 4, !tbaa !19
  %23 = icmp slt i32 %22, 8
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %33

25:                                               ; preds = %21
  %26 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 7
  %27 = load i32, ptr %3, align 4, !tbaa !19
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [8 x i8], ptr %26, i64 0, i64 %28
  store i8 10, ptr %29, align 1, !tbaa !20
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !19
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !19
  br label %21, !llvm.loop !21

33:                                               ; preds = %24
  %34 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 10
  store i32 10, ptr %34, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 3, ptr %4) #6
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %4, i8 noundef zeroext 0, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %35 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %35, ptr align 1 %4, i64 3, i1 false), !tbaa.struct !24
  call void @llvm.lifetime.end.p0(i64 3, ptr %4) #6
  %36 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 14
  store i32 0, ptr %36, align 4, !tbaa !25
  %37 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 15
  call void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60) %37)
  %38 = getelementptr inbounds %class.SoundCaptureResult, ptr %5, i32 0, i32 16
  call void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60) %38)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

; 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) #3

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

declare void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60)) #5

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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 #6 = { 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, !12, i64 4}
!10 = !{!"_ZTS18SoundCaptureResult", !11, i64 0, !12, i64 4, !11, i64 8, !7, i64 12, !7, i64 44, !7, i64 76, !7, i64 108, !7, i64 116, !7, i64 124, !7, i64 132, !11, i64 156, !13, i64 160, !11, i64 164, !11, i64 168, !11, i64 172, !14, i64 176, !14, i64 236}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTS8ColorRgb", !7, i64 0, !7, i64 1, !7, i64 2}
!14 = !{!"_ZTS12MovingTarget", !13, i64 0, !13, i64 3, !13, i64 6, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56}
!15 = !{!10, !11, i64 0}
!16 = !{!10, !11, i64 164}
!17 = !{!10, !11, i64 168}
!18 = !{!10, !11, i64 8}
!19 = !{!11, !11, i64 0}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !11, i64 156}
!24 = !{i64 0, i64 1, !20, i64 1, i64 1, !20, i64 2, i64 1, !20}
!25 = !{!10, !11, i64 172}


; 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.ColorRgb = type { i8, i8, i8 }

; 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
define dso_local void @_ZN18SoundCaptureResult9ResetDataEv(ptr noundef nonnull align 4 dereferenceable(296) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %struct.ColorRgb, align 1
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 0, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %0, align 4, !tbaa !13
  %4 = getelementptr inbounds i8, ptr %0, i64 164
  store i32 0, ptr %4, align 4, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 0, ptr %5, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = getelementptr inbounds i8, ptr %0, i64 124
  store i64 0, ptr %7, align 4
  %8 = getelementptr inbounds i8, ptr %0, i64 116
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(108) %6, i8 0, i64 108, i1 false)
  store i64 723401728380766730, ptr %8, align 4
  %9 = getelementptr inbounds i8, ptr %0, i64 156
  store i32 10, ptr %9, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 3, ptr nonnull %2) #6
  call void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3) %2, i8 noundef zeroext 0, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %10 = getelementptr inbounds i8, ptr %0, i64 160
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(3) %10, ptr noundef nonnull align 1 dereferenceable(3) %2, i64 3, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 3, ptr nonnull %2) #6
  %11 = getelementptr inbounds i8, ptr %0, i64 172
  store i32 0, ptr %11, align 4, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 176
  call void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60) %12)
  %13 = getelementptr inbounds i8, ptr %0, i64 236
  call void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60) %13)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8ColorRgbC2Ehhh(ptr noundef nonnull align 1 dereferenceable(3), i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) unnamed_addr #2 align 2

; 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) #3

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

declare void @_ZN12MovingTarget5ClearEv(ptr noundef nonnull align 4 dereferenceable(60)) local_unnamed_addr #5

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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { "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 #6 = { 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, !10, i64 4}
!6 = !{!"_ZTS18SoundCaptureResult", !7, i64 0, !10, i64 4, !7, i64 8, !8, i64 12, !8, i64 44, !8, i64 76, !8, i64 108, !8, i64 116, !8, i64 124, !8, i64 132, !7, i64 156, !11, i64 160, !7, i64 164, !7, i64 168, !7, i64 172, !12, i64 176, !12, i64 236}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS8ColorRgb", !8, i64 0, !8, i64 1, !8, i64 2}
!12 = !{!"_ZTS12MovingTarget", !11, i64 0, !11, i64 3, !11, i64 6, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !7, i64 56}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 164}
!15 = !{!6, !7, i64 168}
!16 = !{!6, !7, i64 156}
!17 = !{i64 0, i64 1, !18, i64 1, i64 1, !18, i64 2, i64 1, !18}
!18 = !{!8, !8, i64 0}
!19 = !{!6, !7, i64 172}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass