; LLVM IR from jrouwe/JoltPhysics :: Jolt/Physics/Collision/Shape (PlaneShape)

; 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.JPH::AssertLastParam" = type { i8 }
%"class.JPH::SubShapeID" = type { i32 }
%"struct.JPH::PlaneShape::PSGetTrianglesContext" = type <{ [4 x %"class.JPH::Float3"], i8, [3 x i8] }>
%"class.JPH::Float3" = type { float, float, float }

@.str.3 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [62 x i8], align 1

; 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: 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) #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH10SubShapeIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3JPH10PlaneShape16GetTrianglesNextERNS_5Shape19GetTrianglesContextEiPNS_6Float3EPPKNS_15PhysicsMaterialE(ptr noundef nonnull align 16 dereferenceable(96) %0, ptr noundef nonnull align 16 dereferenceable(4288) %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) unnamed_addr #5 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %"struct.JPH::AssertLastParam", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca %"class.JPH::SubShapeID", align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8
  br label %18

18:                                               ; preds = %5
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp sge i32 %19, 32
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 416)
  br i1 %22, label %23, label %24

23:                                               ; preds = %21
  call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #6, !srcloc !11
  br label %24

24:                                               ; preds = %23, %21, %18
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %26, ptr %13, align 8, !tbaa !5
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %27, i32 0, i32 1
  %29 = load i8, ptr %28, align 4, !tbaa !12, !range !15, !noundef !16
  %30 = trunc i8 %29 to i1
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  store i32 0, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %76

32:                                               ; preds = %25
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %33, i32 0, i32 1
  store i8 1, ptr %34, align 4, !tbaa !12
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %36, i64 0, i64 0
  %38 = load ptr, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.JPH::Float3", ptr %38, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %39, ptr align 4 %37, i64 12, i1 false), !tbaa.struct !17
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %41, i64 0, i64 1
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %"class.JPH::Float3", ptr %43, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %44, ptr align 4 %42, i64 12, i1 false), !tbaa.struct !17
  %45 = load ptr, ptr %13, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %46, i64 0, i64 2
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.JPH::Float3", ptr %48, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %47, i64 12, i1 false), !tbaa.struct !17
  %50 = load ptr, ptr %13, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %51, i64 0, i64 0
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %"class.JPH::Float3", ptr %53, i64 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %54, ptr align 4 %52, i64 12, i1 false), !tbaa.struct !17
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %56, i64 0, i64 2
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.JPH::Float3", ptr %58, i64 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 4 %57, i64 12, i1 false), !tbaa.struct !17
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.JPH::PlaneShape::PSGetTrianglesContext", ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds [4 x %"class.JPH::Float3"], ptr %61, i64 0, i64 3
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.JPH::Float3", ptr %63, i64 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %64, ptr align 4 %62, i64 12, i1 false), !tbaa.struct !17
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %75

67:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  call void @llvm.memset.p0.i64(ptr align 4 %16, i8 0, i64 4, i1 false)
  call void @_ZN3JPH10SubShapeIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %16) #6
  %68 = call noundef ptr @_ZNK3JPH10PlaneShape11GetMaterialERKNS_10SubShapeIDE(ptr noundef nonnull align 16 dereferenceable(96) %17, ptr noundef nonnull align 4 dereferenceable(4) %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  store ptr %68, ptr %15, align 8, !tbaa !5
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = load ptr, ptr %11, align 8, !tbaa !5
  %71 = getelementptr inbounds ptr, ptr %70, i64 0
  store ptr %69, ptr %71, align 8, !tbaa !5
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = getelementptr inbounds ptr, ptr %73, i64 1
  store ptr %72, ptr %74, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %75

75:                                               ; preds = %67, %32
  store i32 2, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %76

76:                                               ; preds = %75, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %77 = load i32, ptr %6, align 4
  ret i32 %77
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK3JPH10PlaneShape11GetMaterialERKNS_10SubShapeIDE(ptr noundef nonnull align 16 dereferenceable(96), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 2158189138}
!12 = !{!13, !14, i64 48}
!13 = !{!"_ZTSN3JPH10PlaneShape21PSGetTrianglesContextE", !7, i64 0, !14, i64 48}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 4, !18}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !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.JPH::SubShapeID" = type { i32 }

@.str.3 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [62 x i8], align 1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3JPH10SubShapeIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZNK3JPH10PlaneShape16GetTrianglesNextERNS_5Shape19GetTrianglesContextEiPNS_6Float3EPPKNS_15PhysicsMaterialE(ptr noundef nonnull align 16 dereferenceable(96) %0, ptr nocapture noundef nonnull align 16 dereferenceable(4288) %1, i32 noundef %2, ptr nocapture noundef writeonly %3, ptr noundef writeonly %4) unnamed_addr #4 align 2 {
  %6 = alloca %"class.JPH::SubShapeID", align 4
  %7 = icmp sgt i32 %2, 31
  br i1 %7, label %11, label %8

8:                                                ; preds = %5
  %9 = tail call noundef zeroext i1 @_ZN3JPH23AssertFailedParamHelperEPKcS1_jNS_15AssertLastParamE(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 416)
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  tail call void asm sideeffect "int $$0x3", "~{dirflag},~{fpsr},~{flags}"() #5, !srcloc !5
  br label %11

11:                                               ; preds = %5, %8, %10
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  %13 = load i8, ptr %12, align 16, !tbaa !6, !range !11, !noundef !12
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %27, label %15

15:                                               ; preds = %11
  store i8 1, ptr %12, align 16, !tbaa !6
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %3, ptr noundef nonnull align 16 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !13
  %16 = getelementptr inbounds i8, ptr %1, i64 12
  %17 = getelementptr inbounds i8, ptr %3, i64 12
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %17, ptr noundef nonnull align 4 dereferenceable(12) %16, i64 12, i1 false), !tbaa.struct !13
  %18 = getelementptr inbounds i8, ptr %1, i64 24
  %19 = getelementptr inbounds i8, ptr %3, i64 24
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %19, ptr noundef nonnull align 8 dereferenceable(12) %18, i64 12, i1 false), !tbaa.struct !13
  %20 = getelementptr inbounds i8, ptr %3, i64 36
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %20, ptr noundef nonnull align 16 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !13
  %21 = getelementptr inbounds i8, ptr %3, i64 48
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %21, ptr noundef nonnull align 8 dereferenceable(12) %18, i64 12, i1 false), !tbaa.struct !13
  %22 = getelementptr inbounds i8, ptr %1, i64 36
  %23 = getelementptr inbounds i8, ptr %3, i64 60
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %23, ptr noundef nonnull align 4 dereferenceable(12) %22, i64 12, i1 false), !tbaa.struct !13
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %27, label %24

24:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 0, ptr %6, align 4
  call void @_ZN3JPH10SubShapeIDC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %6) #5
  %25 = call noundef ptr @_ZNK3JPH10PlaneShape11GetMaterialERKNS_10SubShapeIDE(ptr noundef nonnull align 16 dereferenceable(96) %0, ptr noundef nonnull align 4 dereferenceable(4) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  store ptr %25, ptr %4, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %25, ptr %26, align 8, !tbaa !16
  br label %27

27:                                               ; preds = %15, %24, %11
  %.0 = phi i32 [ 0, %11 ], [ 2, %24 ], [ 2, %15 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK3JPH10PlaneShape11GetMaterialERKNS_10SubShapeIDE(ptr noundef nonnull align 16 dereferenceable(96), ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #4 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = { 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 #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 = !{i64 2158189138}
!6 = !{!7, !10, i64 48}
!7 = !{!"_ZTSN3JPH10PlaneShape21PSGetTrianglesContextE", !8, i64 0, !10, i64 48}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"any pointer", !8, i64 0}


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