; LLVM IR from DarrenSweeney/3D-Physics-Engine :: Physics Engine/Imgui/imgui.ll (ZN10ImDrawList9AddCircleERK6ImVec2fji)

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

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ImDrawList9AddCircleERK6ImVec2fji(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, float noundef %2, i32 noundef %3, i32 noundef %4) #3 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca %struct.ImVec2, align 4
  %16 = alloca %struct.ImVec2, align 4
  %17 = alloca %struct.ImVec2, align 4
  %18 = alloca %struct.ImVec2, align 4
  %19 = alloca %struct.ImVec2, align 4
  %20 = alloca %struct.ImVec2, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  %21 = load ptr, ptr %6, align 8
  %22 = load i32, ptr %9, align 4, !tbaa !11
  %23 = lshr i32 %22, 24
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %5
  br label %71

26:                                               ; preds = %5
  %27 = load i32, ptr %10, align 4, !tbaa !11
  %28 = mul i32 %27, 6
  call void @_ZN10ImDrawList15ReserveVerticesEj(ptr noundef nonnull align 8 dereferenceable(104) %21, i32 noundef %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %29 = load i32, ptr %10, align 4, !tbaa !11
  %30 = sitofp i32 %29 to float
  %31 = fdiv float 0x401921FB60000000, %30
  store float %31, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store float 0.000000e+00, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %67, %26
  %33 = load i32, ptr %13, align 4, !tbaa !11
  %34 = load i32, ptr %10, align 4, !tbaa !11
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %70

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %38 = load i32, ptr %13, align 4, !tbaa !11
  %39 = add nsw i32 %38, 1
  %40 = load i32, ptr %10, align 4, !tbaa !11
  %41 = icmp eq i32 %39, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  br label %47

43:                                               ; preds = %37
  %44 = load float, ptr %12, align 4, !tbaa !9
  %45 = load float, ptr %11, align 4, !tbaa !9
  %46 = fadd float %44, %45
  br label %47

47:                                               ; preds = %43, %42
  %48 = phi float [ 0.000000e+00, %42 ], [ %46, %43 ]
  store float %48, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %50 = load float, ptr %12, align 4, !tbaa !9
  %51 = call float @cosf(float noundef %50) #6
  %52 = load float, ptr %12, align 4, !tbaa !9
  %53 = call float @sinf(float noundef %52) #6
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %17, float noundef %51, float noundef %53)
  %54 = load float, ptr %8, align 4, !tbaa !9
  %55 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %17, float noundef %54)
  store <2 x float> %55, ptr %16, align 4
  %56 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %49, ptr noundef nonnull align 4 dereferenceable(8) %16)
  store <2 x float> %56, ptr %15, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %58 = load float, ptr %14, align 4, !tbaa !9
  %59 = call float @cosf(float noundef %58) #6
  %60 = load float, ptr %14, align 4, !tbaa !9
  %61 = call float @sinf(float noundef %60) #6
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %20, float noundef %59, float noundef %61)
  %62 = load float, ptr %8, align 4, !tbaa !9
  %63 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %20, float noundef %62)
  store <2 x float> %63, ptr %19, align 4
  %64 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %57, ptr noundef nonnull align 4 dereferenceable(8) %19)
  store <2 x float> %64, ptr %18, align 4
  %65 = load i32, ptr %9, align 4, !tbaa !11
  call void @_ZN10ImDrawList10AddVtxLineERK6ImVec2S2_j(ptr noundef nonnull align 8 dereferenceable(104) %21, ptr noundef nonnull align 4 dereferenceable(8) %15, ptr noundef nonnull align 4 dereferenceable(8) %18, i32 noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  %66 = load float, ptr %14, align 4, !tbaa !9
  store float %66, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %67

67:                                               ; preds = %47
  %68 = load i32, ptr %13, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %13, align 4, !tbaa !11
  br label %32, !llvm.loop !13

70:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %71

71:                                               ; preds = %70, %25
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList15ReserveVerticesEj(ptr noundef nonnull align 8 dereferenceable(104), i32 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList10AddVtxLineERK6ImVec2S2_j(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) #3 align 2

; Function Attrs: nounwind
declare float @cosf(float noundef) #5

; Function Attrs: nounwind
declare float @sinf(float noundef) #5

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 #4 = { 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 "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 }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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.ImVec2 = type { float, float }

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10ImDrawList9AddCircleERK6ImVec2fji(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, float noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #3 align 2 {
  %6 = alloca %struct.ImVec2, align 8
  %7 = alloca %struct.ImVec2, align 8
  %8 = alloca %struct.ImVec2, align 4
  %9 = alloca %struct.ImVec2, align 8
  %10 = alloca %struct.ImVec2, align 8
  %11 = alloca %struct.ImVec2, align 4
  %12 = icmp ult i32 %3, 16777216
  br i1 %12, label %.loopexit, label %13

13:                                               ; preds = %5
  %14 = mul i32 %4, 6
  tail call void @_ZN10ImDrawList15ReserveVerticesEj(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %14)
  %15 = sitofp i32 %4 to float
  %16 = fdiv float 0x401921FB60000000, %15
  %17 = icmp sgt i32 %4, 0
  br i1 %17, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %13, %.lr.ph
  %.023 = phi float [ %21, %.lr.ph ], [ 0.000000e+00, %13 ]
  %.02022 = phi i32 [ %18, %.lr.ph ], [ 0, %13 ]
  %18 = add nuw nsw i32 %.02022, 1
  %19 = icmp eq i32 %18, %4
  %20 = fadd float %16, %.023
  %21 = select i1 %19, float 0.000000e+00, float %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #6
  %22 = call float @cosf(float noundef %.023) #6
  %23 = call float @sinf(float noundef %.023) #6
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef %22, float noundef %23)
  %24 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %8, float noundef %2)
  store <2 x float> %24, ptr %7, align 8
  %25 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %25, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #6
  %26 = call float @cosf(float noundef %21) #6
  %27 = call float @sinf(float noundef %21) #6
  call void @_ZN6ImVec2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %11, float noundef %26, float noundef %27)
  %28 = call <2 x float> @_ZmlRK6ImVec2f(ptr noundef nonnull align 4 dereferenceable(8) %11, float noundef %2)
  store <2 x float> %28, ptr %10, align 8
  %29 = call <2 x float> @_ZplRK6ImVec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %10)
  store <2 x float> %29, ptr %9, align 8
  call void @_ZN10ImDrawList10AddVtxLineERK6ImVec2S2_j(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(8) %9, i32 noundef %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %exitcond.not = icmp eq i32 %18, %4
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !5

.loopexit:                                        ; preds = %.lr.ph, %13, %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList15ReserveVerticesEj(ptr noundef nonnull align 8 dereferenceable(104), i32 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10ImDrawList10AddVtxLineERK6ImVec2S2_j(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 #4 = { 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 = { mustprogress nofree nounwind willreturn memory(write) "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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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