; 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.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 }
%struct.frVector2_ = type { float, float }

; 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
declare dso_local void @frStepWorld(ptr noundef, float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @frUpdateWorld(ptr noundef %0, float noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %13, label %10

10:                                               ; preds = %2
  %11 = load float, ptr %4, align 4, !tbaa !9
  %12 = fcmp ole float %11, 0.000000e+00
  br i1 %12, label %13, label %14

13:                                               ; preds = %10, %2
  br label %56

14:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %15 = call float @frGetCurrentTime()
  store float %15, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.frWorld_, ptr %16, i32 0, i32 5
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = fcmp ole float %18, 0.000000e+00
  br i1 %19, label %20, label %24

20:                                               ; preds = %14
  %21 = load float, ptr %5, align 4, !tbaa !9
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.frWorld_, ptr %22, i32 0, i32 5
  store float %21, ptr %23, align 4, !tbaa !11
  store i32 1, ptr %6, align 4
  br label %54

24:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %25 = load float, ptr %5, align 4, !tbaa !9
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.frWorld_, ptr %26, i32 0, i32 5
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = fsub float %25, %28
  store float %29, ptr %7, align 4, !tbaa !9
  %30 = load float, ptr %5, align 4, !tbaa !9
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.frWorld_, ptr %31, i32 0, i32 5
  store float %30, ptr %32, align 4, !tbaa !11
  %33 = load float, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.frWorld_, ptr %34, i32 0, i32 4
  %36 = load float, ptr %35, align 8, !tbaa !19
  %37 = fadd float %36, %33
  store float %37, ptr %35, align 8, !tbaa !19
  br label %38

38:                                               ; preds = %47, %24
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.frWorld_, ptr %39, i32 0, i32 4
  %41 = load float, ptr %40, align 8, !tbaa !19
  %42 = load float, ptr %4, align 4, !tbaa !9
  %43 = fcmp oge float %41, %42
  br i1 %43, label %44, label %53

44:                                               ; preds = %38
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = load float, ptr %4, align 4, !tbaa !9
  call void @frStepWorld(ptr noundef %45, float noundef %46)
  br label %47

47:                                               ; preds = %44
  %48 = load float, ptr %4, align 4, !tbaa !9
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.frWorld_, ptr %49, i32 0, i32 4
  %51 = load float, ptr %50, align 8, !tbaa !19
  %52 = fsub float %51, %48
  store float %52, ptr %50, align 8, !tbaa !19
  br label %38, !llvm.loop !20

53:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  store i32 0, ptr %6, align 4
  br label %54

54:                                               ; preds = %53, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %55 = load i32, ptr %6, align 4
  switch i32 %55, label %57 [
    i32 0, label %56
    i32 1, label %56
  ]

56:                                               ; preds = %54, %54, %13
  ret void

57:                                               ; preds = %54
  unreachable
}

declare float @frGetCurrentTime() #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 68}
!12 = !{!"frWorld_", !13, i64 0, !15, i64 24, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !17, i64 72, !18, i64 88}
!13 = !{!"", !6, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"", !6, i64 0, !14, i64 8, !16, i64 16, !16, i64 20}
!16 = !{!"int", !7, i64 0}
!17 = !{!"frCollisionHandler_", !6, i64 0, !6, i64 8}
!18 = !{!"frVector2_", !10, i64 0, !10, i64 4}
!19 = !{!12, !10, i64 64}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: nounwind uwtable
declare dso_local void @frStepWorld(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @frUpdateWorld(ptr noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  %4 = fcmp ole float %1, 0.000000e+00
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %.loopexit, label %5

5:                                                ; preds = %2
  %6 = tail call float @frGetCurrentTime() #3
  %7 = getelementptr inbounds i8, ptr %0, i64 68
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = fcmp ugt float %8, 0.000000e+00
  br i1 %9, label %11, label %10

10:                                               ; preds = %5
  store float %6, ptr %7, align 4, !tbaa !5
  br label %.loopexit

11:                                               ; preds = %5
  %12 = fsub float %6, %8
  store float %6, ptr %7, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  %14 = load float, ptr %13, align 8, !tbaa !17
  %15 = fadd float %12, %14
  store float %15, ptr %13, align 8, !tbaa !17
  %16 = fcmp ult float %15, %1
  br i1 %16, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  tail call void @frStepWorld(ptr noundef nonnull %0, float noundef %1)
  %17 = load float, ptr %13, align 8, !tbaa !17
  %18 = fsub float %17, %1
  store float %18, ptr %13, align 8, !tbaa !17
  %19 = fcmp ult float %18, %1
  br i1 %19, label %.loopexit, label %.lr.ph, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph, %11, %10, %2
  ret void
}

declare float @frGetCurrentTime() local_unnamed_addr #2

attributes #0 = { 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 #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 = { 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, !14, i64 68}
!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, !14, i64 64}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass