; LLVM IR from devlinzhou/deterministic_physics :: gphysics/src/collision/glacier_collision_shape.ll (ZNK15GCollisionShape11GetLocalBoxEv)

; 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.GAABB = type { %class.GVector3, %class.GVector3 }
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { i32 }
%class.GCollisionShape = type { i32, %class.GVector3, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK15GCollisionShape11GetLocalBoxEv(ptr dead_on_unwind noalias writable sret(%class.GAABB) align 4 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca %class.GVector3, align 4
  %5 = alloca %class.GFloat, align 4
  %6 = alloca %class.GFloat, align 4
  %7 = alloca %class.GVector3, align 4
  %8 = alloca %class.GFloat, align 4
  %9 = alloca %class.GVector3, align 4
  %10 = alloca %class.GVector3, align 4
  %11 = alloca { i64, i32 }, align 8
  %12 = alloca { i64, i32 }, align 8
  %13 = alloca %class.GVector3, align 4
  %14 = alloca { i64, i32 }, align 8
  %15 = alloca %class.GVector3, align 4
  %16 = alloca { i64, i32 }, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %3, align 8
  %18 = getelementptr inbounds %class.GCollisionShape, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  switch i32 %19, label %36 [
    i32 0, label %20
    i32 1, label %21
    i32 2, label %32
    i32 3, label %37
    i32 4, label %37
    i32 5, label %37
    i32 6, label %37
    i32 7, label %37
    i32 8, label %37
    i32 9, label %37
    i32 10, label %37
  ]

20:                                               ; preds = %2
  br label %37

21:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %22 = call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %23 = getelementptr inbounds %class.GFloat, ptr %6, i32 0, i32 0
  store i32 %22, ptr %23, align 4
  %24 = call i32 @_ZNK6GFloatngEv(ptr noundef nonnull align 4 dereferenceable(4) %6)
  %25 = getelementptr inbounds %class.GFloat, ptr %5, i32 0, i32 0
  store i32 %24, ptr %25, align 4
  %26 = getelementptr inbounds %class.GFloat, ptr %5, i32 0, i32 0
  %27 = load i32, ptr %26, align 4
  call void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12) %4, i32 %27)
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #6
  %28 = call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %29 = getelementptr inbounds %class.GFloat, ptr %8, i32 0, i32 0
  store i32 %28, ptr %29, align 4
  %30 = getelementptr inbounds %class.GFloat, ptr %8, i32 0, i32 0
  %31 = load i32, ptr %30, align 4
  call void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12) %7, i32 %31)
  call void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #6
  br label %39

32:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #6
  %33 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  store { i64, i32 } %33, ptr %11, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %11, i64 12, i1 false)
  %34 = call { i64, i32 } @_ZNK8GVector3ngEv(ptr noundef nonnull align 4 dereferenceable(12) %10)
  store { i64, i32 } %34, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #6
  %35 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  store { i64, i32 } %35, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 8 %14, i64 12, i1 false)
  call void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #6
  br label %39

36:                                               ; preds = %2
  br label %37

37:                                               ; preds = %36, %20, %2, %2, %2, %2, %2, %2, %2, %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %15) #6
  %38 = call { i64, i32 } @_ZN8GVector34ZeroEv()
  store { i64, i32 } %38, ptr %16, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 8 %16, i64 12, i1 false)
  call void @_ZN5GAABBC2ERK8GVector3(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %15)
  call void @llvm.lifetime.end.p0(i64 12, ptr %15) #6
  br label %39

39:                                               ; preds = %37, %32, %21
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6GFloatngEv(ptr noundef nonnull align 4 dereferenceable(4)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12), i32) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24)) #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) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK8GVector3ngEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZN8GVector34ZeroEv() #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5GAABBC2ERK8GVector3(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #4 = { inlinehint 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"_ZTS15GCollisionShape", !11, i64 0, !12, i64 4, !6, i64 16}
!11 = !{!"_ZTS6EShape", !7, i64 0}
!12 = !{!"_ZTS8GVector3", !13, i64 0, !13, i64 4, !13, i64 8}
!13 = !{!"_ZTS6GFloat", !14, i64 0}
!14 = !{!"int", !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"

%class.GAABB = type { %class.GVector3, %class.GVector3 }
%class.GVector3 = type { %class.GFloat, %class.GFloat, %class.GFloat }
%class.GFloat = type { i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK15GCollisionShape11GetLocalBoxEv(ptr dead_on_unwind noalias writable sret(%class.GAABB) align 4 %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %class.GVector3, align 4
  %4 = alloca %class.GFloat, align 4
  %5 = alloca %class.GVector3, align 4
  %6 = alloca %class.GVector3, align 8
  %7 = alloca %class.GVector3, align 8
  %8 = alloca %class.GVector3, align 8
  %9 = alloca %class.GVector3, align 8
  %10 = load i32, ptr %1, align 8, !tbaa !5
  switch i32 %10, label %19 [
    i32 2, label %15
    i32 1, label %11
  ]

11:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %12 = tail call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  store i32 %12, ptr %4, align 4
  %13 = call i32 @_ZNK6GFloatngEv(ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12) %3, i32 %13)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #5
  %14 = call i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  call void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12) %5, i32 %14)
  call void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #5
  br label %21

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #5
  %16 = tail call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.fca.0.extract9 = extractvalue { i64, i32 } %16, 0
  %.fca.1.extract10 = extractvalue { i64, i32 } %16, 1
  store i64 %.fca.0.extract9, ptr %7, align 8
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %.fca.1.extract10, ptr %.sroa.212.0..sroa_idx, align 8
  %17 = call { i64, i32 } @_ZNK8GVector3ngEv(ptr noundef nonnull align 4 dereferenceable(12) %7)
  %.fca.0.extract5 = extractvalue { i64, i32 } %17, 0
  %.fca.1.extract6 = extractvalue { i64, i32 } %17, 1
  store i64 %.fca.0.extract5, ptr %6, align 8
  %.sroa.28.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract6, ptr %.sroa.28.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #5
  %18 = call { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.fca.0.extract1 = extractvalue { i64, i32 } %18, 0
  %.fca.1.extract2 = extractvalue { i64, i32 } %18, 1
  store i64 %.fca.0.extract1, ptr %8, align 8
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %8, i64 8
  store i32 %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  call void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %8)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #5
  br label %21

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #5
  %20 = tail call { i64, i32 } @_ZN8GVector34ZeroEv()
  %.fca.0.extract = extractvalue { i64, i32 } %20, 0
  %.fca.1.extract = extractvalue { i64, i32 } %20, 1
  store i64 %.fca.0.extract, ptr %9, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  call void @_ZN5GAABBC2ERK8GVector3(ptr noundef nonnull align 4 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #5
  br label %21

21:                                               ; preds = %19, %15, %11
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @_ZNK15GCollisionShape9GetRaiudsEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6GFloatngEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8GVector3C2E6GFloat(ptr noundef nonnull align 4 dereferenceable(12), i32) unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5GAABBC2ERK8GVector3S2_(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { i64, i32 } @_ZNK15GCollisionShape13GetHalfExternEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK8GVector3ngEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i32 } @_ZN8GVector34ZeroEv() local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5GAABBC2ERK8GVector3(ptr noundef nonnull align 4 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #4 = { inlinehint 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 #5 = { 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 0}
!6 = !{!"_ZTS15GCollisionShape", !7, i64 0, !10, i64 4, !13, i64 16}
!7 = !{!"_ZTS6EShape", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS8GVector3", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"_ZTS6GFloat", !12, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass