; LLVM IR from mbrenman/TetrisPlayground :: game/Tetris.ll (ZN6Tetris9copyBoardEPA20_i)

; 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.Tetris = type { [10 x [20 x i32]], i32, i8, i8, ptr, 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: mustprogress nounwind uwtable
define dso_local void @_ZN6Tetris9copyBoardEPA20_i(ptr noundef nonnull align 8 dereferenceable(824) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %38, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 10
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %41

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %34, %13
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 20
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %37

18:                                               ; preds = %14
  %19 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 0
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [10 x [20 x i32]], ptr %19, i64 0, i64 %21
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [20 x i32], ptr %22, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [20 x i32], ptr %27, i64 %29
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [20 x i32], ptr %30, i64 0, i64 %32
  store i32 %26, ptr %33, align 4, !tbaa !9
  br label %34

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

37:                                               ; preds = %17
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !13

41:                                               ; preds = %12
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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"}
!13 = distinct !{!13, !12}


; 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 nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_ZN6Tetris9copyBoardEPA20_i(ptr nocapture noundef nonnull readonly align 8 dereferenceable(824) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 align 2 {
  br label %.preheader

.preheader:                                       ; preds = %2, %.preheader
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %.preheader ]
  %3 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 0
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 0
  store i32 %4, ptr %5, align 4, !tbaa !5
  %6 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 1
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 1
  store i32 %7, ptr %8, align 4, !tbaa !5
  %9 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 2
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 2
  store i32 %10, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 3
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 3
  store i32 %13, ptr %14, align 4, !tbaa !5
  %15 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 4
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 4
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 5
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 5
  store i32 %19, ptr %20, align 4, !tbaa !5
  %21 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 6
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 6
  store i32 %22, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 7
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 7
  store i32 %25, ptr %26, align 4, !tbaa !5
  %27 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 8
  store i32 %28, ptr %29, align 4, !tbaa !5
  %30 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 9
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 9
  store i32 %31, ptr %32, align 4, !tbaa !5
  %33 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 10
  %34 = load i32, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 10
  store i32 %34, ptr %35, align 4, !tbaa !5
  %36 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 11
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 11
  store i32 %37, ptr %38, align 4, !tbaa !5
  %39 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 12
  %40 = load i32, ptr %39, align 8, !tbaa !5
  %41 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 12
  store i32 %40, ptr %41, align 4, !tbaa !5
  %42 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 13
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 13
  store i32 %43, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 14
  %46 = load i32, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 14
  store i32 %46, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 15
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 15
  store i32 %49, ptr %50, align 4, !tbaa !5
  %51 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 16
  %52 = load i32, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 16
  store i32 %52, ptr %53, align 4, !tbaa !5
  %54 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 17
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 17
  store i32 %55, ptr %56, align 4, !tbaa !5
  %57 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 18
  %58 = load i32, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 18
  store i32 %58, ptr %59, align 4, !tbaa !5
  %60 = getelementptr inbounds [10 x [20 x i32]], ptr %0, i64 0, i64 %indvars.iv, i64 19
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = getelementptr inbounds [20 x i32], ptr %1, i64 %indvars.iv, i64 19
  store i32 %61, ptr %62, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
  br i1 %exitcond.not, label %63, label %.preheader, !llvm.loop !9

63:                                               ; preds = %.preheader
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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