; LLVM IR from Sopiro/Muli :: src/collision/simplex.ll (ZNK4muli7Simplex18GetSearchDirectionEv)

; 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.muli::Vec2" = type { float, float }
%"struct.muli::Simplex" = type { i32, [3 x %"struct.muli::SupportPoint"], float }
%"struct.muli::SupportPoint" = type { %"struct.muli::Point", %"struct.muli::Point", %"struct.muli::Vec2", float }
%"struct.muli::Point" = type { %"struct.muli::Vec2", i32 }

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4muli7Simplex18GetSearchDirectionEv = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK4muli7Simplex18GetSearchDirectionEv(ptr noundef nonnull align 4 dereferenceable(116) %0) #0 align 2 {
  %2 = alloca %"struct.muli::Vec2", align 4
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.muli::Vec2", align 4
  %5 = alloca %"struct.muli::Vec2", align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca %"struct.muli::Vec2", align 4
  %9 = alloca %"struct.muli::Vec2", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  %11 = getelementptr inbounds %"struct.muli::Simplex", ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !9
  switch i32 %12, label %37 [
    i32 1, label %13
    i32 2, label %18
  ]

13:                                               ; preds = %1
  %14 = getelementptr inbounds %"struct.muli::Simplex", ptr %10, i32 0, i32 1
  %15 = getelementptr inbounds [3 x %"struct.muli::SupportPoint"], ptr %14, i64 0, i64 0
  %16 = getelementptr inbounds %"struct.muli::SupportPoint", ptr %15, i32 0, i32 2
  %17 = call <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8) %16)
  store <2 x float> %17, ptr %2, align 4
  br label %38

18:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %19 = getelementptr inbounds %"struct.muli::Simplex", ptr %10, i32 0, i32 1
  %20 = getelementptr inbounds [3 x %"struct.muli::SupportPoint"], ptr %19, i64 0, i64 1
  %21 = getelementptr inbounds %"struct.muli::SupportPoint", ptr %20, i32 0, i32 2
  %22 = getelementptr inbounds %"struct.muli::Simplex", ptr %10, i32 0, i32 1
  %23 = getelementptr inbounds [3 x %"struct.muli::SupportPoint"], ptr %22, i64 0, i64 0
  %24 = getelementptr inbounds %"struct.muli::SupportPoint", ptr %23, i32 0, i32 2
  %25 = call <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %21, ptr noundef nonnull align 4 dereferenceable(8) %24)
  store <2 x float> %25, ptr %4, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %26 = getelementptr inbounds %"struct.muli::Simplex", ptr %10, i32 0, i32 1
  %27 = getelementptr inbounds [3 x %"struct.muli::SupportPoint"], ptr %26, i64 0, i64 0
  %28 = getelementptr inbounds %"struct.muli::SupportPoint", ptr %27, i32 0, i32 2
  %29 = call <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8) %28)
  store <2 x float> %29, ptr %5, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %30 = call noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store float %30, ptr %6, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %31 = call noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5)
  store float %31, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %32 = load float, ptr %6, align 4, !tbaa !13
  %33 = call <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef %32)
  store <2 x float> %33, ptr %8, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %34 = load float, ptr %7, align 4, !tbaa !13
  %35 = call <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %34)
  store <2 x float> %35, ptr %9, align 4
  %36 = call <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %8, ptr noundef nonnull align 4 dereferenceable(8) %9)
  store <2 x float> %36, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %38

37:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 26, ptr noundef @__PRETTY_FUNCTION__._ZNK4muli7Simplex18GetSearchDirectionEv) #6
  unreachable

38:                                               ; preds = %18, %13
  %39 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %39
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 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 #4 = { noreturn nounwind "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 }
attributes #6 = { noreturn 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 = !{!"_ZTSN4muli7SimplexE", !11, i64 0, !7, i64 4, !12, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, 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.muli::Vec2" = type { float, float }

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4muli7Simplex18GetSearchDirectionEv = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK4muli7Simplex18GetSearchDirectionEv(ptr noundef nonnull align 4 dereferenceable(116) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"struct.muli::Vec2", align 8
  %3 = alloca %"struct.muli::Vec2", align 8
  %4 = alloca %"struct.muli::Vec2", align 8
  %5 = alloca %"struct.muli::Vec2", align 8
  %6 = load i32, ptr %0, align 4, !tbaa !5
  switch i32 %6, label %20 [
    i32 1, label %7
    i32 2, label %10
  ]

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  %9 = tail call <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8) %8)
  br label %21

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = getelementptr inbounds i8, ptr %0, i64 28
  %13 = tail call <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %11, ptr noundef nonnull align 4 dereferenceable(8) %12)
  store <2 x float> %13, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %14 = tail call <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8) %12)
  store <2 x float> %14, ptr %3, align 8
  %15 = call noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %2)
  %16 = call noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %17 = call <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %15)
  store <2 x float> %17, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %18 = call <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8) %2, float noundef %16)
  store <2 x float> %18, ptr %5, align 8
  %19 = call <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br label %21

20:                                               ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 26, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK4muli7Simplex18GetSearchDirectionEv) #6
  unreachable

21:                                               ; preds = %10, %7
  %.sroa.0.0 = phi <2 x float> [ %19, %10 ], [ %9, %7 ]
  ret <2 x float> %.sroa.0.0
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZNK4muli4Vec2ngEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4mulimiERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN4muli3DotERKNS_4Vec2ES2_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN4mulimlERKNS_4Vec2Ef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="64" "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 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 #4 = { noreturn nounwind "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 }
attributes #6 = { noreturn 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 = !{!"_ZTSN4muli7SimplexE", !7, i64 0, !8, i64 4, !10, i64 112}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}


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