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

; 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: mustprogress uwtable
define dso_local void @_ZN6TetrisC2Eb(ptr noundef nonnull align 8 dereferenceable(824) %0, i1 noundef zeroext %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = zext i1 %1 to i8
  store i8 %7, ptr %4, align 1, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 3
  %10 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  %12 = zext i1 %11 to i8
  store i8 %12, ptr %9, align 1, !tbaa !13
  call void @_ZN6Tetris10clearBoardEv(ptr noundef nonnull align 8 dereferenceable(824) %8)
  %13 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 20) #5
  invoke void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %13)
          to label %14 unwind label %21

14:                                               ; preds = %2
  %15 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 4
  store ptr %13, ptr %15, align 8, !tbaa !16
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 20) #5
  invoke void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %16)
          to label %17 unwind label %25

17:                                               ; preds = %14
  %18 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 5
  store ptr %16, ptr %18, align 8, !tbaa !17
  %19 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 2
  store i8 0, ptr %19, align 4, !tbaa !18
  %20 = getelementptr inbounds %class.Tetris, ptr %8, i32 0, i32 1
  store i32 0, ptr %20, align 8, !tbaa !19
  ret void

21:                                               ; preds = %2
  %22 = landingpad { ptr, i32 }
          cleanup
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %5, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 20) #6
  br label %29

25:                                               ; preds = %14
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %5, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 20) #6
  br label %29

29:                                               ; preds = %25, %21
  %30 = load ptr, ptr %5, align 8
  %31 = load i32, ptr %6, align 4
  %32 = insertvalue { ptr, i32 } poison, ptr %30, 0
  %33 = insertvalue { ptr, i32 } %32, i32 %31, 1
  resume { ptr, i32 } %33
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Tetris10clearBoardEv(ptr noundef nonnull align 8 dereferenceable(824)) #1 align 2

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

declare void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { 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 #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 = { 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 #3 = { "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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !10, i64 805}
!14 = !{!"_ZTS6Tetris", !7, i64 0, !15, i64 800, !10, i64 804, !10, i64 805, !6, i64 808, !6, i64 816}
!15 = !{!"int", !7, i64 0}
!16 = !{!14, !6, i64 808}
!17 = !{!14, !6, i64 816}
!18 = !{!14, !10, i64 804}
!19 = !{!14, !15, i64 800}


; 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 uwtable
define dso_local void @_ZN6TetrisC2Eb(ptr noundef nonnull align 8 dereferenceable(824) %0, i1 noundef zeroext %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = zext i1 %1 to i8
  %4 = getelementptr inbounds i8, ptr %0, i64 805
  store i8 %3, ptr %4, align 1, !tbaa !5
  tail call void @_ZN6Tetris10clearBoardEv(ptr noundef nonnull align 8 dereferenceable(824) %0)
  %5 = tail call noalias noundef nonnull dereferenceable(20) ptr @_Znwm(i64 noundef 20) #5
  invoke void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %5)
          to label %6 unwind label %13

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 808
  store ptr %5, ptr %7, align 8, !tbaa !12
  %8 = tail call noalias noundef nonnull dereferenceable(20) ptr @_Znwm(i64 noundef 20) #5
  invoke void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20) %8)
          to label %9 unwind label %15

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 816
  store ptr %8, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 804
  store i8 0, ptr %11, align 4, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 800
  store i32 0, ptr %12, align 8, !tbaa !15
  ret void

13:                                               ; preds = %2
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %6
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %17

17:                                               ; preds = %15, %13
  %.sink = phi ptr [ %8, %15 ], [ %5, %13 ]
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.sink, i64 noundef 20) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6Tetris10clearBoardEv(ptr noundef nonnull align 8 dereferenceable(824)) local_unnamed_addr #1 align 2

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

declare void @_ZN5PieceC1Ev(ptr noundef nonnull align 4 dereferenceable(20)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { 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 #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 = { 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 #3 = { "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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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, !10, i64 805}
!6 = !{!"_ZTS6Tetris", !7, i64 0, !9, i64 800, !10, i64 804, !10, i64 805, !11, i64 808, !11, i64 816}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!6, !11, i64 808}
!13 = !{!6, !11, i64 816}
!14 = !{!6, !10, i64 804}
!15 = !{!6, !9, i64 800}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass