; LLVM IR from mrbid/CSGO_TENSOR_TRIGGER :: GOBOT15/TBVGG3 (aim)

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

; 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: nounwind uwtable
define dso_local float @TBVGG3_RandomWeight() #1 {
  %1 = alloca float, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  %4 = call i32 @rand() #4
  %5 = sitofp i32 %4 to float
  %6 = fmul float %5, 0x3E00000000000000
  %7 = call float @llvm.fmuladd.f32(float %6, float 2.000000e+00, float -1.000000e+00)
  store float %7, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %8 = call i32 @rand() #4
  %9 = sitofp i32 %8 to float
  %10 = fmul float %9, 0x3E00000000000000
  %11 = call float @llvm.fmuladd.f32(float %10, float 2.000000e+00, float -1.000000e+00)
  store float %11, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %12 = load float, ptr %1, align 4, !tbaa !5
  %13 = load float, ptr %1, align 4, !tbaa !5
  %14 = load float, ptr %2, align 4, !tbaa !5
  %15 = load float, ptr %2, align 4, !tbaa !5
  %16 = fmul float %14, %15
  %17 = call float @llvm.fmuladd.f32(float %12, float %13, float %16)
  store float %17, ptr %3, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %26, %0
  %19 = load float, ptr %3, align 4, !tbaa !5
  %20 = fcmp oeq float %19, 0.000000e+00
  br i1 %20, label %24, label %21

21:                                               ; preds = %18
  %22 = load float, ptr %3, align 4, !tbaa !5
  %23 = fcmp ogt float %22, 1.000000e+00
  br label %24

24:                                               ; preds = %21, %18
  %25 = phi i1 [ true, %18 ], [ %23, %21 ]
  br i1 %25, label %26, label %41

26:                                               ; preds = %24
  %27 = call i32 @rand() #4
  %28 = sitofp i32 %27 to float
  %29 = fmul float %28, 0x3E00000000000000
  %30 = call float @llvm.fmuladd.f32(float %29, float 2.000000e+00, float -1.000000e+00)
  store float %30, ptr %1, align 4, !tbaa !5
  %31 = call i32 @rand() #4
  %32 = sitofp i32 %31 to float
  %33 = fmul float %32, 0x3E00000000000000
  %34 = call float @llvm.fmuladd.f32(float %33, float 2.000000e+00, float -1.000000e+00)
  store float %34, ptr %2, align 4, !tbaa !5
  %35 = load float, ptr %1, align 4, !tbaa !5
  %36 = load float, ptr %1, align 4, !tbaa !5
  %37 = load float, ptr %2, align 4, !tbaa !5
  %38 = load float, ptr %2, align 4, !tbaa !5
  %39 = fmul float %37, %38
  %40 = call float @llvm.fmuladd.f32(float %35, float %36, float %39)
  store float %40, ptr %3, align 4, !tbaa !5
  br label %18, !llvm.loop !9

41:                                               ; preds = %24
  %42 = load float, ptr %1, align 4, !tbaa !5
  %43 = load float, ptr %3, align 4, !tbaa !5
  %44 = call float @logf(float noundef %43) #4
  %45 = fmul float -2.000000e+00, %44
  %46 = load float, ptr %3, align 4, !tbaa !5
  %47 = fdiv float %45, %46
  %48 = call float @sqrtf(float noundef %47) #4
  %49 = fmul float %42, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret float %49
}

; Function Attrs: nounwind
declare i32 @rand() #2

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

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

; Function Attrs: nounwind
declare float @logf(float noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 "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 = { 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 = distinct !{!9, !10}
!10 = !{!"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: nounwind uwtable
define dso_local float @TBVGG3_RandomWeight() local_unnamed_addr #0 {
  %1 = tail call i32 @rand() #4
  %2 = sitofp i32 %1 to float
  %3 = fmul float %2, 0x3E00000000000000
  %4 = tail call float @llvm.fmuladd.f32(float %3, float 2.000000e+00, float -1.000000e+00)
  %5 = tail call i32 @rand() #4
  %6 = sitofp i32 %5 to float
  %7 = fmul float %6, 0x3E00000000000000
  %8 = tail call float @llvm.fmuladd.f32(float %7, float 2.000000e+00, float -1.000000e+00)
  %9 = fmul float %8, %8
  %10 = tail call float @llvm.fmuladd.f32(float %4, float %4, float %9)
  %11 = fcmp oeq float %10, 0.000000e+00
  %12 = fcmp ogt float %10, 1.000000e+00
  %13 = or i1 %11, %12
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %14 = tail call i32 @rand() #4
  %15 = sitofp i32 %14 to float
  %16 = fmul float %15, 0x3E00000000000000
  %17 = tail call float @llvm.fmuladd.f32(float %16, float 2.000000e+00, float -1.000000e+00)
  %18 = tail call i32 @rand() #4
  %19 = sitofp i32 %18 to float
  %20 = fmul float %19, 0x3E00000000000000
  %21 = tail call float @llvm.fmuladd.f32(float %20, float 2.000000e+00, float -1.000000e+00)
  %22 = fmul float %21, %21
  %23 = tail call float @llvm.fmuladd.f32(float %17, float %17, float %22)
  %24 = fcmp oeq float %23, 0.000000e+00
  %25 = fcmp ogt float %23, 1.000000e+00
  %26 = or i1 %24, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.013.lcssa = phi float [ %4, %0 ], [ %17, %.lr.ph ]
  %.0.lcssa = phi float [ %10, %0 ], [ %23, %.lr.ph ]
  %27 = tail call float @logf(float noundef %.0.lcssa) #4
  %28 = fmul float %27, -2.000000e+00
  %29 = fdiv float %28, %.0.lcssa
  %30 = tail call float @sqrtf(float noundef %29) #4
  %31 = fmul float %.013.lcssa, %30
  ret float %31
}

; Function Attrs: nounwind
declare i32 @rand() 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: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #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 = { nounwind "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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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