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

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local zeroext i1 @GuiToggle(<2 x float>, <2 x float>, ptr noundef, i1 noundef zeroext) #4

; Function Attrs: mustprogress uwtable
define dso_local i32 @GuiToggleGroup(<2 x float> %0, <2 x float> %1, ptr noundef %2, i32 noundef %3) #4 {
  %5 = alloca %struct.Rectangle, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca [32 x i32], align 16
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %struct.Rectangle, align 4
  %15 = alloca %struct.Rectangle, align 4
  %16 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  store <2 x float> %0, ptr %16, align 4
  %17 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  store <2 x float> %1, ptr %17, align 4
  store ptr %2, ptr %6, align 8, !tbaa !5
  store i32 %3, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %18 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !11
  store float %19, ptr %8, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 128, ptr %9) #6
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 128, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 0
  %22 = call noundef ptr @_ZL12GuiTextSplitPKcPiS1_(ptr noundef %20, ptr noundef %10, ptr noundef %21)
  store ptr %22, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %23 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 0
  %24 = load i32, ptr %23, align 16, !tbaa !9
  store i32 %24, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %92, %4
  %26 = load i32, ptr %13, align 4, !tbaa !9
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %95

30:                                               ; preds = %25
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !9
  %36 = icmp ne i32 %31, %35
  br i1 %36, label %37, label %52

37:                                               ; preds = %30
  %38 = load float, ptr %8, align 4, !tbaa !14
  %39 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  store float %38, ptr %39, align 4, !tbaa !11
  %40 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 3
  %41 = load float, ptr %40, align 4, !tbaa !15
  %42 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %43 = sitofp i32 %42 to float
  %44 = fadd float %41, %43
  %45 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !16
  %47 = fadd float %46, %44
  store float %47, ptr %45, align 4, !tbaa !16
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [32 x i32], ptr %9, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !9
  store i32 %51, ptr %12, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %37, %30
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = icmp eq i32 %53, %54
  br i1 %55, label %56, label %67

56:                                               ; preds = %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %5, i64 16, i1 false), !tbaa.struct !17
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds ptr, ptr %57, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !5
  %62 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 0
  %63 = load <2 x float>, ptr %62, align 4
  %64 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 1
  %65 = load <2 x float>, ptr %64, align 4
  %66 = call zeroext i1 @GuiToggle(<2 x float> %63, <2 x float> %65, ptr noundef %61, i1 noundef zeroext true)
  br label %83

67:                                               ; preds = %52
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %5, i64 16, i1 false), !tbaa.struct !17
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i32, ptr %13, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds ptr, ptr %68, i64 %70
  %72 = load ptr, ptr %71, align 8, !tbaa !5
  %73 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 0
  %74 = load <2 x float>, ptr %73, align 4
  %75 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 1
  %76 = load <2 x float>, ptr %75, align 4
  %77 = call zeroext i1 @GuiToggle(<2 x float> %74, <2 x float> %76, ptr noundef %72, i1 noundef zeroext false)
  %78 = zext i1 %77 to i32
  %79 = icmp eq i32 %78, 1
  br i1 %79, label %80, label %82

80:                                               ; preds = %67
  %81 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %81, ptr %7, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %80, %67
  br label %83

83:                                               ; preds = %82, %56
  %84 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 2
  %85 = load float, ptr %84, align 4, !tbaa !18
  %86 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %87 = sitofp i32 %86 to float
  %88 = fadd float %85, %87
  %89 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %90 = load float, ptr %89, align 4, !tbaa !11
  %91 = fadd float %90, %88
  store float %91, ptr %89, align 4, !tbaa !11
  br label %92

92:                                               ; preds = %83
  %93 = load i32, ptr %13, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %13, align 4, !tbaa !9
  br label %25, !llvm.loop !19

95:                                               ; preds = %29
  %96 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  ret i32 %96
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL12GuiTextSplitPKcPiS1_(ptr noundef, ptr noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 = { 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 #6 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS9Rectangle", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 12}
!16 = !{!12, !13, i64 4}
!17 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14}
!18 = !{!12, !13, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local zeroext i1 @GuiToggle(<2 x float>, <2 x float>, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @GuiToggleGroup(<2 x float> %0, <2 x float> %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca [32 x i32], align 16
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %5) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(128) %5, i8 0, i64 128, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  %7 = call noundef ptr @_ZL12GuiTextSplitPKcPiS1_(ptr noundef %2, ptr noundef nonnull %6, ptr noundef nonnull %5)
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %10 = load i32, ptr %5, align 16, !tbaa !5
  %.sroa.9.12.vec.extract = extractelement <2 x float> %1, i64 1
  %.sroa.9.8.vec.extract = extractelement <2 x float> %1, i64 0
  br label %11

._crit_edge:                                      ; preds = %30, %4
  %.0.lcssa = phi i32 [ %3, %4 ], [ %.1, %30 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #5
  ret i32 %.0.lcssa

11:                                               ; preds = %.lr.ph, %30
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %30 ]
  %.sroa.016.033 = phi <2 x float> [ %0, %.lr.ph ], [ %.sroa.016.0.vec.insert23, %30 ]
  %.032 = phi i32 [ %3, %.lr.ph ], [ %.1, %30 ]
  %.02731 = phi i32 [ %10, %.lr.ph ], [ %.128, %30 ]
  %12 = getelementptr inbounds [32 x i32], ptr %5, i64 0, i64 %indvars.iv
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %.not = icmp eq i32 %.02731, %13
  br i1 %.not, label %20, label %14

14:                                               ; preds = %11
  %15 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %16 = sitofp i32 %15 to float
  %17 = fadd float %.sroa.9.12.vec.extract, %16
  %.sroa.016.4.vec.extract = extractelement <2 x float> %.sroa.016.033, i64 1
  %18 = fadd float %.sroa.016.4.vec.extract, %17
  %.sroa.016.4.vec.insert = insertelement <2 x float> %0, float %18, i64 1
  %19 = load i32, ptr %12, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %14, %11
  %.128 = phi i32 [ %19, %14 ], [ %.02731, %11 ]
  %.sroa.016.1 = phi <2 x float> [ %.sroa.016.4.vec.insert, %14 ], [ %.sroa.016.033, %11 ]
  %21 = zext i32 %.032 to i64
  %22 = icmp eq i64 %indvars.iv, %21
  %23 = getelementptr inbounds ptr, ptr %7, i64 %indvars.iv
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  br i1 %22, label %25, label %27

25:                                               ; preds = %20
  %26 = call zeroext i1 @GuiToggle(<2 x float> %.sroa.016.1, <2 x float> %1, ptr noundef %24, i1 noundef zeroext true)
  br label %30

27:                                               ; preds = %20
  %28 = call zeroext i1 @GuiToggle(<2 x float> %.sroa.016.1, <2 x float> %1, ptr noundef %24, i1 noundef zeroext false)
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  %spec.select = select i1 %28, i32 %29, i32 %.032
  br label %30

30:                                               ; preds = %27, %25
  %.1 = phi i32 [ %.032, %25 ], [ %spec.select, %27 ]
  %31 = call i32 @GuiGetStyle(i32 noundef 3, i32 noundef 16)
  %32 = sitofp i32 %31 to float
  %33 = fadd float %.sroa.9.8.vec.extract, %32
  %.sroa.016.0.vec.extract21 = extractelement <2 x float> %.sroa.016.1, i64 0
  %34 = fadd float %.sroa.016.0.vec.extract21, %33
  %.sroa.016.0.vec.insert23 = insertelement <2 x float> %.sroa.016.1, float %34, i64 0
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %indvars.iv.next, %36
  br i1 %37, label %11, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL12GuiTextSplitPKcPiS1_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass