; LLVM IR from SOHNE/Dura2D :: src/kinetics/d2World.ll (ZN7d2World9DrawShapeEPK6d2BodyRKbRK7d2Color)

; 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.d2Vec2 = type { float, float }
%struct.d2CircleShape = type <{ %struct.d2Shape, float, [4 x i8] }>
%struct.d2Shape = type { ptr }
%class.d2World = type { %struct.d2Vec2, ptr, %class.d2BlockAllocator, ptr, i32, ptr, i32, ptr }
%class.d2BlockAllocator = type { ptr, i32, i32, [14 x ptr] }
%struct.d2PolygonShape = type { %struct.d2Shape, float, float, i32, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7d2World9DrawShapeEPK6d2BodyRKbRK7d2Color(ptr noundef nonnull align 8 dereferenceable(184) %0, ptr noundef %1, ptr noundef nonnull align 1 dereferenceable(1) %2, ptr noundef nonnull align 4 dereferenceable(16) %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.d2Vec2, align 4
  %11 = alloca float, align 4
  %12 = alloca ptr, align 8
  %13 = alloca float, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %18)
  store ptr %19, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(132) %20)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %21, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call noundef float @_ZNK6d2Body11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(132) %22)
  store float %23, ptr %11, align 4, !tbaa !10
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds ptr, ptr %25, i64 2
  %27 = load ptr, ptr %26, align 8
  %28 = call noundef i32 %27(ptr noundef nonnull align 8 dereferenceable(8) %24)
  switch i32 %28, label %58 [
    i32 0, label %29
    i32 2, label %41
    i32 1, label %41
  ]

29:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %30, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.d2CircleShape, ptr %31, i32 0, i32 1
  %33 = load float, ptr %32, align 8, !tbaa !14
  store float %33, ptr %13, align 4, !tbaa !10
  %34 = getelementptr inbounds %class.d2World, ptr %17, i32 0, i32 7
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = load float, ptr %13, align 4, !tbaa !10
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load ptr, ptr %35, align 8, !tbaa !12
  %39 = getelementptr inbounds ptr, ptr %38, i64 5
  %40 = load ptr, ptr %39, align 8
  call void %40(ptr noundef nonnull align 8 dereferenceable(12) %35, ptr noundef nonnull align 4 dereferenceable(8) %10, float noundef %36, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(16) %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %59

41:                                               ; preds = %4, %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %42, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.d2PolygonShape, ptr %43, i32 0, i32 5
  %45 = load ptr, ptr %44, align 8, !tbaa !22
  store ptr %45, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.d2PolygonShape, ptr %46, i32 0, i32 3
  %48 = load i32, ptr %47, align 8, !tbaa !24
  store i32 %48, ptr %16, align 4, !tbaa !25
  %49 = getelementptr inbounds %class.d2World, ptr %17, i32 0, i32 7
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = load ptr, ptr %15, align 8, !tbaa !5
  %52 = load i32, ptr %16, align 4, !tbaa !25
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load ptr, ptr %50, align 8, !tbaa !12
  %56 = getelementptr inbounds ptr, ptr %55, i64 3
  %57 = load ptr, ptr %56, align 8
  call void %57(ptr noundef nonnull align 8 dereferenceable(12) %50, ptr noundef %51, i32 noundef %52, ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 1 dereferenceable(1) %53, ptr noundef nonnull align 4 dereferenceable(16) %54)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %59

58:                                               ; preds = %4
  br label %59

59:                                               ; preds = %58, %41, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK6d2Body11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(132)) #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint mustprogress 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 #5 = { 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++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !8, i64 0}
!14 = !{!15, !11, i64 8}
!15 = !{!"_ZTS13d2CircleShape", !16, i64 0, !11, i64 8}
!16 = !{!"_ZTS7d2Shape"}
!17 = !{!18, !6, i64 176}
!18 = !{!"_ZTS7d2World", !19, i64 0, !6, i64 8, !20, i64 16, !6, i64 144, !21, i64 152, !6, i64 160, !21, i64 168, !6, i64 176}
!19 = !{!"_ZTS6d2Vec2", !11, i64 0, !11, i64 4}
!20 = !{!"_ZTS16d2BlockAllocator", !6, i64 0, !21, i64 8, !21, i64 12, !7, i64 16}
!21 = !{!"int", !7, i64 0}
!22 = !{!23, !6, i64 32}
!23 = !{!"_ZTS14d2PolygonShape", !16, i64 0, !11, i64 8, !11, i64 12, !21, i64 16, !6, i64 24, !6, i64 32}
!24 = !{!23, !21, i64 16}
!25 = !{!21, !21, i64 0}


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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7d2World9DrawShapeEPK6d2BodyRKbRK7d2Color(ptr nocapture noundef nonnull readonly align 8 dereferenceable(184) %0, ptr noundef nonnull %1, ptr noundef nonnull align 1 dereferenceable(1) %2, ptr noundef nonnull align 4 dereferenceable(16) %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %struct.d2Vec2, align 8
  %6 = alloca float, align 4
  %7 = tail call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %8 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  %9 = load i64, ptr %8, align 4
  store i64 %9, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %10 = tail call noundef float @_ZNK6d2Body11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  store float %10, ptr %6, align 4, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef i32 %13(ptr noundef nonnull align 8 dereferenceable(8) %7)
  switch i32 %14, label %33 [
    i32 0, label %15
    i32 2, label %23
    i32 1, label %23
  ]

15:                                               ; preds = %4
  %16 = getelementptr inbounds i8, ptr %7, i64 8
  %17 = load float, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %0, i64 176
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 40
  %22 = load ptr, ptr %21, align 8
  call void %22(ptr noundef nonnull align 8 dereferenceable(12) %19, ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef %17, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(16) %3)
  br label %33

23:                                               ; preds = %4, %4
  %24 = getelementptr inbounds i8, ptr %7, i64 32
  %25 = load ptr, ptr %24, align 8, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %7, i64 16
  %27 = load i32, ptr %26, align 8, !tbaa !22
  %28 = getelementptr inbounds i8, ptr %0, i64 176
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %30, i64 24
  %32 = load ptr, ptr %31, align 8
  call void %32(ptr noundef nonnull align 8 dereferenceable(12) %29, ptr noundef %25, i32 noundef %27, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 1 dereferenceable(1) %2, ptr noundef nonnull align 4 dereferenceable(16) %3)
  br label %33

33:                                               ; preds = %4, %23, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNK6d2Body11GetPositionEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK6d2Body11GetRotationEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint mustprogress 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 = { inlinehint mustprogress 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTS13d2CircleShape", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTS7d2Shape"}
!14 = !{!15, !17, i64 176}
!15 = !{!"_ZTS7d2World", !16, i64 0, !17, i64 8, !18, i64 16, !17, i64 144, !19, i64 152, !17, i64 160, !19, i64 168, !17, i64 176}
!16 = !{!"_ZTS6d2Vec2", !6, i64 0, !6, i64 4}
!17 = !{!"any pointer", !7, i64 0}
!18 = !{!"_ZTS16d2BlockAllocator", !17, i64 0, !19, i64 8, !19, i64 12, !7, i64 16}
!19 = !{!"int", !7, i64 0}
!20 = !{!21, !17, i64 32}
!21 = !{!"_ZTS14d2PolygonShape", !13, i64 0, !6, i64 8, !6, i64 12, !19, i64 16, !17, i64 24, !17, i64 32}
!22 = !{!21, !19, i64 16}


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