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

; 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: 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 void @_ZN5Piece8pullDownEv(ptr noundef nonnull align 4 dereferenceable(20) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  br label %7

7:                                                ; preds = %50, %1
  %8 = call noundef zeroext i1 @_ZN5Piece11emptyBottomEv(ptr noundef nonnull align 4 dereferenceable(20) %6)
  br i1 %8, label %9, label %51

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

10:                                               ; preds = %47, %9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 4
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  store i32 4, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %50

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

15:                                               ; preds = %38, %14
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %41

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

38:                                               ; preds = %19
  %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 %15, !llvm.loop !15

41:                                               ; preds = %18
  %42 = getelementptr inbounds %class.Piece, ptr %6, i32 0, i32 0
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [4 x [4 x i8]], ptr %42, i64 0, i64 %44
  %46 = getelementptr inbounds [4 x i8], ptr %45, i64 0, i64 0
  store i8 0, ptr %46, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %41
  %48 = load i32, ptr %3, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %3, align 4, !tbaa !9
  br label %10, !llvm.loop !17

50:                                               ; preds = %13
  br label %7, !llvm.loop !18

51:                                               ; preds = %7
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5Piece11emptyBottomEv(ptr noundef nonnull align 4 dereferenceable(20)) #2 align 2

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 = { 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}
!18 = distinct !{!18, !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 nounwind uwtable
define dso_local void @_ZN5Piece8pullDownEv(ptr noundef nonnull align 4 dereferenceable(20) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef zeroext i1 @_ZN5Piece11emptyBottomEv(ptr noundef nonnull align 4 dereferenceable(20) %0)
  br i1 %2, label %.preheader10.preheader, label %._crit_edge

.preheader10.preheader:                           ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 2
  %4 = getelementptr inbounds i8, ptr %0, i64 3
  %5 = getelementptr inbounds i8, ptr %0, i64 1
  %6 = getelementptr inbounds i8, ptr %0, i64 6
  %7 = getelementptr inbounds i8, ptr %0, i64 7
  %8 = getelementptr inbounds i8, ptr %0, i64 5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = getelementptr inbounds i8, ptr %0, i64 10
  %11 = getelementptr inbounds i8, ptr %0, i64 11
  %12 = getelementptr inbounds i8, ptr %0, i64 9
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = getelementptr inbounds i8, ptr %0, i64 14
  %15 = getelementptr inbounds i8, ptr %0, i64 15
  %16 = getelementptr inbounds i8, ptr %0, i64 13
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  br label %.preheader10

.preheader10:                                     ; preds = %.preheader10.preheader, %.preheader10
  %18 = load i8, ptr %3, align 2, !tbaa !5, !range !9, !noundef !10
  store i8 %18, ptr %4, align 1, !tbaa !5
  %19 = load i8, ptr %5, align 1, !tbaa !5, !range !9, !noundef !10
  store i8 %19, ptr %3, align 2, !tbaa !5
  %20 = load i8, ptr %0, align 4, !tbaa !5, !range !9, !noundef !10
  store i8 %20, ptr %5, align 1, !tbaa !5
  store i8 0, ptr %0, align 4, !tbaa !5
  %21 = load i8, ptr %6, align 2, !tbaa !5, !range !9, !noundef !10
  store i8 %21, ptr %7, align 1, !tbaa !5
  %22 = load i8, ptr %8, align 1, !tbaa !5, !range !9, !noundef !10
  store i8 %22, ptr %6, align 2, !tbaa !5
  %23 = load i8, ptr %9, align 4, !tbaa !5, !range !9, !noundef !10
  store i8 %23, ptr %8, align 1, !tbaa !5
  store i8 0, ptr %9, align 4, !tbaa !5
  %24 = load i8, ptr %10, align 2, !tbaa !5, !range !9, !noundef !10
  store i8 %24, ptr %11, align 1, !tbaa !5
  %25 = load i8, ptr %12, align 1, !tbaa !5, !range !9, !noundef !10
  store i8 %25, ptr %10, align 2, !tbaa !5
  %26 = load i8, ptr %13, align 4, !tbaa !5, !range !9, !noundef !10
  store i8 %26, ptr %12, align 1, !tbaa !5
  store i8 0, ptr %13, align 4, !tbaa !5
  %27 = load i8, ptr %14, align 2, !tbaa !5, !range !9, !noundef !10
  store i8 %27, ptr %15, align 1, !tbaa !5
  %28 = load i8, ptr %16, align 1, !tbaa !5, !range !9, !noundef !10
  store i8 %28, ptr %14, align 2, !tbaa !5
  %29 = load i8, ptr %17, align 4, !tbaa !5, !range !9, !noundef !10
  store i8 %29, ptr %16, align 1, !tbaa !5
  store i8 0, ptr %17, align 4, !tbaa !5
  %30 = tail call noundef zeroext i1 @_ZN5Piece11emptyBottomEv(ptr noundef nonnull align 4 dereferenceable(20) %0)
  br i1 %30, label %.preheader10, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.preheader10, %1
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5Piece11emptyBottomEv(ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #0 align 2

attributes #0 = { 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" }

!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 = !{}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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