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

; 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.b2HashSet = type { ptr, i32, i32 }
%struct.b2SetItem = type { i64, i32 }

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [63 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @b2KeyHash(i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @b2FindSlot(ptr noundef, i64 noundef, i32 noundef) #3

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @b2AddKey(ptr noundef %0, i64 noundef %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %2
  %10 = load i64, ptr %5, align 8, !tbaa !9
  %11 = icmp ne i64 %10, 0
  br i1 %11, label %16, label %12

12:                                               ; preds = %9
  %13 = call i32 @b2InternalAssertFcn(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 154)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  call void @llvm.trap()
  br label %16

16:                                               ; preds = %15, %12, %9
  br label %17

17:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = load i64, ptr %5, align 8, !tbaa !9
  %19 = call i32 @b2KeyHash(i64 noundef %18)
  store i32 %19, ptr %6, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %17
  %21 = load i32, ptr %6, align 4, !tbaa !11
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %27, label %23

23:                                               ; preds = %20
  %24 = call i32 @b2InternalAssertFcn(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 157)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

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

27:                                               ; preds = %26, %23, %20
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = call i32 @b2FindSlot(ptr noundef %30, i64 noundef %31, i32 noundef %32)
  store i32 %33, ptr %7, align 4, !tbaa !11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.b2HashSet, ptr %34, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load i32, ptr %7, align 4, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.b2SetItem, ptr %36, i64 %38
  %40 = getelementptr inbounds %struct.b2SetItem, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %73

43:                                               ; preds = %29
  br label %44

44:                                               ; preds = %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.b2HashSet, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = load i32, ptr %7, align 4, !tbaa !11
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %struct.b2SetItem, ptr %47, i64 %49
  %51 = getelementptr inbounds %struct.b2SetItem, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %6, align 4, !tbaa !11
  %54 = icmp eq i32 %52, %53
  br i1 %54, label %55, label %66

55:                                               ; preds = %44
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.b2HashSet, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !13
  %59 = load i32, ptr %7, align 4, !tbaa !11
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.b2SetItem, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.b2SetItem, ptr %61, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !17
  %64 = load i64, ptr %5, align 8, !tbaa !9
  %65 = icmp eq i64 %63, %64
  br i1 %65, label %70, label %66

66:                                               ; preds = %55, %44
  %67 = call i32 @b2InternalAssertFcn(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 163)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  call void @llvm.trap()
  br label %70

70:                                               ; preds = %69, %66, %55
  br label %71

71:                                               ; preds = %70
  br label %72

72:                                               ; preds = %71
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %88

73:                                               ; preds = %29
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.b2HashSet, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 4, !tbaa !18
  %77 = mul i32 2, %76
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.b2HashSet, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %79, align 8, !tbaa !19
  %81 = icmp uge i32 %77, %80
  br i1 %81, label %82, label %84

82:                                               ; preds = %73
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @b2GrowTable(ptr noundef %83)
  br label %84

84:                                               ; preds = %82, %73
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = load i64, ptr %5, align 8, !tbaa !9
  %87 = load i32, ptr %6, align 4, !tbaa !11
  call void @b2AddKeyHaveCapacity(ptr noundef %85, i64 noundef %86, i32 noundef %87)
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %88

88:                                               ; preds = %84, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %89 = load i1, ptr %3, align 1
  ret i1 %89
}

; Function Attrs: nounwind uwtable
declare hidden void @b2GrowTable(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @b2AddKeyHaveCapacity(ptr noundef, i64 noundef, i32 noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"b2HashSet", !6, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!16, !12, i64 8}
!16 = !{!"b2SetItem", !10, i64 0, !12, i64 8}
!17 = !{!16, !10, i64 0}
!18 = !{!14, !12, i64 12}
!19 = !{!14, !12, i64 8}


; 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.b2SetItem = type { i64, i32 }

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [63 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
declare hidden i32 @b2KeyHash(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @b2FindSlot(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @b2AddKey(ptr noundef %0, i64 noundef %1) local_unnamed_addr #2 {
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %3, label %6

3:                                                ; preds = %2
  %4 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 154) #3
  %.not21 = icmp eq i32 %4, 0
  br i1 %.not21, label %6, label %5

5:                                                ; preds = %3
  tail call void @llvm.trap()
  unreachable

6:                                                ; preds = %2, %3
  %7 = tail call i32 @b2KeyHash(i64 noundef %1)
  %.not22 = icmp eq i32 %7, 0
  br i1 %.not22, label %8, label %11

8:                                                ; preds = %6
  %9 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 157) #3
  %.not23 = icmp eq i32 %9, 0
  br i1 %.not23, label %11, label %10

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

11:                                               ; preds = %8, %6
  %12 = tail call i32 @b2FindSlot(ptr noundef %0, i64 noundef %1, i32 noundef %7)
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = sext i32 %12 to i64
  %15 = getelementptr inbounds %struct.b2SetItem, ptr %13, i64 %14
  %16 = getelementptr inbounds i8, ptr %15, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %.not24 = icmp ne i32 %17, 0
  br i1 %.not24, label %18, label %26

18:                                               ; preds = %11
  %19 = icmp eq i32 %17, %7
  br i1 %19, label %20, label %23

20:                                               ; preds = %18
  %21 = load i64, ptr %15, align 8, !tbaa !14
  %22 = icmp eq i64 %21, %1
  br i1 %22, label %34, label %23

23:                                               ; preds = %20, %18
  %24 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 163) #3
  %.not26 = icmp eq i32 %24, 0
  br i1 %.not26, label %34, label %25

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

26:                                               ; preds = %11
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = shl i32 %28, 1
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  %31 = load i32, ptr %30, align 8, !tbaa !16
  %.not25 = icmp ult i32 %29, %31
  br i1 %.not25, label %33, label %32

32:                                               ; preds = %26
  tail call void @b2GrowTable(ptr noundef nonnull %0)
  br label %33

33:                                               ; preds = %32, %26
  tail call void @b2AddKeyHaveCapacity(ptr noundef nonnull %0, i64 noundef %1, i32 noundef %7)
  br label %34

34:                                               ; preds = %20, %23, %33
  ret i1 %.not24
}

; Function Attrs: nounwind uwtable
declare hidden void @b2GrowTable(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @b2AddKeyHaveCapacity(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

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"="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 = { 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 0}
!6 = !{!"b2HashSet", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"b2SetItem", !13, i64 0, !10, i64 8}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!6, !10, i64 12}
!16 = !{!6, !10, i64 8}


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