; LLVM IR from mbrenman/TetrisPlayground :: agents/HeuristicAgent.ll (ZN14HeuristicAgent13valueOfActionEiiiiiib)

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

%class.HeuristicAgent = type { %class.Agent, [6 x double] }
%class.Agent = type { ptr }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN14HeuristicAgent13valueOfActionEiiiiiib(ptr noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7) #2 align 2 {
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  %17 = alloca double, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i32 %1, ptr %10, align 4, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  %18 = zext i1 %7 to i8
  store i8 %18, ptr %16, align 1, !tbaa !11
  %19 = load ptr, ptr %9, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %20 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds [6 x double], ptr %20, i64 0, i64 0
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = sitofp i32 %23 to double
  %25 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %26 = getelementptr inbounds [6 x double], ptr %25, i64 0, i64 1
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = load i32, ptr %12, align 4, !tbaa !9
  %29 = sitofp i32 %28 to double
  %30 = fmul double %27, %29
  %31 = call double @llvm.fmuladd.f64(double %22, double %24, double %30)
  %32 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %33 = getelementptr inbounds [6 x double], ptr %32, i64 0, i64 2
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = sitofp i32 %35 to double
  %37 = call double @llvm.fmuladd.f64(double %34, double %36, double %31)
  %38 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %39 = getelementptr inbounds [6 x double], ptr %38, i64 0, i64 3
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = sitofp i32 %41 to double
  %43 = call double @llvm.fmuladd.f64(double %40, double %42, double %37)
  %44 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %45 = getelementptr inbounds [6 x double], ptr %44, i64 0, i64 4
  %46 = load double, ptr %45, align 8, !tbaa !13
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = sitofp i32 %47 to double
  %49 = call double @llvm.fmuladd.f64(double %46, double %48, double %43)
  %50 = getelementptr inbounds %class.HeuristicAgent, ptr %19, i32 0, i32 1
  %51 = getelementptr inbounds [6 x double], ptr %50, i64 0, i64 5
  %52 = load double, ptr %51, align 8, !tbaa !13
  %53 = load i32, ptr %15, align 4, !tbaa !9
  %54 = sitofp i32 %53 to double
  %55 = call double @llvm.fmuladd.f64(double %52, double %54, double %49)
  store double %55, ptr %17, align 8, !tbaa !13
  %56 = load i8, ptr %16, align 1, !tbaa !11, !range !15, !noundef !16
  %57 = trunc i8 %56 to i1
  br i1 %57, label %58, label %61

58:                                               ; preds = %8
  %59 = load double, ptr %17, align 8, !tbaa !13
  %60 = fsub double %59, 1.000000e+03
  store double %60, ptr %17, align 8, !tbaa !13
  br label %61

61:                                               ; preds = %58, %8
  %62 = load double, ptr %17, align 8, !tbaa !13
  %63 = fptrunc double %62 to float
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  ret float %63
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef float @_ZN14HeuristicAgent13valueOfActionEiiiiiib(ptr nocapture noundef nonnull readonly align 8 dereferenceable(56) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6, i1 noundef zeroext %7) local_unnamed_addr #1 align 2 {
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = sitofp i32 %1 to double
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = sitofp i32 %3 to double
  %15 = fmul double %13, %14
  %16 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %15)
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = sitofp i32 %4 to double
  %20 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %16)
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = sitofp i32 %5 to double
  %24 = tail call double @llvm.fmuladd.f64(double %22, double %23, double %20)
  %25 = getelementptr inbounds i8, ptr %0, i64 40
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = sitofp i32 %2 to double
  %28 = tail call double @llvm.fmuladd.f64(double %26, double %27, double %24)
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = sitofp i32 %6 to double
  %32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %28)
  %33 = fadd double %32, -1.000000e+03
  %.0 = select i1 %7, double %33, double %32
  %34 = fptrunc double %.0 to float
  ret float %34
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass