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

; 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.b2ConstraintGraph = type { [12 x %struct.b2GraphColor] }
%struct.b2GraphColor = type { %struct.b2BitSet, %struct.b2ContactSimArray, %struct.b2JointSimArray, %union.anon }
%struct.b2BitSet = type { ptr, i32, i32 }
%struct.b2ContactSimArray = type { ptr, i32, i32 }
%struct.b2JointSimArray = type { ptr, i32, i32 }
%union.anon = type { ptr }

@.str = external hidden unnamed_addr constant [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 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: nounwind uwtable
define dso_local void @b2DestroyGraph(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %38, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 12
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %41

9:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.b2ConstraintGraph, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds [12 x %struct.b2GraphColor], ptr %11, i64 0, i64 0
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds %struct.b2GraphColor, ptr %12, i64 %14
  store ptr %15, ptr %4, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %9
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = icmp ne i32 %17, 11
  br i1 %18, label %29, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.b2GraphColor, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %struct.b2BitSet, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = icmp eq ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %19
  %26 = call i32 @b2InternalAssertFcn(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 56)
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  call void @llvm.trap()
  br label %29

29:                                               ; preds = %28, %25, %19, %16
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.b2GraphColor, ptr %32, i32 0, i32 0
  call void @b2DestroyBitSet(ptr noundef %33)
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.b2GraphColor, ptr %34, i32 0, i32 1
  call void @b2ContactSimArray_Destroy(ptr noundef %35)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.b2GraphColor, ptr %36, i32 0, i32 2
  call void @b2JointSimArray_Destroy(ptr noundef %37)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %38

38:                                               ; preds = %31
  %39 = load i32, ptr %3, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !15

41:                                               ; preds = %8
  ret void
}

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

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

declare void @b2DestroyBitSet(ptr noundef) #2

declare void @b2ContactSimArray_Destroy(ptr noundef) #2

declare void @b2JointSimArray_Destroy(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
attributes #3 = { cold noreturn nounwind memory(inaccessiblemem: write) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"b2GraphColor", !13, i64 0, !14, i64 16, !14, i64 32, !7, i64 48}
!13 = !{!"b2BitSet", !6, i64 0, !10, i64 8, !10, i64 12}
!14 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @b2DestroyGraph(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @b2DestroyBitSet(ptr noundef %0) #3
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @b2DestroyBitSet(ptr noundef nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @b2DestroyBitSet(ptr noundef nonnull %7) #3
  %8 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %8) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 144
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %9) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 168
  tail call void @b2DestroyBitSet(ptr noundef nonnull %10) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 184
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %11) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 200
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %12) #3
  %13 = getelementptr inbounds i8, ptr %0, i64 224
  tail call void @b2DestroyBitSet(ptr noundef nonnull %13) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 240
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %14) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 256
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %15) #3
  %16 = getelementptr inbounds i8, ptr %0, i64 280
  tail call void @b2DestroyBitSet(ptr noundef nonnull %16) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 296
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %17) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 312
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %18) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 336
  tail call void @b2DestroyBitSet(ptr noundef nonnull %19) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 352
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %20) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 368
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %21) #3
  %22 = getelementptr inbounds i8, ptr %0, i64 392
  tail call void @b2DestroyBitSet(ptr noundef nonnull %22) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 408
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %23) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 424
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %24) #3
  %25 = getelementptr inbounds i8, ptr %0, i64 448
  tail call void @b2DestroyBitSet(ptr noundef nonnull %25) #3
  %26 = getelementptr inbounds i8, ptr %0, i64 464
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %26) #3
  %27 = getelementptr inbounds i8, ptr %0, i64 480
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %27) #3
  %28 = getelementptr inbounds i8, ptr %0, i64 504
  tail call void @b2DestroyBitSet(ptr noundef nonnull %28) #3
  %29 = getelementptr inbounds i8, ptr %0, i64 520
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %29) #3
  %30 = getelementptr inbounds i8, ptr %0, i64 536
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %30) #3
  %31 = getelementptr inbounds i8, ptr %0, i64 560
  tail call void @b2DestroyBitSet(ptr noundef nonnull %31) #3
  %32 = getelementptr inbounds i8, ptr %0, i64 576
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %32) #3
  %33 = getelementptr inbounds i8, ptr %0, i64 592
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %33) #3
  %34 = getelementptr inbounds i8, ptr %0, i64 616
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = icmp eq ptr %35, null
  br i1 %36, label %40, label %38

37:                                               ; preds = %38
  tail call void @llvm.trap()
  unreachable

38:                                               ; preds = %1
  %39 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 56) #3
  %.not8.11 = icmp eq i32 %39, 0
  br i1 %.not8.11, label %40, label %37

40:                                               ; preds = %38, %1
  tail call void @b2DestroyBitSet(ptr noundef nonnull %34) #3
  %41 = getelementptr inbounds i8, ptr %0, i64 632
  tail call void @b2ContactSimArray_Destroy(ptr noundef nonnull %41) #3
  %42 = getelementptr inbounds i8, ptr %0, i64 648
  tail call void @b2JointSimArray_Destroy(ptr noundef nonnull %42) #3
  ret void
}

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

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

declare void @b2DestroyBitSet(ptr noundef) local_unnamed_addr #1

declare void @b2ContactSimArray_Destroy(ptr noundef) local_unnamed_addr #1

declare void @b2JointSimArray_Destroy(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
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, !8, i64 0}
!6 = !{!"b2GraphColor", !7, i64 0, !12, i64 16, !12, i64 32, !9, i64 48}
!7 = !{!"b2BitSet", !8, i64 0, !11, i64 8, !11, i64 12}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"", !8, i64 0, !11, i64 8, !11, i64 12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass