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

; 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

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @GuiButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) #3 {
  %4 = alloca %struct.Rectangle, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca %struct.Vector2, align 4
  %9 = alloca %struct.Vector2, align 4
  %10 = alloca %struct.Rectangle, align 4
  %11 = alloca %struct.Rectangle, align 4
  %12 = alloca %struct.Color, align 1
  %13 = alloca %struct.Color, align 1
  %14 = alloca %struct.Color, align 1
  %15 = alloca %struct.Color, align 1
  %16 = alloca %struct.Rectangle, align 4
  %17 = alloca %struct.Rectangle, align 4
  %18 = alloca %struct.Color, align 1
  %19 = alloca %struct.Color, align 1
  %20 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %0, ptr %20, align 4
  %21 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %1, ptr %21, align 4
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %22 = load i32, ptr @_ZL8guiState, align 4, !tbaa !9
  store i32 %22, 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
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 3
  br i1 %24, label %25, label %45

25:                                               ; preds = %3
  %26 = load i8, ptr @_ZL9guiLocked, align 1, !tbaa !11, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  br i1 %27, label %45, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %29 = call <2 x float> @GetMousePosition()
  store <2 x float> %29, ptr %8, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !15
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !18
  %30 = load <2 x float>, ptr %9, align 4
  %31 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 0
  %32 = load <2 x float>, ptr %31, align 4
  %33 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 1
  %34 = load <2 x float>, ptr %33, align 4
  %35 = call zeroext i1 @CheckCollisionPointRec(<2 x float> %30, <2 x float> %32, <2 x float> %34)
  br i1 %35, label %36, label %44

36:                                               ; preds = %28
  %37 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %37, label %38, label %39

38:                                               ; preds = %36
  store i32 2, ptr %6, align 4, !tbaa !9
  br label %40

39:                                               ; preds = %36
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %39, %38
  %41 = call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br i1 %41, label %42, label %43

42:                                               ; preds = %40
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %43

43:                                               ; preds = %42, %40
  br label %44

44:                                               ; preds = %43, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %45

45:                                               ; preds = %44, %25, %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !18
  %46 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef 12)
  %47 = load i32, ptr %6, align 4, !tbaa !9
  %48 = mul nsw i32 %47, 3
  %49 = add nsw i32 0, %48
  %50 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %49)
  %51 = call i32 @GetColor(i32 noundef %50)
  store i32 %51, ptr %13, align 1
  %52 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !16
  %53 = load i32, ptr %13, align 1
  %54 = call i32 @Fade(i32 %53, float noundef %52)
  store i32 %54, ptr %12, align 1
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = mul nsw i32 %55, 3
  %57 = add nsw i32 1, %56
  %58 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %57)
  %59 = call i32 @GetColor(i32 noundef %58)
  store i32 %59, ptr %15, align 1
  %60 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !16
  %61 = load i32, ptr %15, align 1
  %62 = call i32 @Fade(i32 %61, float noundef %60)
  store i32 %62, ptr %14, align 1
  %63 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 0
  %64 = load <2 x float>, ptr %63, align 4
  %65 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %11, i32 0, i32 1
  %66 = load <2 x float>, ptr %65, align 4
  %67 = load i32, ptr %12, align 1
  %68 = load i32, ptr %14, align 1
  call void @_ZL16GuiDrawRectangle9Rectanglei5ColorS0_(<2 x float> %64, <2 x float> %66, i32 noundef %46, i32 %67, i32 %68)
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !18
  %70 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %17, i32 0, i32 0
  %71 = load <2 x float>, ptr %70, align 4
  %72 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %17, i32 0, i32 1
  %73 = load <2 x float>, ptr %72, align 4
  %74 = call { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef 2, <2 x float> %71, <2 x float> %73)
  %75 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 0
  %76 = extractvalue { <2 x float>, <2 x float> } %74, 0
  store <2 x float> %76, ptr %75, align 4
  %77 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 1
  %78 = extractvalue { <2 x float>, <2 x float> } %74, 1
  store <2 x float> %78, ptr %77, align 4
  %79 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef 14)
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = mul nsw i32 %80, 3
  %82 = add nsw i32 2, %81
  %83 = call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %82)
  %84 = call i32 @GetColor(i32 noundef %83)
  store i32 %84, ptr %19, align 1
  %85 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !16
  %86 = load i32, ptr %19, align 1
  %87 = call i32 @Fade(i32 %86, float noundef %85)
  store i32 %87, ptr %18, align 1
  %88 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 0
  %89 = load <2 x float>, ptr %88, align 4
  %90 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 1
  %91 = load <2 x float>, ptr %90, align 4
  %92 = load i32, ptr %18, align 1
  call void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef %69, <2 x float> %89, <2 x float> %91, i32 noundef %79, i32 %92)
  %93 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %94 = trunc i8 %93 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  ret i1 %94
}

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

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

declare i32 @GetColor(i32 noundef) #4

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

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

declare zeroext i1 @IsMouseButtonDown(i32 noundef) #4

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

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

declare zeroext i1 @IsMouseButtonReleased(i32 noundef) #4

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 = { 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 = { "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 = !{i8 0, i8 2}
!14 = !{}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16, i64 12, i64 4, !16}


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

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

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

; Function Attrs: mustprogress uwtable
define dso_local zeroext i1 @GuiButton(<2 x float> %0, <2 x float> %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = load i32, ptr @_ZL8guiState, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 3
  br i1 %.not, label %14, label %5

5:                                                ; preds = %3
  %6 = load i8, ptr @_ZL9guiLocked, align 1, !tbaa !9, !range !11, !noundef !12
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %14, label %8

8:                                                ; preds = %5
  %9 = tail call <2 x float> @GetMousePosition()
  %10 = tail call zeroext i1 @CheckCollisionPointRec(<2 x float> %9, <2 x float> %0, <2 x float> %1)
  br i1 %10, label %11, label %14

11:                                               ; preds = %8
  %12 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  %. = select i1 %12, i32 2, i32 1
  %13 = tail call zeroext i1 @IsMouseButtonReleased(i32 noundef 0)
  br label %14

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL16GuiDrawRectangle9Rectanglei5ColorS0_(<2 x float>, <2 x float>, i32 noundef, i32, i32) 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 #1

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

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

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

!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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}


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