; LLVM IR from godofecht/GANN-Object-Avoidance :: Box2D/Testbed/Framework/RenderGL3.ll (Z13AddGfxCmdLinefffffj)

; 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.GfxCmd = type { i8, i8, [2 x i8], i32, %union.anon }
%union.anon = type { %struct.GfxText }
%struct.GfxText = type { float, float, i32, ptr }
%struct.GfxLine = type { i16, i16, i16, i16, i16 }

@_ZL17g_gfxCmdQueueSize = external hidden global i32, align 4
@_ZL13g_gfxCmdQueue = external hidden global [5000 x %struct.GfxCmd], align 16

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13AddGfxCmdLinefffffj(float noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, i32 noundef %5) #1 {
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  store float %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !5
  store float %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !9
  %14 = load i32, ptr @_ZL17g_gfxCmdQueueSize, align 4, !tbaa !9
  %15 = icmp uge i32 %14, 5000
  br i1 %15, label %16, label %17

16:                                               ; preds = %6
  br label %59

17:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %18 = load i32, ptr @_ZL17g_gfxCmdQueueSize, align 4, !tbaa !9
  %19 = add i32 %18, 1
  store i32 %19, ptr @_ZL17g_gfxCmdQueueSize, align 4, !tbaa !9
  %20 = zext i32 %18 to i64
  %21 = getelementptr inbounds [5000 x %struct.GfxCmd], ptr @_ZL13g_gfxCmdQueue, i64 0, i64 %20
  store ptr %21, ptr %13, align 8, !tbaa !11
  %22 = load ptr, ptr %13, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.GfxCmd, ptr %22, i32 0, i32 0
  store i8 2, ptr %23, align 8, !tbaa !13
  %24 = load ptr, ptr %13, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.GfxCmd, ptr %24, i32 0, i32 1
  store i8 0, ptr %25, align 1, !tbaa !15
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = load ptr, ptr %13, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.GfxCmd, ptr %27, i32 0, i32 3
  store i32 %26, ptr %28, align 4, !tbaa !16
  %29 = load float, ptr %7, align 4, !tbaa !5
  %30 = fmul float %29, 8.000000e+00
  %31 = fptosi float %30 to i16
  %32 = load ptr, ptr %13, align 8, !tbaa !11
  %33 = getelementptr inbounds %struct.GfxCmd, ptr %32, i32 0, i32 4
  %34 = getelementptr inbounds %struct.GfxLine, ptr %33, i32 0, i32 0
  store i16 %31, ptr %34, align 8, !tbaa !17
  %35 = load float, ptr %8, align 4, !tbaa !5
  %36 = fmul float %35, 8.000000e+00
  %37 = fptosi float %36 to i16
  %38 = load ptr, ptr %13, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.GfxCmd, ptr %38, i32 0, i32 4
  %40 = getelementptr inbounds %struct.GfxLine, ptr %39, i32 0, i32 1
  store i16 %37, ptr %40, align 2, !tbaa !17
  %41 = load float, ptr %9, align 4, !tbaa !5
  %42 = fmul float %41, 8.000000e+00
  %43 = fptosi float %42 to i16
  %44 = load ptr, ptr %13, align 8, !tbaa !11
  %45 = getelementptr inbounds %struct.GfxCmd, ptr %44, i32 0, i32 4
  %46 = getelementptr inbounds %struct.GfxLine, ptr %45, i32 0, i32 2
  store i16 %43, ptr %46, align 4, !tbaa !17
  %47 = load float, ptr %10, align 4, !tbaa !5
  %48 = fmul float %47, 8.000000e+00
  %49 = fptosi float %48 to i16
  %50 = load ptr, ptr %13, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.GfxCmd, ptr %50, i32 0, i32 4
  %52 = getelementptr inbounds %struct.GfxLine, ptr %51, i32 0, i32 3
  store i16 %49, ptr %52, align 2, !tbaa !17
  %53 = load float, ptr %11, align 4, !tbaa !5
  %54 = fmul float %53, 8.000000e+00
  %55 = fptosi float %54 to i16
  %56 = load ptr, ptr %13, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.GfxCmd, ptr %56, i32 0, i32 4
  %58 = getelementptr inbounds %struct.GfxLine, ptr %57, i32 0, i32 4
  store i16 %55, ptr %58, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  br label %59

59:                                               ; preds = %17, %16
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"float", !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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"_ZTS6GfxCmd", !7, i64 0, !7, i64 1, !7, i64 2, !10, i64 4, !7, i64 8}
!15 = !{!14, !7, i64 1}
!16 = !{!14, !10, i64 4}
!17 = !{!7, !7, i64 0}


; 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.GfxCmd = type { i8, i8, [2 x i8], i32, %union.anon }
%union.anon = type { %struct.GfxText }
%struct.GfxText = type { float, float, i32, ptr }

@_ZL17g_gfxCmdQueueSize = external hidden local_unnamed_addr global i32, align 4
@_ZL13g_gfxCmdQueue = external hidden local_unnamed_addr global [5000 x %struct.GfxCmd], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z13AddGfxCmdLinefffffj(float noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = load i32, ptr @_ZL17g_gfxCmdQueueSize, align 4, !tbaa !5
  %8 = icmp ugt i32 %7, 4999
  br i1 %8, label %25, label %9

9:                                                ; preds = %6
  %10 = add nuw nsw i32 %7, 1
  store i32 %10, ptr @_ZL17g_gfxCmdQueueSize, align 4, !tbaa !5
  %11 = zext nneg i32 %7 to i64
  %12 = getelementptr inbounds [5000 x %struct.GfxCmd], ptr @_ZL13g_gfxCmdQueue, i64 0, i64 %11
  store i8 2, ptr %12, align 16, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %12, i64 1
  store i8 0, ptr %13, align 1, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %12, i64 4
  store i32 %5, ptr %14, align 4, !tbaa !12
  %15 = insertelement <4 x float> poison, float %0, i64 0
  %16 = insertelement <4 x float> %15, float %1, i64 1
  %17 = insertelement <4 x float> %16, float %2, i64 2
  %18 = insertelement <4 x float> %17, float %3, i64 3
  %19 = fmul <4 x float> %18, <float 8.000000e+00, float 8.000000e+00, float 8.000000e+00, float 8.000000e+00>
  %20 = getelementptr inbounds i8, ptr %12, i64 8
  %21 = fptosi <4 x float> %19 to <4 x i16>
  store <4 x i16> %21, ptr %20, align 8, !tbaa !13
  %22 = fmul float %4, 8.000000e+00
  %23 = fptosi float %22 to i16
  %24 = getelementptr inbounds i8, ptr %12, i64 16
  store i16 %23, ptr %24, align 16, !tbaa !13
  br label %25

25:                                               ; preds = %6, %9
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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" }

!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, !7, i64 0}
!10 = !{!"_ZTS6GfxCmd", !7, i64 0, !7, i64 1, !7, i64 2, !6, i64 4, !7, i64 8}
!11 = !{!10, !7, i64 1}
!12 = !{!10, !6, i64 4}
!13 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass