; LLVM IR from Devaniti/BoolkaEngine :: ThirdParty/imgui/imgui_draw.ll (ZN20ImDrawListSharedData24SetCircleSegmentMaxErrorEf)

; 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.ImDrawListSharedData = type { %struct.ImVec2, ptr, float, float, float, %struct.ImVec4, i32, [12 x %struct.ImVec2], [64 x i8], ptr }
%struct.ImVec2 = type { float, float }
%struct.ImVec4 = type { float, float, 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: mustprogress uwtable
define dso_local void @_ZN20ImDrawListSharedData24SetCircleSegmentMaxErrorEf(ptr noundef nonnull align 8 dereferenceable(216) %0, float noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, 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
  %9 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %8, i32 0, i32 4
  %10 = load float, ptr %9, align 8, !tbaa !11
  %11 = load float, ptr %4, align 4, !tbaa !9
  %12 = fcmp oeq float %10, %11
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %45

14:                                               ; preds = %2
  %15 = load float, ptr %4, align 4, !tbaa !9
  %16 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %8, i32 0, i32 4
  store float %15, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !16
  br label %17

17:                                               ; preds = %42, %14
  %18 = load i32, ptr %5, align 4, !tbaa !16
  %19 = icmp slt i32 %18, 64
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %45

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %22 = load i32, ptr %5, align 4, !tbaa !16
  %23 = sitofp i32 %22 to float
  %24 = fadd float %23, 1.000000e+00
  store float %24, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %25 = load float, ptr %6, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %8, i32 0, i32 4
  %27 = load float, ptr %26, align 8, !tbaa !11
  %28 = fsub float %25, %27
  %29 = load float, ptr %6, align 4, !tbaa !9
  %30 = fdiv float %28, %29
  %31 = call float @acosf(float noundef %30) #4
  %32 = fdiv float 0x401921FB60000000, %31
  %33 = fptosi float %32 to i32
  %34 = call noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef %33, i32 noundef 12, i32 noundef 512)
  store i32 %34, ptr %7, align 4, !tbaa !16
  %35 = load i32, ptr %7, align 4, !tbaa !16
  %36 = call noundef i32 @_ZL5ImMinIiET_S0_S0_(i32 noundef %35, i32 noundef 255)
  %37 = trunc i32 %36 to i8
  %38 = getelementptr inbounds %struct.ImDrawListSharedData, ptr %8, i32 0, i32 8
  %39 = load i32, ptr %5, align 4, !tbaa !16
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [64 x i8], ptr %38, i64 0, i64 %40
  store i8 %37, ptr %41, align 1, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %42

42:                                               ; preds = %21
  %43 = load i32, ptr %5, align 4, !tbaa !16
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !16
  br label %17, !llvm.loop !18

45:                                               ; preds = %20, %13
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare float @acosf(float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5ImMinIiET_S0_S0_(i32 noundef, i32 noundef) #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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTS20ImDrawListSharedData", !13, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !14, i64 28, !15, i64 44, !7, i64 48, !7, i64 144, !6, i64 208}
!13 = !{!"_ZTS6ImVec2", !10, i64 0, !10, i64 4}
!14 = !{!"_ZTS6ImVec4", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!15 = !{!"int", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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: mustprogress nounwind uwtable
define dso_local void @_ZN20ImDrawListSharedData24SetCircleSegmentMaxErrorEf(ptr nocapture noundef nonnull align 8 dereferenceable(216) %0, float noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = fcmp oeq float %4, %1
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %2
  store float %1, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  br label %8

8:                                                ; preds = %6, %8
  %indvars.iv = phi i64 [ 0, %6 ], [ %indvars.iv.next, %8 ]
  %9 = trunc nuw nsw i64 %indvars.iv to i32
  %10 = uitofp nneg i32 %9 to float
  %11 = fadd float %10, 1.000000e+00
  %12 = load float, ptr %3, align 8, !tbaa !5
  %13 = fsub float %11, %12
  %14 = fdiv float %13, %11
  %15 = tail call float @acosf(float noundef %14) #3
  %16 = fdiv float 0x401921FB60000000, %15
  %17 = fptosi float %16 to i32
  %18 = tail call noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef %17, i32 noundef 12, i32 noundef 512)
  %19 = tail call noundef i32 @_ZL5ImMinIiET_S0_S0_(i32 noundef %18, i32 noundef 255)
  %20 = trunc i32 %19 to i8
  %21 = getelementptr inbounds [64 x i8], ptr %7, i64 0, i64 %indvars.iv
  store i8 %20, ptr %21, align 1, !tbaa !14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.loopexit, label %8, !llvm.loop !15

.loopexit:                                        ; preds = %8, %2
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL7ImClampIiET_S0_S0_S0_(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL5ImMinIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { 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 #2 = { 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 #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, !8, i64 24}
!6 = !{!"_ZTS20ImDrawListSharedData", !7, i64 0, !11, i64 8, !8, i64 16, !8, i64 20, !8, i64 24, !12, i64 28, !13, i64 44, !9, i64 48, !9, i64 144, !11, i64 208}
!7 = !{!"_ZTS6ImVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS6ImVec4", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12}
!13 = !{!"int", !9, i64 0}
!14 = !{!9, !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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