; 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.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 }
%struct.b2ConstraintGraph = type { [12 x %struct.b2GraphColor] }

@constinit = external hidden constant [12 x %struct.b2GraphColor], align 8

; Function Attrs: nounwind uwtable
define dso_local void @b2CreateGraph(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.b2ConstraintGraph, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %struct.b2BitSet, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 672, i1 false)
  %10 = getelementptr inbounds %struct.b2ConstraintGraph, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 @constinit, i64 672, i1 false), !tbaa.struct !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %5, i64 672, i1 false), !tbaa.struct !11
  %11 = load i32, ptr %4, align 4, !tbaa !9
  %12 = call i32 @b2MaxInt(i32 noundef %11, i32 noundef 8)
  store i32 %12, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %35, %2
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 11
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %38

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.b2ConstraintGraph, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds [12 x %struct.b2GraphColor], ptr %19, i64 0, i64 0
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds %struct.b2GraphColor, ptr %20, i64 %22
  store ptr %23, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.b2GraphColor, ptr %24, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = call { ptr, i64 } @b2CreateBitSet(i32 noundef %26)
  %28 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 0
  %29 = extractvalue { ptr, i64 } %27, 0
  store ptr %29, ptr %28, align 8
  %30 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 1
  %31 = extractvalue { ptr, i64 } %27, 1
  store i64 %31, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %8, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.b2GraphColor, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %4, align 4, !tbaa !9
  call void @b2SetBitCountAndClear(ptr noundef %33, i32 noundef %34)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %35

35:                                               ; preds = %17
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %6, align 4, !tbaa !9
  br label %13, !llvm.loop !14

38:                                               ; preds = %16
  ret void
}

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @b2MaxInt(i32 noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #4

declare { ptr, i64 } @b2CreateBitSet(i32 noundef) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #4

declare void @b2SetBitCountAndClear(ptr noundef, i32 noundef) #5

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 672, !12}
!12 = !{!7, !7, i64 0}
!13 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 12, i64 4, !9}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%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 }

@constinit = external hidden local_unnamed_addr constant [12 x %struct.b2GraphColor], align 8

; Function Attrs: nounwind uwtable
define dso_local void @b2CreateGraph(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(672) %0, ptr noundef nonnull align 8 dereferenceable(672) @constinit, i64 672, i1 false)
  %3 = tail call i32 @b2MaxInt(i32 noundef %1, i32 noundef 8)
  %4 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %5 = extractvalue { ptr, i64 } %4, 0
  %6 = extractvalue { ptr, i64 } %4, 1
  store ptr %5, ptr %0, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %6, ptr %.sroa.4.0..sroa_idx, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %0, i32 noundef %3) #4
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %9 = extractvalue { ptr, i64 } %8, 0
  %10 = extractvalue { ptr, i64 } %8, 1
  store ptr %9, ptr %7, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.1 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %10, ptr %.sroa.4.0..sroa_idx.1, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %7, i32 noundef %3) #4
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  %12 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %13 = extractvalue { ptr, i64 } %12, 0
  %14 = extractvalue { ptr, i64 } %12, 1
  store ptr %13, ptr %11, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.2 = getelementptr inbounds i8, ptr %0, i64 120
  store i64 %14, ptr %.sroa.4.0..sroa_idx.2, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %11, i32 noundef %3) #4
  %15 = getelementptr inbounds i8, ptr %0, i64 168
  %16 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %17 = extractvalue { ptr, i64 } %16, 0
  %18 = extractvalue { ptr, i64 } %16, 1
  store ptr %17, ptr %15, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.3 = getelementptr inbounds i8, ptr %0, i64 176
  store i64 %18, ptr %.sroa.4.0..sroa_idx.3, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %15, i32 noundef %3) #4
  %19 = getelementptr inbounds i8, ptr %0, i64 224
  %20 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %21 = extractvalue { ptr, i64 } %20, 0
  %22 = extractvalue { ptr, i64 } %20, 1
  store ptr %21, ptr %19, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.4 = getelementptr inbounds i8, ptr %0, i64 232
  store i64 %22, ptr %.sroa.4.0..sroa_idx.4, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %19, i32 noundef %3) #4
  %23 = getelementptr inbounds i8, ptr %0, i64 280
  %24 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %25 = extractvalue { ptr, i64 } %24, 0
  %26 = extractvalue { ptr, i64 } %24, 1
  store ptr %25, ptr %23, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.5 = getelementptr inbounds i8, ptr %0, i64 288
  store i64 %26, ptr %.sroa.4.0..sroa_idx.5, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %23, i32 noundef %3) #4
  %27 = getelementptr inbounds i8, ptr %0, i64 336
  %28 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %29 = extractvalue { ptr, i64 } %28, 0
  %30 = extractvalue { ptr, i64 } %28, 1
  store ptr %29, ptr %27, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.6 = getelementptr inbounds i8, ptr %0, i64 344
  store i64 %30, ptr %.sroa.4.0..sroa_idx.6, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %27, i32 noundef %3) #4
  %31 = getelementptr inbounds i8, ptr %0, i64 392
  %32 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %33 = extractvalue { ptr, i64 } %32, 0
  %34 = extractvalue { ptr, i64 } %32, 1
  store ptr %33, ptr %31, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.7 = getelementptr inbounds i8, ptr %0, i64 400
  store i64 %34, ptr %.sroa.4.0..sroa_idx.7, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %31, i32 noundef %3) #4
  %35 = getelementptr inbounds i8, ptr %0, i64 448
  %36 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %37 = extractvalue { ptr, i64 } %36, 0
  %38 = extractvalue { ptr, i64 } %36, 1
  store ptr %37, ptr %35, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.8 = getelementptr inbounds i8, ptr %0, i64 456
  store i64 %38, ptr %.sroa.4.0..sroa_idx.8, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %35, i32 noundef %3) #4
  %39 = getelementptr inbounds i8, ptr %0, i64 504
  %40 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %41 = extractvalue { ptr, i64 } %40, 0
  %42 = extractvalue { ptr, i64 } %40, 1
  store ptr %41, ptr %39, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.9 = getelementptr inbounds i8, ptr %0, i64 512
  store i64 %42, ptr %.sroa.4.0..sroa_idx.9, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %39, i32 noundef %3) #4
  %43 = getelementptr inbounds i8, ptr %0, i64 560
  %44 = tail call { ptr, i64 } @b2CreateBitSet(i32 noundef %3) #4
  %45 = extractvalue { ptr, i64 } %44, 0
  %46 = extractvalue { ptr, i64 } %44, 1
  store ptr %45, ptr %43, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx.10 = getelementptr inbounds i8, ptr %0, i64 568
  store i64 %46, ptr %.sroa.4.0..sroa_idx.10, align 8
  tail call void @b2SetBitCountAndClear(ptr noundef nonnull %43, i32 noundef %3) #4
  ret void
}

; 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 nounwind uwtable
declare hidden i32 @b2MaxInt(i32 noundef, i32 noundef) local_unnamed_addr #2

declare { ptr, i64 } @b2CreateBitSet(i32 noundef) local_unnamed_addr #3

declare void @b2SetBitCountAndClear(ptr noundef, i32 noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass