; LLVM IR from mbrenman/TetrisPlayground :: Train.ll (Z14evaluatePlayerP5Agent)

; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

declare void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824), i1 noundef zeroext) unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

; 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
define dso_local noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %0) #4 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %25, %1
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 5
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %32

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %13 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 824) #7
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %13, i1 noundef zeroext true)
          to label %14 unwind label %28

14:                                               ; preds = %12
  store ptr %13, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_Z8playGameP6TetrisP5Agentb(ptr noundef %15, ptr noundef %16, i1 noundef zeroext false)
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %17)
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = add nsw i32 %19, %18
  store i32 %20, ptr %3, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %14
  call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %21) #6
  call void @_ZdlPvm(ptr noundef %21, i64 noundef 824) #8
  br label %24

24:                                               ; preds = %23, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %4, align 4, !tbaa !9
  br label %8, !llvm.loop !11

28:                                               ; preds = %12
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %6, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %7, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 824) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %36

32:                                               ; preds = %11
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = sitofp i32 %33 to double
  %35 = fdiv double %34, 5.000000e+00
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret double %35

36:                                               ; preds = %28
  %37 = load ptr, ptr %6, align 8
  %38 = load i32, ptr %7, align 4
  %39 = insertvalue { ptr, i32 } poison, ptr %37, 0
  %40 = insertvalue { ptr, i32 } %39, i32 %38, 1
  resume { ptr, i32 } %40
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8playGameP6TetrisP5Agentb(ptr noundef, ptr noundef, i1 noundef zeroext) #4

; Function Attrs: nounwind
declare void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824)) unnamed_addr #5

declare noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = distinct !{!11, !12}
!12 = !{!"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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

declare void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824), i1 noundef zeroext) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %0) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %2 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #5
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %2, i1 noundef zeroext true)
          to label %3 unwind label %23

3:                                                ; preds = %1
  tail call void @_Z8playGameP6TetrisP5Agentb(ptr noundef nonnull %2, ptr noundef %0, i1 noundef zeroext false)
  %4 = tail call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %2)
  tail call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %2) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %2, i64 noundef 824) #7
  %5 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #5
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %5, i1 noundef zeroext true)
          to label %6 unwind label %23

6:                                                ; preds = %3
  tail call void @_Z8playGameP6TetrisP5Agentb(ptr noundef nonnull %5, ptr noundef %0, i1 noundef zeroext false)
  %7 = tail call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %5)
  tail call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %5) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 824) #7
  %8 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #5
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %8, i1 noundef zeroext true)
          to label %9 unwind label %23

9:                                                ; preds = %6
  tail call void @_Z8playGameP6TetrisP5Agentb(ptr noundef nonnull %8, ptr noundef %0, i1 noundef zeroext false)
  %10 = tail call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %8)
  tail call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %8) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 824) #7
  %11 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #5
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %11, i1 noundef zeroext true)
          to label %12 unwind label %23

12:                                               ; preds = %9
  tail call void @_Z8playGameP6TetrisP5Agentb(ptr noundef nonnull %11, ptr noundef %0, i1 noundef zeroext false)
  %13 = tail call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %11)
  tail call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %11) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 824) #7
  %14 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #5
  invoke void @_ZN6TetrisC1Eb(ptr noundef nonnull align 8 dereferenceable(824) %14, i1 noundef zeroext true)
          to label %15 unwind label %23

15:                                               ; preds = %12
  %16 = add nsw i32 %7, %4
  %17 = add nsw i32 %10, %16
  %18 = add nsw i32 %13, %17
  tail call void @_Z8playGameP6TetrisP5Agentb(ptr noundef nonnull %14, ptr noundef %0, i1 noundef zeroext false)
  %19 = tail call noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824) %14)
  %20 = add nsw i32 %19, %18
  tail call void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824) %14) #6
  tail call void @_ZdlPvm(ptr noundef nonnull %14, i64 noundef 824) #7
  %21 = sitofp i32 %20 to double
  %22 = fdiv double %21, 5.000000e+00
  ret double %22

23:                                               ; preds = %12, %9, %6, %3, %1
  %.lcssa = phi ptr [ %2, %1 ], [ %5, %3 ], [ %8, %6 ], [ %11, %9 ], [ %14, %12 ]
  %24 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %.lcssa, i64 noundef 824) #7
  resume { ptr, i32 } %24
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8playGameP6TetrisP5Agentb(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZN6TetrisD1Ev(ptr noundef nonnull align 8 dereferenceable(824)) unnamed_addr #4

declare noundef i32 @_ZN6Tetris15getLinesClearedEv(ptr noundef nonnull align 8 dereferenceable(824)) local_unnamed_addr #1

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin 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 = { 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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
attributes #7 = { builtin 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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass