; LLVM IR from SOHNE/Dura2D :: src/collision/d2Shape.ll (ZN14d2PolygonShape14UpdateVerticesERK11d2Transform)

; 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.d2PolygonShape = type { %struct.d2Shape, float, float, i32, ptr, ptr }
%struct.d2Shape = type { ptr }
%struct.d2Transform = type { %struct.d2Vec2, %struct.d2Rot }
%struct.d2Rot = type { float, float }

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

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6d2Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 align 2

declare <2 x float> @_ZNK6d2Vec2plERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14d2PolygonShape14UpdateVerticesERK11d2Transform(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) unnamed_addr #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.d2Vec2, align 4
  %7 = alloca %struct.d2Vec2, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %74, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 3
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp slt i32 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %77

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.d2Transform, ptr %16, i32 0, i32 1
  %18 = getelementptr inbounds %struct.d2Rot, ptr %17, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !15
  %20 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.d2Vec2, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct.d2Vec2, ptr %24, i32 0, i32 0
  %26 = load float, ptr %25, align 4, !tbaa !20
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.d2Transform, ptr %27, i32 0, i32 1
  %29 = getelementptr inbounds %struct.d2Rot, ptr %28, i32 0, i32 0
  %30 = load float, ptr %29, align 4, !tbaa !21
  %31 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.d2Vec2, ptr %32, i64 %34
  %36 = getelementptr inbounds %struct.d2Vec2, ptr %35, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !22
  %38 = fmul float %30, %37
  %39 = fneg float %38
  %40 = call float @llvm.fmuladd.f32(float %19, float %26, float %39)
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.d2Transform, ptr %41, i32 0, i32 1
  %43 = getelementptr inbounds %struct.d2Rot, ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 4, !tbaa !21
  %45 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !19
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.d2Vec2, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.d2Vec2, ptr %49, i32 0, i32 0
  %51 = load float, ptr %50, align 4, !tbaa !20
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.d2Transform, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.d2Rot, ptr %53, i32 0, i32 1
  %55 = load float, ptr %54, align 4, !tbaa !15
  %56 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %struct.d2Vec2, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct.d2Vec2, ptr %60, i32 0, i32 1
  %62 = load float, ptr %61, align 4, !tbaa !22
  %63 = fmul float %55, %62
  %64 = call float @llvm.fmuladd.f32(float %44, float %51, float %63)
  call void @_ZN6d2Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %6, float noundef %40, float noundef %64)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.d2Transform, ptr %65, i32 0, i32 0
  %67 = call <2 x float> @_ZNK6d2Vec2plERKS_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %66)
  store <2 x float> %67, ptr %7, align 4
  %68 = getelementptr inbounds %struct.d2PolygonShape, ptr %8, i32 0, i32 5
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = load i32, ptr %5, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds %struct.d2Vec2, ptr %69, i64 %71
  %73 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8) %72, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %74

74:                                               ; preds = %15
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !24

77:                                               ; preds = %14
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 = { 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 nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress 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 #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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTS14d2PolygonShape", !13, i64 0, !14, i64 8, !14, i64 12, !10, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"_ZTS7d2Shape"}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !14, i64 12}
!16 = !{!"_ZTS11d2Transform", !17, i64 0, !18, i64 8}
!17 = !{!"_ZTS6d2Vec2", !14, i64 0, !14, i64 4}
!18 = !{!"_ZTS5d2Rot", !14, i64 0, !14, i64 4}
!19 = !{!12, !6, i64 24}
!20 = !{!17, !14, i64 0}
!21 = !{!16, !14, i64 8}
!22 = !{!17, !14, i64 4}
!23 = !{!12, !6, i64 32}
!24 = distinct !{!24, !25}
!25 = !{!"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.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

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; 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 nounwind uwtable
declare dso_local void @_ZN6d2Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #2 align 2

declare <2 x float> @_ZNK6d2Vec2plERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14d2PolygonShape14UpdateVerticesERK11d2Transform(ptr nocapture noundef nonnull readonly align 8 dereferenceable(40) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) unnamed_addr #4 align 2 {
  %3 = alloca %struct.d2Vec2, align 4
  %4 = alloca %struct.d2Vec2, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = getelementptr inbounds i8, ptr %1, i64 12
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  br label %12

._crit_edge:                                      ; preds = %12, %2
  ret void

12:                                               ; preds = %.lr.ph, %12
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %12 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %13 = load float, ptr %9, align 4, !tbaa !13
  %14 = load ptr, ptr %10, align 8, !tbaa !17
  %15 = getelementptr inbounds %struct.d2Vec2, ptr %14, i64 %indvars.iv
  %16 = load float, ptr %15, align 4, !tbaa !18
  %17 = load float, ptr %8, align 4, !tbaa !19
  %18 = getelementptr inbounds i8, ptr %15, i64 4
  %19 = load float, ptr %18, align 4, !tbaa !20
  %20 = fneg float %17
  %21 = fmul float %19, %20
  %22 = call float @llvm.fmuladd.f32(float %13, float %16, float %21)
  %23 = fmul float %13, %19
  %24 = call float @llvm.fmuladd.f32(float %17, float %16, float %23)
  call void @_ZN6d2Vec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %3, float noundef %22, float noundef %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %25 = call <2 x float> @_ZNK6d2Vec2plERKS_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %1)
  store <2 x float> %25, ptr %4, align 8
  %26 = load ptr, ptr %11, align 8, !tbaa !21
  %27 = getelementptr inbounds %struct.d2Vec2, ptr %26, i64 %indvars.iv
  %28 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8) %27, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr %5, align 8, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next, %30
  br i1 %31, label %12, label %._crit_edge, !llvm.loop !22
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 = { 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { mustprogress 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 #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, !11, i64 16}
!6 = !{!"_ZTS14d2PolygonShape", !7, i64 0, !8, i64 8, !8, i64 12, !11, i64 16, !12, i64 24, !12, i64 32}
!7 = !{!"_ZTS7d2Shape"}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!14, !8, i64 12}
!14 = !{!"_ZTS11d2Transform", !15, i64 0, !16, i64 8}
!15 = !{!"_ZTS6d2Vec2", !8, i64 0, !8, i64 4}
!16 = !{!"_ZTS5d2Rot", !8, i64 0, !8, i64 4}
!17 = !{!6, !12, i64 24}
!18 = !{!15, !8, i64 0}
!19 = !{!14, !8, i64 8}
!20 = !{!15, !8, i64 4}
!21 = !{!6, !12, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass