; LLVM IR from VTIvanov20/eight-ball-pool :: src (main)

; 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.Font = type { i32, i32, i32, %struct.Texture, ptr, ptr }
%struct.Texture = type { i32, i32, i32, i32, i32 }
%struct.Rectangle = type { float, float, float, float }
%struct.Vector2 = type { float, float }
%struct.Color = type { i8, i8, i8, i8 }

@_ZL8guiState = external hidden global i32, align 4
@_ZL9guiLocked = external hidden global i8, align 1
@_ZL8guiAlpha = external hidden global float, align 4
@_ZL7guiFont = external hidden global %struct.Font, align 8

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) #2

declare i32 @Fade(i32, float noundef) #3

declare i32 @GetColor(i32 noundef) #3

declare <2 x float> @GetMousePosition() #3

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) #3

declare zeroext i1 @IsMouseButtonDown(i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) #4

; Function Attrs: mustprogress uwtable
declare hidden { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef, <2 x float>, <2 x float>) #4

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @GuiLabelButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) #4 {
  %4 = alloca %struct.Rectangle, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca float, align 4
  %9 = alloca %struct.Vector2, align 4
  %10 = alloca %struct.Font, align 8
  %11 = alloca %struct.Vector2, align 4
  %12 = alloca %struct.Vector2, align 4
  %13 = alloca %struct.Rectangle, align 4
  %14 = alloca %struct.Rectangle, align 4
  %15 = alloca %struct.Rectangle, align 4
  %16 = alloca %struct.Color, align 1
  %17 = alloca %struct.Color, align 1
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %18, align 4
  %19 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %19, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %20 = load i32, ptr @_ZL8guiState, align 4, !tbaa !9
  store i32 %20, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  store i8 0, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 @_ZL7guiFont, i64 48, i1 false), !tbaa.struct !13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %23 = sitofp i32 %22 to float
  %24 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 17)
  %25 = sitofp i32 %24 to float
  %26 = call <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8 %10, ptr noundef %21, float noundef %23, float noundef %25)
  store <2 x float> %26, ptr %9, align 4
  %27 = getelementptr inbounds %struct.Vector2, ptr %9, i32 0, i32 0
  %28 = load float, ptr %27, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  store float %28, ptr %8, align 4, !tbaa !19
  %29 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  %30 = load float, ptr %29, align 4, !tbaa !20
  %31 = load float, ptr %8, align 4, !tbaa !19
  %32 = fcmp olt float %30, %31
  br i1 %32, label %33, label %36

33:                                               ; preds = %3
  %34 = load float, ptr %8, align 4, !tbaa !19
  %35 = getelementptr inbounds %struct.Rectangle, ptr %4, i32 0, i32 2
  store float %34, ptr %35, align 4, !tbaa !20
  br label %36

36:                                               ; preds = %33, %3
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 3
  br i1 %38, label %39, label %59

39:                                               ; preds = %36
  %40 = load i8, ptr @_ZL9guiLocked, align 1, !tbaa !11, !range !22, !noundef !23
  %41 = trunc i8 %40 to i1
  br i1 %41, label %59, label %42

42:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %43 = call <2 x float> @GetMousePosition()
  store <2 x float> %43, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !24
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !25
  %44 = load <2 x float>, ptr %12, align 4
  %45 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 0
  %46 = load <2 x float>, ptr %45, align 4
  %47 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 1
  %48 = load <2 x float>, ptr %47, align 4
  %49 = call zeroext i1 @CheckCollisionPointRec(<2 x float> %44, <2 x float> %46, <2 x float> %48)
  br i1 %49, label %50, label %58

50:                                               ; preds = %42
  %51 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %51, label %52, label %53

52:                                               ; preds = %50
  store i32 2, ptr %6, align 4, !tbaa !9
  br label %54

53:                                               ; preds = %50
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %53, %52
  %55 = call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br i1 %55, label %56, label %57

56:                                               ; preds = %54
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %57

57:                                               ; preds = %56, %54
  br label %58

58:                                               ; preds = %57, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %59

59:                                               ; preds = %58, %39, %36
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !25
  %61 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 0
  %62 = load <2 x float>, ptr %61, align 4
  %63 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 1
  %64 = load <2 x float>, ptr %63, align 4
  %65 = call { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef 1, <2 x float> %62, <2 x float> %64)
  %66 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 0
  %67 = extractvalue { <2 x float>, <2 x float> } %65, 0
  store <2 x float> %67, ptr %66, align 4
  %68 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 1
  %69 = extractvalue { <2 x float>, <2 x float> } %65, 1
  store <2 x float> %69, ptr %68, align 4
  %70 = call i32 @GuiGetStyle(i32 noundef 1, i32 noundef 14)
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = mul nsw i32 %71, 3
  %73 = add nsw i32 2, %72
  %74 = call i32 @GuiGetStyle(i32 noundef 1, i32 noundef %73)
  %75 = call i32 @GetColor(i32 noundef %74)
  store i32 %75, ptr %17, align 1
  %76 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !19
  %77 = load i32, ptr %17, align 1
  %78 = call i32 @Fade(i32 %77, float noundef %76)
  store i32 %78, ptr %16, align 1
  %79 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 0
  %80 = load <2 x float>, ptr %79, align 4
  %81 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 1
  %82 = load <2 x float>, ptr %81, align 4
  %83 = load i32, ptr %16, align 1
  call void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef %60, <2 x float> %80, <2 x float> %82, i32 noundef %70, i32 %83)
  %84 = load i8, ptr %7, align 1, !tbaa !11, !range !22, !noundef !23
  %85 = trunc i8 %84 to i1
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  ret i1 %85
}

declare <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8, ptr noundef, float noundef, float noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS15GuiControlState", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14, i64 16, i64 4, !14, i64 20, i64 4, !14, i64 24, i64 4, !14, i64 28, i64 4, !14, i64 32, i64 8, !5, i64 40, i64 8, !5}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !18, i64 0}
!17 = !{!"_ZTS7Vector2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!21, !18, i64 8}
!21 = !{!"_ZTS9Rectangle", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{i64 0, i64 4, !19, i64 4, i64 4, !19}
!25 = !{i64 0, i64 4, !19, i64 4, i64 4, !19, i64 8, i64 4, !19, i64 12, i64 4, !19}


; 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.Font = type { i32, i32, i32, %struct.Texture, ptr, ptr }
%struct.Texture = type { i32, i32, i32, i32, i32 }

@_ZL8guiState = external hidden local_unnamed_addr global i32, align 4
@_ZL9guiLocked = external hidden local_unnamed_addr global i8, align 1
@_ZL8guiAlpha = external hidden local_unnamed_addr global float, align 4
@_ZL7guiFont = external hidden local_unnamed_addr global %struct.Font, align 8

; Function Attrs: mustprogress 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) #0

; Function Attrs: mustprogress uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @Fade(i32, float noundef) local_unnamed_addr #2

declare i32 @GetColor(i32 noundef) local_unnamed_addr #2

declare <2 x float> @GetMousePosition() local_unnamed_addr #2

declare zeroext i1 @CheckCollisionPointRec(<2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #2

declare zeroext i1 @IsMouseButtonDown(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef, <2 x float>, <2 x float>, i32 noundef, i32) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef, <2 x float>, <2 x float>) local_unnamed_addr #3

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @GuiLabelButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.Font, align 8
  %5 = load i32, ptr @_ZL8guiState, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(48) @_ZL7guiFont, i64 48, i1 false), !tbaa.struct !9
  %6 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 16)
  %7 = sitofp i32 %6 to float
  %8 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef 17)
  %9 = sitofp i32 %8 to float
  %10 = tail call <2 x float> @MeasureTextEx(ptr noundef nonnull byval(%struct.Font) align 8 %4, ptr noundef %2, float noundef %7, float noundef %9)
  %.sroa.09.0.vec.extract = extractelement <2 x float> %10, i64 0
  %.sroa.3.8.vec.extract = extractelement <2 x float> %1, i64 0
  %11 = fcmp olt float %.sroa.3.8.vec.extract, %.sroa.09.0.vec.extract
  %sel = select i1 %11, <2 x float> %10, <2 x float> %1
  %.sroa.3.0 = shufflevector <2 x float> %sel, <2 x float> %1, <2 x i32> <i32 0, i32 3>
  %.not = icmp eq i32 %5, 3
  br i1 %.not, label %21, label %12

12:                                               ; preds = %3
  %13 = load i8, ptr @_ZL9guiLocked, align 1, !tbaa !14, !range !16, !noundef !17
  %14 = trunc nuw i8 %13 to i1
  br i1 %14, label %21, label %15

15:                                               ; preds = %12
  %16 = tail call <2 x float> @GetMousePosition()
  %17 = tail call zeroext i1 @CheckCollisionPointRec(<2 x float> %16, <2 x float> %0, <2 x float> %.sroa.3.0)
  br i1 %17, label %18, label %21

18:                                               ; preds = %15
  %19 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  %. = select i1 %19, i32 2, i32 1
  %20 = tail call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br label %21

21:                                               ; preds = %18, %15, %12, %3
  %.121 = phi i1 [ false, %12 ], [ false, %3 ], [ false, %15 ], [ %20, %18 ]
  %.2 = phi i32 [ %5, %12 ], [ 3, %3 ], [ %5, %15 ], [ %., %18 ]
  %22 = tail call { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef 1, <2 x float> %0, <2 x float> %.sroa.3.0)
  %23 = extractvalue { <2 x float>, <2 x float> } %22, 0
  %24 = extractvalue { <2 x float>, <2 x float> } %22, 1
  %25 = tail call i32 @GuiGetStyle(i32 noundef 1, i32 noundef 14)
  %26 = mul nsw i32 %.2, 3
  %27 = add nsw i32 %26, 2
  %28 = tail call i32 @GuiGetStyle(i32 noundef 1, i32 noundef %27)
  %29 = tail call i32 @GetColor(i32 noundef %28)
  %30 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !18
  %31 = tail call i32 @Fade(i32 %29, float noundef %30)
  tail call void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef %2, <2 x float> %23, <2 x float> %24, i32 noundef %25, i32 %31)
  ret i1 %.121
}

declare <2 x float> @MeasureTextEx(ptr noundef byval(%struct.Font) align 8, ptr noundef, float noundef, float noundef) local_unnamed_addr #2

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

!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 = !{!"_ZTS15GuiControlState", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10, i64 16, i64 4, !10, i64 20, i64 4, !10, i64 24, i64 4, !10, i64 28, i64 4, !10, i64 32, i64 8, !12, i64 40, i64 8, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}


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