; LLVM IR from mbrenman/TetrisPlayground :: game/Piece.ll (ZN5Piece12replacePieceEPA4_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 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN5Piece12replacePieceEPA4_b = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5Piece12replacePieceEPA4_b(ptr noundef nonnull align 4 dereferenceable(20) %0, ptr noundef %1) #2 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) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %65, %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) #3
  br label %68

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

14:                                               ; preds = %61, %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) #3
  br label %64

18:                                               ; preds = %14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [4 x i8], ptr %19, 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 = getelementptr inbounds %class.Piece, ptr %8, i32 0, i32 0
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4 x [4 x i8]], ptr %28, i64 0, 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
  %36 = getelementptr inbounds %class.Piece, ptr %8, i32 0, i32 0
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [4 x [4 x i8]], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !11, !range !13, !noundef !14
  %44 = trunc i8 %43 to i1
  %45 = zext i1 %44 to i32
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [4 x i8], ptr %46, i64 %48
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [4 x i8], ptr %49, i64 0, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !11, !range !13, !noundef !14
  %54 = trunc i8 %53 to i1
  %55 = zext i1 %54 to i32
  %56 = icmp eq i32 %45, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %18
  br label %60

58:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 240, ptr noundef @__PRETTY_FUNCTION__._ZN5Piece12replacePieceEPA4_b) #4
  unreachable

59:                                               ; No predecessors!
  br label %60

60:                                               ; preds = %59, %57
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %7, align 4, !tbaa !9
  br label %14, !llvm.loop !15

64:                                               ; preds = %17
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !9
  br label %9, !llvm.loop !17

68:                                               ; preds = %12
  ret void
}

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }
attributes #4 = { noreturn 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 @_ZN5Piece12replacePieceEPA4_b(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(20) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 align 2 {
  %3 = load i8, ptr %1, align 1, !tbaa !5, !range !9, !noundef !10
  store i8 %3, ptr %0, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5, !range !9, !noundef !10
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %5, ptr %6, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 2
  %8 = load i8, ptr %7, align 1, !tbaa !5, !range !9, !noundef !10
  %9 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %8, ptr %9, align 2, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 3
  %11 = load i8, ptr %10, align 1, !tbaa !5, !range !9, !noundef !10
  %12 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %11, ptr %12, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i8, ptr %13, align 1, !tbaa !5, !range !9, !noundef !10
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %14, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 5
  %17 = load i8, ptr %16, align 1, !tbaa !5, !range !9, !noundef !10
  %18 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 %17, ptr %18, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 6
  %20 = load i8, ptr %19, align 1, !tbaa !5, !range !9, !noundef !10
  %21 = getelementptr inbounds i8, ptr %0, i64 6
  store i8 %20, ptr %21, align 2, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 7
  %23 = load i8, ptr %22, align 1, !tbaa !5, !range !9, !noundef !10
  %24 = getelementptr inbounds i8, ptr %0, i64 7
  store i8 %23, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load i8, ptr %25, align 1, !tbaa !5, !range !9, !noundef !10
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %26, ptr %27, align 4, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 9
  %29 = load i8, ptr %28, align 1, !tbaa !5, !range !9, !noundef !10
  %30 = getelementptr inbounds i8, ptr %0, i64 9
  store i8 %29, ptr %30, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 10
  %32 = load i8, ptr %31, align 1, !tbaa !5, !range !9, !noundef !10
  %33 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 %32, ptr %33, align 2, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 11
  %35 = load i8, ptr %34, align 1, !tbaa !5, !range !9, !noundef !10
  %36 = getelementptr inbounds i8, ptr %0, i64 11
  store i8 %35, ptr %36, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 12
  %38 = load i8, ptr %37, align 1, !tbaa !5, !range !9, !noundef !10
  %39 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %38, ptr %39, align 4, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %1, i64 13
  %41 = load i8, ptr %40, align 1, !tbaa !5, !range !9, !noundef !10
  %42 = getelementptr inbounds i8, ptr %0, i64 13
  store i8 %41, ptr %42, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 14
  %44 = load i8, ptr %43, align 1, !tbaa !5, !range !9, !noundef !10
  %45 = getelementptr inbounds i8, ptr %0, i64 14
  store i8 %44, ptr %45, align 2, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 15
  %47 = load i8, ptr %46, align 1, !tbaa !5, !range !9, !noundef !10
  %48 = getelementptr inbounds i8, ptr %0, i64 15
  store i8 %47, ptr %48, 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,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass