; LLVM IR from Xingyu-Lin/softgym :: PyFlex/bindings/demo/imgui.ll (Z11imguiButtonPKcb)

; 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 }

@_ZL7g_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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20addGfxCmdRoundedRectfffffj(float noundef, float noundef, float noundef, float noundef, float noundef, i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL13addGfxCmdTextiiiPKcj(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #2

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

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

; 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) #3

; 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 @_Z11imguiButtonPKcb(ptr noundef %0, i1 noundef zeroext %1) #2 {
  %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 @_ZL7g_state, i32 0, i32 20), align 4, !tbaa !11
  %14 = add i32 %13, 1
  store i32 %14, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7g_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 @_ZL7g_state, i32 0, i32 19), align 4, !tbaa !15
  %16 = shl i32 %15, 16
  %17 = load i32, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7g_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 @_ZL7g_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 @_ZL7g_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 @_ZL7g_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 @_ZL7g_state, i32 0, i32 16), align 4, !tbaa !18
  %24 = sub nsw i32 %23, 24
  store i32 %24, ptr getelementptr inbounds (%struct.GuiState, ptr @_ZL7g_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 %6, align 4, !tbaa !16
  %42 = sitofp i32 %41 to float
  %43 = load i32, ptr %7, align 4, !tbaa !16
  %44 = sitofp i32 %43 to float
  %45 = load i32, ptr %8, align 4, !tbaa !16
  %46 = sitofp i32 %45 to float
  %47 = load i32, ptr %9, align 4, !tbaa !16
  %48 = sitofp i32 %47 to float
  %49 = load i32, ptr %5, align 4, !tbaa !16
  %50 = call noundef zeroext i1 @_Z8isActivej(i32 noundef %49)
  %51 = zext i1 %50 to i64
  %52 = select i1 %50, i32 196, i32 96
  %53 = trunc i32 %52 to i8
  %54 = call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext %53)
  call void @_ZL20addGfxCmdRoundedRectfffffj(float noundef %42, float noundef %44, float noundef %46, float noundef %48, float noundef 9.000000e+00, i32 noundef %54)
  %55 = load i8, ptr %4, align 1, !tbaa !9, !range !20, !noundef !21
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %72

57:                                               ; preds = %33
  %58 = load i32, ptr %6, align 4, !tbaa !16
  %59 = add nsw i32 %58, 10
  %60 = load i32, ptr %7, align 4, !tbaa !16
  %61 = add nsw i32 %60, 10
  %62 = sub nsw i32 %61, 4
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load i32, ptr %5, align 4, !tbaa !16
  %65 = call noundef zeroext i1 @_Z5isHotj(i32 noundef %64)
  br i1 %65, label %66, label %68

66:                                               ; preds = %57
  %67 = call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -60, i8 noundef zeroext 0, i8 noundef zeroext -1)
  br label %70

68:                                               ; preds = %57
  %69 = call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -56)
  br label %70

70:                                               ; preds = %68, %66
  %71 = phi i32 [ %67, %66 ], [ %69, %68 ]
  call void @_ZL13addGfxCmdTextiiiPKcj(i32 noundef %59, i32 noundef %62, i32 noundef 0, ptr noundef %63, i32 noundef %71)
  br label %80

72:                                               ; preds = %33
  %73 = load i32, ptr %6, align 4, !tbaa !16
  %74 = add nsw i32 %73, 10
  %75 = load i32, ptr %7, align 4, !tbaa !16
  %76 = add nsw i32 %75, 10
  %77 = sub nsw i32 %76, 4
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -56)
  call void @_ZL13addGfxCmdTextiiiPKcj(i32 noundef %74, i32 noundef %77, i32 noundef 0, ptr noundef %78, i32 noundef %79)
  br label %80

80:                                               ; preds = %72, %70
  %81 = load i8, ptr %11, align 1, !tbaa !9, !range !20, !noundef !21
  %82 = trunc i8 %81 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 %82
}

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 = { 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

@_ZL7g_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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL20addGfxCmdRoundedRectfffffj(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 @_Z9imguiRGBAhhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL13addGfxCmdTextiiiPKcj(i32 noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; 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 @_Z11imguiButtonPKcb(ptr noundef %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7g_state, i64 64), align 4, !tbaa !5
  %4 = add i32 %3, 1
  store i32 %4, ptr getelementptr inbounds (i8, ptr @_ZL7g_state, i64 64), align 4, !tbaa !5
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7g_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 @_ZL7g_state, i64 44), align 4, !tbaa !13
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7g_state, i64 48), align 4, !tbaa !14
  %10 = add nsw i32 %9, -20
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @_ZL7g_state, i64 52), align 4, !tbaa !15
  %12 = add nsw i32 %9, -24
  store i32 %12, ptr getelementptr inbounds (i8, ptr @_ZL7g_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 = sitofp i32 %8 to float
  %19 = sitofp i32 %10 to float
  %20 = sitofp i32 %11 to float
  %21 = tail call noundef zeroext i1 @_Z8isActivej(i32 noundef %7)
  %22 = select i1 %21, i8 -60, i8 96
  %23 = tail call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext %22)
  tail call void @_ZL20addGfxCmdRoundedRectfffffj(float noundef %18, float noundef %19, float noundef %20, float noundef 2.000000e+01, float noundef 9.000000e+00, i32 noundef %23)
  br i1 %1, label %24, label %30

24:                                               ; preds = %15
  %25 = tail call noundef zeroext i1 @_Z5isHotj(i32 noundef %7)
  br i1 %25, label %26, label %28

26:                                               ; preds = %24
  %27 = tail call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -60, i8 noundef zeroext 0, i8 noundef zeroext -1)
  br label %32

28:                                               ; preds = %24
  %29 = tail call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -1, i8 noundef zeroext -56)
  br label %32

30:                                               ; preds = %15
  %31 = tail call noundef i32 @_Z9imguiRGBAhhhh(i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -128, i8 noundef zeroext -56)
  br label %32

32:                                               ; preds = %26, %28, %30
  %.sink = phi i32 [ %31, %30 ], [ %27, %26 ], [ %29, %28 ]
  %33 = add nsw i32 %9, -14
  %34 = add nsw i32 %8, 10
  tail call void @_ZL13addGfxCmdTextiiiPKcj(i32 noundef %34, i32 noundef %33, 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 = { 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 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