; 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
@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
@lives = external dso_local global i16, align 2
@vel = external dso_local global %struct.Vec2, align 2
@bx = external dso_local global i16, align 2
@by = external dso_local global i16, align 2
@score = external dso_local global i16, align 2
@hiscore = external dso_local global i16, align 2
@tiles1 = external global i8, align 1
@tiles2 = external global i8, align 1
@bg1map = external global i8, align 1
@palette = external global 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: 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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @setBrightness(i8 noundef zeroext 0)
  call void @WaitForVBlank()
  call void @dmaCopyVram(ptr noundef @tiles1, i16 noundef zeroext 4096, i16 noundef zeroext 3840)
  call void @dmaCopyVram(ptr noundef @tiles2, i16 noundef zeroext 8192, i16 noundef zeroext 592)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @blockmap, ptr align 1 @bg1map, i64 2048, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @backmap, ptr align 1 @bg2map, i64 2048, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @blocks, ptr align 16 @map, i64 100, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @pal, ptr align 1 @palette, i64 512, i1 false)
  store i16 0, ptr @blockcount, align 2, !tbaa !5
  store i16 5, ptr @bx, align 2, !tbaa !5
  store i16 11, ptr @by, align 2, !tbaa !5
  store i16 0, ptr @score, align 2, !tbaa !5
  store i16 -15536, ptr @hiscore, align 2, !tbaa !5
  store i16 1, ptr @level2, align 2, !tbaa !5
  store i16 0, ptr @color, align 2, !tbaa !5
  store i16 0, ptr @level, align 2, !tbaa !5
  store i16 4, ptr @lives, align 2, !tbaa !5
  store i16 80, ptr @px, align 2, !tbaa !5
  store i16 2, ptr @vel, align 2, !tbaa !9
  store i16 1, ptr getelementptr inbounds (%struct.Vec2, ptr @vel, i32 0, i32 1), align 2, !tbaa !11
  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 0, ptr @b, align 2, !tbaa !5
  store i8 0, ptr @j, align 1, !tbaa !12
  br label %2

2:                                                ; preds = %76, %0
  %3 = load i8, ptr @j, align 1, !tbaa !12
  %4 = zext i8 %3 to i32
  %5 = icmp slt i32 %4, 10
  br i1 %5, label %6, label %79

6:                                                ; preds = %2
  store i8 0, ptr @i, align 1, !tbaa !12
  br label %7

7:                                                ; preds = %70, %6
  %8 = load i8, ptr @i, align 1, !tbaa !12
  %9 = zext i8 %8 to i32
  %10 = icmp slt i32 %9, 20
  br i1 %10, label %11, label %75

11:                                               ; preds = %7
  %12 = load i16, ptr @b, align 2, !tbaa !5
  %13 = add i16 %12, 1
  store i16 %13, ptr @b, align 2, !tbaa !5
  %14 = zext i16 %12 to i64
  %15 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !12
  %17 = zext i8 %16 to i16
  store i16 %17, ptr @a, align 2, !tbaa !5
  %18 = load i16, ptr @a, align 2, !tbaa !5
  %19 = zext i16 %18 to i32
  %20 = icmp slt i32 %19, 8
  br i1 %20, label %21, label %69

21:                                               ; preds = %11
  %22 = load i8, ptr @j, align 1, !tbaa !12
  %23 = zext i8 %22 to i32
  %24 = shl i32 %23, 5
  %25 = load i8, ptr @i, align 1, !tbaa !12
  %26 = zext i8 %25 to i32
  %27 = add nsw i32 %24, %26
  %28 = trunc i32 %27 to i16
  store i16 %28, ptr @c, align 2, !tbaa !5
  %29 = load i16, ptr @blockcount, align 2, !tbaa !5
  %30 = add i16 %29, 1
  store i16 %30, ptr @blockcount, align 2, !tbaa !5
  %31 = load i16, ptr @a, align 2, !tbaa !5
  %32 = zext i16 %31 to i32
  %33 = shl i32 %32, 10
  %34 = add nsw i32 13, %33
  %35 = trunc i32 %34 to i16
  %36 = load i16, ptr @c, align 2, !tbaa !5
  %37 = zext i16 %36 to i32
  %38 = add nsw i32 98, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %39
  store i16 %35, ptr %40, align 2, !tbaa !5
  %41 = load i16, ptr @a, align 2, !tbaa !5
  %42 = zext i16 %41 to i32
  %43 = shl i32 %42, 10
  %44 = add nsw i32 14, %43
  %45 = trunc i32 %44 to i16
  %46 = load i16, ptr @c, align 2, !tbaa !5
  %47 = zext i16 %46 to i32
  %48 = add nsw i32 99, %47
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %49
  store i16 %45, ptr %50, align 2, !tbaa !5
  %51 = load i16, ptr @c, align 2, !tbaa !5
  %52 = zext i16 %51 to i32
  %53 = add nsw i32 131, %52
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %54
  %56 = load i16, ptr %55, align 2, !tbaa !5
  %57 = zext i16 %56 to i32
  %58 = add nsw i32 %57, 1024
  %59 = trunc i32 %58 to i16
  store i16 %59, ptr %55, align 2, !tbaa !5
  %60 = load i16, ptr @c, align 2, !tbaa !5
  %61 = zext i16 %60 to i32
  %62 = add nsw i32 132, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %63
  %65 = load i16, ptr %64, align 2, !tbaa !5
  %66 = zext i16 %65 to i32
  %67 = add nsw i32 %66, 1024
  %68 = trunc i32 %67 to i16
  store i16 %68, ptr %64, align 2, !tbaa !5
  br label %69

69:                                               ; preds = %21, %11
  br label %70

70:                                               ; preds = %69
  %71 = load i8, ptr @i, align 1, !tbaa !12
  %72 = zext i8 %71 to i32
  %73 = add nsw i32 %72, 2
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr @i, align 1, !tbaa !12
  br label %7, !llvm.loop !13

75:                                               ; preds = %7
  br label %76

76:                                               ; preds = %75
  %77 = load i8, ptr @j, align 1, !tbaa !12
  %78 = add i8 %77, 1
  store i8 %78, ptr @j, align 1, !tbaa !12
  br label %2, !llvm.loop !15

79:                                               ; preds = %2
  %80 = load i16, ptr @lives, align 2, !tbaa !5
  call void @writenum(i16 noundef zeroext %80, i8 noundef zeroext 8, ptr noundef @blockmap, i16 noundef zeroext 310, i16 noundef zeroext 1062)
  call void @writestring(ptr noundef @.str, ptr noundef @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  call void @WaitForVBlank()
  call void @bgInitMapSet(i8 noundef zeroext 0, ptr noundef @blockmap, i16 noundef zeroext 2048, i8 noundef zeroext 0, i16 noundef zeroext 0)
  call void @bgInitMapSet(i8 noundef zeroext 2, ptr noundef @backmap, i16 noundef zeroext 2048, i8 noundef zeroext 0, i16 noundef zeroext 1024)
  call void @dmaCopyCGram(ptr noundef @pal, i16 noundef zeroext 0, i16 noundef zeroext 512)
  call void @bgSetGfxPtr(i8 noundef zeroext 0, i16 noundef zeroext 4096)
  call void @bgSetGfxPtr(i8 noundef zeroext 2, i16 noundef zeroext 8192)
  call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0)
  call void @bgSetDisable(i8 noundef zeroext 1)
  call void @setScreenOn()
  call void @draw_screen()
  store i8 0, ptr @i, align 1, !tbaa !12
  br label %81

81:                                               ; preds = %88, %79
  %82 = load i8, ptr @i, align 1, !tbaa !12
  %83 = zext i8 %82 to i32
  %84 = icmp slt i32 %83, 40
  br i1 %84, label %85, label %93

85:                                               ; preds = %81
  %86 = load i8, ptr @i, align 1, !tbaa !12
  %87 = zext i8 %86 to i16
  call void @oamSetEx(i16 noundef zeroext %87, i8 noundef zeroext 0, i8 noundef zeroext 0)
  br label %88

88:                                               ; preds = %85
  %89 = load i8, ptr @i, align 1, !tbaa !12
  %90 = zext i8 %89 to i32
  %91 = add nsw i32 %90, 4
  %92 = trunc i32 %91 to i8
  store i8 %92, ptr @i, align 1, !tbaa !12
  br label %81, !llvm.loop !16

93:                                               ; preds = %81
  br label %94

94:                                               ; preds = %98, %93
  %95 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %96 = zext i16 %95 to i32
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %94
  call void @WaitForVBlank()
  br label %94, !llvm.loop !17

99:                                               ; preds = %94
  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)
  br label %100

100:                                              ; preds = %100, %99
  call void @run_frame()
  br label %100
}

declare void @setBrightness(i8 noundef zeroext) #2

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

declare void @bgSetGfxPtr(i8 noundef zeroext, i16 noundef zeroext) #2

declare void @setMode(i8 noundef zeroext, i8 noundef zeroext) #2

declare void @bgSetDisable(i8 noundef zeroext) #2

declare void @setScreenOn() #2

declare void @oamSetEx(i16 noundef zeroext, i8 noundef zeroext, i8 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}
!17 = distinct !{!17, !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
@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
@lives = external dso_local local_unnamed_addr global i16, align 2
@vel = external dso_local local_unnamed_addr global %struct.Vec2, align 2
@bx = external dso_local local_unnamed_addr global i16, align 2
@by = external dso_local local_unnamed_addr global i16, align 2
@score = external dso_local local_unnamed_addr global i16, align 2
@hiscore = external dso_local local_unnamed_addr global i16, align 2
@tiles1 = external global i8, align 1
@tiles2 = external global i8, align 1
@bg1map = external local_unnamed_addr global i8, align 1
@palette = external local_unnamed_addr global 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: 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

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

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  tail call void @setBrightness(i8 noundef zeroext 0) #4
  tail call void @WaitForVBlank() #4
  tail call void @dmaCopyVram(ptr noundef nonnull @tiles1, i16 noundef zeroext 4096, i16 noundef zeroext 3840) #4
  tail call void @dmaCopyVram(ptr noundef nonnull @tiles2, i16 noundef zeroext 8192, i16 noundef zeroext 592) #4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(2048) @blockmap, ptr noundef nonnull align 1 dereferenceable(2048) @bg1map, i64 2048, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(2048) @backmap, ptr noundef nonnull align 1 dereferenceable(2048) @bg2map, 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)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) @pal, ptr noundef nonnull align 1 dereferenceable(512) @palette, i64 512, i1 false)
  store i16 0, ptr @blockcount, align 2, !tbaa !5
  store i16 5, ptr @bx, align 2, !tbaa !5
  store i16 11, ptr @by, align 2, !tbaa !5
  store i16 0, ptr @score, align 2, !tbaa !5
  store i16 -15536, ptr @hiscore, align 2, !tbaa !5
  store i16 1, ptr @level2, align 2, !tbaa !5
  store i16 0, ptr @color, align 2, !tbaa !5
  store i16 0, ptr @level, align 2, !tbaa !5
  store i16 4, ptr @lives, align 2, !tbaa !5
  store i16 80, ptr @px, align 2, !tbaa !5
  store i16 2, ptr @vel, align 2, !tbaa !9
  store i16 1, ptr getelementptr inbounds (i8, ptr @vel, i64 2), align 2, !tbaa !11
  store i16 94, ptr @pos, align 2, !tbaa !9
  store i16 109, ptr getelementptr inbounds (i8, ptr @pos, i64 2), align 2, !tbaa !11
  br label %.preheader3

.preheader3:                                      ; preds = %0, %229
  %indvars.iv24 = phi i64 [ 0, %0 ], [ %indvars.iv.next25, %229 ]
  %.lcssa815 = phi i16 [ 0, %0 ], [ %208, %229 ]
  %blockcount.promoted1314 = phi i16 [ 0, %0 ], [ %blockcount.promoted11.9, %229 ]
  %1 = shl nuw nsw i64 %indvars.iv24, 5
  %2 = or disjoint i16 %.lcssa815, 1
  %3 = zext i16 %.lcssa815 to i64
  %4 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %3
  %5 = load i8, ptr %4, align 2, !tbaa !12
  %6 = icmp ult i8 %5, 8
  br i1 %6, label %7, label %22

7:                                                ; preds = %.preheader3
  %8 = zext i8 %5 to i16
  %9 = trunc nuw nsw i64 %1 to i16
  store i16 %9, ptr @c, align 2, !tbaa !5
  %10 = add i16 %blockcount.promoted1314, 1
  store i16 %10, ptr @blockcount, align 2, !tbaa !5
  %11 = shl nuw nsw i16 %8, 10
  %12 = or disjoint i16 %11, 13
  %13 = add nuw nsw i64 %1, 98
  %14 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %13
  store i16 %12, ptr %14, align 4, !tbaa !5
  %15 = or disjoint i16 %11, 14
  %16 = add nuw nsw i64 %1, 99
  %17 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %16
  store i16 %15, ptr %17, align 2, !tbaa !5
  %18 = add nuw nsw i64 %1, 131
  %19 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %18
  %20 = load <2 x i16>, ptr %19, align 2, !tbaa !5
  %21 = add <2 x i16> %20, <i16 1024, i16 1024>
  store <2 x i16> %21, ptr %19, align 2, !tbaa !5
  br label %22

22:                                               ; preds = %.preheader3, %7
  %23 = phi i16 [ %blockcount.promoted1314, %.preheader3 ], [ %10, %7 ]
  %24 = add i16 %.lcssa815, 2
  %25 = zext i16 %2 to i64
  %26 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !12
  %28 = icmp ult i8 %27, 8
  br i1 %28, label %29, label %45

29:                                               ; preds = %22
  %30 = zext i8 %27 to i16
  %31 = trunc i64 %1 to i16
  %32 = or disjoint i16 %31, 2
  store i16 %32, ptr @c, align 2, !tbaa !5
  %33 = add i16 %23, 1
  store i16 %33, ptr @blockcount, align 2, !tbaa !5
  %34 = shl nuw nsw i16 %30, 10
  %35 = or disjoint i16 %34, 13
  %36 = add nuw nsw i64 %1, 100
  %37 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %36
  store i16 %35, ptr %37, align 8, !tbaa !5
  %38 = or disjoint i16 %34, 14
  %39 = add nuw nsw i64 %1, 101
  %40 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %39
  store i16 %38, ptr %40, align 2, !tbaa !5
  %41 = add nuw nsw i64 %1, 133
  %42 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %41
  %43 = load <2 x i16>, ptr %42, align 2, !tbaa !5
  %44 = add <2 x i16> %43, <i16 1024, i16 1024>
  store <2 x i16> %44, ptr %42, align 2, !tbaa !5
  br label %45

45:                                               ; preds = %29, %22
  %46 = phi i16 [ %23, %22 ], [ %33, %29 ]
  %47 = add i16 %.lcssa815, 3
  %48 = zext i16 %24 to i64
  %49 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %48
  %50 = load i8, ptr %49, align 2, !tbaa !12
  %51 = icmp ult i8 %50, 8
  br i1 %51, label %52, label %68

52:                                               ; preds = %45
  %53 = zext i8 %50 to i16
  %54 = trunc i64 %1 to i16
  %55 = or disjoint i16 %54, 4
  store i16 %55, ptr @c, align 2, !tbaa !5
  %56 = add i16 %46, 1
  store i16 %56, ptr @blockcount, align 2, !tbaa !5
  %57 = shl nuw nsw i16 %53, 10
  %58 = or disjoint i16 %57, 13
  %59 = add nuw nsw i64 %1, 102
  %60 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %59
  store i16 %58, ptr %60, align 4, !tbaa !5
  %61 = or disjoint i16 %57, 14
  %62 = add nuw nsw i64 %1, 103
  %63 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %62
  store i16 %61, ptr %63, align 2, !tbaa !5
  %64 = add nuw nsw i64 %1, 135
  %65 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %64
  %66 = load <2 x i16>, ptr %65, align 2, !tbaa !5
  %67 = add <2 x i16> %66, <i16 1024, i16 1024>
  store <2 x i16> %67, ptr %65, align 2, !tbaa !5
  br label %68

68:                                               ; preds = %52, %45
  %69 = phi i16 [ %46, %45 ], [ %56, %52 ]
  %70 = add i16 %.lcssa815, 4
  %71 = zext i16 %47 to i64
  %72 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %71
  %73 = load i8, ptr %72, align 1, !tbaa !12
  %74 = icmp ult i8 %73, 8
  br i1 %74, label %75, label %91

75:                                               ; preds = %68
  %76 = zext i8 %73 to i16
  %77 = trunc i64 %1 to i16
  %78 = or disjoint i16 %77, 6
  store i16 %78, ptr @c, align 2, !tbaa !5
  %79 = add i16 %69, 1
  store i16 %79, ptr @blockcount, align 2, !tbaa !5
  %80 = shl nuw nsw i16 %76, 10
  %81 = or disjoint i16 %80, 13
  %82 = add nuw nsw i64 %1, 104
  %83 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %82
  store i16 %81, ptr %83, align 16, !tbaa !5
  %84 = or disjoint i16 %80, 14
  %85 = add nuw nsw i64 %1, 105
  %86 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %85
  store i16 %84, ptr %86, align 2, !tbaa !5
  %87 = add nuw nsw i64 %1, 137
  %88 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %87
  %89 = load <2 x i16>, ptr %88, align 2, !tbaa !5
  %90 = add <2 x i16> %89, <i16 1024, i16 1024>
  store <2 x i16> %90, ptr %88, align 2, !tbaa !5
  br label %91

91:                                               ; preds = %75, %68
  %92 = phi i16 [ %69, %68 ], [ %79, %75 ]
  %93 = add i16 %.lcssa815, 5
  %94 = zext i16 %70 to i64
  %95 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %94
  %96 = load i8, ptr %95, align 2, !tbaa !12
  %97 = icmp ult i8 %96, 8
  br i1 %97, label %98, label %114

98:                                               ; preds = %91
  %99 = zext i8 %96 to i16
  %100 = trunc i64 %1 to i16
  %101 = or disjoint i16 %100, 8
  store i16 %101, ptr @c, align 2, !tbaa !5
  %102 = add i16 %92, 1
  store i16 %102, ptr @blockcount, align 2, !tbaa !5
  %103 = shl nuw nsw i16 %99, 10
  %104 = or disjoint i16 %103, 13
  %105 = add nuw nsw i64 %1, 106
  %106 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %105
  store i16 %104, ptr %106, align 4, !tbaa !5
  %107 = or disjoint i16 %103, 14
  %108 = add nuw nsw i64 %1, 107
  %109 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %108
  store i16 %107, ptr %109, align 2, !tbaa !5
  %110 = add nuw nsw i64 %1, 139
  %111 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %110
  %112 = load <2 x i16>, ptr %111, align 2, !tbaa !5
  %113 = add <2 x i16> %112, <i16 1024, i16 1024>
  store <2 x i16> %113, ptr %111, align 2, !tbaa !5
  br label %114

114:                                              ; preds = %98, %91
  %115 = phi i16 [ %92, %91 ], [ %102, %98 ]
  %116 = add i16 %.lcssa815, 6
  %117 = zext i16 %93 to i64
  %118 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %117
  %119 = load i8, ptr %118, align 1, !tbaa !12
  %120 = icmp ult i8 %119, 8
  br i1 %120, label %121, label %137

121:                                              ; preds = %114
  %122 = zext i8 %119 to i16
  %123 = trunc i64 %1 to i16
  %124 = or disjoint i16 %123, 10
  store i16 %124, ptr @c, align 2, !tbaa !5
  %125 = add i16 %115, 1
  store i16 %125, ptr @blockcount, align 2, !tbaa !5
  %126 = shl nuw nsw i16 %122, 10
  %127 = or disjoint i16 %126, 13
  %128 = add nuw nsw i64 %1, 108
  %129 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %128
  store i16 %127, ptr %129, align 8, !tbaa !5
  %130 = or disjoint i16 %126, 14
  %131 = add nuw nsw i64 %1, 109
  %132 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %131
  store i16 %130, ptr %132, align 2, !tbaa !5
  %133 = add nuw nsw i64 %1, 141
  %134 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %133
  %135 = load <2 x i16>, ptr %134, align 2, !tbaa !5
  %136 = add <2 x i16> %135, <i16 1024, i16 1024>
  store <2 x i16> %136, ptr %134, align 2, !tbaa !5
  br label %137

137:                                              ; preds = %121, %114
  %138 = phi i16 [ %115, %114 ], [ %125, %121 ]
  %139 = add i16 %.lcssa815, 7
  %140 = zext i16 %116 to i64
  %141 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %140
  %142 = load i8, ptr %141, align 2, !tbaa !12
  %143 = icmp ult i8 %142, 8
  br i1 %143, label %144, label %160

144:                                              ; preds = %137
  %145 = zext i8 %142 to i16
  %146 = trunc i64 %1 to i16
  %147 = or disjoint i16 %146, 12
  store i16 %147, ptr @c, align 2, !tbaa !5
  %148 = add i16 %138, 1
  store i16 %148, ptr @blockcount, align 2, !tbaa !5
  %149 = shl nuw nsw i16 %145, 10
  %150 = or disjoint i16 %149, 13
  %151 = add nuw nsw i64 %1, 110
  %152 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %151
  store i16 %150, ptr %152, align 4, !tbaa !5
  %153 = or disjoint i16 %149, 14
  %154 = add nuw nsw i64 %1, 111
  %155 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %154
  store i16 %153, ptr %155, align 2, !tbaa !5
  %156 = add nuw nsw i64 %1, 143
  %157 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %156
  %158 = load <2 x i16>, ptr %157, align 2, !tbaa !5
  %159 = add <2 x i16> %158, <i16 1024, i16 1024>
  store <2 x i16> %159, ptr %157, align 2, !tbaa !5
  br label %160

160:                                              ; preds = %144, %137
  %161 = phi i16 [ %138, %137 ], [ %148, %144 ]
  %162 = add i16 %.lcssa815, 8
  %163 = zext i16 %139 to i64
  %164 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %163
  %165 = load i8, ptr %164, align 1, !tbaa !12
  %166 = icmp ult i8 %165, 8
  br i1 %166, label %167, label %183

167:                                              ; preds = %160
  %168 = zext i8 %165 to i16
  %169 = trunc i64 %1 to i16
  %170 = or disjoint i16 %169, 14
  store i16 %170, ptr @c, align 2, !tbaa !5
  %171 = add i16 %161, 1
  store i16 %171, ptr @blockcount, align 2, !tbaa !5
  %172 = shl nuw nsw i16 %168, 10
  %173 = or disjoint i16 %172, 13
  %174 = add nuw nsw i64 %1, 112
  %175 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %174
  store i16 %173, ptr %175, align 16, !tbaa !5
  %176 = or disjoint i16 %172, 14
  %177 = add nuw nsw i64 %1, 113
  %178 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %177
  store i16 %176, ptr %178, align 2, !tbaa !5
  %179 = add nuw nsw i64 %1, 145
  %180 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %179
  %181 = load <2 x i16>, ptr %180, align 2, !tbaa !5
  %182 = add <2 x i16> %181, <i16 1024, i16 1024>
  store <2 x i16> %182, ptr %180, align 2, !tbaa !5
  br label %183

183:                                              ; preds = %167, %160
  %184 = phi i16 [ %161, %160 ], [ %171, %167 ]
  %185 = add i16 %.lcssa815, 9
  %186 = zext i16 %162 to i64
  %187 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %186
  %188 = load i8, ptr %187, align 2, !tbaa !12
  %189 = icmp ult i8 %188, 8
  br i1 %189, label %190, label %206

190:                                              ; preds = %183
  %191 = zext i8 %188 to i16
  %192 = trunc i64 %1 to i16
  %193 = or disjoint i16 %192, 16
  store i16 %193, ptr @c, align 2, !tbaa !5
  %194 = add i16 %184, 1
  store i16 %194, ptr @blockcount, align 2, !tbaa !5
  %195 = shl nuw nsw i16 %191, 10
  %196 = or disjoint i16 %195, 13
  %197 = add nuw nsw i64 %1, 114
  %198 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %197
  store i16 %196, ptr %198, align 4, !tbaa !5
  %199 = or disjoint i16 %195, 14
  %200 = add nuw nsw i64 %1, 115
  %201 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %200
  store i16 %199, ptr %201, align 2, !tbaa !5
  %202 = add nuw nsw i64 %1, 147
  %203 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %202
  %204 = load <2 x i16>, ptr %203, align 2, !tbaa !5
  %205 = add <2 x i16> %204, <i16 1024, i16 1024>
  store <2 x i16> %205, ptr %203, align 2, !tbaa !5
  br label %206

206:                                              ; preds = %190, %183
  %207 = phi i16 [ %184, %183 ], [ %194, %190 ]
  %208 = add i16 %.lcssa815, 10
  %209 = zext i16 %185 to i64
  %210 = getelementptr inbounds [100 x i8], ptr @blocks, i64 0, i64 %209
  %211 = load i8, ptr %210, align 1, !tbaa !12
  %212 = zext i8 %211 to i16
  %213 = icmp ult i8 %211, 8
  br i1 %213, label %214, label %229

214:                                              ; preds = %206
  %215 = trunc i64 %1 to i16
  %216 = or disjoint i16 %215, 18
  store i16 %216, ptr @c, align 2, !tbaa !5
  %217 = add i16 %207, 1
  store i16 %217, ptr @blockcount, align 2, !tbaa !5
  %218 = shl nuw nsw i16 %212, 10
  %219 = or disjoint i16 %218, 13
  %220 = add nuw nsw i64 %1, 116
  %221 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %220
  store i16 %219, ptr %221, align 8, !tbaa !5
  %222 = or disjoint i16 %218, 14
  %223 = add nuw nsw i64 %1, 117
  %224 = getelementptr inbounds [1024 x i16], ptr @blockmap, i64 0, i64 %223
  store i16 %222, ptr %224, align 2, !tbaa !5
  %225 = add nuw nsw i64 %1, 149
  %226 = getelementptr inbounds [1024 x i16], ptr @backmap, i64 0, i64 %225
  %227 = load <2 x i16>, ptr %226, align 2, !tbaa !5
  %228 = add <2 x i16> %227, <i16 1024, i16 1024>
  store <2 x i16> %228, ptr %226, align 2, !tbaa !5
  br label %229

229:                                              ; preds = %214, %206
  %blockcount.promoted11.9 = phi i16 [ %207, %206 ], [ %217, %214 ]
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next25, 10
  br i1 %exitcond27.not, label %230, label %.preheader3, !llvm.loop !13

230:                                              ; preds = %229
  store i8 10, ptr @j, align 1, !tbaa !12
  store i8 20, ptr @i, align 1, !tbaa !12
  store i16 %208, ptr @b, align 2, !tbaa !5
  store i16 %212, ptr @a, align 2, !tbaa !5
  tail call void @writenum(i16 noundef zeroext 4, i8 noundef zeroext 8, ptr noundef nonnull @blockmap, i16 noundef zeroext 310, i16 noundef zeroext 1062)
  tail call void @writestring(ptr noundef nonnull @.str, ptr noundef nonnull @blockmap, i16 noundef zeroext 584, i16 noundef zeroext 1014)
  tail call void @WaitForVBlank() #4
  tail call void @bgInitMapSet(i8 noundef zeroext 0, ptr noundef nonnull @blockmap, i16 noundef zeroext 2048, i8 noundef zeroext 0, i16 noundef zeroext 0) #4
  tail call void @bgInitMapSet(i8 noundef zeroext 2, ptr noundef nonnull @backmap, i16 noundef zeroext 2048, i8 noundef zeroext 0, i16 noundef zeroext 1024) #4
  tail call void @dmaCopyCGram(ptr noundef nonnull @pal, i16 noundef zeroext 0, i16 noundef zeroext 512) #4
  tail call void @bgSetGfxPtr(i8 noundef zeroext 0, i16 noundef zeroext 4096) #4
  tail call void @bgSetGfxPtr(i8 noundef zeroext 2, i16 noundef zeroext 8192) #4
  tail call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0) #4
  tail call void @bgSetDisable(i8 noundef zeroext 1) #4
  tail call void @setScreenOn() #4
  tail call void @draw_screen()
  store i8 0, ptr @i, align 1, !tbaa !12
  br label %233

.preheader:                                       ; preds = %233
  %231 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %232 = icmp eq i16 %231, 0
  br i1 %232, label %.lr.ph, label %._crit_edge

233:                                              ; preds = %230, %233
  %storemerge117 = phi i8 [ 0, %230 ], [ %236, %233 ]
  %234 = zext nneg i8 %storemerge117 to i16
  tail call void @oamSetEx(i16 noundef zeroext %234, i8 noundef zeroext 0, i8 noundef zeroext 0) #4
  %235 = load i8, ptr @i, align 1, !tbaa !12
  %236 = add i8 %235, 4
  store i8 %236, ptr @i, align 1, !tbaa !12
  %237 = icmp ult i8 %236, 40
  br i1 %237, label %233, label %.preheader, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  tail call void @WaitForVBlank() #4
  %238 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %239 = icmp eq i16 %238, 0
  br i1 %239, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  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() #4
  tail call void @dmaCopyVram(ptr noundef nonnull @blockmap, i16 noundef zeroext 0, i16 noundef zeroext 2048) #4
  br label %240

240:                                              ; preds = %240, %._crit_edge
  tail call void @run_frame()
  br label %240
}

declare void @setBrightness(i8 noundef zeroext) local_unnamed_addr #2

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

declare void @bgSetGfxPtr(i8 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

declare void @setMode(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

declare void @bgSetDisable(i8 noundef zeroext) local_unnamed_addr #2

declare void @setScreenOn() local_unnamed_addr #2

declare void @oamSetEx(i16 noundef zeroext, i8 noundef zeroext, i8 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 = { noreturn 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 #4 = { 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}
!16 = distinct !{!16, !14}


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