; LLVM IR from alekmaul/pvsneslib :: snes-examples/input/mouse (mouse)

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

@p1_mouse_x = external dso_local global i16, align 2
@p1_mouse_y = external dso_local global i16, align 2
@p2_mouse_x = external dso_local global i16, align 2
@p2_mouse_y = external dso_local global i16, align 2
@odd = external dso_local global i8, align 1
@mc_mem = external dso_local global [2 x i8], align 1
@printed = external dso_local global [2 x i8], align 1
@mouseDown_L = external dso_local global [2 x i8], align 1
@mouseDown_R = external dso_local global [2 x i8], align 1
@mouseDown_LR = external dso_local global [2 x i8], align 1
@cursorsprite = external global i8, align 1
@cursorsprite_end = external global i8, align 1
@cursorpal = external global i8, align 1
@snesfont = external global i8, align 1
@snespal = external global i8, align 1
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@mouseConnect = external global [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@buttonsmap = external global i8, align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@buttonstiles = external global i8, align 1
@buttonspal = external global i8, align 1
@buttonstiles_end = external global i8, align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1
@mouse_x = external global [2 x i8], align 1
@mouse_y = external global [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@mouseButton = external global [2 x i8], align 1
@hex_string = external dso_local global [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@mousePressed = external global [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [27 x i8], align 1
@mouseSensitivity = external global [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @oamInitGfxSet(ptr noundef @cursorsprite, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @cursorsprite_end to i64), i64 ptrtoint (ptr @cursorsprite to i64)) to i16), ptr noundef @cursorpal, i16 noundef zeroext 96, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext 96)
  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 (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 1, ptr noundef @.str)
  call void @initMouse(i8 noundef zeroext 0)
  call void @WaitForVBlank()
  %2 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %3 = zext i8 %2 to i32
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %5, label %6

5:                                                ; preds = %0
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef @.str.1)
  br label %7

6:                                                ; preds = %0
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 24968, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25000, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 74), i16 noundef zeroext 24973, i16 noundef zeroext 22)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 138), i16 noundef zeroext 25005, i16 noundef zeroext 22)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 5, i16 noundef zeroext 5, ptr noundef @.str.2)
  br label %7

7:                                                ; preds = %6, %5
  %8 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %7
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef @.str.3)
  br label %13

12:                                               ; preds = %7
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 25352, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25384, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 74), i16 noundef zeroext 25357, i16 noundef zeroext 22)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 138), i16 noundef zeroext 25389, i16 noundef zeroext 22)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 5, i16 noundef zeroext 17, ptr noundef @.str.4)
  br label %13

13:                                               ; preds = %12, %11
  call void @bgSetGfxPtr(i8 noundef zeroext 0, i16 noundef zeroext 8192)
  call void @bgSetGfxPtr(i8 noundef zeroext 1, i16 noundef zeroext 16384)
  call void @bgSetMapPtr(i8 noundef zeroext 0, i16 noundef zeroext 26624, i8 noundef zeroext 0)
  call void @bgSetMapPtr(i8 noundef zeroext 1, i16 noundef zeroext 24576, i8 noundef zeroext 0)
  call void @bgInitTileSet(i8 noundef zeroext 1, ptr noundef @buttonstiles, ptr noundef @buttonspal, i8 noundef zeroext 1, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @buttonstiles_end to i64), i64 ptrtoint (ptr @buttonstiles to i64)) to i16), i16 noundef zeroext 32, i16 noundef zeroext 16, i16 noundef zeroext 16384)
  call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0)
  call void @bgSetDisable(i8 noundef zeroext 2)
  call void @setScreenOn()
  br label %14

14:                                               ; preds = %395, %13
  %15 = load i8, ptr @odd, align 1, !tbaa !5
  %16 = add i8 %15, 1
  store i8 %16, ptr @odd, align 1, !tbaa !5
  %17 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %18 = zext i8 %17 to i32
  %19 = load i8, ptr @mc_mem, align 1, !tbaa !5
  %20 = zext i8 %19 to i32
  %21 = icmp ne i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %14
  store i8 -1, ptr @printed, align 1, !tbaa !5
  br label %23

23:                                               ; preds = %22, %14
  %24 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  store i8 %24, ptr @mc_mem, align 1, !tbaa !5
  %25 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = load i8, ptr @printed, align 1, !tbaa !5
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @WaitForVBlank()
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef @.str.1)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 7, ptr noundef @.str.5)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef @.str.6)
  store i8 0, ptr @printed, align 1, !tbaa !5
  br label %32

32:                                               ; preds = %31, %28
  call void @oamSetVisible(i16 noundef zeroext 0, i8 noundef zeroext 1)
  br label %145

33:                                               ; preds = %23
  %34 = load i8, ptr @mouse_x, align 1, !tbaa !5
  %35 = zext i8 %34 to i32
  %36 = and i32 %35, 128
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %46

38:                                               ; preds = %33
  %39 = load i8, ptr @mouse_x, align 1, !tbaa !5
  %40 = zext i8 %39 to i32
  %41 = and i32 %40, 127
  %42 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %43 = zext i16 %42 to i32
  %44 = sub nsw i32 %43, %41
  %45 = trunc i32 %44 to i16
  store i16 %45, ptr @p1_mouse_x, align 2, !tbaa !8
  br label %54

46:                                               ; preds = %33
  %47 = load i8, ptr @mouse_x, align 1, !tbaa !5
  %48 = zext i8 %47 to i32
  %49 = and i32 %48, 127
  %50 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %51 = zext i16 %50 to i32
  %52 = add nsw i32 %51, %49
  %53 = trunc i32 %52 to i16
  store i16 %53, ptr @p1_mouse_x, align 2, !tbaa !8
  br label %54

54:                                               ; preds = %46, %38
  %55 = load i8, ptr @mouse_y, align 1, !tbaa !5
  %56 = zext i8 %55 to i32
  %57 = and i32 %56, 128
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %67

59:                                               ; preds = %54
  %60 = load i8, ptr @mouse_y, align 1, !tbaa !5
  %61 = zext i8 %60 to i32
  %62 = and i32 %61, 127
  %63 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %64 = zext i16 %63 to i32
  %65 = sub nsw i32 %64, %62
  %66 = trunc i32 %65 to i16
  store i16 %66, ptr @p1_mouse_y, align 2, !tbaa !8
  br label %75

67:                                               ; preds = %54
  %68 = load i8, ptr @mouse_y, align 1, !tbaa !5
  %69 = zext i8 %68 to i32
  %70 = and i32 %69, 127
  %71 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %72 = zext i16 %71 to i32
  %73 = add nsw i32 %72, %70
  %74 = trunc i32 %73 to i16
  store i16 %74, ptr @p1_mouse_y, align 2, !tbaa !8
  br label %75

75:                                               ; preds = %67, %59
  %76 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %77 = zext i16 %76 to i32
  %78 = icmp sgt i32 %77, 65280
  br i1 %78, label %79, label %80

79:                                               ; preds = %75
  store i16 0, ptr @p1_mouse_x, align 2, !tbaa !8
  br label %80

80:                                               ; preds = %79, %75
  %81 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %82 = zext i16 %81 to i32
  %83 = icmp sgt i32 %82, 255
  br i1 %83, label %84, label %85

84:                                               ; preds = %80
  store i16 255, ptr @p1_mouse_x, align 2, !tbaa !8
  br label %85

85:                                               ; preds = %84, %80
  %86 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %87 = zext i16 %86 to i32
  %88 = icmp sgt i32 %87, 65280
  br i1 %88, label %89, label %90

89:                                               ; preds = %85
  store i16 0, ptr @p1_mouse_y, align 2, !tbaa !8
  br label %90

90:                                               ; preds = %89, %85
  %91 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %92 = zext i16 %91 to i32
  %93 = icmp sgt i32 %92, 239
  br i1 %93, label %94, label %95

94:                                               ; preds = %90
  store i16 239, ptr @p1_mouse_y, align 2, !tbaa !8
  br label %95

95:                                               ; preds = %94, %90
  %96 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %97 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %98 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  call void @oamSet(i16 noundef zeroext 0, i16 noundef zeroext %96, i16 noundef zeroext %97, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext %98)
  %99 = load i8, ptr @printed, align 1, !tbaa !5
  %100 = icmp ne i8 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %95
  call void @WaitForVBlank()
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef @.str.7)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 7, ptr noundef @.str.8)
  store i8 0, ptr @printed, align 1, !tbaa !5
  br label %102

102:                                              ; preds = %101, %95
  %103 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  %104 = zext i8 %103 to i32
  %105 = icmp eq i32 %104, 0
  br i1 %105, label %106, label %107

106:                                              ; preds = %102
  store i8 1, ptr @odd, align 1, !tbaa !5
  br label %107

107:                                              ; preds = %106, %102
  %108 = load i8, ptr @odd, align 1, !tbaa !5
  %109 = zext i8 %108 to i32
  %110 = and i32 %109, 1
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %123

112:                                              ; preds = %107
  %113 = load i8, ptr @mouseButton, align 1, !tbaa !5
  %114 = zext i8 %113 to i32
  %115 = icmp eq i32 %114, 0
  br i1 %115, label %116, label %123

116:                                              ; preds = %112
  %117 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %118 = zext i16 %117 to i32
  %119 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @hex_string, ptr noundef @.str.9, i32 noundef %118) #3
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 13, i16 noundef zeroext 7, ptr noundef @hex_string)
  %120 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %121 = zext i16 %120 to i32
  %122 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @hex_string, ptr noundef @.str.9, i32 noundef %121) #3
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 19, i16 noundef zeroext 7, ptr noundef @hex_string)
  br label %123

123:                                              ; preds = %116, %112, %107
  %124 = load i8, ptr @mousePressed, align 1, !tbaa !5
  %125 = zext i8 %124 to i32
  switch i32 %125, label %144 [
    i32 1, label %126
    i32 2, label %132
    i32 3, label %138
  ]

126:                                              ; preds = %123
  %127 = load i8, ptr @mouseDown_L, align 1, !tbaa !5
  %128 = zext i8 %127 to i32
  %129 = icmp eq i32 %128, 0
  br i1 %129, label %130, label %131

130:                                              ; preds = %126
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef @.str.10)
  store i8 -1, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %131

131:                                              ; preds = %130, %126
  br label %144

132:                                              ; preds = %123
  %133 = load i8, ptr @mouseDown_R, align 1, !tbaa !5
  %134 = zext i8 %133 to i32
  %135 = icmp eq i32 %134, 0
  br i1 %135, label %136, label %137

136:                                              ; preds = %132
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef @.str.11)
  store i8 0, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 -1, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %137

137:                                              ; preds = %136, %132
  br label %144

138:                                              ; preds = %123
  %139 = load i8, ptr @mouseDown_LR, align 1, !tbaa !5
  %140 = zext i8 %139 to i32
  %141 = icmp eq i32 %140, 0
  br i1 %141, label %142, label %143

142:                                              ; preds = %138
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef @.str.12)
  store i8 0, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 -1, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %143

143:                                              ; preds = %142, %138
  br label %144

144:                                              ; preds = %143, %137, %131, %123
  br label %145

145:                                              ; preds = %144, %32
  %146 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  %147 = zext i8 %146 to i32
  %148 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mc_mem, i64 0, i64 1), align 1, !tbaa !5
  %149 = zext i8 %148 to i32
  %150 = icmp ne i32 %147, %149
  br i1 %150, label %151, label %152

151:                                              ; preds = %145
  store i8 -1, ptr getelementptr inbounds ([2 x i8], ptr @printed, i64 0, i64 1), align 1, !tbaa !5
  br label %152

152:                                              ; preds = %151, %145
  %153 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  store i8 %153, ptr getelementptr inbounds ([2 x i8], ptr @mc_mem, i64 0, i64 1), align 1, !tbaa !5
  %154 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  %155 = zext i8 %154 to i32
  %156 = icmp eq i32 %155, 0
  br i1 %156, label %157, label %162

157:                                              ; preds = %152
  %158 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @printed, i64 0, i64 1), align 1, !tbaa !5
  %159 = icmp ne i8 %158, 0
  br i1 %159, label %160, label %161

160:                                              ; preds = %157
  call void @WaitForVBlank()
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef @.str.3)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 19, ptr noundef @.str.5)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef @.str.6)
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @printed, i64 0, i64 1), align 1, !tbaa !5
  br label %161

161:                                              ; preds = %160, %157
  call void @oamSetVisible(i16 noundef zeroext 4, i8 noundef zeroext 1)
  br label %279

162:                                              ; preds = %152
  %163 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_x, i64 0, i64 1), align 1, !tbaa !5
  %164 = zext i8 %163 to i32
  %165 = and i32 %164, 128
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %175

167:                                              ; preds = %162
  %168 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_x, i64 0, i64 1), align 1, !tbaa !5
  %169 = zext i8 %168 to i32
  %170 = and i32 %169, 127
  %171 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %172 = zext i16 %171 to i32
  %173 = sub nsw i32 %172, %170
  %174 = trunc i32 %173 to i16
  store i16 %174, ptr @p2_mouse_x, align 2, !tbaa !8
  br label %183

175:                                              ; preds = %162
  %176 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_x, i64 0, i64 1), align 1, !tbaa !5
  %177 = zext i8 %176 to i32
  %178 = and i32 %177, 127
  %179 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %180 = zext i16 %179 to i32
  %181 = add nsw i32 %180, %178
  %182 = trunc i32 %181 to i16
  store i16 %182, ptr @p2_mouse_x, align 2, !tbaa !8
  br label %183

183:                                              ; preds = %175, %167
  %184 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_y, i64 0, i64 1), align 1, !tbaa !5
  %185 = zext i8 %184 to i32
  %186 = and i32 %185, 128
  %187 = icmp ne i32 %186, 0
  br i1 %187, label %188, label %196

188:                                              ; preds = %183
  %189 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_y, i64 0, i64 1), align 1, !tbaa !5
  %190 = zext i8 %189 to i32
  %191 = and i32 %190, 127
  %192 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %193 = zext i16 %192 to i32
  %194 = sub nsw i32 %193, %191
  %195 = trunc i32 %194 to i16
  store i16 %195, ptr @p2_mouse_y, align 2, !tbaa !8
  br label %204

196:                                              ; preds = %183
  %197 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouse_y, i64 0, i64 1), align 1, !tbaa !5
  %198 = zext i8 %197 to i32
  %199 = and i32 %198, 127
  %200 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %201 = zext i16 %200 to i32
  %202 = add nsw i32 %201, %199
  %203 = trunc i32 %202 to i16
  store i16 %203, ptr @p2_mouse_y, align 2, !tbaa !8
  br label %204

204:                                              ; preds = %196, %188
  %205 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %206 = zext i16 %205 to i32
  %207 = icmp sgt i32 %206, 65280
  br i1 %207, label %208, label %209

208:                                              ; preds = %204
  store i16 0, ptr @p2_mouse_x, align 2, !tbaa !8
  br label %209

209:                                              ; preds = %208, %204
  %210 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %211 = zext i16 %210 to i32
  %212 = icmp sgt i32 %211, 255
  br i1 %212, label %213, label %214

213:                                              ; preds = %209
  store i16 255, ptr @p2_mouse_x, align 2, !tbaa !8
  br label %214

214:                                              ; preds = %213, %209
  %215 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %216 = zext i16 %215 to i32
  %217 = icmp sgt i32 %216, 65280
  br i1 %217, label %218, label %219

218:                                              ; preds = %214
  store i16 0, ptr @p2_mouse_y, align 2, !tbaa !8
  br label %219

219:                                              ; preds = %218, %214
  %220 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %221 = zext i16 %220 to i32
  %222 = icmp sgt i32 %221, 239
  br i1 %222, label %223, label %224

223:                                              ; preds = %219
  store i16 239, ptr @p2_mouse_y, align 2, !tbaa !8
  br label %224

224:                                              ; preds = %223, %219
  %225 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %226 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %227 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %228 = zext i8 %227 to i32
  %229 = shl i32 %228, 1
  %230 = trunc i32 %229 to i8
  call void @oamSet(i16 noundef zeroext 4, i16 noundef zeroext %225, i16 noundef zeroext %226, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext %230)
  %231 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @printed, i64 0, i64 1), align 1, !tbaa !5
  %232 = icmp ne i8 %231, 0
  br i1 %232, label %233, label %234

233:                                              ; preds = %224
  call void @WaitForVBlank()
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef @.str.13)
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 19, ptr noundef @.str.8)
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @printed, i64 0, i64 1), align 1, !tbaa !5
  br label %234

234:                                              ; preds = %233, %224
  %235 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %236 = zext i8 %235 to i32
  %237 = icmp eq i32 %236, 0
  br i1 %237, label %238, label %239

238:                                              ; preds = %234
  store i8 0, ptr @odd, align 1, !tbaa !5
  br label %239

239:                                              ; preds = %238, %234
  %240 = load i8, ptr @odd, align 1, !tbaa !5
  %241 = zext i8 %240 to i32
  %242 = and i32 %241, 1
  %243 = icmp eq i32 %242, 0
  br i1 %243, label %244, label %257

244:                                              ; preds = %239
  %245 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseButton, i64 0, i64 1), align 1, !tbaa !5
  %246 = zext i8 %245 to i32
  %247 = icmp eq i32 %246, 0
  br i1 %247, label %248, label %257

248:                                              ; preds = %244
  %249 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %250 = zext i16 %249 to i32
  %251 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %252 = zext i16 %251 to i32
  %253 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @hex_string, ptr noundef @.str.9, i32 noundef %250, i32 noundef %252) #3
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 13, i16 noundef zeroext 19, ptr noundef @hex_string)
  %254 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %255 = zext i16 %254 to i32
  %256 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef @hex_string, ptr noundef @.str.9, i32 noundef %255) #3
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 19, i16 noundef zeroext 19, ptr noundef @hex_string)
  br label %257

257:                                              ; preds = %248, %244, %239
  %258 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mousePressed, i64 0, i64 1), align 1, !tbaa !5
  %259 = zext i8 %258 to i32
  switch i32 %259, label %278 [
    i32 1, label %260
    i32 2, label %266
    i32 3, label %272
  ]

260:                                              ; preds = %257
  %261 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_L, i64 0, i64 1), align 1, !tbaa !5
  %262 = zext i8 %261 to i32
  %263 = icmp eq i32 %262, 0
  br i1 %263, label %264, label %265

264:                                              ; preds = %260
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef @.str.10)
  store i8 -1, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_L, i64 0, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_R, i64 0, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_LR, i64 0, i64 1), align 1, !tbaa !5
  br label %265

265:                                              ; preds = %264, %260
  br label %278

266:                                              ; preds = %257
  %267 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_R, i64 0, i64 1), align 1, !tbaa !5
  %268 = zext i8 %267 to i32
  %269 = icmp eq i32 %268, 0
  br i1 %269, label %270, label %271

270:                                              ; preds = %266
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef @.str.11)
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_L, i64 0, i64 1), align 1, !tbaa !5
  store i8 -1, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_R, i64 0, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_LR, i64 0, i64 1), align 1, !tbaa !5
  br label %271

271:                                              ; preds = %270, %266
  br label %278

272:                                              ; preds = %257
  %273 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_LR, i64 0, i64 1), align 1, !tbaa !5
  %274 = zext i8 %273 to i32
  %275 = icmp eq i32 %274, 0
  br i1 %275, label %276, label %277

276:                                              ; preds = %272
  call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef @.str.12)
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_L, i64 0, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_R, i64 0, i64 1), align 1, !tbaa !5
  store i8 -1, ptr getelementptr inbounds ([2 x i8], ptr @mouseDown_LR, i64 0, i64 1), align 1, !tbaa !5
  br label %277

277:                                              ; preds = %276, %272
  br label %278

278:                                              ; preds = %277, %271, %265, %257
  br label %279

279:                                              ; preds = %278, %161
  %280 = load i8, ptr @mouseButton, align 1, !tbaa !5
  %281 = zext i8 %280 to i32
  %282 = and i32 %281, 1
  %283 = icmp ne i32 %282, 0
  br i1 %283, label %284, label %321

284:                                              ; preds = %279
  %285 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %286 = zext i16 %285 to i32
  %287 = icmp sgt i32 %286, 94
  br i1 %287, label %288, label %320

288:                                              ; preds = %284
  %289 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %290 = zext i16 %289 to i32
  %291 = icmp slt i32 %290, 108
  br i1 %291, label %292, label %320

292:                                              ; preds = %288
  %293 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %294 = zext i16 %293 to i32
  %295 = icmp sgt i32 %294, 68
  br i1 %295, label %296, label %301

296:                                              ; preds = %292
  %297 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %298 = zext i16 %297 to i32
  %299 = icmp slt i32 %298, 100
  br i1 %299, label %300, label %301

300:                                              ; preds = %296
  call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 0)
  br label %301

301:                                              ; preds = %300, %296, %292
  %302 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %303 = zext i16 %302 to i32
  %304 = icmp sgt i32 %303, 108
  br i1 %304, label %305, label %310

305:                                              ; preds = %301
  %306 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %307 = zext i16 %306 to i32
  %308 = icmp slt i32 %307, 148
  br i1 %308, label %309, label %310

309:                                              ; preds = %305
  call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 1)
  br label %310

310:                                              ; preds = %309, %305, %301
  %311 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %312 = zext i16 %311 to i32
  %313 = icmp sgt i32 %312, 156
  br i1 %313, label %314, label %319

314:                                              ; preds = %310
  %315 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %316 = zext i16 %315 to i32
  %317 = icmp slt i32 %316, 188
  br i1 %317, label %318, label %319

318:                                              ; preds = %314
  call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 2)
  br label %319

319:                                              ; preds = %318, %314, %310
  br label %320

320:                                              ; preds = %319, %288, %284
  br label %321

321:                                              ; preds = %320, %279
  %322 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseButton, i64 0, i64 1), align 1, !tbaa !5
  %323 = zext i8 %322 to i32
  %324 = and i32 %323, 1
  %325 = icmp ne i32 %324, 0
  br i1 %325, label %326, label %363

326:                                              ; preds = %321
  %327 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %328 = zext i16 %327 to i32
  %329 = icmp sgt i32 %328, 190
  br i1 %329, label %330, label %362

330:                                              ; preds = %326
  %331 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %332 = zext i16 %331 to i32
  %333 = icmp slt i32 %332, 204
  br i1 %333, label %334, label %362

334:                                              ; preds = %330
  %335 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %336 = zext i16 %335 to i32
  %337 = icmp sgt i32 %336, 68
  br i1 %337, label %338, label %343

338:                                              ; preds = %334
  %339 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %340 = zext i16 %339 to i32
  %341 = icmp slt i32 %340, 100
  br i1 %341, label %342, label %343

342:                                              ; preds = %338
  call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 0)
  br label %343

343:                                              ; preds = %342, %338, %334
  %344 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %345 = zext i16 %344 to i32
  %346 = icmp sgt i32 %345, 108
  br i1 %346, label %347, label %352

347:                                              ; preds = %343
  %348 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %349 = zext i16 %348 to i32
  %350 = icmp slt i32 %349, 148
  br i1 %350, label %351, label %352

351:                                              ; preds = %347
  call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 1)
  br label %352

352:                                              ; preds = %351, %347, %343
  %353 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %354 = zext i16 %353 to i32
  %355 = icmp sgt i32 %354, 156
  br i1 %355, label %356, label %361

356:                                              ; preds = %352
  %357 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %358 = zext i16 %357 to i32
  %359 = icmp slt i32 %358, 188
  br i1 %359, label %360, label %361

360:                                              ; preds = %356
  call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 2)
  br label %361

361:                                              ; preds = %360, %356, %352
  br label %362

362:                                              ; preds = %361, %330, %326
  br label %363

363:                                              ; preds = %362, %321
  call void @WaitForVBlank()
  %364 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %365 = icmp ne i8 %364, 0
  br i1 %365, label %366, label %378

366:                                              ; preds = %363
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 24968, i16 noundef zeroext 32)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25000, i16 noundef zeroext 32)
  %367 = load i8, ptr @mouseSensitivity, align 1, !tbaa !5
  %368 = zext i8 %367 to i32
  switch i32 %368, label %372 [
    i32 0, label %369
    i32 1, label %370
    i32 2, label %371
  ]

369:                                              ; preds = %366
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 24968, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25000, i16 noundef zeroext 10)
  br label %372

370:                                              ; preds = %366
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 106), i16 noundef zeroext 24973, i16 noundef zeroext 12)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 170), i16 noundef zeroext 25005, i16 noundef zeroext 12)
  br label %372

371:                                              ; preds = %366
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 118), i16 noundef zeroext 24979, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 182), i16 noundef zeroext 25011, i16 noundef zeroext 10)
  br label %372

372:                                              ; preds = %371, %370, %369, %366
  %373 = load i8, ptr @mousePressed, align 1, !tbaa !5
  %374 = zext i8 %373 to i32
  %375 = icmp eq i32 %374, 0
  br i1 %375, label %376, label %377

376:                                              ; preds = %372
  call void @dmaFillVram(ptr noundef @buttonsmap, i16 noundef zeroext 26944, i16 noundef zeroext 64)
  br label %377

377:                                              ; preds = %376, %372
  br label %379

378:                                              ; preds = %363
  call void @dmaFillVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 24968, i16 noundef zeroext 32)
  call void @dmaFillVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25000, i16 noundef zeroext 32)
  br label %379

379:                                              ; preds = %378, %377
  %380 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseConnect, i64 0, i64 1), align 1, !tbaa !5
  %381 = icmp ne i8 %380, 0
  br i1 %381, label %382, label %394

382:                                              ; preds = %379
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 25352, i16 noundef zeroext 32)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25384, i16 noundef zeroext 32)
  %383 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mouseSensitivity, i64 0, i64 1), align 1, !tbaa !5
  %384 = zext i8 %383 to i32
  switch i32 %384, label %388 [
    i32 0, label %385
    i32 1, label %386
    i32 2, label %387
  ]

385:                                              ; preds = %382
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 25352, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25384, i16 noundef zeroext 10)
  br label %388

386:                                              ; preds = %382
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 106), i16 noundef zeroext 25357, i16 noundef zeroext 12)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 170), i16 noundef zeroext 25389, i16 noundef zeroext 12)
  br label %388

387:                                              ; preds = %382
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 118), i16 noundef zeroext 25363, i16 noundef zeroext 10)
  call void @dmaCopyVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 182), i16 noundef zeroext 25395, i16 noundef zeroext 10)
  br label %388

388:                                              ; preds = %387, %386, %385, %382
  %389 = load i8, ptr getelementptr inbounds ([2 x i8], ptr @mousePressed, i64 0, i64 1), align 1, !tbaa !5
  %390 = zext i8 %389 to i32
  %391 = icmp eq i32 %390, 0
  br i1 %391, label %392, label %393

392:                                              ; preds = %388
  call void @dmaFillVram(ptr noundef @buttonsmap, i16 noundef zeroext 27328, i16 noundef zeroext 64)
  br label %393

393:                                              ; preds = %392, %388
  br label %395

394:                                              ; preds = %379
  call void @dmaFillVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 25352, i16 noundef zeroext 32)
  call void @dmaFillVram(ptr noundef getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25384, i16 noundef zeroext 32)
  br label %395

395:                                              ; preds = %394, %393
  br label %14
}

declare void @oamInitGfxSet(ptr noundef, i16 noundef zeroext, ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext) #1

declare void @consoleSetTextMapPtr(i16 noundef zeroext) #1

declare void @consoleSetTextGfxPtr(i16 noundef zeroext) #1

declare void @consoleSetTextOffset(i16 noundef zeroext) #1

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

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

declare void @initMouse(i8 noundef zeroext) #1

declare void @WaitForVBlank() #1

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

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

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

declare void @bgInitTileSet(i8 noundef zeroext, ptr noundef, ptr noundef, i8 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext) #1

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

declare void @bgSetDisable(i8 noundef zeroext) #1

declare void @setScreenOn() #1

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

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

declare void @dmaFillVram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #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 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, 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"

@p1_mouse_x = external dso_local local_unnamed_addr global i16, align 2
@p1_mouse_y = external dso_local local_unnamed_addr global i16, align 2
@p2_mouse_x = external dso_local local_unnamed_addr global i16, align 2
@p2_mouse_y = external dso_local local_unnamed_addr global i16, align 2
@odd = external dso_local local_unnamed_addr global i8, align 1
@mc_mem = external dso_local local_unnamed_addr global [2 x i8], align 1
@printed = external dso_local local_unnamed_addr global [2 x i8], align 1
@mouseDown_L = external dso_local local_unnamed_addr global [2 x i8], align 1
@mouseDown_R = external dso_local local_unnamed_addr global [2 x i8], align 1
@mouseDown_LR = external dso_local local_unnamed_addr global [2 x i8], align 1
@cursorsprite = external global i8, align 1
@cursorsprite_end = external global i8, align 1
@cursorpal = external global i8, align 1
@snesfont = external global i8, align 1
@snespal = external global i8, align 1
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@mouseConnect = external local_unnamed_addr global [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@buttonsmap = external global i8, align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [24 x i8], align 1
@buttonstiles = external global i8, align 1
@buttonspal = external global i8, align 1
@buttonstiles_end = external global i8, align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1
@mouse_x = external local_unnamed_addr global [2 x i8], align 1
@mouse_y = external local_unnamed_addr global [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@mouseButton = external local_unnamed_addr global [2 x i8], align 1
@hex_string = external dso_local global [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@mousePressed = external local_unnamed_addr global [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [27 x i8], align 1
@mouseSensitivity = external local_unnamed_addr global [2 x i8], align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @oamInitGfxSet(ptr noundef nonnull @cursorsprite, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @cursorsprite_end to i64), i64 ptrtoint (ptr @cursorsprite to i64)) to i16), ptr noundef nonnull @cursorpal, i16 noundef zeroext 96, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext 96) #3
  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 (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 1, ptr noundef nonnull @.str) #3
  tail call void @initMouse(i8 noundef zeroext 0) #3
  tail call void @WaitForVBlank() #3
  %1 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %2 = icmp eq i8 %1, 0
  br i1 %2, label %3, label %4

3:                                                ; preds = %0
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef nonnull @.str.1) #3
  br label %5

4:                                                ; preds = %0
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 24968, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25000, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 74), i16 noundef zeroext 24973, i16 noundef zeroext 22) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 138), i16 noundef zeroext 25005, i16 noundef zeroext 22) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 5, i16 noundef zeroext 5, ptr noundef nonnull @.str.2) #3
  br label %5

5:                                                ; preds = %4, %3
  %6 = load i8, ptr getelementptr inbounds (i8, ptr @mouseConnect, i64 1), align 1, !tbaa !5
  %7 = icmp eq i8 %6, 0
  br i1 %7, label %8, label %9

8:                                                ; preds = %5
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef nonnull @.str.3) #3
  br label %10

9:                                                ; preds = %5
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 25352, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25384, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 74), i16 noundef zeroext 25357, i16 noundef zeroext 22) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 138), i16 noundef zeroext 25389, i16 noundef zeroext 22) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 5, i16 noundef zeroext 17, ptr noundef nonnull @.str.4) #3
  br label %10

10:                                               ; preds = %9, %8
  tail call void @bgSetGfxPtr(i8 noundef zeroext 0, i16 noundef zeroext 8192) #3
  tail call void @bgSetGfxPtr(i8 noundef zeroext 1, i16 noundef zeroext 16384) #3
  tail call void @bgSetMapPtr(i8 noundef zeroext 0, i16 noundef zeroext 26624, i8 noundef zeroext 0) #3
  tail call void @bgSetMapPtr(i8 noundef zeroext 1, i16 noundef zeroext 24576, i8 noundef zeroext 0) #3
  tail call void @bgInitTileSet(i8 noundef zeroext 1, ptr noundef nonnull @buttonstiles, ptr noundef nonnull @buttonspal, i8 noundef zeroext 1, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @buttonstiles_end to i64), i64 ptrtoint (ptr @buttonstiles to i64)) to i16), i16 noundef zeroext 32, i16 noundef zeroext 16, i16 noundef zeroext 16384) #3
  tail call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0) #3
  tail call void @bgSetDisable(i8 noundef zeroext 2) #3
  tail call void @setScreenOn() #3
  br label %11

11:                                               ; preds = %.backedge, %10
  %12 = load i8, ptr @odd, align 1, !tbaa !5
  %13 = add i8 %12, 1
  store i8 %13, ptr @odd, align 1, !tbaa !5
  %14 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %15 = load i8, ptr @mc_mem, align 1, !tbaa !5
  %.not = icmp eq i8 %14, %15
  br i1 %.not, label %17, label %16

16:                                               ; preds = %11
  store i8 -1, ptr @printed, align 1, !tbaa !5
  br label %17

17:                                               ; preds = %16, %11
  store i8 %14, ptr @mc_mem, align 1, !tbaa !5
  %18 = icmp eq i8 %14, 0
  br i1 %18, label %19, label %23

19:                                               ; preds = %17
  %20 = load i8, ptr @printed, align 1, !tbaa !5
  %.not34 = icmp eq i8 %20, 0
  br i1 %.not34, label %22, label %21

21:                                               ; preds = %19
  tail call void @WaitForVBlank() #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef nonnull @.str.1) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 7, ptr noundef nonnull @.str.5) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef nonnull @.str.6) #3
  store i8 0, ptr @printed, align 1, !tbaa !5
  br label %22

22:                                               ; preds = %21, %19
  tail call void @oamSetVisible(i16 noundef zeroext 0, i8 noundef zeroext 1) #3
  br label %90

23:                                               ; preds = %17
  %24 = load i8, ptr @mouse_x, align 1, !tbaa !5
  %.not30 = icmp sgt i8 %24, -1
  br i1 %.not30, label %30, label %25

25:                                               ; preds = %23
  %26 = and i8 %24, 127
  %27 = zext nneg i8 %26 to i16
  %28 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %29 = sub i16 %28, %27
  br label %34

30:                                               ; preds = %23
  %31 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %32 = zext nneg i8 %24 to i16
  %33 = add i16 %31, %32
  br label %34

34:                                               ; preds = %30, %25
  %.pr = phi i16 [ %33, %30 ], [ %29, %25 ]
  store i16 %.pr, ptr @p1_mouse_x, align 2, !tbaa !8
  %35 = load i8, ptr @mouse_y, align 1, !tbaa !5
  %.not31 = icmp sgt i8 %35, -1
  br i1 %.not31, label %41, label %36

36:                                               ; preds = %34
  %37 = and i8 %35, 127
  %38 = zext nneg i8 %37 to i16
  %39 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %40 = sub i16 %39, %38
  br label %45

41:                                               ; preds = %34
  %42 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %43 = zext nneg i8 %35 to i16
  %44 = add i16 %42, %43
  br label %45

45:                                               ; preds = %41, %36
  %.pr47 = phi i16 [ %44, %41 ], [ %40, %36 ]
  store i16 %.pr47, ptr @p1_mouse_y, align 2, !tbaa !8
  %46 = icmp ugt i16 %.pr, -256
  br i1 %46, label %.sink.split, label %47

47:                                               ; preds = %45
  %48 = icmp ugt i16 %.pr, 255
  br i1 %48, label %.sink.split, label %49

.sink.split:                                      ; preds = %47, %45
  %.sink = phi i16 [ 0, %45 ], [ 255, %47 ]
  store i16 %.sink, ptr @p1_mouse_x, align 2, !tbaa !8
  br label %49

49:                                               ; preds = %.sink.split, %47
  %50 = phi i16 [ %.pr, %47 ], [ %.sink, %.sink.split ]
  %51 = icmp ugt i16 %.pr47, -256
  br i1 %51, label %.sink.split61, label %52

52:                                               ; preds = %49
  %53 = icmp ugt i16 %.pr47, 239
  br i1 %53, label %.sink.split61, label %54

.sink.split61:                                    ; preds = %52, %49
  %.sink63 = phi i16 [ 0, %49 ], [ 239, %52 ]
  store i16 %.sink63, ptr @p1_mouse_y, align 2, !tbaa !8
  br label %54

54:                                               ; preds = %.sink.split61, %52
  %55 = phi i16 [ %.pr47, %52 ], [ %.sink63, %.sink.split61 ]
  %56 = load i8, ptr getelementptr inbounds (i8, ptr @mouseConnect, i64 1), align 1, !tbaa !5
  tail call void @oamSet(i16 noundef zeroext 0, i16 noundef zeroext %50, i16 noundef zeroext %55, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext %56) #3
  %57 = load i8, ptr @printed, align 1, !tbaa !5
  %.not33 = icmp eq i8 %57, 0
  br i1 %.not33, label %59, label %58

58:                                               ; preds = %54
  tail call void @WaitForVBlank() #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 5, ptr noundef nonnull @.str.7) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 7, ptr noundef nonnull @.str.8) #3
  store i8 0, ptr @printed, align 1, !tbaa !5
  br label %59

59:                                               ; preds = %58, %54
  %60 = load i8, ptr getelementptr inbounds (i8, ptr @mouseConnect, i64 1), align 1, !tbaa !5
  %61 = icmp eq i8 %60, 0
  br i1 %61, label %62, label %._crit_edge

._crit_edge:                                      ; preds = %59
  %.pre = load i8, ptr @odd, align 1, !tbaa !5
  br label %63

62:                                               ; preds = %59
  store i8 1, ptr @odd, align 1, !tbaa !5
  br label %63

63:                                               ; preds = %._crit_edge, %62
  %64 = phi i8 [ %.pre, %._crit_edge ], [ 1, %62 ]
  %65 = and i8 %64, 1
  %66 = icmp ne i8 %65, 0
  %67 = load i8, ptr @mouseButton, align 1
  %68 = icmp eq i8 %67, 0
  %or.cond = select i1 %66, i1 %68, i1 false
  br i1 %or.cond, label %69, label %76

69:                                               ; preds = %63
  %70 = load i16, ptr @p1_mouse_x, align 2, !tbaa !8
  %71 = zext i16 %70 to i32
  %72 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @hex_string, ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %71) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 13, i16 noundef zeroext 7, ptr noundef nonnull @hex_string) #3
  %73 = load i16, ptr @p1_mouse_y, align 2, !tbaa !8
  %74 = zext i16 %73 to i32
  %75 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @hex_string, ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %74) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 19, i16 noundef zeroext 7, ptr noundef nonnull @hex_string) #3
  br label %76

76:                                               ; preds = %69, %63
  %77 = load i8, ptr @mousePressed, align 1, !tbaa !5
  switch i8 %77, label %90 [
    i8 1, label %78
    i8 2, label %82
    i8 3, label %86
  ]

78:                                               ; preds = %76
  %79 = load i8, ptr @mouseDown_L, align 1, !tbaa !5
  %80 = icmp eq i8 %79, 0
  br i1 %80, label %81, label %90

81:                                               ; preds = %78
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef nonnull @.str.10) #3
  store i8 -1, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %90

82:                                               ; preds = %76
  %83 = load i8, ptr @mouseDown_R, align 1, !tbaa !5
  %84 = icmp eq i8 %83, 0
  br i1 %84, label %85, label %90

85:                                               ; preds = %82
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef nonnull @.str.11) #3
  store i8 0, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 -1, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %90

86:                                               ; preds = %76
  %87 = load i8, ptr @mouseDown_LR, align 1, !tbaa !5
  %88 = icmp eq i8 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %86
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 10, ptr noundef nonnull @.str.12) #3
  store i8 0, ptr @mouseDown_L, align 1, !tbaa !5
  store i8 0, ptr @mouseDown_R, align 1, !tbaa !5
  store i8 -1, ptr @mouseDown_LR, align 1, !tbaa !5
  br label %90

90:                                               ; preds = %76, %81, %78, %85, %82, %89, %86, %22
  %91 = load i8, ptr getelementptr inbounds (i8, ptr @mouseConnect, i64 1), align 1, !tbaa !5
  %92 = load i8, ptr getelementptr inbounds (i8, ptr @mc_mem, i64 1), align 1, !tbaa !5
  %.not35 = icmp eq i8 %91, %92
  br i1 %.not35, label %94, label %93

93:                                               ; preds = %90
  store i8 -1, ptr getelementptr inbounds (i8, ptr @printed, i64 1), align 1, !tbaa !5
  br label %94

94:                                               ; preds = %93, %90
  store i8 %91, ptr getelementptr inbounds (i8, ptr @mc_mem, i64 1), align 1, !tbaa !5
  %95 = icmp eq i8 %91, 0
  br i1 %95, label %96, label %100

96:                                               ; preds = %94
  %97 = load i8, ptr getelementptr inbounds (i8, ptr @printed, i64 1), align 1, !tbaa !5
  %.not41 = icmp eq i8 %97, 0
  br i1 %.not41, label %99, label %98

98:                                               ; preds = %96
  tail call void @WaitForVBlank() #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef nonnull @.str.3) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 19, ptr noundef nonnull @.str.5) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef nonnull @.str.6) #3
  store i8 0, ptr getelementptr inbounds (i8, ptr @printed, i64 1), align 1, !tbaa !5
  br label %99

99:                                               ; preds = %98, %96
  tail call void @oamSetVisible(i16 noundef zeroext 4, i8 noundef zeroext 1) #3
  br label %170

100:                                              ; preds = %94
  %101 = load i8, ptr getelementptr inbounds (i8, ptr @mouse_x, i64 1), align 1, !tbaa !5
  %.not36 = icmp sgt i8 %101, -1
  br i1 %.not36, label %107, label %102

102:                                              ; preds = %100
  %103 = and i8 %101, 127
  %104 = zext nneg i8 %103 to i16
  %105 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %106 = sub i16 %105, %104
  br label %111

107:                                              ; preds = %100
  %108 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %109 = zext nneg i8 %101 to i16
  %110 = add i16 %108, %109
  br label %111

111:                                              ; preds = %107, %102
  %.pr50 = phi i16 [ %110, %107 ], [ %106, %102 ]
  store i16 %.pr50, ptr @p2_mouse_x, align 2, !tbaa !8
  %112 = load i8, ptr getelementptr inbounds (i8, ptr @mouse_y, i64 1), align 1, !tbaa !5
  %.not38 = icmp sgt i8 %112, -1
  br i1 %.not38, label %118, label %113

113:                                              ; preds = %111
  %114 = and i8 %112, 127
  %115 = zext nneg i8 %114 to i16
  %116 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %117 = sub i16 %116, %115
  br label %122

118:                                              ; preds = %111
  %119 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %120 = zext nneg i8 %112 to i16
  %121 = add i16 %119, %120
  br label %122

122:                                              ; preds = %118, %113
  %.pr53 = phi i16 [ %121, %118 ], [ %117, %113 ]
  store i16 %.pr53, ptr @p2_mouse_y, align 2, !tbaa !8
  %123 = icmp ugt i16 %.pr50, -256
  br i1 %123, label %.sink.split64, label %124

124:                                              ; preds = %122
  %125 = icmp ugt i16 %.pr50, 255
  br i1 %125, label %.sink.split64, label %126

.sink.split64:                                    ; preds = %124, %122
  %.sink66 = phi i16 [ 0, %122 ], [ 255, %124 ]
  store i16 %.sink66, ptr @p2_mouse_x, align 2, !tbaa !8
  br label %126

126:                                              ; preds = %.sink.split64, %124
  %127 = phi i16 [ %.pr50, %124 ], [ %.sink66, %.sink.split64 ]
  %128 = icmp ugt i16 %.pr53, -256
  br i1 %128, label %.sink.split67, label %129

129:                                              ; preds = %126
  %130 = icmp ugt i16 %.pr53, 239
  br i1 %130, label %.sink.split67, label %131

.sink.split67:                                    ; preds = %129, %126
  %.sink69 = phi i16 [ 0, %126 ], [ 239, %129 ]
  store i16 %.sink69, ptr @p2_mouse_y, align 2, !tbaa !8
  br label %131

131:                                              ; preds = %.sink.split67, %129
  %132 = phi i16 [ %.pr53, %129 ], [ %.sink69, %.sink.split67 ]
  %133 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %134 = shl i8 %133, 1
  tail call void @oamSet(i16 noundef zeroext 4, i16 noundef zeroext %127, i16 noundef zeroext %132, i8 noundef zeroext 3, i8 noundef zeroext 0, i8 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext %134) #3
  %135 = load i8, ptr getelementptr inbounds (i8, ptr @printed, i64 1), align 1, !tbaa !5
  %.not40 = icmp eq i8 %135, 0
  br i1 %.not40, label %137, label %136

136:                                              ; preds = %131
  tail call void @WaitForVBlank() #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 3, i16 noundef zeroext 17, ptr noundef nonnull @.str.13) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 11, i16 noundef zeroext 19, ptr noundef nonnull @.str.8) #3
  store i8 0, ptr getelementptr inbounds (i8, ptr @printed, i64 1), align 1, !tbaa !5
  br label %137

137:                                              ; preds = %136, %131
  %138 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %139 = icmp eq i8 %138, 0
  br i1 %139, label %140, label %._crit_edge55

._crit_edge55:                                    ; preds = %137
  %.pre56 = load i8, ptr @odd, align 1, !tbaa !5
  br label %141

140:                                              ; preds = %137
  store i8 0, ptr @odd, align 1, !tbaa !5
  br label %141

141:                                              ; preds = %._crit_edge55, %140
  %142 = phi i8 [ %.pre56, %._crit_edge55 ], [ 0, %140 ]
  %143 = and i8 %142, 1
  %144 = icmp eq i8 %143, 0
  %145 = load i8, ptr getelementptr inbounds (i8, ptr @mouseButton, i64 1), align 1
  %146 = icmp eq i8 %145, 0
  %or.cond5 = select i1 %144, i1 %146, i1 false
  br i1 %or.cond5, label %147, label %156

147:                                              ; preds = %141
  %148 = load i16, ptr @p2_mouse_x, align 2, !tbaa !8
  %149 = zext i16 %148 to i32
  %150 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %151 = zext i16 %150 to i32
  %152 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @hex_string, ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %149, i32 noundef %151) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 13, i16 noundef zeroext 19, ptr noundef nonnull @hex_string) #3
  %153 = load i16, ptr @p2_mouse_y, align 2, !tbaa !8
  %154 = zext i16 %153 to i32
  %155 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) @hex_string, ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %154) #3
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 19, i16 noundef zeroext 19, ptr noundef nonnull @hex_string) #3
  br label %156

156:                                              ; preds = %147, %141
  %157 = load i8, ptr getelementptr inbounds (i8, ptr @mousePressed, i64 1), align 1, !tbaa !5
  switch i8 %157, label %170 [
    i8 1, label %158
    i8 2, label %162
    i8 3, label %166
  ]

158:                                              ; preds = %156
  %159 = load i8, ptr getelementptr inbounds (i8, ptr @mouseDown_L, i64 1), align 1, !tbaa !5
  %160 = icmp eq i8 %159, 0
  br i1 %160, label %161, label %170

161:                                              ; preds = %158
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef nonnull @.str.10) #3
  store i8 -1, ptr getelementptr inbounds (i8, ptr @mouseDown_L, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_R, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_LR, i64 1), align 1, !tbaa !5
  br label %170

162:                                              ; preds = %156
  %163 = load i8, ptr getelementptr inbounds (i8, ptr @mouseDown_R, i64 1), align 1, !tbaa !5
  %164 = icmp eq i8 %163, 0
  br i1 %164, label %165, label %170

165:                                              ; preds = %162
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef nonnull @.str.11) #3
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_L, i64 1), align 1, !tbaa !5
  store i8 -1, ptr getelementptr inbounds (i8, ptr @mouseDown_R, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_LR, i64 1), align 1, !tbaa !5
  br label %170

166:                                              ; preds = %156
  %167 = load i8, ptr getelementptr inbounds (i8, ptr @mouseDown_LR, i64 1), align 1, !tbaa !5
  %168 = icmp eq i8 %167, 0
  br i1 %168, label %169, label %170

169:                                              ; preds = %166
  tail call void (i16, i16, ptr, ...) @consoleDrawText(i16 noundef zeroext 7, i16 noundef zeroext 22, ptr noundef nonnull @.str.12) #3
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_L, i64 1), align 1, !tbaa !5
  store i8 0, ptr getelementptr inbounds (i8, ptr @mouseDown_R, i64 1), align 1, !tbaa !5
  store i8 -1, ptr getelementptr inbounds (i8, ptr @mouseDown_LR, i64 1), align 1, !tbaa !5
  br label %170

170:                                              ; preds = %156, %161, %158, %165, %162, %169, %166, %99
  %171 = load i8, ptr @mouseButton, align 1, !tbaa !5
  %172 = and i8 %171, 1
  %.not42 = icmp eq i8 %172, 0
  br i1 %.not42, label %188, label %173

173:                                              ; preds = %170
  %174 = load i16, ptr @p1_mouse_y, align 2
  %175 = add i16 %174, -95
  %or.cond8 = icmp ult i16 %175, 13
  br i1 %or.cond8, label %176, label %188

176:                                              ; preds = %173
  %177 = load i16, ptr @p1_mouse_x, align 2
  %178 = add i16 %177, -69
  %or.cond11 = icmp ult i16 %178, 31
  br i1 %or.cond11, label %179, label %180

179:                                              ; preds = %176
  tail call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 0) #3
  %.pre57 = load i16, ptr @p1_mouse_x, align 2
  br label %180

180:                                              ; preds = %179, %176
  %181 = phi i16 [ %.pre57, %179 ], [ %177, %176 ]
  %182 = add i16 %181, -109
  %or.cond14 = icmp ult i16 %182, 39
  br i1 %or.cond14, label %183, label %184

183:                                              ; preds = %180
  tail call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 1) #3
  %.pre58 = load i16, ptr @p1_mouse_x, align 2
  br label %184

184:                                              ; preds = %183, %180
  %185 = phi i16 [ %.pre58, %183 ], [ %181, %180 ]
  %186 = add i16 %185, -157
  %or.cond17 = icmp ult i16 %186, 31
  br i1 %or.cond17, label %187, label %188

187:                                              ; preds = %184
  tail call void @mouseSetSensitivity(i16 noundef zeroext 0, i8 noundef zeroext 2) #3
  br label %188

188:                                              ; preds = %173, %187, %184, %170
  %189 = load i8, ptr getelementptr inbounds (i8, ptr @mouseButton, i64 1), align 1, !tbaa !5
  %190 = and i8 %189, 1
  %.not43 = icmp eq i8 %190, 0
  br i1 %.not43, label %206, label %191

191:                                              ; preds = %188
  %192 = load i16, ptr @p2_mouse_y, align 2
  %193 = add i16 %192, -191
  %or.cond20 = icmp ult i16 %193, 13
  br i1 %or.cond20, label %194, label %206

194:                                              ; preds = %191
  %195 = load i16, ptr @p2_mouse_x, align 2
  %196 = add i16 %195, -69
  %or.cond23 = icmp ult i16 %196, 31
  br i1 %or.cond23, label %197, label %198

197:                                              ; preds = %194
  tail call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 0) #3
  %.pre59 = load i16, ptr @p2_mouse_x, align 2
  br label %198

198:                                              ; preds = %197, %194
  %199 = phi i16 [ %.pre59, %197 ], [ %195, %194 ]
  %200 = add i16 %199, -109
  %or.cond26 = icmp ult i16 %200, 39
  br i1 %or.cond26, label %201, label %202

201:                                              ; preds = %198
  tail call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 1) #3
  %.pre60 = load i16, ptr @p2_mouse_x, align 2
  br label %202

202:                                              ; preds = %201, %198
  %203 = phi i16 [ %.pre60, %201 ], [ %199, %198 ]
  %204 = add i16 %203, -157
  %or.cond29 = icmp ult i16 %204, 31
  br i1 %or.cond29, label %205, label %206

205:                                              ; preds = %202
  tail call void @mouseSetSensitivity(i16 noundef zeroext 1, i8 noundef zeroext 2) #3
  br label %206

206:                                              ; preds = %191, %205, %202, %188
  tail call void @WaitForVBlank() #3
  %207 = load i8, ptr @mouseConnect, align 1, !tbaa !5
  %.not44 = icmp eq i8 %207, 0
  br i1 %.not44, label %217, label %208

208:                                              ; preds = %206
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 24968, i16 noundef zeroext 32) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25000, i16 noundef zeroext 32) #3
  %209 = load i8, ptr @mouseSensitivity, align 1, !tbaa !5
  switch i8 %209, label %213 [
    i8 0, label %210
    i8 1, label %211
    i8 2, label %212
  ]

210:                                              ; preds = %208
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 24968, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25000, i16 noundef zeroext 10) #3
  br label %213

211:                                              ; preds = %208
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 106), i16 noundef zeroext 24973, i16 noundef zeroext 12) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 170), i16 noundef zeroext 25005, i16 noundef zeroext 12) #3
  br label %213

212:                                              ; preds = %208
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 118), i16 noundef zeroext 24979, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 182), i16 noundef zeroext 25011, i16 noundef zeroext 10) #3
  br label %213

213:                                              ; preds = %212, %211, %210, %208
  %214 = load i8, ptr @mousePressed, align 1, !tbaa !5
  %215 = icmp eq i8 %214, 0
  br i1 %215, label %216, label %218

216:                                              ; preds = %213
  tail call void @dmaFillVram(ptr noundef nonnull @buttonsmap, i16 noundef zeroext 26944, i16 noundef zeroext 64) #3
  br label %218

217:                                              ; preds = %206
  tail call void @dmaFillVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 24968, i16 noundef zeroext 32) #3
  tail call void @dmaFillVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25000, i16 noundef zeroext 32) #3
  br label %218

218:                                              ; preds = %213, %216, %217
  %219 = load i8, ptr getelementptr inbounds (i8, ptr @mouseConnect, i64 1), align 1, !tbaa !5
  %.not45 = icmp eq i8 %219, 0
  br i1 %.not45, label %229, label %220

220:                                              ; preds = %218
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 25352, i16 noundef zeroext 32) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25384, i16 noundef zeroext 32) #3
  %221 = load i8, ptr getelementptr inbounds (i8, ptr @mouseSensitivity, i64 1), align 1, !tbaa !5
  switch i8 %221, label %225 [
    i8 0, label %222
    i8 1, label %223
    i8 2, label %224
  ]

222:                                              ; preds = %220
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 96), i16 noundef zeroext 25352, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 160), i16 noundef zeroext 25384, i16 noundef zeroext 10) #3
  br label %225

223:                                              ; preds = %220
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 106), i16 noundef zeroext 25357, i16 noundef zeroext 12) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 170), i16 noundef zeroext 25389, i16 noundef zeroext 12) #3
  br label %225

224:                                              ; preds = %220
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 118), i16 noundef zeroext 25363, i16 noundef zeroext 10) #3
  tail call void @dmaCopyVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 182), i16 noundef zeroext 25395, i16 noundef zeroext 10) #3
  br label %225

225:                                              ; preds = %224, %223, %222, %220
  %226 = load i8, ptr getelementptr inbounds (i8, ptr @mousePressed, i64 1), align 1, !tbaa !5
  %227 = icmp eq i8 %226, 0
  br i1 %227, label %228, label %.backedge

.backedge:                                        ; preds = %225, %228, %229
  br label %11

228:                                              ; preds = %225
  tail call void @dmaFillVram(ptr noundef nonnull @buttonsmap, i16 noundef zeroext 27328, i16 noundef zeroext 64) #3
  br label %.backedge

229:                                              ; preds = %218
  tail call void @dmaFillVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 64), i16 noundef zeroext 25352, i16 noundef zeroext 32) #3
  tail call void @dmaFillVram(ptr noundef nonnull getelementptr inbounds (i8, ptr @buttonsmap, i64 128), i16 noundef zeroext 25384, i16 noundef zeroext 32) #3
  br label %.backedge
}

declare void @oamInitGfxSet(ptr noundef, i16 noundef zeroext, ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #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 @consoleDrawText(i16 noundef zeroext, i16 noundef zeroext, ptr noundef, ...) local_unnamed_addr #1

declare void @initMouse(i8 noundef zeroext) local_unnamed_addr #1

declare void @WaitForVBlank() local_unnamed_addr #1

declare void @dmaCopyVram(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) 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 @bgInitTileSet(i8 noundef zeroext, ptr noundef, ptr noundef, i8 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #1

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

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

declare void @setScreenOn() local_unnamed_addr #1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

attributes #0 = { 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 #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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}


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