; 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.Color = type { i8, i8, i8, i8 }
%struct.Rectangle = type { float, float, float, float }
%struct.Vector3 = type { 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: mustprogress uwtable
declare dso_local i32 @GuiGetStyle(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @GuiColorPanel(<2 x float>, <2 x float>, i32) #3

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

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

; Function Attrs: mustprogress uwtable
declare dso_local float @GuiColorBarHue(<2 x float>, <2 x float>, float noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @GuiColorPicker(<2 x float> %0, <2 x float> %1, i32 %2) #3 {
  %4 = alloca %struct.Color, align 1
  %5 = alloca %struct.Rectangle, align 4
  %6 = alloca %struct.Color, align 1
  %7 = alloca %struct.Color, align 1
  %8 = alloca %struct.Rectangle, align 4
  %9 = alloca %struct.Color, align 1
  %10 = alloca %struct.Rectangle, align 4
  %11 = alloca %struct.Vector3, align 4
  %12 = alloca %struct.Vector3, align 4
  %13 = alloca { <2 x float>, float }, align 4
  %14 = alloca { <2 x float>, float }, align 8
  %15 = alloca %struct.Rectangle, align 4
  %16 = alloca %struct.Vector3, align 4
  %17 = alloca %struct.Vector3, align 4
  %18 = alloca { <2 x float>, float }, align 4
  %19 = alloca { <2 x float>, float }, align 8
  %20 = alloca %struct.Color, align 1
  %21 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  store <2 x float> %0, ptr %21, align 4
  %22 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  store <2 x float> %1, ptr %22, align 4
  store i32 %2, ptr %6, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %5, i64 16, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 1 %6, i64 4, i1 false), !tbaa.struct !10
  %23 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 0
  %24 = load <2 x float>, ptr %23, align 4
  %25 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 1
  %26 = load <2 x float>, ptr %25, align 4
  %27 = load i32, ptr %9, align 1
  %28 = call i32 @GuiColorPanel(<2 x float> %24, <2 x float> %26, i32 %27)
  store i32 %28, ptr %7, align 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 %7, i64 4, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %29 = getelementptr inbounds %struct.Rectangle, ptr %10, i32 0, i32 0
  %30 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !12
  %32 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = fadd float %31, %33
  %35 = call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 18)
  %36 = sitofp i32 %35 to float
  %37 = fadd float %34, %36
  store float %37, ptr %29, align 4, !tbaa !12
  %38 = getelementptr inbounds %struct.Rectangle, ptr %10, i32 0, i32 1
  %39 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !15
  store float %40, ptr %38, align 4, !tbaa !15
  %41 = getelementptr inbounds %struct.Rectangle, ptr %10, i32 0, i32 2
  %42 = call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 17)
  %43 = sitofp i32 %42 to float
  store float %43, ptr %41, align 4, !tbaa !14
  %44 = getelementptr inbounds %struct.Rectangle, ptr %10, i32 0, i32 3
  %45 = getelementptr inbounds %struct.Rectangle, ptr %5, i32 0, i32 3
  %46 = load float, ptr %45, align 4, !tbaa !16
  store float %46, ptr %44, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #6
  %47 = getelementptr inbounds %struct.Vector3, ptr %12, i32 0, i32 0
  %48 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 0
  %49 = load i8, ptr %48, align 1, !tbaa !17
  %50 = zext i8 %49 to i32
  %51 = sitofp i32 %50 to float
  %52 = fdiv float %51, 2.550000e+02
  store float %52, ptr %47, align 4, !tbaa !19
  %53 = getelementptr inbounds %struct.Vector3, ptr %12, i32 0, i32 1
  %54 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 1
  %55 = load i8, ptr %54, align 1, !tbaa !21
  %56 = zext i8 %55 to i32
  %57 = sitofp i32 %56 to float
  %58 = fdiv float %57, 2.550000e+02
  store float %58, ptr %53, align 4, !tbaa !22
  %59 = getelementptr inbounds %struct.Vector3, ptr %12, i32 0, i32 2
  %60 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 2
  %61 = load i8, ptr %60, align 1, !tbaa !23
  %62 = zext i8 %61 to i32
  %63 = sitofp i32 %62 to float
  %64 = fdiv float %63, 2.550000e+02
  store float %64, ptr %59, align 4, !tbaa !24
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %12, i64 12, i1 false)
  %65 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 0
  %66 = load <2 x float>, ptr %65, align 4
  %67 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 1
  %68 = load float, ptr %67, align 4
  %69 = call { <2 x float>, float } @_ZL15ConvertRGBtoHSV7Vector3(<2 x float> %66, float %68)
  store { <2 x float>, float } %69, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %14, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %10, i64 16, i1 false), !tbaa.struct !5
  %70 = getelementptr inbounds %struct.Vector3, ptr %11, i32 0, i32 0
  %71 = load float, ptr %70, align 4, !tbaa !19
  %72 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 0
  %73 = load <2 x float>, ptr %72, align 4
  %74 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 1
  %75 = load <2 x float>, ptr %74, align 4
  %76 = call float @GuiColorBarHue(<2 x float> %73, <2 x float> %75, float noundef %71)
  %77 = getelementptr inbounds %struct.Vector3, ptr %11, i32 0, i32 0
  store float %76, ptr %77, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %11, i64 12, i1 false), !tbaa.struct !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %17, i64 12, i1 false)
  %78 = getelementptr inbounds { <2 x float>, float }, ptr %18, i32 0, i32 0
  %79 = load <2 x float>, ptr %78, align 4
  %80 = getelementptr inbounds { <2 x float>, float }, ptr %18, i32 0, i32 1
  %81 = load float, ptr %80, align 4
  %82 = call { <2 x float>, float } @_ZL15ConvertHSVtoRGB7Vector3(<2 x float> %79, float %81)
  store { <2 x float>, float } %82, ptr %19, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 8 %19, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %83 = getelementptr inbounds %struct.Color, ptr %20, i32 0, i32 0
  %84 = getelementptr inbounds %struct.Vector3, ptr %16, i32 0, i32 0
  %85 = load float, ptr %84, align 4, !tbaa !19
  %86 = fmul float %85, 2.550000e+02
  %87 = call float @llvm.round.f32(float %86)
  %88 = fptoui float %87 to i8
  store i8 %88, ptr %83, align 1, !tbaa !17
  %89 = getelementptr inbounds %struct.Color, ptr %20, i32 0, i32 1
  %90 = getelementptr inbounds %struct.Vector3, ptr %16, i32 0, i32 1
  %91 = load float, ptr %90, align 4, !tbaa !22
  %92 = fmul float %91, 2.550000e+02
  %93 = call float @llvm.round.f32(float %92)
  %94 = fptoui float %93 to i8
  store i8 %94, ptr %89, align 1, !tbaa !21
  %95 = getelementptr inbounds %struct.Color, ptr %20, i32 0, i32 2
  %96 = getelementptr inbounds %struct.Vector3, ptr %16, i32 0, i32 2
  %97 = load float, ptr %96, align 4, !tbaa !24
  %98 = fmul float %97, 2.550000e+02
  %99 = call float @llvm.round.f32(float %98)
  %100 = fptoui float %99 to i8
  store i8 %100, ptr %95, align 1, !tbaa !23
  %101 = getelementptr inbounds %struct.Color, ptr %20, i32 0, i32 3
  %102 = getelementptr inbounds %struct.Color, ptr %6, i32 0, i32 3
  %103 = load i8, ptr %102, align 1, !tbaa !26
  store i8 %103, ptr %101, align 1, !tbaa !26
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 %20, i64 4, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %4, ptr align 1 %6, i64 4, i1 false), !tbaa.struct !10
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  %104 = load i32, ptr %4, align 1
  ret i32 %104
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #5

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 = { mustprogress nounwind 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{i64 0, i64 1, !11, i64 1, i64 1, !11, i64 2, i64 1, !11, i64 3, i64 1, !11}
!11 = !{!8, !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTS9Rectangle", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!14 = !{!13, !7, i64 8}
!15 = !{!13, !7, i64 4}
!16 = !{!13, !7, i64 12}
!17 = !{!18, !8, i64 0}
!18 = !{!"_ZTS5Color", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3}
!19 = !{!20, !7, i64 0}
!20 = !{!"_ZTS7Vector3", !7, i64 0, !7, i64 4, !7, i64 8}
!21 = !{!18, !8, i64 1}
!22 = !{!20, !7, i64 4}
!23 = !{!18, !8, i64 2}
!24 = !{!20, !7, i64 8}
!25 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!26 = !{!18, !8, 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"

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @GuiColorPanel(<2 x float>, <2 x float>, i32) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden { <2 x float>, float } @_ZL15ConvertRGBtoHSV7Vector3(<2 x float>, float) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare hidden { <2 x float>, float } @_ZL15ConvertHSVtoRGB7Vector3(<2 x float>, float) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local float @GuiColorBarHue(<2 x float>, <2 x float>, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local i32 @GuiColorPicker(<2 x float> %0, <2 x float> %1, i32 %2) local_unnamed_addr #1 {
  %4 = tail call i32 @GuiColorPanel(<2 x float> %0, <2 x float> %1, i32 %2)
  %.sroa.632.0.extract.shift33 = lshr i32 %4, 8
  %.sroa.8.0.extract.shift35 = lshr i32 %4, 16
  %.sroa.10.0.extract.shift37 = and i32 %4, -16777216
  %5 = fadd <2 x float> %0, %1
  %6 = extractelement <2 x float> %5, i64 0
  %7 = tail call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 18)
  %8 = sitofp i32 %7 to float
  %9 = fadd float %6, %8
  %.sroa.022.4.vec.insert = insertelement <2 x float> %0, float %9, i64 0
  %10 = tail call i32 @GuiGetStyle(i32 noundef 13, i32 noundef 17)
  %11 = sitofp i32 %10 to float
  %.sroa.524.12.vec.insert = insertelement <2 x float> %1, float %11, i64 0
  %12 = insertelement <2 x i32> poison, i32 %4, i64 0
  %13 = insertelement <2 x i32> %12, i32 %.sroa.632.0.extract.shift33, i64 1
  %14 = and <2 x i32> %13, <i32 255, i32 255>
  %15 = uitofp nneg <2 x i32> %14 to <2 x float>
  %16 = fdiv <2 x float> %15, <float 2.550000e+02, float 2.550000e+02>
  %17 = and i32 %.sroa.8.0.extract.shift35, 255
  %18 = uitofp nneg i32 %17 to float
  %19 = fdiv float %18, 2.550000e+02
  %20 = tail call { <2 x float>, float } @_ZL15ConvertRGBtoHSV7Vector3(<2 x float> %16, float %19)
  %.fca.0.extract10 = extractvalue { <2 x float>, float } %20, 0
  %.fca.1.extract11 = extractvalue { <2 x float>, float } %20, 1
  %.sroa.018.0.vec.extract = extractelement <2 x float> %.fca.0.extract10, i64 0
  %21 = tail call float @GuiColorBarHue(<2 x float> %.sroa.022.4.vec.insert, <2 x float> %.sroa.524.12.vec.insert, float noundef %.sroa.018.0.vec.extract)
  %.sroa.018.0.vec.insert = insertelement <2 x float> %.fca.0.extract10, float %21, i64 0
  %22 = tail call { <2 x float>, float } @_ZL15ConvertHSVtoRGB7Vector3(<2 x float> %.sroa.018.0.vec.insert, float %.fca.1.extract11)
  %.fca.0.extract = extractvalue { <2 x float>, float } %22, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %22, 1
  %.sroa.06.0.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 0
  %23 = fmul float %.sroa.06.0.vec.extract, 2.550000e+02
  %24 = tail call float @llvm.round.f32(float %23)
  %25 = fptoui float %24 to i8
  %.sroa.06.4.vec.extract = extractelement <2 x float> %.fca.0.extract, i64 1
  %26 = fmul float %.sroa.06.4.vec.extract, 2.550000e+02
  %27 = tail call float @llvm.round.f32(float %26)
  %28 = fptoui float %27 to i8
  %29 = fmul float %.fca.1.extract, 2.550000e+02
  %30 = tail call float @llvm.round.f32(float %29)
  %31 = fptoui float %30 to i8
  %.sroa.345.0.insert.ext = zext i8 %31 to i32
  %.sroa.345.0.insert.shift = shl nuw nsw i32 %.sroa.345.0.insert.ext, 16
  %.sroa.345.0.insert.insert = or disjoint i32 %.sroa.345.0.insert.shift, %.sroa.10.0.extract.shift37
  %.sroa.244.0.insert.ext = zext i8 %28 to i32
  %.sroa.244.0.insert.shift = shl nuw nsw i32 %.sroa.244.0.insert.ext, 8
  %.sroa.244.0.insert.insert = or disjoint i32 %.sroa.345.0.insert.insert, %.sroa.244.0.insert.shift
  %.sroa.043.0.insert.ext = zext i8 %25 to i32
  %.sroa.043.0.insert.insert = or disjoint i32 %.sroa.244.0.insert.insert, %.sroa.043.0.insert.ext
  ret i32 %.sroa.043.0.insert.insert
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #3

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 = { mustprogress nounwind 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 #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass