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

; 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.b2Shape = type { i32, i32, i32, i32, i32, i32, float, float, float, float, float, i32, %struct.b2AABB, %struct.b2AABB, %struct.b2Vec2, i32, %struct.b2Filter, ptr, i32, %union.anon.0, i16, i8, i8, i8, i8, i8 }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Filter = type { i64, i64, i32 }
%union.anon.0 = type { %struct.b2Polygon }
%struct.b2Polygon = type { [8 x %struct.b2Vec2], [8 x %struct.b2Vec2], %struct.b2Vec2, float, i32 }

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [52 x i8], align 1

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #1

; Function Attrs: nounwind uwtable
define dso_local void @b2CreateShapeProxy(ptr noundef %0, ptr noundef %1, i32 noundef %2, <2 x float> %3, <2 x float> %4, i1 noundef zeroext %5) #2 {
  %7 = alloca %struct.b2Transform, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  store <2 x float> %3, ptr %12, align 4
  %13 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  store <2 x float> %4, ptr %13, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  %14 = zext i1 %5 to i8
  store i8 %14, ptr %11, align 1, !tbaa !11
  br label %15

15:                                               ; preds = %6
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.b2Shape, ptr %16, i32 0, i32 15
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = icmp eq i32 %18, -1
  br i1 %19, label %24, label %20

20:                                               ; preds = %15
  %21 = call i32 @b2InternalAssertFcn(ptr noundef @.str.13, ptr noundef @.str.1, i32 noundef 903)
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  call void @llvm.trap()
  br label %24

24:                                               ; preds = %23, %20, %15
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  %29 = load <2 x float>, ptr %28, align 4
  %30 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  %31 = load <2 x float>, ptr %30, align 4
  call void @b2UpdateShapeAABBs(ptr noundef %26, <2 x float> %29, <2 x float> %31, i32 noundef %27)
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.b2Shape, ptr %34, i32 0, i32 13
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.b2Shape, ptr %36, i32 0, i32 16
  %38 = getelementptr inbounds %struct.b2Filter, ptr %37, i32 0, i32 0
  %39 = load i64, ptr %38, align 8, !tbaa !21
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.b2Shape, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !22
  %43 = load i8, ptr %11, align 1, !tbaa !11, !range !23, !noundef !24
  %44 = trunc i8 %43 to i1
  %45 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %35, i32 0, i32 0
  %46 = load <2 x float>, ptr %45, align 8
  %47 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %35, i32 0, i32 1
  %48 = load <2 x float>, ptr %47, align 8
  %49 = call i32 @b2BroadPhase_CreateProxy(ptr noundef %32, i32 noundef %33, <2 x float> %46, <2 x float> %48, i64 noundef %39, i32 noundef %42, i1 noundef zeroext %44)
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.b2Shape, ptr %50, i32 0, i32 15
  store i32 %49, ptr %51, align 8, !tbaa !13
  br label %52

52:                                               ; preds = %25
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.b2Shape, ptr %53, i32 0, i32 15
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %56 = and i32 %55, 3
  %57 = icmp ult i32 %56, 3
  br i1 %57, label %62, label %58

58:                                               ; preds = %52
  %59 = call i32 @b2InternalAssertFcn(ptr noundef @.str.14, ptr noundef @.str.1, i32 noundef 910)
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  call void @llvm.trap()
  br label %62

62:                                               ; preds = %61, %58, %52
  br label %63

63:                                               ; preds = %62
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @b2UpdateShapeAABBs(ptr noundef, <2 x float>, <2 x float>, i32 noundef) #2

declare i32 @b2BroadPhase_CreateProxy(ptr noundef, i32 noundef, <2 x float>, <2 x float>, i64 noundef, i32 noundef, i1 noundef zeroext) #0

attributes #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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #2 = { nounwind 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" }

!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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !10, i64 88}
!14 = !{!"b2Shape", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40, !10, i64 44, !16, i64 48, !16, i64 64, !17, i64 80, !10, i64 88, !18, i64 96, !6, i64 120, !10, i64 128, !7, i64 132, !20, i64 276, !12, i64 278, !12, i64 279, !12, i64 280, !12, i64 281, !12, i64 282}
!15 = !{!"float", !7, i64 0}
!16 = !{!"b2AABB", !17, i64 0, !17, i64 8}
!17 = !{!"b2Vec2", !15, i64 0, !15, i64 4}
!18 = !{!"b2Filter", !19, i64 0, !19, i64 8, !10, i64 16}
!19 = !{!"long", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!14, !19, i64 96}
!22 = !{!14, !10, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}


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

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [52 x i8], align 1

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #1

; Function Attrs: nounwind uwtable
define dso_local void @b2CreateShapeProxy(ptr noundef %0, ptr noundef %1, i32 noundef %2, <2 x float> %3, <2 x float> %4, i1 noundef zeroext %5) local_unnamed_addr #2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i32 %8, -1
  br i1 %9, label %13, label %10

10:                                               ; preds = %6
  %11 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.1, i32 noundef 903) #3
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %13, label %12

12:                                               ; preds = %10
  tail call void @llvm.trap()
  unreachable

13:                                               ; preds = %6, %10
  tail call void @b2UpdateShapeAABBs(ptr noundef nonnull %0, <2 x float> %3, <2 x float> %4, i32 noundef %2)
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  %16 = load i64, ptr %15, align 8, !tbaa !18
  %17 = load i32, ptr %0, align 8, !tbaa !19
  %18 = load <2 x float>, ptr %14, align 8
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = load <2 x float>, ptr %19, align 8
  %21 = tail call i32 @b2BroadPhase_CreateProxy(ptr noundef %1, i32 noundef %2, <2 x float> %18, <2 x float> %20, i64 noundef %16, i32 noundef %17, i1 noundef zeroext %5) #3
  store i32 %21, ptr %7, align 8, !tbaa !5
  %22 = and i32 %21, 3
  %.not10 = icmp eq i32 %22, 3
  br i1 %.not10, label %23, label %26

23:                                               ; preds = %13
  %24 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i32 noundef 910) #3
  %.not11 = icmp eq i32 %24, 0
  br i1 %.not11, label %26, label %25

25:                                               ; preds = %23
  tail call void @llvm.trap()
  unreachable

26:                                               ; preds = %13, %23
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @b2UpdateShapeAABBs(ptr noundef, <2 x float>, <2 x float>, i32 noundef) local_unnamed_addr #2

declare i32 @b2BroadPhase_CreateProxy(ptr noundef, i32 noundef, <2 x float>, <2 x float>, i64 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

attributes #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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #2 = { nounwind 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 = { 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 88}
!6 = !{!"b2Shape", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44, !11, i64 48, !11, i64 64, !12, i64 80, !7, i64 88, !13, i64 96, !15, i64 120, !7, i64 128, !8, i64 132, !16, i64 276, !17, i64 278, !17, i64 279, !17, i64 280, !17, i64 281, !17, i64 282}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"b2AABB", !12, i64 0, !12, i64 8}
!12 = !{!"b2Vec2", !10, i64 0, !10, i64 4}
!13 = !{!"b2Filter", !14, i64 0, !14, i64 8, !7, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"short", !8, i64 0}
!17 = !{!"_Bool", !8, i64 0}
!18 = !{!6, !14, i64 96}
!19 = !{!6, !7, i64 0}


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