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

; 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.playerWithScore = type <{ ptr, double, i32, [4 x i8] }>

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z16randomPopulationv() #1 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca %struct.playerWithScore, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  %8 = call noalias noundef nonnull ptr @_Znam(i64 noundef 240) #7
  %9 = getelementptr inbounds %struct.playerWithScore, ptr %8, i64 10
  br label %10

10:                                               ; preds = %12, %0
  %11 = phi ptr [ %8, %0 ], [ %13, %12 ]
  invoke void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %11)
          to label %12 unwind label %20

12:                                               ; preds = %10
  %13 = getelementptr inbounds %struct.playerWithScore, ptr %11, i64 1
  %14 = icmp eq ptr %13, %9
  br i1 %14, label %15, label %10

15:                                               ; preds = %12
  store ptr %8, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %34, %15
  %17 = load i32, ptr %4, align 4, !tbaa !9
  %18 = icmp slt i32 %17, 10
  br i1 %18, label %24, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %37

20:                                               ; preds = %10
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %2, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %3, align 4
  call void @_ZdaPvm(ptr noundef %8, i64 noundef 240) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  br label %39

24:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %25 = call noundef ptr @_Z12randomPlayerv()
  store ptr %25, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %26)
  store double %27, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load double, ptr %6, align 8, !tbaa !11
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %7, ptr noundef %28, double noundef %29, i32 noundef 5)
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.playerWithScore, ptr %30, i64 %32
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %33, ptr align 8 %7, i64 20, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %34

34:                                               ; preds = %24
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %4, align 4, !tbaa !9
  br label %16, !llvm.loop !14

37:                                               ; preds = %19
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret ptr %38

39:                                               ; preds = %20
  %40 = load ptr, ptr %2, align 8
  %41 = load i32, ptr %3, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; 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
declare dso_local noundef double @_Z14evaluatePlayerP5Agent(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef, double noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z12randomPlayerv() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #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 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i64 0, i64 8, !5, i64 8, i64 8, !11, i64 16, i64 4, !9}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%struct.playerWithScore = type <{ ptr, double, i32, [4 x i8] }>

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_Z16randomPopulationv() local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
.preheader.preheader:
  %0 = alloca %struct.playerWithScore, align 8
  %1 = tail call noalias noundef nonnull dereferenceable(240) ptr @_Znam(i64 noundef 240) #5
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %1)
  %.ptr.1 = getelementptr inbounds i8, ptr %1, i64 24
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %1, i64 48
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %1, i64 72
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %1, i64 96
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %1, i64 120
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.5)
  %.ptr.6 = getelementptr inbounds i8, ptr %1, i64 144
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.6)
  %.ptr.7 = getelementptr inbounds i8, ptr %1, i64 168
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.7)
  %.ptr.8 = getelementptr inbounds i8, ptr %1, i64 192
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.8)
  %.ptr.9 = getelementptr inbounds i8, ptr %1, i64 216
  tail call void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.9)
  %2 = tail call noundef ptr @_Z12randomPlayerv()
  %3 = tail call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %2, double noundef %3, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %1, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %4 = call noundef ptr @_Z12randomPlayerv()
  %5 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %4, double noundef %5, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.1, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %6 = call noundef ptr @_Z12randomPlayerv()
  %7 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %6, double noundef %7, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.2, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %8 = call noundef ptr @_Z12randomPlayerv()
  %9 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %8, double noundef %9, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.3, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %10 = call noundef ptr @_Z12randomPlayerv()
  %11 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %10, double noundef %11, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.4, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %12 = call noundef ptr @_Z12randomPlayerv()
  %13 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %12, double noundef %13, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.5, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %14 = call noundef ptr @_Z12randomPlayerv()
  %15 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %14)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %14, double noundef %15, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.6, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %16 = call noundef ptr @_Z12randomPlayerv()
  %17 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %16)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %16, double noundef %17, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.7, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %18 = call noundef ptr @_Z12randomPlayerv()
  %19 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %18, double noundef %19, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.8, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  %20 = call noundef ptr @_Z12randomPlayerv()
  %21 = call noundef double @_Z14evaluatePlayerP5Agent(ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %0) #6
  call void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef %20, double noundef %21, i32 noundef 5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %.ptr.9, ptr noundef nonnull align 8 dereferenceable(20) %0, i64 20, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %0) #6
  ret ptr %1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z14evaluatePlayerP5Agent(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15playerWithScoreC2EP14HeuristicAgentdi(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef, double noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15playerWithScoreC2Ev(ptr noundef nonnull align 8 dereferenceable(20)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z12randomPlayerv() local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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 = !{i64 0, i64 8, !6, i64 8, i64 8, !10, i64 16, i64 4, !12}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass