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

; Function Attrs: mustprogress uwtable
define dso_local void @GuiDummyRec(<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 %struct.Vector2, align 4
  %8 = alloca %struct.Vector2, align 4
  %9 = alloca %struct.Rectangle, align 4
  %10 = alloca %struct.Rectangle, align 4
  %11 = alloca %struct.Color, align 1
  %12 = alloca %struct.Color, align 1
  %13 = alloca %struct.Color, align 1
  %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
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = icmp ne i32 %21, 3
  br i1 %22, label %23, label %40

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

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

34:                                               ; preds = %26
  %35 = call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br i1 %35, label %36, label %37

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

37:                                               ; preds = %34
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %37, %36
  br label %39

39:                                               ; preds = %38, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %40

40:                                               ; preds = %39, %23, %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %4, i64 16, i1 false), !tbaa.struct !18
  %41 = getelementptr inbounds %struct.Color, ptr %11, i32 0, i32 0
  store i8 0, ptr %41, align 1, !tbaa !19
  %42 = getelementptr inbounds %struct.Color, ptr %11, i32 0, i32 1
  store i8 0, ptr %42, align 1, !tbaa !21
  %43 = getelementptr inbounds %struct.Color, ptr %11, i32 0, i32 2
  store i8 0, ptr %43, align 1, !tbaa !22
  %44 = getelementptr inbounds %struct.Color, ptr %11, i32 0, i32 3
  store i8 0, ptr %44, align 1, !tbaa !23
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 3
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, i32 1, i32 10
  %49 = call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %48)
  %50 = call i32 @GetColor(i32 noundef %49)
  store i32 %50, ptr %13, align 1
  %51 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !16
  %52 = load i32, ptr %13, align 1
  %53 = call i32 @Fade(i32 %52, float noundef %51)
  store i32 %53, ptr %12, align 1
  %54 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 0
  %55 = load <2 x float>, ptr %54, align 4
  %56 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 1
  %57 = load <2 x float>, ptr %56, align 4
  %58 = load i32, ptr %11, align 1
  %59 = load i32, ptr %12, align 1
  call void @_ZL16GuiDrawRectangle9Rectanglei5ColorS0_(<2 x float> %55, <2 x float> %57, i32 noundef 0, i32 %58, i32 %59)
  %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 !18
  %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 0, <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 = load i32, ptr %6, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 3
  %72 = zext i1 %71 to i64
  %73 = select i1 %71, i32 2, i32 11
  %74 = call i32 @GuiGetStyle(i32 noundef 2, 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 !16
  %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 1, i32 %83)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  ret void
}

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}
!19 = !{!20, !7, i64 0}
!20 = !{!"_ZTS5Color", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3}
!21 = !{!20, !7, i64 1}
!22 = !{!20, !7, i64 2}
!23 = !{!20, !7, i64 3}


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

; Function Attrs: mustprogress uwtable
define dso_local void @GuiDummyRec(<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 %.thread30, 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 %.thread30, 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 %.thread30

11:                                               ; preds = %8
  %12 = tail call zeroext i1 @IsMouseButtonDown(i32 noundef 0)
  br label %.thread30

.thread30:                                        ; preds = %5, %3, %11, %8
  %spec.select = phi i32 [ 2, %8 ], [ 2, %11 ], [ 11, %3 ], [ 2, %5 ]
  %13 = phi i32 [ 1, %8 ], [ 1, %11 ], [ 10, %3 ], [ 1, %5 ]
  %14 = tail call i32 @GuiGetStyle(i32 noundef 0, i32 noundef %13)
  %15 = tail call i32 @GetColor(i32 noundef %14)
  %16 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !13
  %17 = tail call i32 @Fade(i32 %15, float noundef %16)
  tail call void @_ZL16GuiDrawRectangle9Rectanglei5ColorS0_(<2 x float> %0, <2 x float> %1, i32 noundef 0, i32 0, i32 %17)
  %18 = tail call { <2 x float>, <2 x float> } @_ZL13GetTextBoundsi9Rectangle(i32 noundef 0, <2 x float> %0, <2 x float> %1)
  %19 = extractvalue { <2 x float>, <2 x float> } %18, 0
  %20 = extractvalue { <2 x float>, <2 x float> } %18, 1
  %21 = tail call i32 @GuiGetStyle(i32 noundef 2, i32 noundef %spec.select)
  %22 = tail call i32 @GetColor(i32 noundef %21)
  %23 = load float, ptr @_ZL8guiAlpha, align 4, !tbaa !13
  %24 = tail call i32 @Fade(i32 %22, float noundef %23)
  tail call void @_ZL11GuiDrawTextPKc9Rectanglei5Color(ptr noundef %2, <2 x float> %19, <2 x float> %20, i32 noundef 1, i32 %24)
  ret void
}

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,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass