; LLVM IR from godofecht/GANN-Object-Avoidance :: Box2D/Testbed/Framework/imgui.ll (Z9imguiItemPKcb)

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

@_ZL7s_state = external hidden global %struct.GuiState, align 4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6inRectiiiib(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) #0

declare void @_Z20AddGfxCmdRoundedRectfffffj(float noundef, float noundef, float noundef, float noundef, float noundef, i32 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #0

declare void @_Z13AddGfxCmdTextii9TextAlignPKcj(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL11buttonLogicjb(i32 noundef, i1 noundef zeroext) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z8isActivej(i32 noundef) #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5isHotj(i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9imguiItemPKcb(ptr noundef %0, i1 noundef zeroext %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %12 = zext i1 %1 to i8
  store i8 %12, ptr %4, align 1, !tbaa !9
  %13 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 20), align 4, !tbaa !11
  %14 = add i32 %13, 1
  store i32 %14, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 20), align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %15 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 19), align 4, !tbaa !15
  %16 = shl i32 %15, 16
  %17 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 20), align 4, !tbaa !11
  %18 = or i32 %16, %17
  store i32 %18, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %19 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 15), align 4, !tbaa !17
  store i32 %19, ptr %6, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 16), align 4, !tbaa !18
  %21 = sub nsw i32 %20, 20
  store i32 %21, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %22 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 17), align 4, !tbaa !19
  store i32 %22, ptr %8, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 20, ptr %9, align 4, !tbaa !16
  %23 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 16), align 4, !tbaa !18
  %24 = sub nsw i32 %23, 24
  store i32 %24, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7s_state, i32 0, i32 16), align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %25 = load i8, ptr %4, align 1, !tbaa !9, !range !20, !noundef !21
  %26 = trunc i8 %25 to i1
  br i1 %26, label %27, label %33

27:                                               ; preds = %2
  %28 = load i32, ptr %6, align 4, !tbaa !16
  %29 = load i32, ptr %7, align 4, !tbaa !16
  %30 = load i32, ptr %8, align 4, !tbaa !16
  %31 = load i32, ptr %9, align 4, !tbaa !16
  %32 = call noundef zeroext i1 @_Z6inRectiiiib(i32 noundef %28, i32 noundef %29, i32 noundef %30, i32 noundef %31, i1 noundef zeroext true)
  br label %33

33:                                               ; preds = %27, %2
  %34 = phi i1 [ false, %2 ], [ %32, %27 ]
  %35 = zext i1 %34 to i8
  store i8 %35, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %36 = load i32, ptr %5, align 4, !tbaa !16
  %37 = load i8, ptr %10, align 1, !tbaa !9, !range !20, !noundef !21
  %38 = trunc i8 %37 to i1
  %39 = call noundef zeroext i1 @_ZL11buttonLogicjb(i32 noundef %36, i1 noundef zeroext %38)
  %40 = zext i1 %39 to i8
  store i8 %40, ptr %11, align 1, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !16
  %42 = call noundef zeroext i1 @_Z5isHotj(i32 noundef %41)
  br i1 %42, label %43, label %58

43:                                               ; preds = %33
  %44 = load i32, ptr %6, align 4, !tbaa !16
  %45 = sitofp i32 %44 to float
  %46 = load i32, ptr %7, align 4, !tbaa !16
  %47 = sitofp i32 %46 to float
  %48 = load i32, ptr %8, align 4, !tbaa !16
  %49 = sitofp i32 %48 to float
  %50 = load i32, ptr %9, align 4, !tbaa !16
  %51 = sitofp i32 %50 to float
  %52 = load i32, ptr %5, align 4, !tbaa !16
  %53 = call noundef zeroext i1 @_Z8isActivej(i32 noundef %52)
  %54 = zext i1 %53 to i64
  %55 = select i1 %53, i32 196, i32 96
  %56 = trunc i32 %55 to i8
  %57 = call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -60, i8 noundef zeroext 0, i8 noundef zeroext %56)
  call void @_Z20AddGfxCmdRoundedRectfffffj(float noundef %45, float noundef %47, float noundef %49, float noundef %51, float noundef 2.000000e+00, i32 noundef %57)
  br label %58

58:                                               ; preds = %43, %33
  %59 = load i8, ptr %4, align 1, !tbaa !9, !range !20, !noundef !21
  %60 = trunc i8 %59 to i1
  br i1 %60, label %61, label %69

61:                                               ; preds = %58
  %62 = load i32, ptr %6, align 4, !tbaa !16
  %63 = add nsw i32 %62, 10
  %64 = load i32, ptr %7, align 4, !tbaa !16
  %65 = add nsw i32 %64, 10
  %66 = sub nsw i32 %65, 4
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -56)
  call void @_Z13AddGfxCmdTextii9TextAlignPKcj(i32 noundef %63, i32 noundef %66, i32 noundef 0, ptr noundef %67, i32 noundef %68)
  br label %77

69:                                               ; preds = %58
  %70 = load i32, ptr %6, align 4, !tbaa !16
  %71 = add nsw i32 %70, 10
  %72 = load i32, ptr %7, align 4, !tbaa !16
  %73 = add nsw i32 %72, 10
  %74 = sub nsw i32 %73, 4
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -56)
  call void @_Z13AddGfxCmdTextii9TextAlignPKcj(i32 noundef %71, i32 noundef %74, i32 noundef 0, ptr noundef %75, i32 noundef %76)
  br label %77

77:                                               ; preds = %69, %61
  %78 = load i8, ptr %11, align 1, !tbaa !9, !range !20, !noundef !21
  %79 = trunc i8 %78 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  ret i1 %79
}

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"bool", !7, i64 0}
!11 = !{!12, !13, i64 64}
!12 = !{!"_ZTS8GuiState", !10, i64 0, !10, i64 1, !10, i64 2, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !10, i64 28, !10, i64 29, !10, i64 30, !13, i64 32, !13, i64 36, !14, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !10, i64 56, !13, i64 60, !13, i64 64}
!13 = !{!"int", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !13, i64 60}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 44}
!18 = !{!12, !13, i64 48}
!19 = !{!12, !13, i64 52}
!20 = !{i8 0, i8 2}
!21 = !{}


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

@_ZL7s_state = external hidden local_unnamed_addr global %struct.GuiState, align 4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6inRectiiiib(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

declare void @_Z20AddGfxCmdRoundedRectfffffj(float noundef, float noundef, float noundef, float noundef, float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

declare void @_Z13AddGfxCmdTextii9TextAlignPKcj(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i1 @_ZL11buttonLogicjb(i32 noundef, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z8isActivej(i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5isHotj(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z9imguiItemPKcb(ptr noundef %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 64), align 4, !tbaa !5
  %4 = add i32 %3, 1
  store i32 %4, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 64), align 4, !tbaa !5
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 60), align 4, !tbaa !12
  %6 = shl i32 %5, 16
  %7 = or i32 %6, %4
  %8 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 44), align 4, !tbaa !13
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 48), align 4, !tbaa !14
  %10 = add nsw i32 %9, -20
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 52), align 4, !tbaa !15
  %12 = add nsw i32 %9, -24
  store i32 %12, ptr getelementptr inbounds (i8, ptr @_ZL7s_state, i64 48), align 4, !tbaa !14
  br i1 %1, label %13, label %15

13:                                               ; preds = %2
  %14 = tail call noundef zeroext i1 @_Z6inRectiiiib(i32 noundef %8, i32 noundef %10, i32 noundef %11, i32 noundef 20, i1 noundef zeroext true)
  br label %15

15:                                               ; preds = %13, %2
  %16 = phi i1 [ false, %2 ], [ %14, %13 ]
  %17 = tail call noundef zeroext i1 @_ZL11buttonLogicjb(i32 noundef %7, i1 noundef zeroext %16)
  %18 = tail call noundef zeroext i1 @_Z5isHotj(i32 noundef %7)
  br i1 %18, label %19, label %26

19:                                               ; preds = %15
  %20 = sitofp i32 %8 to float
  %21 = sitofp i32 %10 to float
  %22 = sitofp i32 %11 to float
  %23 = tail call noundef zeroext i1 @_Z8isActivej(i32 noundef %7)
  %24 = select i1 %23, i8 -60, i8 96
  %25 = tail call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -60, i8 noundef zeroext 0, i8 noundef zeroext %24)
  tail call void @_Z20AddGfxCmdRoundedRectfffffj(float noundef %20, float noundef %21, float noundef %22, float noundef 2.000000e+01, float noundef 2.000000e+00, i32 noundef %25)
  br label %26

26:                                               ; preds = %19, %15
  br i1 %1, label %27, label %29

27:                                               ; preds = %26
  %28 = tail call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -56)
  br label %31

29:                                               ; preds = %26
  %30 = tail call noundef i32 @_Z7SetRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -56)
  br label %31

31:                                               ; preds = %29, %27
  %.sink = phi i32 [ %30, %29 ], [ %28, %27 ]
  %32 = add nsw i32 %9, -14
  %33 = add nsw i32 %8, 10
  tail call void @_Z13AddGfxCmdTextii9TextAlignPKcj(i32 noundef %33, i32 noundef %32, i32 noundef 0, ptr noundef %0, i32 noundef %.sink)
  ret i1 %17
}

attributes #0 = { 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 #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 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" }

!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, !10, i64 64}
!6 = !{!"_ZTS8GuiState", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !10, i64 32, !10, i64 36, !11, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !7, i64 56, !10, i64 60, !10, i64 64}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 60}
!13 = !{!6, !10, i64 44}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 52}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass