; LLVM IR from erincatto/box2d :: src (geometry)

; 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.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Vec2 = type { float, float }
%struct.b2Rot = type { float, float }
%struct.b2ShapeProxy = type { [8 x %struct.b2Vec2], i32, float }
%struct.b2CastOutput = type { %struct.b2Vec2, %struct.b2Vec2, float, i32, i8 }
%struct.b2ShapeCastPairInput = type { %struct.b2ShapeProxy, %struct.b2ShapeProxy, %struct.b2Transform, %struct.b2Transform, %struct.b2Vec2, float, i8 }
%struct.b2Polygon = type { [8 x %struct.b2Vec2], [8 x %struct.b2Vec2], %struct.b2Vec2, float, i32 }
%struct.b2ShapeCastInput = type { %struct.b2ShapeProxy, %struct.b2Vec2, float, i8 }

@b2Transform_identity = external hidden constant %struct.b2Transform, align 4

; 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

declare void @b2MakeProxy(ptr dead_on_unwind writable sret(%struct.b2ShapeProxy) align 4, ptr noundef, i32 noundef, float noundef) #2

declare void @b2ShapeCast(ptr dead_on_unwind writable sret(%struct.b2CastOutput) align 4, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @b2ShapeCastPolygon(ptr dead_on_unwind noalias writable sret(%struct.b2CastOutput) align 4 %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.b2ShapeCastPairInput, align 4
  %7 = alloca %struct.b2ShapeProxy, align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 192, ptr %6) #4
  %8 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 72, ptr %7) #4
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.b2Polygon, ptr %9, i32 0, i32 0
  %11 = getelementptr inbounds [8 x %struct.b2Vec2], ptr %10, i64 0, i64 0
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.b2Polygon, ptr %12, i32 0, i32 4
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.b2Polygon, ptr %15, i32 0, i32 3
  %17 = load float, ptr %16, align 4, !tbaa !14
  call void @b2MakeProxy(ptr dead_on_unwind writable sret(%struct.b2ShapeProxy) align 4 %7, ptr noundef %11, i32 noundef %14, float noundef %17)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %7, i64 72, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #4
  %18 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 1
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.b2ShapeCastInput, ptr %19, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %20, i64 72, i1 false), !tbaa.struct !15
  %21 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 @b2Transform_identity, i64 16, i1 false), !tbaa.struct !19
  %22 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 @b2Transform_identity, i64 16, i1 false), !tbaa.struct !19
  %23 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 4
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.b2ShapeCastInput, ptr %24, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %25, i64 8, i1 false), !tbaa.struct !20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.b2ShapeCastInput, ptr %26, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !21
  %29 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 5
  store float %28, ptr %29, align 4, !tbaa !25
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.b2ShapeCastInput, ptr %30, i32 0, i32 3
  %32 = load i8, ptr %31, align 4, !tbaa !29, !range !30, !noundef !31
  %33 = trunc i8 %32 to i1
  %34 = getelementptr inbounds %struct.b2ShapeCastPairInput, ptr %6, i32 0, i32 6
  %35 = zext i1 %33 to i8
  store i8 %35, ptr %34, align 4, !tbaa !32
  call void @b2ShapeCast(ptr dead_on_unwind writable sret(%struct.b2CastOutput) align 4 %0, ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 192, ptr %6) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !13, i64 140}
!10 = !{!"b2Polygon", !7, i64 0, !7, i64 64, !11, i64 128, !12, i64 136, !13, i64 140}
!11 = !{!"b2Vec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !12, i64 136}
!15 = !{i64 0, i64 64, !16, i64 64, i64 4, !17, i64 68, i64 4, !18}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 4, !18, i64 12, i64 4, !18}
!20 = !{i64 0, i64 4, !18, i64 4, i64 4, !18}
!21 = !{!22, !12, i64 80}
!22 = !{!"b2ShapeCastInput", !23, i64 0, !11, i64 72, !12, i64 80, !24, i64 84}
!23 = !{!"b2ShapeProxy", !7, i64 0, !13, i64 64, !12, i64 68}
!24 = !{!"_Bool", !7, i64 0}
!25 = !{!26, !12, i64 184}
!26 = !{!"b2ShapeCastPairInput", !23, i64 0, !23, i64 72, !27, i64 144, !27, i64 160, !11, i64 176, !12, i64 184, !24, i64 188}
!27 = !{!"b2Transform", !11, i64 0, !28, i64 8}
!28 = !{!"b2Rot", !12, i64 0, !12, i64 4}
!29 = !{!22, !24, i64 84}
!30 = !{i8 0, i8 2}
!31 = !{}
!32 = !{!26, !24, i64 188}


; 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.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Vec2 = type { float, float }
%struct.b2Rot = type { float, float }
%struct.b2ShapeProxy = type { [8 x %struct.b2Vec2], i32, float }
%struct.b2CastOutput = type { %struct.b2Vec2, %struct.b2Vec2, float, i32, i8 }
%struct.b2ShapeCastPairInput = type { %struct.b2ShapeProxy, %struct.b2ShapeProxy, %struct.b2Transform, %struct.b2Transform, %struct.b2Vec2, float, i8 }

@b2Transform_identity = external hidden local_unnamed_addr constant %struct.b2Transform, align 4

; 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

declare void @b2MakeProxy(ptr dead_on_unwind writable sret(%struct.b2ShapeProxy) align 4, ptr noundef, i32 noundef, float noundef) local_unnamed_addr #2

declare void @b2ShapeCast(ptr dead_on_unwind writable sret(%struct.b2CastOutput) align 4, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @b2ShapeCastPolygon(ptr dead_on_unwind noalias writable sret(%struct.b2CastOutput) align 4 %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.b2ShapeCastPairInput, align 4
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %4) #4
  %5 = getelementptr inbounds i8, ptr %2, i64 140
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 136
  %8 = load float, ptr %7, align 4, !tbaa !12
  call void @b2MakeProxy(ptr dead_on_unwind nonnull writable sret(%struct.b2ShapeProxy) align 4 %4, ptr noundef %2, i32 noundef %6, float noundef %8) #4
  %9 = getelementptr inbounds i8, ptr %4, i64 72
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(72) %9, ptr noundef nonnull align 4 dereferenceable(72) %1, i64 72, i1 false), !tbaa.struct !13
  %10 = getelementptr inbounds i8, ptr %4, i64 144
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(16) @b2Transform_identity, i64 16, i1 false), !tbaa.struct !17
  %11 = getelementptr inbounds i8, ptr %4, i64 160
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(16) @b2Transform_identity, i64 16, i1 false), !tbaa.struct !17
  %12 = getelementptr inbounds i8, ptr %4, i64 176
  %13 = getelementptr inbounds i8, ptr %1, i64 72
  %14 = load i64, ptr %13, align 4
  store i64 %14, ptr %12, align 4
  %15 = getelementptr inbounds i8, ptr %1, i64 80
  %16 = load float, ptr %15, align 4, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %4, i64 184
  store float %16, ptr %17, align 4, !tbaa !22
  %18 = getelementptr inbounds i8, ptr %1, i64 84
  %19 = load i8, ptr %18, align 4, !tbaa !26, !range !27, !noundef !28
  %20 = getelementptr inbounds i8, ptr %4, i64 188
  store i8 %19, ptr %20, align 4, !tbaa !29
  call void @b2ShapeCast(ptr dead_on_unwind writable sret(%struct.b2CastOutput) align 4 %0, ptr noundef nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %4) #4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 = { 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, !11, i64 140}
!6 = !{!"b2Polygon", !7, i64 0, !7, i64 64, !9, i64 128, !10, i64 136, !11, i64 140}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"b2Vec2", !10, i64 0, !10, i64 4}
!10 = !{!"float", !7, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!6, !10, i64 136}
!13 = !{i64 0, i64 64, !14, i64 64, i64 4, !15, i64 68, i64 4, !16}
!14 = !{!7, !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16, i64 12, i64 4, !16}
!18 = !{!19, !10, i64 80}
!19 = !{!"b2ShapeCastInput", !20, i64 0, !9, i64 72, !10, i64 80, !21, i64 84}
!20 = !{!"b2ShapeProxy", !7, i64 0, !11, i64 64, !10, i64 68}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!23, !10, i64 184}
!23 = !{!"b2ShapeCastPairInput", !20, i64 0, !20, i64 72, !24, i64 144, !24, i64 160, !9, i64 176, !10, i64 184, !21, i64 188}
!24 = !{!"b2Transform", !9, i64 0, !25, i64 8}
!25 = !{!"b2Rot", !10, i64 0, !10, i64 4}
!26 = !{!19, !21, i64 84}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!23, !21, i64 188}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass