; LLVM IR from alekmaul/pvsneslib :: snes-examples/games/breakout (breakout)

; 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"

%struct.Vec2 = type { i16, i16 }

@map = external dso_local constant [100 x i8], align 16
@pos = external dso_local global %struct.Vec2, align 2
@px = external dso_local global i16, align 2
@level = external dso_local global i16, align 2
@level2 = external dso_local global i16, align 2
@blockmap = external dso_local global [1024 x i16], align 16
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@backmap = external dso_local global [1024 x i16], align 16
@bg2map = external global i8, align 1
@blocks = external dso_local global [100 x i8], align 16
@color = external dso_local global i16, align 2
@pal = external dso_local global [256 x i16], align 16
@backpal = external global i8, align 1
@b = external dso_local global i16, align 2
@j = external dso_local global i8, align 1
@i = external dso_local global i8, align 1
@a = external dso_local global i16, align 2
@c = external dso_local global i16, align 2
@blockcount = external dso_local global i16, align 2
@pad_keys = external global [5 x i16], align 2
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @writestring(ptr noundef, ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare dso_local void @writenum(i16 noundef zeroext, i8 noundef zeroext, ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare dso_local void @draw_screen() #0

; Function Attrs: nounwind uwtable
define dso_local void @new_level() #0 {
  %1 = load i16, ptr @level, align 2, !tbaa !5
  %2 = add i16 %1, 1
  store i16 %2, ptr @level, align 2, !tbaa !5
  %3 = load i16, ptr @level2, align 2, !tbaa !5
  %4 = add i16 %3, 1
  store i16 %4, ptr @level2, align 2, !tbaa !5
  store i16 94, ptr @pos, align 2, !tbaa !9
  store i16 109, ptr getelementptr inbounds (%struct.Vec2, ptr @pos, i32 0, i32 1), align 2, !tbaa !11
  store i16 80, ptr @px, align 2, !tbaa !5
  %5 = load i16, ptr @level2, align 2, !tbaa !5
  call void @writenum(i16 noundef zeroext %5, i8 noundef zeroext 8, ptr noundef @blockmap, i16 noundef zeroext 726, i16 noundef zeroext 1062)
  call void @writestring(ptr noundef @.str, ptr noundef @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  %6 = load i16, ptr @level, align 2, !tbaa !5
  %7 = zext i16 %6 to i32
  %8 = and i32 %7, 3
  %9 = mul nsw i32 2048, %8
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds i8, ptr @bg2map, i64 %10
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @backmap, ptr align 1 %11, i64 2048, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @blocks, ptr align 16 @map, i64 100, i1 false)
  %12 = load i16, ptr @color, align 2, !tbaa !5
  %13 = zext i16 %12 to i32
  %14 = icmp slt i32 %13, 6
  br i1 %14, label %15, label %18

15:                                               ; preds = %0
  %16 = load i16, ptr @color, align 2, !tbaa !5
  %17 = add i16 %16, 1
  store i16 %17, ptr @color, align 2, !tbaa !5
  br label %19

18:                                               ; preds = %0
  store i16 0, ptr @color, align 2, !tbaa !5
  br label %19

19:                                               ; preds = %18, %15
  %20 = load i16, ptr @color, align 2, !tbaa !5
  %21 = zext i16 %20 to i32
  %22 = mul nsw i32 %21, 16
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr @backpal, i64 %23
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 getelementptr inbounds (i8, ptr @pal, i64 16), ptr align 1 %24, i64 16, i1 false)
  store i16 0, ptr @b, align 2, !tbaa !5
  store i8 0, ptr @j, align 1, !tbaa !12
  br label %25

25:                                               ; preds = %100, %19
  %26 = load i8, ptr @j, align 1, !tbaa !12
  %27 = zext i8 %26 to i32
  %28 = icmp slt i32 %27, 10
  br i1 %28, label %29, label %103

29:                                               ; preds = %25
  store i8 0, ptr @i, align 1, !tbaa !12
  br label %30

30:                                               ; preds = %94, %29
  %31 = load i8, ptr @i, align 1, !tbaa !12
  %32 = zext i8 %31 to i32
  %33 = icmp slt i32 %32, 20
  br i1 %33, label %34, label %99

34:                                               ; preds = %30
  %35 = load i16, ptr @b, align 2, !tbaa !5
  %36 = zext i16 %35 to i64
  %37 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !12
  %39 = zext i8 %38 to i16
  store i16 %39, ptr @a, align 2, !tbaa !5
  %40 = load i16, ptr @a, align 2, !tbaa !5
  %41 = zext i16 %40 to i32
  %42 = icmp slt i32 %41, 8
  br i1 %42, label %43, label %91

43:                                               ; preds = %34
  %44 = load i8, ptr @j, align 1, !tbaa !12
  %45 = zext i8 %44 to i32
  %46 = shl i32 %45, 5
  %47 = load i8, ptr @i, align 1, !tbaa !12
  %48 = zext i8 %47 to i32
  %49 = add nsw i32 %46, %48
  %50 = trunc i32 %49 to i16
  store i16 %50, ptr @c, align 2, !tbaa !5
  %51 = load i16, ptr @blockcount, align 2, !tbaa !5
  %52 = add i16 %51, 1
  store i16 %52, ptr @blockcount, align 2, !tbaa !5
  %53 = load i16, ptr @a, align 2, !tbaa !5
  %54 = zext i16 %53 to i32
  %55 = shl i32 %54, 10
  %56 = add nsw i32 13, %55
  %57 = trunc i32 %56 to i16
  %58 = load i16, ptr @c, align 2, !tbaa !5
  %59 = zext i16 %58 to i32
  %60 = add nsw i32 98, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %61
  store i16 %57, ptr %62, align 2, !tbaa !5
  %63 = load i16, ptr @a, align 2, !tbaa !5
  %64 = zext i16 %63 to i32
  %65 = shl i32 %64, 10
  %66 = add nsw i32 14, %65
  %67 = trunc i32 %66 to i16
  %68 = load i16, ptr @c, align 2, !tbaa !5
  %69 = zext i16 %68 to i32
  %70 = add nsw i32 99, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %71
  store i16 %67, ptr %72, align 2, !tbaa !5
  %73 = load i16, ptr @c, align 2, !tbaa !5
  %74 = zext i16 %73 to i32
  %75 = add nsw i32 131, %74
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %76
  %78 = load i16, ptr %77, align 2, !tbaa !5
  %79 = zext i16 %78 to i32
  %80 = add nsw i32 %79, 1024
  %81 = trunc i32 %80 to i16
  store i16 %81, ptr %77, align 2, !tbaa !5
  %82 = load i16, ptr @c, align 2, !tbaa !5
  %83 = zext i16 %82 to i32
  %84 = add nsw i32 132, %83
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %85
  %87 = load i16, ptr %86, align 2, !tbaa !5
  %88 = zext i16 %87 to i32
  %89 = add nsw i32 %88, 1024
  %90 = trunc i32 %89 to i16
  store i16 %90, ptr %86, align 2, !tbaa !5
  br label %91

91:                                               ; preds = %43, %34
  %92 = load i16, ptr @b, align 2, !tbaa !5
  %93 = add i16 %92, 1
  store i16 %93, ptr @b, align 2, !tbaa !5
  br label %94

94:                                               ; preds = %91
  %95 = load i8, ptr @i, align 1, !tbaa !12
  %96 = add i8 %95, 1
  store i8 %96, ptr @i, align 1, !tbaa !12
  %97 = load i8, ptr @i, align 1, !tbaa !12
  %98 = add i8 %97, 1
  store i8 %98, ptr @i, align 1, !tbaa !12
  br label %30, !llvm.loop !13

99:                                               ; preds = %30
  br label %100

100:                                              ; preds = %99
  %101 = load i8, ptr @j, align 1, !tbaa !12
  %102 = add i8 %101, 1
  store i8 %102, ptr @j, align 1, !tbaa !12
  br label %25, !llvm.loop !15

103:                                              ; preds = %25
  call void @WaitForVBlank()
  call void @dmaCopyCGram(ptr noundef @pal, i16 noundef zeroext 0, i16 noundef zeroext 512)
  call void @dmaCopyVram(ptr noundef @blockmap, i16 noundef zeroext 0, i16 noundef zeroext 2048)
  call void @dmaCopyVram(ptr noundef @backmap, i16 noundef zeroext 1024, i16 noundef zeroext 2048)
  call void @draw_screen()
  br label %104

104:                                              ; preds = %108, %103
  %105 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %106 = zext i16 %105 to i32
  %107 = icmp eq i32 %106, 0
  br i1 %107, label %108, label %109

108:                                              ; preds = %104
  call void @WaitForVBlank()
  br label %104, !llvm.loop !16

109:                                              ; preds = %104
  call void @writestring(ptr noundef @.str.1, ptr noundef @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  call void @writestring(ptr noundef @.str.1, ptr noundef @blockmap, i16 noundef zeroext 649, i16 noundef zeroext 1014)
  call void @WaitForVBlank()
  call void @dmaCopyVram(ptr noundef @blockmap, i16 noundef zeroext 0, i16 noundef zeroext 2048)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare void @WaitForVBlank() #2

declare void @dmaCopyCGram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #2

declare void @dmaCopyVram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #2

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }

!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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 2}
!11 = !{!10, !6, i64 2}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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"

%struct.Vec2 = type { i16, i16 }

@map = external dso_local local_unnamed_addr constant [100 x i8], align 16
@pos = external dso_local local_unnamed_addr global %struct.Vec2, align 2
@px = external dso_local local_unnamed_addr global i16, align 2
@level = external dso_local local_unnamed_addr global i16, align 2
@level2 = external dso_local local_unnamed_addr global i16, align 2
@blockmap = external dso_local global [1024 x i16], align 16
@.str = external hidden unnamed_addr constant [17 x i8], align 1
@backmap = external dso_local global [1024 x i16], align 16
@bg2map = external local_unnamed_addr global i8, align 1
@blocks = external dso_local local_unnamed_addr global [100 x i8], align 16
@color = external dso_local local_unnamed_addr global i16, align 2
@pal = external dso_local global [256 x i16], align 16
@backpal = external local_unnamed_addr global i8, align 1
@b = external dso_local local_unnamed_addr global i16, align 2
@j = external dso_local local_unnamed_addr global i8, align 1
@i = external dso_local local_unnamed_addr global i8, align 1
@a = external dso_local local_unnamed_addr global i16, align 2
@c = external dso_local local_unnamed_addr global i16, align 2
@blockcount = external dso_local local_unnamed_addr global i16, align 2
@pad_keys = external local_unnamed_addr global [5 x i16], align 2
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @writestring(ptr noundef, ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @writenum(i16 noundef zeroext, i8 noundef zeroext, ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @draw_screen() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @new_level() local_unnamed_addr #0 {
  %1 = load i16, ptr @level, align 2, !tbaa !5
  %2 = add i16 %1, 1
  store i16 %2, ptr @level, align 2, !tbaa !5
  %3 = load i16, ptr @level2, align 2, !tbaa !5
  %4 = add i16 %3, 1
  store i16 %4, ptr @level2, align 2, !tbaa !5
  store i16 94, ptr @pos, align 2, !tbaa !9
  store i16 109, ptr getelementptr inbounds (i8, ptr @pos, i64 2), align 2, !tbaa !11
  store i16 80, ptr @px, align 2, !tbaa !5
  tail call void @writenum(i16 noundef zeroext %4, i8 noundef zeroext 8, ptr noundef nonnull @blockmap, i16 noundef zeroext 726, i16 noundef zeroext 1062)
  tail call void @writestring(ptr noundef nonnull @.str, ptr noundef nonnull @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  %5 = load i16, ptr @level, align 2, !tbaa !5
  %6 = shl i16 %5, 11
  %7 = and i16 %6, 6144
  %8 = zext nneg i16 %7 to i64
  %9 = getelementptr inbounds i8, ptr @bg2map, i64 %8
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(2048) @backmap, ptr noundef nonnull align 1 dereferenceable(2048) %9, i64 2048, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) @blocks, ptr noundef nonnull align 16 dereferenceable(100) @map, i64 100, i1 false)
  %10 = load i16, ptr @color, align 2, !tbaa !5
  %11 = icmp ult i16 %10, 6
  %12 = add nuw nsw i16 %10, 1
  %storemerge = select i1 %11, i16 %12, i16 0
  store i16 %storemerge, ptr @color, align 2, !tbaa !5
  %13 = zext i16 %storemerge to i64
  %14 = shl nuw nsw i64 %13, 4
  %15 = getelementptr inbounds i8, ptr @backpal, i64 %14
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) getelementptr inbounds (i8, ptr @pal, i64 16), ptr noundef nonnull align 1 dereferenceable(16) %15, i64 16, i1 false)
  %blockcount.promoted9 = load i16, ptr @blockcount, align 2, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %0, %243
  %indvars.iv22 = phi i64 [ 0, %0 ], [ %indvars.iv.next23, %243 ]
  %.lcssa714 = phi i16 [ 0, %0 ], [ %244, %243 ]
  %blockcount.promoted1213 = phi i16 [ %blockcount.promoted9, %0 ], [ %blockcount.promoted10.9, %243 ]
  %16 = shl nuw nsw i64 %indvars.iv22, 5
  %17 = zext i16 %.lcssa714 to i64
  %18 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %17
  %19 = load i8, ptr %18, align 2, !tbaa !12
  %20 = icmp ult i8 %19, 8
  br i1 %20, label %21, label %36

21:                                               ; preds = %.preheader
  %22 = zext i8 %19 to i16
  %23 = trunc nuw nsw i64 %16 to i16
  store i16 %23, ptr @c, align 2, !tbaa !5
  %24 = add i16 %blockcount.promoted1213, 1
  store i16 %24, ptr @blockcount, align 2, !tbaa !5
  %25 = shl nuw nsw i16 %22, 10
  %26 = or disjoint i16 %25, 13
  %27 = add nuw nsw i64 %16, 98
  %28 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %27
  store i16 %26, ptr %28, align 4, !tbaa !5
  %29 = or disjoint i16 %25, 14
  %30 = add nuw nsw i64 %16, 99
  %31 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %30
  store i16 %29, ptr %31, align 2, !tbaa !5
  %32 = add nuw nsw i64 %16, 131
  %33 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %32
  %34 = load <2 x i16>, ptr %33, align 2, !tbaa !5
  %35 = add <2 x i16> %34, <i16 1024, i16 1024>
  store <2 x i16> %35, ptr %33, align 2, !tbaa !5
  br label %36

36:                                               ; preds = %21, %.preheader
  %37 = phi i16 [ %24, %21 ], [ %blockcount.promoted1213, %.preheader ]
  %38 = or disjoint i16 %.lcssa714, 1
  %39 = zext i16 %38 to i64
  %40 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !12
  %42 = icmp ult i8 %41, 8
  br i1 %42, label %43, label %59

43:                                               ; preds = %36
  %44 = zext i8 %41 to i16
  %45 = trunc i64 %16 to i16
  %46 = or disjoint i16 %45, 2
  store i16 %46, ptr @c, align 2, !tbaa !5
  %47 = add i16 %37, 1
  store i16 %47, ptr @blockcount, align 2, !tbaa !5
  %48 = shl nuw nsw i16 %44, 10
  %49 = or disjoint i16 %48, 13
  %50 = add nuw nsw i64 %16, 100
  %51 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %50
  store i16 %49, ptr %51, align 8, !tbaa !5
  %52 = or disjoint i16 %48, 14
  %53 = add nuw nsw i64 %16, 101
  %54 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %53
  store i16 %52, ptr %54, align 2, !tbaa !5
  %55 = add nuw nsw i64 %16, 133
  %56 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %55
  %57 = load <2 x i16>, ptr %56, align 2, !tbaa !5
  %58 = add <2 x i16> %57, <i16 1024, i16 1024>
  store <2 x i16> %58, ptr %56, align 2, !tbaa !5
  br label %59

59:                                               ; preds = %43, %36
  %60 = phi i16 [ %47, %43 ], [ %37, %36 ]
  %61 = add i16 %.lcssa714, 2
  %62 = zext i16 %61 to i64
  %63 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %62
  %64 = load i8, ptr %63, align 2, !tbaa !12
  %65 = icmp ult i8 %64, 8
  br i1 %65, label %66, label %82

66:                                               ; preds = %59
  %67 = zext i8 %64 to i16
  %68 = trunc i64 %16 to i16
  %69 = or disjoint i16 %68, 4
  store i16 %69, ptr @c, align 2, !tbaa !5
  %70 = add i16 %60, 1
  store i16 %70, ptr @blockcount, align 2, !tbaa !5
  %71 = shl nuw nsw i16 %67, 10
  %72 = or disjoint i16 %71, 13
  %73 = add nuw nsw i64 %16, 102
  %74 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %73
  store i16 %72, ptr %74, align 4, !tbaa !5
  %75 = or disjoint i16 %71, 14
  %76 = add nuw nsw i64 %16, 103
  %77 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %76
  store i16 %75, ptr %77, align 2, !tbaa !5
  %78 = add nuw nsw i64 %16, 135
  %79 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %78
  %80 = load <2 x i16>, ptr %79, align 2, !tbaa !5
  %81 = add <2 x i16> %80, <i16 1024, i16 1024>
  store <2 x i16> %81, ptr %79, align 2, !tbaa !5
  br label %82

82:                                               ; preds = %66, %59
  %83 = phi i16 [ %70, %66 ], [ %60, %59 ]
  %84 = add i16 %.lcssa714, 3
  %85 = zext i16 %84 to i64
  %86 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %85
  %87 = load i8, ptr %86, align 1, !tbaa !12
  %88 = icmp ult i8 %87, 8
  br i1 %88, label %89, label %105

89:                                               ; preds = %82
  %90 = zext i8 %87 to i16
  %91 = trunc i64 %16 to i16
  %92 = or disjoint i16 %91, 6
  store i16 %92, ptr @c, align 2, !tbaa !5
  %93 = add i16 %83, 1
  store i16 %93, ptr @blockcount, align 2, !tbaa !5
  %94 = shl nuw nsw i16 %90, 10
  %95 = or disjoint i16 %94, 13
  %96 = add nuw nsw i64 %16, 104
  %97 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %96
  store i16 %95, ptr %97, align 16, !tbaa !5
  %98 = or disjoint i16 %94, 14
  %99 = add nuw nsw i64 %16, 105
  %100 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %99
  store i16 %98, ptr %100, align 2, !tbaa !5
  %101 = add nuw nsw i64 %16, 137
  %102 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %101
  %103 = load <2 x i16>, ptr %102, align 2, !tbaa !5
  %104 = add <2 x i16> %103, <i16 1024, i16 1024>
  store <2 x i16> %104, ptr %102, align 2, !tbaa !5
  br label %105

105:                                              ; preds = %89, %82
  %106 = phi i16 [ %93, %89 ], [ %83, %82 ]
  %107 = add i16 %.lcssa714, 4
  %108 = zext i16 %107 to i64
  %109 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %108
  %110 = load i8, ptr %109, align 2, !tbaa !12
  %111 = icmp ult i8 %110, 8
  br i1 %111, label %112, label %128

112:                                              ; preds = %105
  %113 = zext i8 %110 to i16
  %114 = trunc i64 %16 to i16
  %115 = or disjoint i16 %114, 8
  store i16 %115, ptr @c, align 2, !tbaa !5
  %116 = add i16 %106, 1
  store i16 %116, ptr @blockcount, align 2, !tbaa !5
  %117 = shl nuw nsw i16 %113, 10
  %118 = or disjoint i16 %117, 13
  %119 = add nuw nsw i64 %16, 106
  %120 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %119
  store i16 %118, ptr %120, align 4, !tbaa !5
  %121 = or disjoint i16 %117, 14
  %122 = add nuw nsw i64 %16, 107
  %123 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %122
  store i16 %121, ptr %123, align 2, !tbaa !5
  %124 = add nuw nsw i64 %16, 139
  %125 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %124
  %126 = load <2 x i16>, ptr %125, align 2, !tbaa !5
  %127 = add <2 x i16> %126, <i16 1024, i16 1024>
  store <2 x i16> %127, ptr %125, align 2, !tbaa !5
  br label %128

128:                                              ; preds = %112, %105
  %129 = phi i16 [ %116, %112 ], [ %106, %105 ]
  %130 = add i16 %.lcssa714, 5
  %131 = zext i16 %130 to i64
  %132 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %131
  %133 = load i8, ptr %132, align 1, !tbaa !12
  %134 = icmp ult i8 %133, 8
  br i1 %134, label %135, label %151

135:                                              ; preds = %128
  %136 = zext i8 %133 to i16
  %137 = trunc i64 %16 to i16
  %138 = or disjoint i16 %137, 10
  store i16 %138, ptr @c, align 2, !tbaa !5
  %139 = add i16 %129, 1
  store i16 %139, ptr @blockcount, align 2, !tbaa !5
  %140 = shl nuw nsw i16 %136, 10
  %141 = or disjoint i16 %140, 13
  %142 = add nuw nsw i64 %16, 108
  %143 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %142
  store i16 %141, ptr %143, align 8, !tbaa !5
  %144 = or disjoint i16 %140, 14
  %145 = add nuw nsw i64 %16, 109
  %146 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %145
  store i16 %144, ptr %146, align 2, !tbaa !5
  %147 = add nuw nsw i64 %16, 141
  %148 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %147
  %149 = load <2 x i16>, ptr %148, align 2, !tbaa !5
  %150 = add <2 x i16> %149, <i16 1024, i16 1024>
  store <2 x i16> %150, ptr %148, align 2, !tbaa !5
  br label %151

151:                                              ; preds = %135, %128
  %152 = phi i16 [ %139, %135 ], [ %129, %128 ]
  %153 = add i16 %.lcssa714, 6
  %154 = zext i16 %153 to i64
  %155 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %154
  %156 = load i8, ptr %155, align 2, !tbaa !12
  %157 = icmp ult i8 %156, 8
  br i1 %157, label %158, label %174

158:                                              ; preds = %151
  %159 = zext i8 %156 to i16
  %160 = trunc i64 %16 to i16
  %161 = or disjoint i16 %160, 12
  store i16 %161, ptr @c, align 2, !tbaa !5
  %162 = add i16 %152, 1
  store i16 %162, ptr @blockcount, align 2, !tbaa !5
  %163 = shl nuw nsw i16 %159, 10
  %164 = or disjoint i16 %163, 13
  %165 = add nuw nsw i64 %16, 110
  %166 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %165
  store i16 %164, ptr %166, align 4, !tbaa !5
  %167 = or disjoint i16 %163, 14
  %168 = add nuw nsw i64 %16, 111
  %169 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %168
  store i16 %167, ptr %169, align 2, !tbaa !5
  %170 = add nuw nsw i64 %16, 143
  %171 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %170
  %172 = load <2 x i16>, ptr %171, align 2, !tbaa !5
  %173 = add <2 x i16> %172, <i16 1024, i16 1024>
  store <2 x i16> %173, ptr %171, align 2, !tbaa !5
  br label %174

174:                                              ; preds = %158, %151
  %175 = phi i16 [ %162, %158 ], [ %152, %151 ]
  %176 = add i16 %.lcssa714, 7
  %177 = zext i16 %176 to i64
  %178 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %177
  %179 = load i8, ptr %178, align 1, !tbaa !12
  %180 = icmp ult i8 %179, 8
  br i1 %180, label %181, label %197

181:                                              ; preds = %174
  %182 = zext i8 %179 to i16
  %183 = trunc i64 %16 to i16
  %184 = or disjoint i16 %183, 14
  store i16 %184, ptr @c, align 2, !tbaa !5
  %185 = add i16 %175, 1
  store i16 %185, ptr @blockcount, align 2, !tbaa !5
  %186 = shl nuw nsw i16 %182, 10
  %187 = or disjoint i16 %186, 13
  %188 = add nuw nsw i64 %16, 112
  %189 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %188
  store i16 %187, ptr %189, align 16, !tbaa !5
  %190 = or disjoint i16 %186, 14
  %191 = add nuw nsw i64 %16, 113
  %192 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %191
  store i16 %190, ptr %192, align 2, !tbaa !5
  %193 = add nuw nsw i64 %16, 145
  %194 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %193
  %195 = load <2 x i16>, ptr %194, align 2, !tbaa !5
  %196 = add <2 x i16> %195, <i16 1024, i16 1024>
  store <2 x i16> %196, ptr %194, align 2, !tbaa !5
  br label %197

197:                                              ; preds = %181, %174
  %198 = phi i16 [ %185, %181 ], [ %175, %174 ]
  %199 = add i16 %.lcssa714, 8
  %200 = zext i16 %199 to i64
  %201 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %200
  %202 = load i8, ptr %201, align 2, !tbaa !12
  %203 = icmp ult i8 %202, 8
  br i1 %203, label %204, label %220

204:                                              ; preds = %197
  %205 = zext i8 %202 to i16
  %206 = trunc i64 %16 to i16
  %207 = or disjoint i16 %206, 16
  store i16 %207, ptr @c, align 2, !tbaa !5
  %208 = add i16 %198, 1
  store i16 %208, ptr @blockcount, align 2, !tbaa !5
  %209 = shl nuw nsw i16 %205, 10
  %210 = or disjoint i16 %209, 13
  %211 = add nuw nsw i64 %16, 114
  %212 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %211
  store i16 %210, ptr %212, align 4, !tbaa !5
  %213 = or disjoint i16 %209, 14
  %214 = add nuw nsw i64 %16, 115
  %215 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %214
  store i16 %213, ptr %215, align 2, !tbaa !5
  %216 = add nuw nsw i64 %16, 147
  %217 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %216
  %218 = load <2 x i16>, ptr %217, align 2, !tbaa !5
  %219 = add <2 x i16> %218, <i16 1024, i16 1024>
  store <2 x i16> %219, ptr %217, align 2, !tbaa !5
  br label %220

220:                                              ; preds = %204, %197
  %221 = phi i16 [ %208, %204 ], [ %198, %197 ]
  %222 = add i16 %.lcssa714, 9
  %223 = zext i16 %222 to i64
  %224 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %223
  %225 = load i8, ptr %224, align 1, !tbaa !12
  %226 = zext i8 %225 to i16
  %227 = icmp ult i8 %225, 8
  br i1 %227, label %228, label %243

228:                                              ; preds = %220
  %229 = trunc i64 %16 to i16
  %230 = or disjoint i16 %229, 18
  store i16 %230, ptr @c, align 2, !tbaa !5
  %231 = add i16 %221, 1
  store i16 %231, ptr @blockcount, align 2, !tbaa !5
  %232 = shl nuw nsw i16 %226, 10
  %233 = or disjoint i16 %232, 13
  %234 = add nuw nsw i64 %16, 116
  %235 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %234
  store i16 %233, ptr %235, align 8, !tbaa !5
  %236 = or disjoint i16 %232, 14
  %237 = add nuw nsw i64 %16, 117
  %238 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %237
  store i16 %236, ptr %238, align 2, !tbaa !5
  %239 = add nuw nsw i64 %16, 149
  %240 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %239
  %241 = load <2 x i16>, ptr %240, align 2, !tbaa !5
  %242 = add <2 x i16> %241, <i16 1024, i16 1024>
  store <2 x i16> %242, ptr %240, align 2, !tbaa !5
  br label %243

243:                                              ; preds = %228, %220
  %blockcount.promoted10.9 = phi i16 [ %231, %228 ], [ %221, %220 ]
  %244 = add i16 %.lcssa714, 10
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 10
  br i1 %exitcond25.not, label %245, label %.preheader, !llvm.loop !13

245:                                              ; preds = %243
  store i8 10, ptr @j, align 1, !tbaa !12
  store i8 20, ptr @i, align 1, !tbaa !12
  store i16 %244, ptr @b, align 2, !tbaa !5
  store i16 %226, ptr @a, align 2, !tbaa !5
  tail call void @WaitForVBlank() #3
  tail call void @dmaCopyCGram(ptr noundef nonnull @pal, i16 noundef zeroext 0, i16 noundef zeroext 512) #3
  tail call void @dmaCopyVram(ptr noundef nonnull @blockmap, i16 noundef zeroext 0, i16 noundef zeroext 2048) #3
  tail call void @dmaCopyVram(ptr noundef nonnull @backmap, i16 noundef zeroext 1024, i16 noundef zeroext 2048) #3
  tail call void @draw_screen()
  %246 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %247 = icmp eq i16 %246, 0
  br i1 %247, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %245, %.lr.ph
  tail call void @WaitForVBlank() #3
  %248 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %249 = icmp eq i16 %248, 0
  br i1 %249, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %245
  tail call void @writestring(ptr noundef nonnull @.str.1, ptr noundef nonnull @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  tail call void @writestring(ptr noundef nonnull @.str.1, ptr noundef nonnull @blockmap, i16 noundef zeroext 649, i16 noundef zeroext 1014)
  tail call void @WaitForVBlank() #3
  tail call void @dmaCopyVram(ptr noundef nonnull @blockmap, i16 noundef zeroext 0, i16 noundef zeroext 2048) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare void @WaitForVBlank() local_unnamed_addr #2

declare void @dmaCopyCGram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

declare void @dmaCopyVram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !6, i64 2}
!11 = !{!10, !6, i64 2}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SimplifyCFGPass,TailCallElimPass