; LLVM IR from mbrenman/TetrisPlayground :: game/Piece.ll (ZN5Piece9copyPieceEPA4_b)

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5Piece9copyPieceEPA4_b(ptr noundef nonnull align 4 dereferenceable(20) %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 = %40, %2
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 4
  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 %43

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 = %36, %13
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 4
  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 %39

18:                                               ; preds = %14
  %19 = getelementptr inbounds %class.Piece, ptr %8, i32 0, i32 0
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [4 x [4 x i8]], ptr %19, i64 0, i64 %21
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4 x i8], ptr %22, i64 0, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4 x i8], ptr %28, i64 %30
  %32 = load i32, ptr %7, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [4 x i8], ptr %31, i64 0, i64 %33
  %35 = zext i1 %27 to i8
  store i8 %35, ptr %34, align 1, !tbaa !11
  br label %36

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

39:                                               ; preds = %17
  br label %40

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

43:                                               ; preds = %12
  ret void
}

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

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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN5Piece9copyPieceEPA4_b(ptr nocapture noundef nonnull readonly align 4 dereferenceable(20) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 align 2 {
.preheader:
  %2 = load i8, ptr %0, align 4, !tbaa !5, !range !9, !noundef !10
  store i8 %2, ptr %1, align 1, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 1
  %4 = load i8, ptr %3, align 1, !tbaa !5, !range !9, !noundef !10
  %5 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %4, ptr %5, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i8, ptr %6, align 2, !tbaa !5, !range !9, !noundef !10
  %8 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %7, ptr %8, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 3
  %10 = load i8, ptr %9, align 1, !tbaa !5, !range !9, !noundef !10
  %11 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %10, ptr %11, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i8, ptr %12, align 4, !tbaa !5, !range !9, !noundef !10
  %14 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %13, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 5
  %16 = load i8, ptr %15, align 1, !tbaa !5, !range !9, !noundef !10
  %17 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %16, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 6
  %19 = load i8, ptr %18, align 2, !tbaa !5, !range !9, !noundef !10
  %20 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %19, ptr %20, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 7
  %22 = load i8, ptr %21, align 1, !tbaa !5, !range !9, !noundef !10
  %23 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %22, ptr %23, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  %25 = load i8, ptr %24, align 4, !tbaa !5, !range !9, !noundef !10
  %26 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %25, ptr %26, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 9
  %28 = load i8, ptr %27, align 1, !tbaa !5, !range !9, !noundef !10
  %29 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %28, ptr %29, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %0, i64 10
  %31 = load i8, ptr %30, align 2, !tbaa !5, !range !9, !noundef !10
  %32 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %31, ptr %32, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 11
  %34 = load i8, ptr %33, align 1, !tbaa !5, !range !9, !noundef !10
  %35 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 %34, ptr %35, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 12
  %37 = load i8, ptr %36, align 4, !tbaa !5, !range !9, !noundef !10
  %38 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 13
  %40 = load i8, ptr %39, align 1, !tbaa !5, !range !9, !noundef !10
  %41 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %40, ptr %41, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %0, i64 14
  %43 = load i8, ptr %42, align 2, !tbaa !5, !range !9, !noundef !10
  %44 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %0, i64 15
  %46 = load i8, ptr %45, align 1, !tbaa !5, !range !9, !noundef !10
  %47 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %46, ptr %47, align 1, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}


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