; LLVM IR from alekmaul/pvsneslib :: snes-examples/maps/DynamicMap (DynamicMap)

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

@scroll_lock = external dso_local global i8, align 1
@map32x32 = external dso_local global i8, align 1
@max_scroll_width = external dso_local global i16, align 2
@max_scroll_height = external dso_local global i16, align 2
@sprites_ram = external global i8, align 1
@c64_sprite = external global i8, align 1
@snesfont = external global i8, align 1
@snespal = external global i8, align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@pad_keys = external global [5 x i16], align 2
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

declare void @consoleNocashMessage(ptr noundef, ...) #2

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

declare zeroext i16 @calculateSpriteIndex32x32(i8 noundef zeroext) #2

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

declare zeroext i16 @calculateSpriteIndex64x64(i8 noundef zeroext) #2

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

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

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

declare void @WaitForVBlank() #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i16, align 2
  %3 = alloca i16, align 2
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  store i32 0, ptr %1, align 4
  call void @consoleSetTextMapPtr(i16 noundef zeroext 26624)
  call void @consoleSetTextGfxPtr(i16 noundef zeroext 12288)
  call void @consoleSetTextOffset(i16 noundef zeroext 256)
  call void @consoleInitText(i8 noundef zeroext 0, i8 noundef zeroext 32, ptr noundef @snesfont, ptr noundef @snespal)
  call void @bgSetGfxPtr(i8 noundef zeroext 1, i16 noundef zeroext 8192)
  call void @bgSetMapPtr(i8 noundef zeroext 1, i16 noundef zeroext 26624, i8 noundef zeroext 0)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 10, ptr noundef @.str.8)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef @.str.9)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 14, ptr noundef @.str.10)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 16, ptr noundef @.str.11)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 18, ptr noundef @.str.12)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 20, ptr noundef @.str.13)
  call void @initDemoMap32x32()
  call void @setScreenOn()
  call void @drawSpriteFrame32x32(i16 noundef zeroext 1)
  call void @refresh()
  call void @llvm.lifetime.start.p0(i64 2, ptr %2) #3
  store i16 0, ptr %2, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #3
  store i16 0, ptr %3, align 2, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #3
  call void (ptr, ...) @consoleNocashMessage(ptr noundef @.str.14, ptr noundef @c64_sprite)
  br label %6

6:                                                ; preds = %167, %0
  br label %7

7:                                                ; preds = %6
  %8 = load i16, ptr @pad_keys, align 2, !tbaa !5
  store i16 %8, ptr %4, align 2, !tbaa !5
  %9 = call zeroext i16 @padsUp(i16 noundef zeroext 0)
  store i16 %9, ptr %5, align 2, !tbaa !5
  %10 = load i16, ptr %4, align 2, !tbaa !5
  %11 = zext i16 %10 to i32
  %12 = and i32 %11, 256
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %35

14:                                               ; preds = %7
  %15 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %22, label %17

17:                                               ; preds = %14
  %18 = load i16, ptr %2, align 2, !tbaa !5
  %19 = sext i16 %18 to i32
  %20 = add nsw i32 %19, 4
  %21 = trunc i32 %20 to i16
  store i16 %21, ptr %2, align 2, !tbaa !5
  br label %34

22:                                               ; preds = %14
  %23 = load i16, ptr %2, align 2, !tbaa !5
  %24 = sext i16 %23 to i32
  %25 = load i16, ptr @max_scroll_width, align 2, !tbaa !5
  %26 = zext i16 %25 to i32
  %27 = icmp slt i32 %24, %26
  br i1 %27, label %28, label %33

28:                                               ; preds = %22
  %29 = load i16, ptr %2, align 2, !tbaa !5
  %30 = sext i16 %29 to i32
  %31 = add nsw i32 %30, 4
  %32 = trunc i32 %31 to i16
  store i16 %32, ptr %2, align 2, !tbaa !5
  br label %33

33:                                               ; preds = %28, %22
  br label %34

34:                                               ; preds = %33, %17
  br label %60

35:                                               ; preds = %7
  %36 = load i16, ptr %4, align 2, !tbaa !5
  %37 = zext i16 %36 to i32
  %38 = and i32 %37, 512
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %59

40:                                               ; preds = %35
  %41 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %48, label %43

43:                                               ; preds = %40
  %44 = load i16, ptr %2, align 2, !tbaa !5
  %45 = sext i16 %44 to i32
  %46 = sub nsw i32 %45, 4
  %47 = trunc i32 %46 to i16
  store i16 %47, ptr %2, align 2, !tbaa !5
  br label %58

48:                                               ; preds = %40
  %49 = load i16, ptr %2, align 2, !tbaa !5
  %50 = sext i16 %49 to i32
  %51 = icmp sgt i32 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %48
  %53 = load i16, ptr %2, align 2, !tbaa !5
  %54 = sext i16 %53 to i32
  %55 = sub nsw i32 %54, 4
  %56 = trunc i32 %55 to i16
  store i16 %56, ptr %2, align 2, !tbaa !5
  br label %57

57:                                               ; preds = %52, %48
  br label %58

58:                                               ; preds = %57, %43
  br label %59

59:                                               ; preds = %58, %35
  br label %60

60:                                               ; preds = %59, %34
  %61 = load i16, ptr %4, align 2, !tbaa !5
  %62 = zext i16 %61 to i32
  %63 = and i32 %62, 2048
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %84

65:                                               ; preds = %60
  %66 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %67 = icmp ne i8 %66, 0
  br i1 %67, label %73, label %68

68:                                               ; preds = %65
  %69 = load i16, ptr %3, align 2, !tbaa !5
  %70 = sext i16 %69 to i32
  %71 = sub nsw i32 %70, 4
  %72 = trunc i32 %71 to i16
  store i16 %72, ptr %3, align 2, !tbaa !5
  br label %83

73:                                               ; preds = %65
  %74 = load i16, ptr %3, align 2, !tbaa !5
  %75 = sext i16 %74 to i32
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %82

77:                                               ; preds = %73
  %78 = load i16, ptr %3, align 2, !tbaa !5
  %79 = sext i16 %78 to i32
  %80 = sub nsw i32 %79, 4
  %81 = trunc i32 %80 to i16
  store i16 %81, ptr %3, align 2, !tbaa !5
  br label %82

82:                                               ; preds = %77, %73
  br label %83

83:                                               ; preds = %82, %68
  br label %111

84:                                               ; preds = %60
  %85 = load i16, ptr %4, align 2, !tbaa !5
  %86 = zext i16 %85 to i32
  %87 = and i32 %86, 1024
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %110

89:                                               ; preds = %84
  %90 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %91 = icmp ne i8 %90, 0
  br i1 %91, label %97, label %92

92:                                               ; preds = %89
  %93 = load i16, ptr %3, align 2, !tbaa !5
  %94 = sext i16 %93 to i32
  %95 = add nsw i32 %94, 4
  %96 = trunc i32 %95 to i16
  store i16 %96, ptr %3, align 2, !tbaa !5
  br label %109

97:                                               ; preds = %89
  %98 = load i16, ptr %3, align 2, !tbaa !5
  %99 = sext i16 %98 to i32
  %100 = load i16, ptr @max_scroll_height, align 2, !tbaa !5
  %101 = zext i16 %100 to i32
  %102 = icmp slt i32 %99, %101
  br i1 %102, label %103, label %108

103:                                              ; preds = %97
  %104 = load i16, ptr %3, align 2, !tbaa !5
  %105 = sext i16 %104 to i32
  %106 = add nsw i32 %105, 4
  %107 = trunc i32 %106 to i16
  store i16 %107, ptr %3, align 2, !tbaa !5
  br label %108

108:                                              ; preds = %103, %97
  br label %109

109:                                              ; preds = %108, %92
  br label %110

110:                                              ; preds = %109, %84
  br label %111

111:                                              ; preds = %110, %83
  %112 = load i16, ptr %5, align 2, !tbaa !5
  %113 = zext i16 %112 to i32
  %114 = and i32 %113, 128
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %127

116:                                              ; preds = %111
  %117 = load i8, ptr @map32x32, align 1, !tbaa !9
  %118 = icmp ne i8 %117, 0
  %119 = xor i1 %118, true
  %120 = zext i1 %119 to i32
  %121 = trunc i32 %120 to i8
  store i8 %121, ptr @map32x32, align 1, !tbaa !9
  %122 = load i8, ptr @map32x32, align 1, !tbaa !9
  %123 = icmp ne i8 %122, 0
  br i1 %123, label %124, label %125

124:                                              ; preds = %116
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef @.str.9)
  call void @setScreenOff()
  call void @initDemoMap32x32()
  call void @setScreenOn()
  call void @drawSpriteFrame32x32(i16 noundef zeroext 1)
  call void @refresh()
  br label %126

125:                                              ; preds = %116
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef @.str.15)
  call void @setScreenOff()
  call void @initDemoMap64x64()
  call void @setScreenOn()
  call void @drawSpriteFrame64x64(i16 noundef zeroext 1)
  call void @refresh()
  br label %126

126:                                              ; preds = %125, %124
  store i16 0, ptr %2, align 2, !tbaa !5
  store i16 0, ptr %3, align 2, !tbaa !5
  br label %127

127:                                              ; preds = %126, %111
  %128 = load i16, ptr %5, align 2, !tbaa !5
  %129 = zext i16 %128 to i32
  %130 = and i32 %129, 32768
  %131 = icmp ne i32 %130, 0
  br i1 %131, label %132, label %143

132:                                              ; preds = %127
  %133 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %134 = icmp ne i8 %133, 0
  %135 = xor i1 %134, true
  %136 = zext i1 %135 to i32
  %137 = trunc i32 %136 to i8
  store i8 %137, ptr @scroll_lock, align 1, !tbaa !9
  %138 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %139 = icmp ne i8 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %132
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 14, ptr noundef @.str.10)
  br label %142

141:                                              ; preds = %132
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 14, ptr noundef @.str.16)
  br label %142

142:                                              ; preds = %141, %140
  br label %143

143:                                              ; preds = %142, %127
  %144 = load i16, ptr %4, align 2, !tbaa !5
  %145 = zext i16 %144 to i32
  %146 = and i32 %145, 64
  %147 = icmp ne i32 %146, 0
  br i1 %147, label %148, label %154

148:                                              ; preds = %143
  %149 = load i8, ptr @map32x32, align 1, !tbaa !9
  %150 = icmp ne i8 %149, 0
  br i1 %150, label %151, label %152

151:                                              ; preds = %148
  call void @testGetSprite32x32()
  br label %153

152:                                              ; preds = %148
  call void @testGetSprite64x64()
  br label %153

153:                                              ; preds = %152, %151
  br label %154

154:                                              ; preds = %153, %143
  %155 = load i16, ptr %4, align 2, !tbaa !5
  %156 = zext i16 %155 to i32
  %157 = and i32 %156, 16384
  %158 = icmp ne i32 %157, 0
  br i1 %158, label %159, label %167

159:                                              ; preds = %154
  %160 = load i8, ptr @map32x32, align 1, !tbaa !9
  %161 = icmp ne i8 %160, 0
  br i1 %161, label %162, label %164

162:                                              ; preds = %159
  %163 = call zeroext i16 @calculateSpriteIndex32x32(i8 noundef zeroext 2)
  call void @convertC64Sprite(i8 noundef zeroext 0, i16 noundef zeroext %163, i8 noundef zeroext -1)
  call void @WaitForVBlank()
  call void @updateSprite32x32(ptr noundef @sprites_ram, i16 noundef zeroext 16384, i16 noundef zeroext 2)
  call void @drawSpriteFrame32x32(i16 noundef zeroext 2)
  call void @refresh()
  br label %166

164:                                              ; preds = %159
  %165 = call zeroext i16 @calculateSpriteIndex64x64(i8 noundef zeroext 2)
  call void @convertC64Sprite(i8 noundef zeroext 0, i16 noundef zeroext %165, i8 noundef zeroext 0)
  call void @WaitForVBlank()
  call void @updateSprite64x64(ptr noundef @sprites_ram, i16 noundef zeroext 16384, i16 noundef zeroext 2)
  call void @drawSpriteFrame64x64(i16 noundef zeroext 2)
  call void @refresh()
  br label %166

166:                                              ; preds = %164, %162
  br label %167

167:                                              ; preds = %166, %154
  %168 = load i16, ptr %2, align 2, !tbaa !5
  %169 = load i16, ptr %3, align 2, !tbaa !5
  call void @bgSetScroll(i8 noundef zeroext 0, i16 noundef zeroext %168, i16 noundef zeroext %169)
  call void @WaitForVBlank()
  br label %6
}

declare void @consoleSetTextMapPtr(i16 noundef zeroext) #2

declare void @consoleSetTextGfxPtr(i16 noundef zeroext) #2

declare void @consoleSetTextOffset(i16 noundef zeroext) #2

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

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

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

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

declare void @setScreenOn() #2

declare zeroext i16 @padsUp(i16 noundef zeroext) #2

declare void @setScreenOff() #2

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

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

declare void @bgSetScroll(i8 noundef zeroext, 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 nosync 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 = !{!7, !7, i64 0}


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

@scroll_lock = external dso_local local_unnamed_addr global i8, align 1
@map32x32 = external dso_local local_unnamed_addr global i8, align 1
@max_scroll_width = external dso_local local_unnamed_addr global i16, align 2
@max_scroll_height = external dso_local local_unnamed_addr global i16, align 2
@sprites_ram = external global i8, align 1
@c64_sprite = external global i8, align 1
@snesfont = external global i8, align 1
@snespal = external global i8, align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [22 x i8], align 1
@pad_keys = external local_unnamed_addr global [5 x i16], align 2
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [20 x i8], align 1

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

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

declare void @consoleNocashMessage(ptr noundef, ...) local_unnamed_addr #1

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

declare zeroext i16 @calculateSpriteIndex32x32(i8 noundef zeroext) local_unnamed_addr #1

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

declare zeroext i16 @calculateSpriteIndex64x64(i8 noundef zeroext) local_unnamed_addr #1

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

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

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

declare void @WaitForVBlank() local_unnamed_addr #1

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

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  tail call void @consoleSetTextMapPtr(i16 noundef zeroext 26624) #3
  tail call void @consoleSetTextGfxPtr(i16 noundef zeroext 12288) #3
  tail call void @consoleSetTextOffset(i16 noundef zeroext 256) #3
  tail call void @consoleInitText(i8 noundef zeroext 0, i8 noundef zeroext 32, ptr noundef nonnull @snesfont, ptr noundef nonnull @snespal) #3
  tail call void @bgSetGfxPtr(i8 noundef zeroext 1, i16 noundef zeroext 8192) #3
  tail call void @bgSetMapPtr(i8 noundef zeroext 1, i16 noundef zeroext 26624, i8 noundef zeroext 0) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 10, ptr noundef nonnull @.str.8) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef nonnull @.str.9) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 14, ptr noundef nonnull @.str.10) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 16, ptr noundef nonnull @.str.11) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 18, ptr noundef nonnull @.str.12) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 20, ptr noundef nonnull @.str.13) #3
  tail call void @initDemoMap32x32()
  tail call void @setScreenOn() #3
  tail call void @drawSpriteFrame32x32(i16 noundef zeroext 1)
  tail call void @refresh()
  tail call void (ptr, ...) @consoleNocashMessage(ptr noundef nonnull @.str.14, ptr noundef nonnull @c64_sprite) #3
  br label %1

1:                                                ; preds = %70, %0
  %.022 = phi i16 [ 0, %0 ], [ %.224, %70 ]
  %.0 = phi i16 [ 0, %0 ], [ %.2, %70 ]
  %2 = load i16, ptr @pad_keys, align 2, !tbaa !5
  %3 = tail call zeroext i16 @padsUp(i16 noundef zeroext 0) #3
  %4 = zext i16 %2 to i32
  %5 = and i32 %4, 256
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %16, label %6

6:                                                ; preds = %1
  %7 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %.not31 = icmp eq i8 %7, 0
  br i1 %.not31, label %8, label %10

8:                                                ; preds = %6
  %9 = add i16 %.0, 4
  br label %25

10:                                               ; preds = %6
  %11 = sext i16 %.0 to i32
  %12 = load i16, ptr @max_scroll_width, align 2, !tbaa !5
  %13 = zext i16 %12 to i32
  %14 = icmp slt i32 %11, %13
  %15 = add i16 %.0, 4
  %spec.select = select i1 %14, i16 %15, i16 %.0
  br label %25

16:                                               ; preds = %1
  %17 = and i32 %4, 512
  %.not29 = icmp eq i32 %17, 0
  br i1 %.not29, label %25, label %18

18:                                               ; preds = %16
  %19 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %.not30 = icmp eq i8 %19, 0
  br i1 %.not30, label %20, label %22

20:                                               ; preds = %18
  %21 = add i16 %.0, -4
  br label %25

22:                                               ; preds = %18
  %23 = icmp sgt i16 %.0, 0
  %24 = add nsw i16 %.0, -4
  %spec.select44 = select i1 %23, i16 %24, i16 %.0
  br label %25

25:                                               ; preds = %22, %10, %16, %20, %8
  %.1 = phi i16 [ %9, %8 ], [ %21, %20 ], [ %.0, %16 ], [ %spec.select, %10 ], [ %spec.select44, %22 ]
  %26 = and i32 %4, 2048
  %.not32 = icmp eq i32 %26, 0
  br i1 %.not32, label %34, label %27

27:                                               ; preds = %25
  %28 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %.not35 = icmp eq i8 %28, 0
  br i1 %.not35, label %29, label %31

29:                                               ; preds = %27
  %30 = add i16 %.022, -4
  br label %46

31:                                               ; preds = %27
  %32 = icmp sgt i16 %.022, 0
  %33 = add nsw i16 %.022, -4
  %spec.select45 = select i1 %32, i16 %33, i16 %.022
  br label %46

34:                                               ; preds = %25
  %35 = and i32 %4, 1024
  %.not33 = icmp eq i32 %35, 0
  br i1 %.not33, label %46, label %36

36:                                               ; preds = %34
  %37 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %.not34 = icmp eq i8 %37, 0
  br i1 %.not34, label %38, label %40

38:                                               ; preds = %36
  %39 = add i16 %.022, 4
  br label %46

40:                                               ; preds = %36
  %41 = sext i16 %.022 to i32
  %42 = load i16, ptr @max_scroll_height, align 2, !tbaa !5
  %43 = zext i16 %42 to i32
  %44 = icmp slt i32 %41, %43
  %45 = add i16 %.022, 4
  %spec.select46 = select i1 %44, i16 %45, i16 %.022
  br label %46

46:                                               ; preds = %40, %31, %34, %38, %29
  %.123 = phi i16 [ %30, %29 ], [ %39, %38 ], [ %.022, %34 ], [ %spec.select45, %31 ], [ %spec.select46, %40 ]
  %47 = and i16 %3, 128
  %.not36 = icmp eq i16 %47, 0
  br i1 %.not36, label %53, label %48

48:                                               ; preds = %46
  %49 = load i8, ptr @map32x32, align 1, !tbaa !9
  %.not37 = icmp eq i8 %49, 0
  %50 = zext i1 %.not37 to i8
  store i8 %50, ptr @map32x32, align 1, !tbaa !9
  br i1 %.not37, label %51, label %52

51:                                               ; preds = %48
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef nonnull @.str.9) #3
  tail call void @setScreenOff() #3
  tail call void @initDemoMap32x32()
  tail call void @setScreenOn() #3
  tail call void @drawSpriteFrame32x32(i16 noundef zeroext 1)
  br label %.sink.split

52:                                               ; preds = %48
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 12, ptr noundef nonnull @.str.15) #3
  tail call void @setScreenOff() #3
  tail call void @initDemoMap64x64()
  tail call void @setScreenOn() #3
  tail call void @drawSpriteFrame64x64(i16 noundef zeroext 1)
  br label %.sink.split

.sink.split:                                      ; preds = %52, %51
  tail call void @refresh()
  br label %53

53:                                               ; preds = %.sink.split, %46
  %.224 = phi i16 [ %.123, %46 ], [ 0, %.sink.split ]
  %.2 = phi i16 [ %.1, %46 ], [ 0, %.sink.split ]
  %.not38 = icmp sgt i16 %3, -1
  br i1 %.not38, label %56, label %.sink.split47

.sink.split47:                                    ; preds = %53
  %54 = load i8, ptr @scroll_lock, align 1, !tbaa !9
  %.not39 = icmp eq i8 %54, 0
  %55 = zext i1 %.not39 to i8
  store i8 %55, ptr @scroll_lock, align 1, !tbaa !9
  %.str.10..str.16 = select i1 %.not39, ptr @.str.10, ptr @.str.16
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 6, i16 noundef zeroext 14, ptr noundef nonnull %.str.10..str.16) #3
  br label %56

56:                                               ; preds = %.sink.split47, %53
  %57 = and i32 %4, 64
  %.not40 = icmp eq i32 %57, 0
  br i1 %.not40, label %62, label %58

58:                                               ; preds = %56
  %59 = load i8, ptr @map32x32, align 1, !tbaa !9
  %.not41 = icmp eq i8 %59, 0
  br i1 %.not41, label %61, label %60

60:                                               ; preds = %58
  tail call void @testGetSprite32x32()
  br label %62

61:                                               ; preds = %58
  tail call void @testGetSprite64x64()
  br label %62

62:                                               ; preds = %60, %61, %56
  %63 = and i32 %4, 16384
  %.not42 = icmp eq i32 %63, 0
  br i1 %.not42, label %70, label %64

64:                                               ; preds = %62
  %65 = load i8, ptr @map32x32, align 1, !tbaa !9
  %.not43 = icmp eq i8 %65, 0
  br i1 %.not43, label %68, label %66

66:                                               ; preds = %64
  %67 = tail call zeroext i16 @calculateSpriteIndex32x32(i8 noundef zeroext 2) #3
  tail call void @convertC64Sprite(i8 noundef zeroext 0, i16 noundef zeroext %67, i8 noundef zeroext -1)
  tail call void @WaitForVBlank() #3
  tail call void @updateSprite32x32(ptr noundef nonnull @sprites_ram, i16 noundef zeroext 16384, i16 noundef zeroext 2) #3
  tail call void @drawSpriteFrame32x32(i16 noundef zeroext 2)
  br label %.sink.split48

68:                                               ; preds = %64
  %69 = tail call zeroext i16 @calculateSpriteIndex64x64(i8 noundef zeroext 2) #3
  tail call void @convertC64Sprite(i8 noundef zeroext 0, i16 noundef zeroext %69, i8 noundef zeroext 0)
  tail call void @WaitForVBlank() #3
  tail call void @updateSprite64x64(ptr noundef nonnull @sprites_ram, i16 noundef zeroext 16384, i16 noundef zeroext 2) #3
  tail call void @drawSpriteFrame64x64(i16 noundef zeroext 2)
  br label %.sink.split48

.sink.split48:                                    ; preds = %68, %66
  tail call void @refresh()
  br label %70

70:                                               ; preds = %.sink.split48, %62
  tail call void @bgSetScroll(i8 noundef zeroext 0, i16 noundef zeroext %.2, i16 noundef zeroext %.224) #3
  tail call void @WaitForVBlank() #3
  br label %1
}

declare void @consoleSetTextMapPtr(i16 noundef zeroext) local_unnamed_addr #1

declare void @consoleSetTextGfxPtr(i16 noundef zeroext) local_unnamed_addr #1

declare void @consoleSetTextOffset(i16 noundef zeroext) local_unnamed_addr #1

declare void @consoleInitText(i8 noundef zeroext, i8 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare void @bgSetMapPtr(i8 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

declare void @consoleDrawText(i16 noundef zeroext, i16 noundef zeroext, ptr noundef, ...) local_unnamed_addr #1

declare void @setScreenOn() local_unnamed_addr #1

declare zeroext i16 @padsUp(i16 noundef zeroext) local_unnamed_addr #1

declare void @setScreenOff() local_unnamed_addr #1

declare void @updateSprite32x32(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

declare void @updateSprite64x64(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

declare void @bgSetScroll(i8 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

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 = { "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 = { 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 #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 = !{!7, !7, i64 0}


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