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

; 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

declare i32 @__gxx_personality_v0(...)

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

declare noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN6Tetris8gameCopyEv(ptr noundef nonnull align 8 dereferenceable(824) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 824) #4
  %7 = getelementptr inbounds %class.Tetris, ptr %5, i32 0, i32 0
  %8 = getelementptr inbounds [10 x [20 x i32]], ptr %7, i64 0, i64 0
  %9 = getelementptr inbounds %class.Tetris, ptr %5, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = invoke noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20) %10)
          to label %12 unwind label %20

12:                                               ; preds = %1
  %13 = getelementptr inbounds %class.Tetris, ptr %5, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = invoke noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20) %14)
          to label %16 unwind label %20

16:                                               ; preds = %12
  %17 = getelementptr inbounds %class.Tetris, ptr %5, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !14
  invoke void @_ZN6TetrisC1EPA20_Kiiii(ptr noundef nonnull align 8 dereferenceable(824) %6, ptr noundef %8, i32 noundef %11, i32 noundef %15, i32 noundef %18)
          to label %19 unwind label %20

19:                                               ; preds = %16
  ret ptr %6

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

24:                                               ; preds = %20
  %25 = load ptr, ptr %3, align 8
  %26 = load i32, ptr %4, align 4
  %27 = insertvalue { ptr, i32 } poison, ptr %25, 0
  %28 = insertvalue { ptr, i32 } %27, i32 %26, 1
  resume { ptr, i32 } %28
}

declare void @_ZN6TetrisC1EPA20_Kiiii(ptr, ptr, i32, i32, i32)

attributes #0 = { 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 #1 = { 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 #2 = { "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 = { 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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, !6, i64 808}
!10 = !{!"_ZTS6Tetris", !7, i64 0, !11, i64 800, !12, i64 804, !12, i64 805, !6, i64 808, !6, i64 816}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !6, i64 816}
!14 = !{!10, !11, 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

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

declare noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN6Tetris8gameCopyEv(ptr noundef nonnull align 8 dereferenceable(824) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = tail call noalias noundef nonnull dereferenceable(824) ptr @_Znwm(i64 noundef 824) #4
  %3 = getelementptr inbounds i8, ptr %0, i64 808
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = invoke noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20) %4)
          to label %6 unwind label %14

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 816
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = invoke noundef i32 @_ZN5Piece10getPieceIDEv(ptr noundef nonnull align 4 dereferenceable(20) %8)
          to label %10 unwind label %14

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 800
  %12 = load i32, ptr %11, align 8, !tbaa !13
  invoke void @_ZN6TetrisC1EPA20_Kiiii(ptr noundef nonnull align 8 dereferenceable(824) %2, ptr noundef nonnull %0, i32 noundef %5, i32 noundef %9, i32 noundef %12)
          to label %13 unwind label %14

13:                                               ; preds = %10
  ret ptr %2

14:                                               ; preds = %10, %6, %1
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %2, i64 noundef 824) #5
  resume { ptr, i32 } %15
}

declare void @_ZN6TetrisC1EPA20_Kiiii(ptr, ptr, i32, i32, i32) local_unnamed_addr

attributes #0 = { 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 #1 = { 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 #2 = { "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 = { 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 #4 = { builtin allocsize(0) }
attributes #5 = { 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, !11, i64 808}
!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 816}
!13 = !{!6, !9, i64 800}


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