; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qbody.ll (ZN5QBody10CanCollideEPS_S0_b)

; 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.QBody = type <{ ptr, float, float, ptr, %struct.QVector, %struct.QVector, float, float, %class.QAABB, i32, i8, i8, i8, i8, float, i32, i8, [3 x i8], float, i8, i8, [2 x i8], %struct.QVector, float, float, float, float, float, i32, i32, i8, i8, i8, i8, i32, i32, i32, i8, [3 x i8], %"class.std::function", %"class.std::function", %"class.std::function.0", i8, [7 x i8], %"class.std::vector", i32, i8, [3 x i8] }>
%class.QAABB = type { %struct.QVector, %struct.QVector, %struct.QVector, float }
%struct.QVector = type { float, float }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.std::function.0" = type { %"class.std::_Function_base", ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl" }
%"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QMesh *, std::allocator<QMesh *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5QBody10CanCollideEPS_S0_b(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %10 = zext i1 %2 to i8
  store i8 %10, ptr %7, align 1, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.QBody, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %class.QBody, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = icmp ne ptr %13, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  br label %89

19:                                               ; preds = %3
  %20 = load i8, ptr %7, align 1, !tbaa !9, !range !27, !noundef !28
  %21 = trunc i8 %20 to i1
  %22 = zext i1 %21 to i32
  %23 = icmp eq i32 %22, 1
  br i1 %23, label %24, label %36

24:                                               ; preds = %19
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %25)
  %27 = zext i1 %26 to i32
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %34, label %29

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %30)
  %32 = zext i1 %31 to i32
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %35

34:                                               ; preds = %29, %24
  store i1 false, ptr %4, align 1
  br label %89

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35, %19
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.QBody, ptr %37, i32 0, i32 32
  %39 = load i8, ptr %38, align 2, !tbaa !29, !range !27, !noundef !28
  %40 = trunc i8 %39 to i1
  br i1 %40, label %46, label %41

41:                                               ; preds = %36
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %class.QBody, ptr %42, i32 0, i32 9
  %44 = load i32, ptr %43, align 4, !tbaa !30
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %57

46:                                               ; preds = %41, %36
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %class.QBody, ptr %47, i32 0, i32 32
  %49 = load i8, ptr %48, align 2, !tbaa !29, !range !27, !noundef !28
  %50 = trunc i8 %49 to i1
  br i1 %50, label %56, label %51

51:                                               ; preds = %46
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %class.QBody, ptr %52, i32 0, i32 9
  %54 = load i32, ptr %53, align 4, !tbaa !30
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %57

56:                                               ; preds = %51, %46
  store i1 false, ptr %4, align 1
  br label %89

57:                                               ; preds = %51, %41
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %class.QBody, ptr %58, i32 0, i32 28
  %60 = load i32, ptr %59, align 4, !tbaa !31
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %class.QBody, ptr %61, i32 0, i32 29
  %63 = load i32, ptr %62, align 8, !tbaa !32
  %64 = and i32 %60, %63
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %76

66:                                               ; preds = %57
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.QBody, ptr %67, i32 0, i32 28
  %69 = load i32, ptr %68, align 4, !tbaa !31
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %class.QBody, ptr %70, i32 0, i32 29
  %72 = load i32, ptr %71, align 8, !tbaa !32
  %73 = and i32 %69, %72
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %66
  store i1 false, ptr %4, align 1
  br label %89

76:                                               ; preds = %66, %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %class.QBody, ptr %77, i32 0, i32 3
  %79 = load ptr, ptr %78, align 8, !tbaa !11
  store ptr %79, ptr %8, align 8, !tbaa !5
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = call noundef zeroext i1 @_ZN6QWorld23CheckCollisionExceptionEP5QBodyS1_(ptr noundef nonnull align 8 dereferenceable(272) %80, ptr noundef %81, ptr noundef %82)
  %84 = zext i1 %83 to i32
  %85 = icmp eq i32 %84, 1
  br i1 %85, label %86, label %87

86:                                               ; preds = %76
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %88

87:                                               ; preds = %76
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %88

88:                                               ; preds = %87, %86
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %89

89:                                               ; preds = %88, %75, %56, %34, %18
  %90 = load i1, ptr %4, align 1
  ret i1 %90
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293)) #2 align 2

declare noundef zeroext i1 @_ZN6QWorld23CheckCollisionExceptionEP5QBodyS1_(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync 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 = { 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 = { "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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS5QBody", !13, i64 8, !13, i64 12, !6, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !13, i64 44, !15, i64 48, !16, i64 76, !10, i64 80, !10, i64 81, !10, i64 82, !13, i64 84, !17, i64 88, !10, i64 92, !13, i64 96, !10, i64 100, !10, i64 101, !14, i64 104, !13, i64 112, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !18, i64 132, !18, i64 136, !10, i64 140, !10, i64 141, !10, i64 142, !18, i64 144, !18, i64 148, !18, i64 152, !10, i64 156, !19, i64 160, !19, i64 192, !21, i64 224, !10, i64 256, !22, i64 264, !26, i64 288, !10, i64 292}
!13 = !{!"float", !7, i64 0}
!14 = !{!"_ZTS7QVector", !13, i64 0, !13, i64 4}
!15 = !{!"_ZTS5QAABB", !14, i64 0, !14, i64 8, !14, i64 16, !13, i64 24}
!16 = !{!"_ZTSN5QBody5ModesE", !7, i64 0}
!17 = !{!"_ZTSN5QBody9BodyTypesE", !7, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSSt8functionIFvP5QBodyEE", !20, i64 0, !6, i64 24}
!20 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!21 = !{!"_ZTSSt8functionIFbP5QBodyNS0_13CollisionInfoEEE", !20, i64 0, !6, i64 24}
!22 = !{!"_ZTSSt6vectorIP5QMeshSaIS1_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIP5QMeshSaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSN5QBody16SimulationModelsE", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!12, !10, i64 142}
!30 = !{!12, !16, i64 76}
!31 = !{!12, !18, i64 132}
!32 = !{!12, !18, i64 136}


; 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"

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5QBody10CanCollideEPS_S0_b(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %5, %7
  br i1 %.not, label %8, label %46

8:                                                ; preds = %3
  br i1 %2, label %9, label %13

9:                                                ; preds = %8
  %10 = tail call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %0)
  br i1 %10, label %11, label %46

11:                                               ; preds = %9
  %12 = tail call noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293) %1)
  br i1 %12, label %13, label %46

13:                                               ; preds = %11, %8
  %14 = getelementptr inbounds i8, ptr %0, i64 142
  %15 = load i8, ptr %14, align 2, !tbaa !25, !range !26, !noundef !27
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %21, label %17

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %0, i64 76
  %19 = load i32, ptr %18, align 4, !tbaa !28
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %29

21:                                               ; preds = %17, %13
  %22 = getelementptr inbounds i8, ptr %1, i64 142
  %23 = load i8, ptr %22, align 2, !tbaa !25, !range !26, !noundef !27
  %24 = trunc nuw i8 %23 to i1
  br i1 %24, label %46, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %1, i64 76
  %27 = load i32, ptr %26, align 4, !tbaa !28
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %46, label %29

29:                                               ; preds = %25, %17
  %30 = getelementptr inbounds i8, ptr %0, i64 132
  %31 = load i32, ptr %30, align 4, !tbaa !29
  %32 = getelementptr inbounds i8, ptr %1, i64 136
  %33 = load i32, ptr %32, align 8, !tbaa !30
  %34 = and i32 %33, %31
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %43

36:                                               ; preds = %29
  %37 = getelementptr inbounds i8, ptr %1, i64 132
  %38 = load i32, ptr %37, align 4, !tbaa !29
  %39 = getelementptr inbounds i8, ptr %0, i64 136
  %40 = load i32, ptr %39, align 8, !tbaa !30
  %41 = and i32 %40, %38
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %46, label %43

43:                                               ; preds = %36, %29
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = tail call noundef zeroext i1 @_ZN6QWorld23CheckCollisionExceptionEP5QBodyS1_(ptr noundef nonnull align 8 dereferenceable(272) %44, ptr noundef nonnull %0, ptr noundef nonnull %1)
  %.0 = xor i1 %45, true
  br label %46

46:                                               ; preds = %36, %21, %25, %9, %11, %3, %43
  %.1 = phi i1 [ %.0, %43 ], [ false, %3 ], [ false, %11 ], [ false, %9 ], [ false, %25 ], [ false, %21 ], [ false, %36 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5QBody10GetEnabledEv(ptr noundef nonnull align 8 dereferenceable(293)) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZN6QWorld23CheckCollisionExceptionEP5QBodyS1_(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef) local_unnamed_addr #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 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 #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, !10, i64 16}
!6 = !{!"_ZTS5QBody", !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !7, i64 44, !12, i64 48, !13, i64 76, !14, i64 80, !14, i64 81, !14, i64 82, !7, i64 84, !15, i64 88, !14, i64 92, !7, i64 96, !14, i64 100, !14, i64 101, !11, i64 104, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !7, i64 128, !16, i64 132, !16, i64 136, !14, i64 140, !14, i64 141, !14, i64 142, !16, i64 144, !16, i64 148, !16, i64 152, !14, i64 156, !17, i64 160, !17, i64 192, !19, i64 224, !14, i64 256, !20, i64 264, !24, i64 288, !14, i64 292}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS7QVector", !7, i64 0, !7, i64 4}
!12 = !{!"_ZTS5QAABB", !11, i64 0, !11, i64 8, !11, i64 16, !7, i64 24}
!13 = !{!"_ZTSN5QBody5ModesE", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!"_ZTSN5QBody9BodyTypesE", !8, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{!"_ZTSSt8functionIFvP5QBodyEE", !18, i64 0, !10, i64 24}
!18 = !{!"_ZTSSt14_Function_base", !8, i64 0, !10, i64 16}
!19 = !{!"_ZTSSt8functionIFbP5QBodyNS0_13CollisionInfoEEE", !18, i64 0, !10, i64 24}
!20 = !{!"_ZTSSt6vectorIP5QMeshSaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIP5QMeshSaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIP5QMeshSaIS1_EE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!24 = !{!"_ZTSN5QBody16SimulationModelsE", !8, i64 0}
!25 = !{!6, !14, i64 142}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!6, !13, i64 76}
!29 = !{!6, !16, i64 132}
!30 = !{!6, !16, i64 136}


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