; LLVM IR from xhub/reshop :: gui/external/imgui/imgui.ll (ZN5ImGui12CalcItemSizeE6ImVec2ff)

; 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 @_ZN6ImVec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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 nounwind uwtable
declare hidden noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef, float noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZN5ImGui21GetContentRegionAvailEv() #4

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZN5ImGui12CalcItemSizeE6ImVec2ff(<2 x float> %0, float noundef %1, float noundef %2) #4 {
  %4 = alloca %struct.ImVec2, align 4
  %5 = alloca %struct.ImVec2, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca %struct.ImVec2, align 4
  %9 = alloca %struct.ImVec2, align 4
  store <2 x float> %0, ptr %5, align 4
  store float %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @_ZN6ImVec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %8)
  %10 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = fcmp olt float %11, 0.000000e+00
  br i1 %12, label %17, label %13

13:                                               ; preds = %3
  %14 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  %15 = load float, ptr %14, align 4, !tbaa !11
  %16 = fcmp olt float %15, 0.000000e+00
  br i1 %16, label %17, label %19

17:                                               ; preds = %13, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = call <2 x float> @_ZN5ImGui21GetContentRegionAvailEv()
  store <2 x float> %18, ptr %9, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %19

19:                                               ; preds = %17, %13
  %20 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !9
  %22 = fcmp oeq float %21, 0.000000e+00
  br i1 %22, label %23, label %26

23:                                               ; preds = %19
  %24 = load float, ptr %6, align 4, !tbaa !5
  %25 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  store float %24, ptr %25, align 4, !tbaa !9
  br label %39

26:                                               ; preds = %19
  %27 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = fcmp olt float %28, 0.000000e+00
  br i1 %29, label %30, label %38

30:                                               ; preds = %26
  %31 = getelementptr inbounds %struct.ImVec2, ptr %8, i32 0, i32 0
  %32 = load float, ptr %31, align 4, !tbaa !9
  %33 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = fadd float %32, %34
  %36 = call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.000000e+00, float noundef %35)
  %37 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 0
  store float %36, ptr %37, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %30, %26
  br label %39

39:                                               ; preds = %38, %23
  %40 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !11
  %42 = fcmp oeq float %41, 0.000000e+00
  br i1 %42, label %43, label %46

43:                                               ; preds = %39
  %44 = load float, ptr %7, align 4, !tbaa !5
  %45 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  store float %44, ptr %45, align 4, !tbaa !11
  br label %59

46:                                               ; preds = %39
  %47 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !11
  %49 = fcmp olt float %48, 0.000000e+00
  br i1 %49, label %50, label %58

50:                                               ; preds = %46
  %51 = getelementptr inbounds %struct.ImVec2, ptr %8, i32 0, i32 1
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !11
  %55 = fadd float %52, %54
  %56 = call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.000000e+00, float noundef %55)
  %57 = getelementptr inbounds %struct.ImVec2, ptr %5, i32 0, i32 1
  store float %56, ptr %57, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %50, %46
  br label %59

59:                                               ; preds = %58, %43
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %60 = load <2 x float>, ptr %4, align 4
  ret <2 x float> %60
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS6ImVec2", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}


; 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 @_ZN6ImVec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) 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 nounwind uwtable
declare hidden noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef, float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZN5ImGui21GetContentRegionAvailEv() local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZN5ImGui12CalcItemSizeE6ImVec2ff(<2 x float> %0, float noundef %1, float noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.ImVec2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @_ZN6ImVec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %4)
  %.sroa.04.0.vec.extract = extractelement <2 x float> %0, i64 0
  %5 = fcmp olt float %.sroa.04.0.vec.extract, 0.000000e+00
  %.sroa.04.4.vec.extract22 = extractelement <2 x float> %0, i64 1
  %6 = fcmp olt float %.sroa.04.4.vec.extract22, 0.000000e+00
  %or.cond = select i1 %5, i1 true, i1 %6
  br i1 %or.cond, label %7, label %9

7:                                                ; preds = %3
  %8 = call <2 x float> @_ZN5ImGui21GetContentRegionAvailEv()
  store <2 x float> %8, ptr %4, align 8
  br label %9

9:                                                ; preds = %3, %7
  %10 = fcmp oeq float %.sroa.04.0.vec.extract, 0.000000e+00
  br i1 %10, label %11, label %12

11:                                               ; preds = %9
  %.sroa.04.0.vec.insert = insertelement <2 x float> %0, float %1, i64 0
  br label %17

12:                                               ; preds = %9
  br i1 %5, label %13, label %17

13:                                               ; preds = %12
  %14 = load float, ptr %4, align 8, !tbaa !5
  %15 = fadd float %.sroa.04.0.vec.extract, %14
  %16 = call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.000000e+00, float noundef %15)
  %.sroa.04.0.vec.insert13 = insertelement <2 x float> %0, float %16, i64 0
  br label %17

17:                                               ; preds = %12, %13, %11
  %.sroa.04.0 = phi <2 x float> [ %.sroa.04.0.vec.insert, %11 ], [ %.sroa.04.0.vec.insert13, %13 ], [ %0, %12 ]
  %.sroa.04.4.vec.extract = extractelement <2 x float> %.sroa.04.0, i64 1
  %18 = fcmp oeq float %.sroa.04.4.vec.extract, 0.000000e+00
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  %.sroa.04.4.vec.insert = insertelement <2 x float> %.sroa.04.0, float %2, i64 1
  br label %27

20:                                               ; preds = %17
  %21 = fcmp olt float %.sroa.04.4.vec.extract, 0.000000e+00
  br i1 %21, label %22, label %27

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %4, i64 4
  %24 = load float, ptr %23, align 4, !tbaa !10
  %25 = fadd float %.sroa.04.4.vec.extract, %24
  %26 = call noundef float @_ZL5ImMaxIfET_S0_S0_(float noundef 4.000000e+00, float noundef %25)
  %.sroa.04.4.vec.insert20 = insertelement <2 x float> %.sroa.04.0, float %26, i64 1
  br label %27

27:                                               ; preds = %20, %22, %19
  %.sroa.04.1 = phi <2 x float> [ %.sroa.04.4.vec.insert, %19 ], [ %.sroa.04.4.vec.insert20, %22 ], [ %.sroa.04.0, %20 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret <2 x float> %.sroa.04.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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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, !7, i64 0}
!6 = !{!"_ZTS6ImVec2", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass