; LLVM IR from VTIvanov20/eight-ball-pool :: src/ui_elements.ll (ZN6Button6UpdateEv)

; 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.Sound = type { %struct.AudioStream, i32 }
%struct.AudioStream = type { ptr, i32, i32, i32 }
%class.Button = type { %class.UIElement, i8, ptr, %struct.Sound, %struct.Sound }
%class.UIElement = type { %"class.DrawableManager::Drawable.base", %struct.Rectangle, float }
%"class.DrawableManager::Drawable.base" = type <{ ptr, i32 }>
%struct.Rectangle = type { float, float, float, float }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Button6UpdateEv(ptr noundef nonnull align 8 dereferenceable(112) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.Sound, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %class.Button, ptr %4, i32 0, i32 1
  %6 = load i8, ptr %5, align 8, !tbaa !9, !range !19, !noundef !20
  %7 = trunc i8 %6 to i1
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = getelementptr inbounds %class.Button, ptr %4, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %3, ptr align 8 %9, i64 32, i1 false), !tbaa.struct !21
  call void @PlaySound(ptr noundef byval(%struct.Sound) align 8 %3)
  br label %10

10:                                               ; preds = %8, %1
  ret void
}

declare void @PlaySound(ptr noundef byval(%struct.Sound) align 8) #2

attributes #0 = { nocallback nofree 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 = { "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, !16, i64 32}
!10 = !{!"_ZTS6Button", !11, i64 0, !16, i64 32, !6, i64 40, !17, i64 48, !17, i64 80}
!11 = !{!"_ZTS9UIElement", !12, i64 0, !14, i64 12, !15, i64 28}
!12 = !{!"_ZTSN15DrawableManager8DrawableE", !13, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTS9Rectangle", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"float", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS5Sound", !18, i64 0, !13, i64 24}
!18 = !{!"_ZTS11AudioStream", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{i64 0, i64 8, !5, i64 8, i64 4, !22, i64 12, i64 4, !22, i64 16, i64 4, !22, i64 24, i64 4, !22}
!22 = !{!13, !13, 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"

%struct.Sound = type { %struct.AudioStream, i32 }
%struct.AudioStream = type { ptr, i32, i32, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Button6UpdateEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(112) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !18, !noundef !19
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %7

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  tail call void @PlaySound(ptr noundef nonnull byval(%struct.Sound) align 8 %6)
  br label %7

7:                                                ; preds = %5, %1
  ret void
}

declare void @PlaySound(ptr noundef byval(%struct.Sound) align 8) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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, !14, i64 32}
!6 = !{!"_ZTS6Button", !7, i64 0, !14, i64 32, !15, i64 40, !16, i64 48, !16, i64 80}
!7 = !{!"_ZTS9UIElement", !8, i64 0, !12, i64 12, !13, i64 28}
!8 = !{!"_ZTSN15DrawableManager8DrawableE", !9, i64 8}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTS9Rectangle", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !10, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{!"any pointer", !10, i64 0}
!16 = !{!"_ZTS5Sound", !17, i64 0, !9, i64 24}
!17 = !{!"_ZTS11AudioStream", !15, i64 0, !9, i64 8, !9, i64 12, !9, i64 16}
!18 = !{i8 0, i8 2}
!19 = !{}


; Effective O3 passes: DSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass