; LLVM IR from Slingshot-Physics/slingshot-community :: common/geometry/src (gjk)

; 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.geometry::types::minkowskiDiffSimplex_t" = type { [4 x i32], [4 x i32], %class.Vector4, i32, [4 x %class.Vector3], [4 x %class.Vector3], [4 x %class.Vector3] }
%class.Vector4 = type { [4 x float] }
%class.Vector3 = type { [3 x float] }
%"struct.geometry::types::minkowskiDiffVertex_t" = type { i32, i32, %class.Vector3, %class.Vector3, %class.Vector3 }

@.str = external hidden unnamed_addr constant [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE = external hidden unnamed_addr constant [80 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE(ptr noundef nonnull align 4 dereferenceable(44) %0, ptr noundef nonnull align 4 dereferenceable(196) %1) #0 {
  %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 %4, align 8, !tbaa !5
  %6 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %5, i32 0, i32 3
  %7 = load i32, ptr %6, align 4, !tbaa !9
  %8 = icmp ugt i32 %7, 0
  br i1 %8, label %9, label %14

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %10, i32 0, i32 3
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = icmp ule i32 %12, 4
  br label %14

14:                                               ; preds = %9, %2
  %15 = phi i1 [ false, %2 ], [ %13, %9 ]
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  br label %19

17:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 18, ptr noundef @__PRETTY_FUNCTION__._ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE) #2
  unreachable

18:                                               ; No predecessors!
  br label %19

19:                                               ; preds = %18, %16
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %25, i32 0, i32 3
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [4 x i32], ptr %24, i64 0, i64 %28
  store i32 %22, ptr %29, align 4, !tbaa !16
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %30, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !17
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %35, i32 0, i32 3
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds [4 x i32], ptr %34, i64 0, i64 %38
  store i32 %32, ptr %39, align 4, !tbaa !16
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %42, i32 0, i32 5
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %44, i32 0, i32 3
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds [4 x %class.Vector3], ptr %43, i64 0, i64 %47
  %49 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %48, ptr noundef nonnull align 4 dereferenceable(12) %41)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %52, i32 0, i32 6
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %54, i32 0, i32 3
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds [4 x %class.Vector3], ptr %53, i64 0, i64 %57
  %59 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %58, ptr noundef nonnull align 4 dereferenceable(12) %51)
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffVertex_t", ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %62, i32 0, i32 4
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %64, i32 0, i32 3
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [4 x %class.Vector3], ptr %63, i64 0, i64 %67
  %69 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %68, ptr noundef nonnull align 4 dereferenceable(12) %61)
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.geometry::types::minkowskiDiffSimplex_t", ptr %70, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = add i32 %72, 1
  store i32 %73, ptr %71, align 4, !tbaa !9
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #0 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 = { 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 #2 = { 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, !12, i64 48}
!10 = !{!"_ZTSN8geometry5types22minkowskiDiffSimplex_tE", !7, i64 0, !7, i64 16, !11, i64 32, !12, i64 48, !7, i64 52, !7, i64 100, !7, i64 148}
!11 = !{!"_ZTS7Vector4", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !12, i64 0, !12, i64 4, !15, i64 8, !15, i64 20, !15, i64 32}
!15 = !{!"_ZTS7Vector3", !7, i64 0}
!16 = !{!12, !12, i64 0}
!17 = !{!14, !12, i64 4}


; 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.Vector3 = type { [3 x float] }

@.str = external hidden unnamed_addr constant [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [99 x i8], align 1
@__PRETTY_FUNCTION__._ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE = external hidden unnamed_addr constant [80 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE(ptr noundef nonnull align 4 dereferenceable(44) %0, ptr noundef nonnull align 4 dereferenceable(196) %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 48
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add i32 %4, -1
  %or.cond = icmp ult i32 %5, 4
  br i1 %or.cond, label %6, label %.critedge

.critedge:                                        ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 18, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8geometry3gjk18addVertexToSimplexERKNS_5types21minkowskiDiffVertex_tERNS1_22minkowskiDiffSimplex_tE) #2
  unreachable

6:                                                ; preds = %2
  %7 = load i32, ptr %0, align 4, !tbaa !11
  %8 = zext nneg i32 %4 to i64
  %9 = getelementptr inbounds [4 x i32], ptr %1, i64 0, i64 %8
  store i32 %7, ptr %9, align 4, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [4 x i32], ptr %12, i64 0, i64 %14
  store i32 %11, ptr %15, align 4, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 20
  %17 = getelementptr inbounds i8, ptr %1, i64 100
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [4 x %class.Vector3], ptr %17, i64 0, i64 %19
  %21 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 4 dereferenceable(12) %16)
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = getelementptr inbounds i8, ptr %1, i64 148
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [4 x %class.Vector3], ptr %23, i64 0, i64 %25
  %27 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %22)
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = getelementptr inbounds i8, ptr %1, i64 52
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds [4 x %class.Vector3], ptr %29, i64 0, i64 %31
  %33 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12) %32, ptr noundef nonnull align 4 dereferenceable(12) %28)
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN7Vector3aSERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 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 = { 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 #2 = { 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, !10, i64 48}
!6 = !{!"_ZTSN8geometry5types22minkowskiDiffSimplex_tE", !7, i64 0, !7, i64 16, !9, i64 32, !10, i64 48, !7, i64 52, !7, i64 100, !7, i64 148}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"_ZTS7Vector4", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN8geometry5types21minkowskiDiffVertex_tE", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 20, !13, i64 32}
!13 = !{!"_ZTS7Vector3", !7, i64 0}
!14 = !{!10, !10, i64 0}
!15 = !{!12, !10, i64 4}


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