; LLVM IR from paroj/gltut :: glsdk/freeglut/progs/demos/spaceball (spaceball)

; 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.vec3_t = type { float, float, float }

@pos = external dso_local global %struct.vec3_t, align 4

; Function Attrs: nounwind uwtable
define dso_local void @sbmot(i32 noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sitofp i32 %7 to float
  %9 = load float, ptr @pos, align 4, !tbaa !9
  %10 = call float @llvm.fmuladd.f32(float %8, float 0x3F50624DE0000000, float %9)
  store float %10, ptr @pos, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sitofp i32 %11 to float
  %13 = load float, ptr getelementptr inbounds (%struct.vec3_t, ptr @pos, i32 0, i32 1), align 4, !tbaa !12
  %14 = call float @llvm.fmuladd.f32(float %12, float 0x3F50624DE0000000, float %13)
  store float %14, ptr getelementptr inbounds (%struct.vec3_t, ptr @pos, i32 0, i32 1), align 4, !tbaa !12
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = sitofp i32 %15 to float
  %17 = load float, ptr getelementptr inbounds (%struct.vec3_t, ptr @pos, i32 0, i32 2), align 4, !tbaa !13
  %18 = fneg float %16
  %19 = call float @llvm.fmuladd.f32(float %18, float 0x3F50624DE0000000, float %17)
  store float %19, ptr getelementptr inbounds (%struct.vec3_t, ptr @pos, i32 0, i32 2), align 4, !tbaa !13
  call void @glutPostRedisplay()
  ret void
}

declare void @glutPostRedisplay() #1

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

attributes #0 = { 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 #1 = { "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 = { 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}


; 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.vec3_t = type { float, float, float }

@pos = external dso_local local_unnamed_addr global %struct.vec3_t, align 4

; Function Attrs: nounwind uwtable
define dso_local void @sbmot(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = insertelement <2 x i32> poison, i32 %0, i64 0
  %5 = insertelement <2 x i32> %4, i32 %1, i64 1
  %6 = sitofp <2 x i32> %5 to <2 x float>
  %7 = load <2 x float>, ptr @pos, align 4, !tbaa !5
  %8 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %6, <2 x float> <float 0x3F50624DE0000000, float 0x3F50624DE0000000>, <2 x float> %7)
  store <2 x float> %8, ptr @pos, align 4, !tbaa !5
  %9 = sitofp i32 %2 to float
  %10 = load float, ptr getelementptr inbounds (i8, ptr @pos, i64 8), align 4, !tbaa !9
  %11 = fneg float %9
  %12 = tail call float @llvm.fmuladd.f32(float %11, float 0x3F50624DE0000000, float %10)
  store float %12, ptr getelementptr inbounds (i8, ptr @pos, i64 8), align 4, !tbaa !9
  tail call void @glutPostRedisplay() #4
  ret void
}

declare void @glutPostRedisplay() local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { 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 #1 = { "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass