; LLVM IR from Devaniti/BoolkaEngine :: ThirdParty/imgui/imgui_widgets.ll (ZN16ImGuiMenuColumns6UpdateEifb)

; 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.ImGuiMenuColumns = type { float, float, float, [3 x float], [3 x float] }

@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.153 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN16ImGuiMenuColumns6UpdateEifb = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN16ImGuiMenuColumns6UpdateEifb(ptr noundef nonnull align 4 dereferenceable(36) %0, i32 noundef %1, float noundef %2, i1 noundef zeroext %3) #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  %10 = zext i1 %3 to i8
  store i8 %10, ptr %8, align 1, !tbaa !13
  %11 = load ptr, ptr %5, align 8
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 3
  br i1 %13, label %14, label %15

14:                                               ; preds = %4
  br label %17

15:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.153, ptr noundef @.str.1, i32 noundef 6461, ptr noundef @__PRETTY_FUNCTION__._ZN16ImGuiMenuColumns6UpdateEifb) #4
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 2
  store float 0.000000e+00, ptr %18, align 4, !tbaa !15
  %19 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 1
  store float 0.000000e+00, ptr %19, align 4, !tbaa !17
  %20 = load float, ptr %7, align 4, !tbaa !11
  %21 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 0
  store float %20, ptr %21, align 4, !tbaa !18
  %22 = load i8, ptr %8, align 1, !tbaa !13, !range !19, !noundef !20
  %23 = trunc i8 %22 to i1
  br i1 %23, label %24, label %27

24:                                               ; preds = %17
  %25 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 4
  %26 = getelementptr inbounds [3 x float], ptr %25, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %26, i8 0, i64 12, i1 false)
  br label %27

27:                                               ; preds = %24, %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %69, %27
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 3
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %28
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %35, label %48

35:                                               ; preds = %32
  %36 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 4
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [3 x float], ptr %36, i64 0, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = fcmp ogt float %40, 0.000000e+00
  br i1 %41, label %42, label %48

42:                                               ; preds = %35
  %43 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 0
  %44 = load float, ptr %43, align 4, !tbaa !18
  %45 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !17
  %47 = fadd float %46, %44
  store float %47, ptr %45, align 4, !tbaa !17
  br label %48

48:                                               ; preds = %42, %35, %32
  %49 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 1
  %50 = load float, ptr %49, align 4, !tbaa !17
  %51 = fptosi float %50 to i32
  %52 = sitofp i32 %51 to float
  %53 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 3
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [3 x float], ptr %53, i64 0, i64 %55
  store float %52, ptr %56, align 4, !tbaa !11
  %57 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 4
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [3 x float], ptr %57, i64 0, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !11
  %62 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 1
  %63 = load float, ptr %62, align 4, !tbaa !17
  %64 = fadd float %63, %61
  store float %64, ptr %62, align 4, !tbaa !17
  %65 = getelementptr inbounds %struct.ImGuiMenuColumns, ptr %11, i32 0, i32 4
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [3 x float], ptr %65, i64 0, i64 %67
  store float 0.000000e+00, ptr %68, align 4, !tbaa !11
  br label %69

69:                                               ; preds = %48
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %9, align 4, !tbaa !9
  br label %28, !llvm.loop !21

72:                                               ; preds = %31
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { noreturn nounwind }
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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !12, i64 8}
!16 = !{!"_ZTS16ImGuiMenuColumns", !12, i64 0, !12, i64 4, !12, i64 8, !7, i64 12, !7, i64 24}
!17 = !{!16, !12, i64 4}
!18 = !{!16, !12, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !22}
!22 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.153 = external hidden unnamed_addr constant [47 x i8], align 1
@__PRETTY_FUNCTION__._ZN16ImGuiMenuColumns6UpdateEifb = external hidden unnamed_addr constant [48 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN16ImGuiMenuColumns6UpdateEifb(ptr nocapture noundef nonnull align 4 dereferenceable(36) %0, i32 noundef %1, float noundef %2, i1 noundef zeroext %3) local_unnamed_addr #1 align 2 {
  %5 = icmp eq i32 %1, 3
  br i1 %5, label %7, label %6

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.153, ptr noundef nonnull @.str.1, i32 noundef 6461, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN16ImGuiMenuColumns6UpdateEifb) #2
  unreachable

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store float 0.000000e+00, ptr %8, align 4, !tbaa !5
  store float %2, ptr %0, align 4, !tbaa !10
  br i1 %3, label %11, label %._crit_edge17

._crit_edge17:                                    ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %.pre.pre = load float, ptr %9, align 4, !tbaa !11
  %10 = fadd float %.pre.pre, 0.000000e+00
  br label %13

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 28
  store i64 0, ptr %12, align 4
  br label %13

13:                                               ; preds = %._crit_edge17, %11
  %.pre = phi float [ %10, %._crit_edge17 ], [ 0.000000e+00, %11 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = getelementptr inbounds i8, ptr %0, i64 24
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  store float 0.000000e+00, ptr %16, align 4, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %0, i64 28
  %18 = load float, ptr %17, align 4, !tbaa !11
  %19 = fcmp ogt float %18, 0.000000e+00
  %20 = fadd float %.pre, %2
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  store <2 x float> zeroinitializer, ptr %15, align 4, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %0, i64 32
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = fcmp ogt float %23, 0.000000e+00
  %25 = select i1 %19, float %20, float %.pre
  %26 = fadd float %25, %18
  %27 = fadd float %26, %2
  %28 = select i1 %24, float %27, float %26
  %29 = insertelement <2 x float> poison, float %25, i64 0
  %30 = insertelement <2 x float> %29, float %28, i64 1
  %31 = fptosi <2 x float> %30 to <2 x i32>
  %32 = sitofp <2 x i32> %31 to <2 x float>
  store <2 x float> %32, ptr %21, align 4, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  %34 = fadd float %28, %23
  store float 0.000000e+00, ptr %33, align 4, !tbaa !11
  store float %34, ptr %14, align 4, !tbaa !12
  ret void
}

attributes #0 = { noreturn 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 #1 = { 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 = { noreturn 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 8}
!6 = !{!"_ZTS16ImGuiMenuColumns", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!6, !7, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass