; LLVM IR from jdeokkim/ferox :: src (world)

; 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.frVector2_ = type { float, float }
%struct.frWorld_ = type { %struct.anon, %struct.anon.0, ptr, ptr, float, float, %struct.frCollisionHandler_, %struct.frVector2_ }
%struct.anon = type { ptr, i64, i64 }
%struct.anon.0 = type { ptr, i64, i32, i32 }
%struct.frCollisionHandler_ = type { ptr, ptr }

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

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @frCreateWorld(<2 x float> %0, float noundef %1) #3 {
  %3 = alloca %struct.frVector2_, align 4
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store <2 x float> %0, ptr %3, align 4
  store float %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %8 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 96) #8
  store ptr %8, ptr %5, align 8, !tbaa !9
  %9 = load ptr, ptr %5, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct.frWorld_, ptr %9, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !11
  %11 = load float, ptr %4, align 4, !tbaa !5
  %12 = call ptr @frCreateSpatialHash(float noundef %11)
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.frWorld_, ptr %13, i32 0, i32 2
  store ptr %12, ptr %14, align 8, !tbaa !12
  br label %15

15:                                               ; preds = %2
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.frWorld_, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.anon, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !20
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %40

21:                                               ; preds = %15
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.frWorld_, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.anon, ptr %24, i32 0, i32 1
  store i64 0, ptr %25, align 8, !tbaa !21
  %26 = load ptr, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.frWorld_, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %struct.anon, ptr %27, i32 0, i32 2
  store i64 8, ptr %28, align 8, !tbaa !22
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.frWorld_, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.anon, ptr %30, i32 0, i32 2
  %32 = load i64, ptr %31, align 8, !tbaa !22
  %33 = mul i64 %32, 8
  %34 = call noalias ptr @malloc(i64 noundef %33) #9
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.frWorld_, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  store ptr %34, ptr %37, align 8, !tbaa !20
  br label %38

38:                                               ; preds = %22
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct.frWorld_, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.anon, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !20
  %45 = call ptr @realloc(ptr noundef %44, i64 noundef 16384) #10
  store ptr %45, ptr %6, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %66

48:                                               ; preds = %40
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = load ptr, ptr %5, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.frWorld_, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %struct.anon, ptr %51, i32 0, i32 0
  store ptr %49, ptr %52, align 8, !tbaa !20
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.frWorld_, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %struct.anon, ptr %54, i32 0, i32 1
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = icmp ugt i64 %56, 2048
  br i1 %57, label %58, label %62

58:                                               ; preds = %48
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.frWorld_, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.anon, ptr %60, i32 0, i32 1
  store i64 2048, ptr %61, align 8, !tbaa !21
  br label %62

62:                                               ; preds = %58, %48
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.frWorld_, ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %struct.anon, ptr %64, i32 0, i32 2
  store i64 2048, ptr %65, align 8, !tbaa !22
  br label %66

66:                                               ; preds = %62, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 2048, ptr %7, align 8, !tbaa !23
  %70 = load i64, ptr %7, align 8, !tbaa !23
  %71 = add i64 %70, -1
  store i64 %71, ptr %7, align 8, !tbaa !23
  %72 = load i64, ptr %7, align 8, !tbaa !23
  %73 = lshr i64 %72, 1
  %74 = load i64, ptr %7, align 8, !tbaa !23
  %75 = or i64 %74, %73
  store i64 %75, ptr %7, align 8, !tbaa !23
  %76 = load i64, ptr %7, align 8, !tbaa !23
  %77 = lshr i64 %76, 2
  %78 = load i64, ptr %7, align 8, !tbaa !23
  %79 = or i64 %78, %77
  store i64 %79, ptr %7, align 8, !tbaa !23
  %80 = load i64, ptr %7, align 8, !tbaa !23
  %81 = lshr i64 %80, 4
  %82 = load i64, ptr %7, align 8, !tbaa !23
  %83 = or i64 %82, %81
  store i64 %83, ptr %7, align 8, !tbaa !23
  %84 = load i64, ptr %7, align 8, !tbaa !23
  %85 = lshr i64 %84, 8
  %86 = load i64, ptr %7, align 8, !tbaa !23
  %87 = or i64 %86, %85
  store i64 %87, ptr %7, align 8, !tbaa !23
  %88 = load i64, ptr %7, align 8, !tbaa !23
  %89 = lshr i64 %88, 16
  %90 = load i64, ptr %7, align 8, !tbaa !23
  %91 = or i64 %90, %89
  store i64 %91, ptr %7, align 8, !tbaa !23
  %92 = load i64, ptr %7, align 8, !tbaa !23
  %93 = add i64 %92, 1
  store i64 %93, ptr %7, align 8, !tbaa !23
  %94 = load ptr, ptr %5, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.frWorld_, ptr %94, i32 0, i32 1
  %96 = getelementptr inbounds %struct.anon.0, ptr %95, i32 0, i32 1
  store i64 %93, ptr %96, align 8, !tbaa !24
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.frWorld_, ptr %97, i32 0, i32 1
  %99 = getelementptr inbounds %struct.anon.0, ptr %98, i32 0, i32 3
  store i32 0, ptr %99, align 4, !tbaa !25
  %100 = load ptr, ptr %5, align 8, !tbaa !9
  %101 = getelementptr inbounds %struct.frWorld_, ptr %100, i32 0, i32 1
  %102 = getelementptr inbounds %struct.anon.0, ptr %101, i32 0, i32 2
  store i32 0, ptr %102, align 8, !tbaa !26
  %103 = load ptr, ptr %5, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.frWorld_, ptr %103, i32 0, i32 1
  %105 = getelementptr inbounds %struct.anon.0, ptr %104, i32 0, i32 1
  %106 = load i64, ptr %105, align 8, !tbaa !24
  %107 = call noalias ptr @calloc(i64 noundef %106, i64 noundef 16) #8
  %108 = load ptr, ptr %5, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.frWorld_, ptr %108, i32 0, i32 1
  %110 = getelementptr inbounds %struct.anon.0, ptr %109, i32 0, i32 0
  store ptr %107, ptr %110, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %111

111:                                              ; preds = %69
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret ptr %113
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

declare ptr @frCreateSpatialHash(float noundef) #5

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind allocsize(0,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 #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 allocsize(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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { nounwind allocsize(1) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!12 = !{!13, !10, i64 48}
!13 = !{!"frWorld_", !14, i64 0, !16, i64 24, !10, i64 48, !10, i64 56, !6, i64 64, !6, i64 68, !18, i64 72, !19, i64 88}
!14 = !{!"", !10, i64 0, !15, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !10, i64 0, !15, i64 8, !17, i64 16, !17, i64 20}
!17 = !{!"int", !7, i64 0}
!18 = !{!"frCollisionHandler_", !10, i64 0, !10, i64 8}
!19 = !{!"frVector2_", !6, i64 0, !6, i64 4}
!20 = !{!13, !10, i64 0}
!21 = !{!13, !15, i64 8}
!22 = !{!13, !15, i64 16}
!23 = !{!15, !15, i64 0}
!24 = !{!13, !15, i64 32}
!25 = !{!13, !17, i64 44}
!26 = !{!13, !17, i64 40}
!27 = !{!13, !10, i64 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"

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @frCreateWorld(<2 x float> %0, float noundef %1) local_unnamed_addr #1 {
  %3 = tail call noalias dereferenceable_or_null(96) ptr @calloc(i64 noundef 1, i64 noundef 96) #5
  %4 = getelementptr inbounds i8, ptr %3, i64 88
  store <2 x float> %0, ptr %4, align 8
  %5 = tail call ptr @frCreateSpatialHash(float noundef %1) #6
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr %5, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 8, ptr %7, align 8, !tbaa !17
  %8 = tail call noalias dereferenceable_or_null(64) ptr @malloc(i64 noundef 64) #7
  store ptr %8, ptr %3, align 8, !tbaa !18
  %9 = tail call dereferenceable_or_null(16384) ptr @realloc(ptr noundef %8, i64 noundef 16384) #8
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %12, label %10

10:                                               ; preds = %2
  store ptr %9, ptr %3, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 2048, ptr %11, align 8, !tbaa !17
  br label %12

12:                                               ; preds = %10, %2
  %13 = getelementptr inbounds i8, ptr %3, i64 24
  %14 = getelementptr inbounds i8, ptr %3, i64 32
  store i64 2048, ptr %14, align 8, !tbaa !19
  %15 = getelementptr inbounds i8, ptr %3, i64 44
  store i32 0, ptr %15, align 4, !tbaa !20
  %16 = getelementptr inbounds i8, ptr %3, i64 40
  store i32 0, ptr %16, align 8, !tbaa !21
  %17 = tail call noalias dereferenceable_or_null(32768) ptr @calloc(i64 noundef 2048, i64 noundef 16) #5
  store ptr %17, ptr %13, align 8, !tbaa !22
  ret ptr %3
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

declare ptr @frCreateSpatialHash(float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind allocsize(0,1) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(1) }

!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 48}
!6 = !{!"frWorld_", !7, i64 0, !12, i64 24, !8, i64 48, !8, i64 56, !14, i64 64, !14, i64 68, !15, i64 72, !16, i64 88}
!7 = !{!"", !8, i64 0, !11, i64 8, !11, i64 16}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"", !8, i64 0, !11, i64 8, !13, i64 16, !13, i64 20}
!13 = !{!"int", !9, i64 0}
!14 = !{!"float", !9, i64 0}
!15 = !{!"frCollisionHandler_", !8, i64 0, !8, i64 8}
!16 = !{!"frVector2_", !14, i64 0, !14, i64 4}
!17 = !{!6, !11, i64 16}
!18 = !{!6, !8, i64 0}
!19 = !{!6, !11, i64 32}
!20 = !{!6, !13, i64 44}
!21 = !{!6, !13, i64 40}
!22 = !{!6, !8, i64 24}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass