; LLVM IR from alekmaul/pvsneslib :: snes-examples/graphics/Sprites/DynamicEngineSprite (DynamicEngineSprite)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.t_sprites = type { i16, i16, i16, i8, i8, ptr, i16, i16 }

@patterns = external global i8, align 1
@palette = external global i8, align 1
@patterns_end = external global i8, align 1
@palette_end = external global i8, align 1
@map = external global i8, align 1
@map_end = external global i8, align 1
@spr16p = external global i8, align 1
@i = external dso_local global i8, align 1
@oambuffer = external global [128 x %struct.t_sprites], align 16
@spr32g = external global i8, align 1
@spr16g = external global 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 @bgInitTileSet(i8 noundef zeroext 0, ptr noundef @patterns, ptr noundef @palette, i8 noundef zeroext 0, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @patterns_end to i64), i64 ptrtoint (ptr @patterns to i64)) to i16), i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @palette_end to i64), i64 ptrtoint (ptr @palette to i64)) to i16), i16 noundef zeroext 16, i16 noundef zeroext 16384)
  call void @bgInitMapSet(i8 noundef zeroext 0, ptr noundef @map, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @map_end to i64), i64 ptrtoint (ptr @map to i64)) to i16), i8 noundef zeroext 0, i16 noundef zeroext 26624)
  call void @dmaCopyCGram(ptr noundef @spr16p, i16 noundef zeroext 128, i16 noundef zeroext 32)
  call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0)
  call void @bgSetDisable(i8 noundef zeroext 1)
  call void @bgSetDisable(i8 noundef zeroext 2)
  call void @setScreenOn()
  call void @oamInitDynamicSprite(i16 noundef zeroext 0, i16 noundef zeroext 4096, i16 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext 96)
  store i8 0, ptr @i, align 1, !tbaa !5
  br label %2

2:                                                ; preds = %57, %0
  %3 = load i8, ptr @i, align 1, !tbaa !5
  %4 = zext i8 %3 to i32
  %5 = icmp slt i32 %4, 64
  br i1 %5, label %6, label %60

6:                                                ; preds = %2
  %7 = call zeroext i16 @rand()
  %8 = zext i16 %7 to i32
  %9 = srem i32 %8, 240
  %10 = trunc i32 %9 to i16
  %11 = load i8, ptr @i, align 1, !tbaa !5
  %12 = zext i8 %11 to i64
  %13 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %12
  %14 = getelementptr inbounds %struct.t_sprites, ptr %13, i32 0, i32 0
  store i16 %10, ptr %14, align 8, !tbaa !8
  %15 = call zeroext i16 @rand()
  %16 = zext i16 %15 to i32
  %17 = srem i32 %16, 208
  %18 = trunc i32 %17 to i16
  %19 = load i8, ptr @i, align 1, !tbaa !5
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.t_sprites, ptr %21, i32 0, i32 1
  store i16 %18, ptr %22, align 2, !tbaa !12
  %23 = load i8, ptr @i, align 1, !tbaa !5
  %24 = zext i8 %23 to i32
  %25 = srem i32 %24, 24
  %26 = trunc i32 %25 to i16
  %27 = load i8, ptr @i, align 1, !tbaa !5
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.t_sprites, ptr %29, i32 0, i32 2
  store i16 %26, ptr %30, align 4, !tbaa !13
  %31 = load i8, ptr @i, align 1, !tbaa !5
  %32 = zext i8 %31 to i64
  %33 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %32
  %34 = getelementptr inbounds %struct.t_sprites, ptr %33, i32 0, i32 4
  store i8 1, ptr %34, align 1, !tbaa !14
  %35 = load i8, ptr @i, align 1, !tbaa !5
  %36 = zext i8 %35 to i32
  %37 = icmp slt i32 %36, 8
  br i1 %37, label %38, label %47

38:                                               ; preds = %6
  %39 = load i8, ptr @i, align 1, !tbaa !5
  %40 = zext i8 %39 to i64
  %41 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %40
  %42 = getelementptr inbounds %struct.t_sprites, ptr %41, i32 0, i32 3
  store i8 32, ptr %42, align 2, !tbaa !15
  %43 = load i8, ptr @i, align 1, !tbaa !5
  %44 = zext i8 %43 to i64
  %45 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %44
  %46 = getelementptr inbounds %struct.t_sprites, ptr %45, i32 0, i32 5
  store ptr @spr32g, ptr %46, align 8, !tbaa !16
  br label %56

47:                                               ; preds = %6
  %48 = load i8, ptr @i, align 1, !tbaa !5
  %49 = zext i8 %48 to i64
  %50 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %49
  %51 = getelementptr inbounds %struct.t_sprites, ptr %50, i32 0, i32 3
  store i8 33, ptr %51, align 2, !tbaa !15
  %52 = load i8, ptr @i, align 1, !tbaa !5
  %53 = zext i8 %52 to i64
  %54 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.t_sprites, ptr %54, i32 0, i32 5
  store ptr @spr16g, ptr %55, align 8, !tbaa !16
  br label %56

56:                                               ; preds = %47, %38
  br label %57

57:                                               ; preds = %56
  %58 = load i8, ptr @i, align 1, !tbaa !5
  %59 = add i8 %58, 1
  store i8 %59, ptr @i, align 1, !tbaa !5
  br label %2, !llvm.loop !17

60:                                               ; preds = %2
  br label %61

61:                                               ; preds = %204, %60
  store i8 0, ptr @i, align 1, !tbaa !5
  br label %62

62:                                               ; preds = %201, %61
  %63 = load i8, ptr @i, align 1, !tbaa !5
  %64 = zext i8 %63 to i32
  %65 = icmp slt i32 %64, 64
  br i1 %65, label %66, label %204

66:                                               ; preds = %62
  %67 = call zeroext i16 @rand()
  %68 = zext i16 %67 to i32
  %69 = and i32 %68, 7
  %70 = icmp eq i32 %69, 7
  br i1 %70, label %71, label %89

71:                                               ; preds = %66
  %72 = load i8, ptr @i, align 1, !tbaa !5
  %73 = zext i8 %72 to i64
  %74 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.t_sprites, ptr %74, i32 0, i32 0
  %76 = load i16, ptr %75, align 8, !tbaa !8
  %77 = sext i16 %76 to i32
  %78 = icmp slt i32 %77, 240
  br i1 %78, label %79, label %88

79:                                               ; preds = %71
  %80 = load i8, ptr @i, align 1, !tbaa !5
  %81 = zext i8 %80 to i64
  %82 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %81
  %83 = getelementptr inbounds %struct.t_sprites, ptr %82, i32 0, i32 0
  %84 = load i16, ptr %83, align 8, !tbaa !8
  %85 = sext i16 %84 to i32
  %86 = add nsw i32 %85, 2
  %87 = trunc i32 %86 to i16
  store i16 %87, ptr %83, align 8, !tbaa !8
  br label %88

88:                                               ; preds = %79, %71
  br label %161

89:                                               ; preds = %66
  %90 = call zeroext i16 @rand()
  %91 = zext i16 %90 to i32
  %92 = and i32 %91, 5
  %93 = icmp eq i32 %92, 5
  br i1 %93, label %94, label %112

94:                                               ; preds = %89
  %95 = load i8, ptr @i, align 1, !tbaa !5
  %96 = zext i8 %95 to i64
  %97 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %96
  %98 = getelementptr inbounds %struct.t_sprites, ptr %97, i32 0, i32 0
  %99 = load i16, ptr %98, align 8, !tbaa !8
  %100 = sext i16 %99 to i32
  %101 = icmp sgt i32 %100, 0
  br i1 %101, label %102, label %111

102:                                              ; preds = %94
  %103 = load i8, ptr @i, align 1, !tbaa !5
  %104 = zext i8 %103 to i64
  %105 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %104
  %106 = getelementptr inbounds %struct.t_sprites, ptr %105, i32 0, i32 0
  %107 = load i16, ptr %106, align 8, !tbaa !8
  %108 = sext i16 %107 to i32
  %109 = sub nsw i32 %108, 2
  %110 = trunc i32 %109 to i16
  store i16 %110, ptr %106, align 8, !tbaa !8
  br label %111

111:                                              ; preds = %102, %94
  br label %160

112:                                              ; preds = %89
  %113 = call zeroext i16 @rand()
  %114 = zext i16 %113 to i32
  %115 = and i32 %114, 8
  %116 = icmp eq i32 %115, 8
  br i1 %116, label %117, label %135

117:                                              ; preds = %112
  %118 = load i8, ptr @i, align 1, !tbaa !5
  %119 = zext i8 %118 to i64
  %120 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %119
  %121 = getelementptr inbounds %struct.t_sprites, ptr %120, i32 0, i32 1
  %122 = load i16, ptr %121, align 2, !tbaa !12
  %123 = sext i16 %122 to i32
  %124 = icmp slt i32 %123, 208
  br i1 %124, label %125, label %134

125:                                              ; preds = %117
  %126 = load i8, ptr @i, align 1, !tbaa !5
  %127 = zext i8 %126 to i64
  %128 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %127
  %129 = getelementptr inbounds %struct.t_sprites, ptr %128, i32 0, i32 1
  %130 = load i16, ptr %129, align 2, !tbaa !12
  %131 = sext i16 %130 to i32
  %132 = add nsw i32 %131, 2
  %133 = trunc i32 %132 to i16
  store i16 %133, ptr %129, align 2, !tbaa !12
  br label %134

134:                                              ; preds = %125, %117
  br label %159

135:                                              ; preds = %112
  %136 = call zeroext i16 @rand()
  %137 = zext i16 %136 to i32
  %138 = and i32 %137, 3
  %139 = icmp eq i32 %138, 3
  br i1 %139, label %140, label %158

140:                                              ; preds = %135
  %141 = load i8, ptr @i, align 1, !tbaa !5
  %142 = zext i8 %141 to i64
  %143 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %142
  %144 = getelementptr inbounds %struct.t_sprites, ptr %143, i32 0, i32 1
  %145 = load i16, ptr %144, align 2, !tbaa !12
  %146 = sext i16 %145 to i32
  %147 = icmp sgt i32 %146, 0
  br i1 %147, label %148, label %157

148:                                              ; preds = %140
  %149 = load i8, ptr @i, align 1, !tbaa !5
  %150 = zext i8 %149 to i64
  %151 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %150
  %152 = getelementptr inbounds %struct.t_sprites, ptr %151, i32 0, i32 1
  %153 = load i16, ptr %152, align 2, !tbaa !12
  %154 = sext i16 %153 to i32
  %155 = sub nsw i32 %154, 2
  %156 = trunc i32 %155 to i16
  store i16 %156, ptr %152, align 2, !tbaa !12
  br label %157

157:                                              ; preds = %148, %140
  br label %158

158:                                              ; preds = %157, %135
  br label %159

159:                                              ; preds = %158, %134
  br label %160

160:                                              ; preds = %159, %111
  br label %161

161:                                              ; preds = %160, %88
  %162 = call zeroext i16 @rand()
  %163 = zext i16 %162 to i32
  %164 = and i32 %163, 15
  %165 = icmp eq i32 %164, 15
  br i1 %165, label %166, label %190

166:                                              ; preds = %161
  %167 = load i8, ptr @i, align 1, !tbaa !5
  %168 = zext i8 %167 to i64
  %169 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %168
  %170 = getelementptr inbounds %struct.t_sprites, ptr %169, i32 0, i32 2
  %171 = load i16, ptr %170, align 4, !tbaa !13
  %172 = add i16 %171, 1
  store i16 %172, ptr %170, align 4, !tbaa !13
  %173 = load i8, ptr @i, align 1, !tbaa !5
  %174 = zext i8 %173 to i64
  %175 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %174
  %176 = getelementptr inbounds %struct.t_sprites, ptr %175, i32 0, i32 2
  %177 = load i16, ptr %176, align 4, !tbaa !13
  %178 = zext i16 %177 to i32
  %179 = icmp sgt i32 %178, 2
  br i1 %179, label %180, label %185

180:                                              ; preds = %166
  %181 = load i8, ptr @i, align 1, !tbaa !5
  %182 = zext i8 %181 to i64
  %183 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %182
  %184 = getelementptr inbounds %struct.t_sprites, ptr %183, i32 0, i32 2
  store i16 0, ptr %184, align 4, !tbaa !13
  br label %185

185:                                              ; preds = %180, %166
  %186 = load i8, ptr @i, align 1, !tbaa !5
  %187 = zext i8 %186 to i64
  %188 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %187
  %189 = getelementptr inbounds %struct.t_sprites, ptr %188, i32 0, i32 4
  store i8 1, ptr %189, align 1, !tbaa !14
  br label %190

190:                                              ; preds = %185, %161
  %191 = load i8, ptr @i, align 1, !tbaa !5
  %192 = zext i8 %191 to i32
  %193 = icmp slt i32 %192, 8
  br i1 %193, label %194, label %197

194:                                              ; preds = %190
  %195 = load i8, ptr @i, align 1, !tbaa !5
  %196 = zext i8 %195 to i16
  call void @oamDynamic32Draw(i16 noundef zeroext %196)
  br label %200

197:                                              ; preds = %190
  %198 = load i8, ptr @i, align 1, !tbaa !5
  %199 = zext i8 %198 to i16
  call void @oamDynamic16Draw(i16 noundef zeroext %199)
  br label %200

200:                                              ; preds = %197, %194
  br label %201

201:                                              ; preds = %200
  %202 = load i8, ptr @i, align 1, !tbaa !5
  %203 = add i8 %202, 1
  store i8 %203, ptr @i, align 1, !tbaa !5
  br label %62, !llvm.loop !19

204:                                              ; preds = %62
  call void @oamInitDynamicSpriteEndFrame()
  call void @WaitForVBlank()
  call void @oamVramQueueUpdate()
  br label %61
}

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 @bgInitMapSet(i8 noundef zeroext, ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext) #1

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

declare zeroext i16 @rand() #1

declare void @oamDynamic32Draw(i16 noundef zeroext) #1

declare void @oamDynamic16Draw(i16 noundef zeroext) #1

declare void @oamInitDynamicSpriteEndFrame() #1

declare void @WaitForVBlank() #1

declare void @oamVramQueueUpdate() #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" }

!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, !10, i64 0}
!9 = !{!"", !10, i64 0, !10, i64 2, !10, i64 4, !6, i64 6, !6, i64 7, !11, i64 8, !10, i64 16, !10, i64 18}
!10 = !{!"short", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!9, !10, i64 2}
!13 = !{!9, !10, i64 4}
!14 = !{!9, !6, i64 7}
!15 = !{!9, !6, i64 6}
!16 = !{!9, !11, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.t_sprites = type { i16, i16, i16, i8, i8, ptr, i16, i16 }

@patterns = external global i8, align 1
@palette = external global i8, align 1
@patterns_end = external global i8, align 1
@palette_end = external global i8, align 1
@map = external global i8, align 1
@map_end = external global i8, align 1
@spr16p = external global i8, align 1
@i = external dso_local local_unnamed_addr global i8, align 1
@oambuffer = external local_unnamed_addr global [128 x %struct.t_sprites], align 16
@spr32g = external global i8, align 1
@spr16g = external global i8, align 1

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @bgInitTileSet(i8 noundef zeroext 0, ptr noundef nonnull @patterns, ptr noundef nonnull @palette, i8 noundef zeroext 0, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @patterns_end to i64), i64 ptrtoint (ptr @patterns to i64)) to i16), i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @palette_end to i64), i64 ptrtoint (ptr @palette to i64)) to i16), i16 noundef zeroext 16, i16 noundef zeroext 16384) #2
  tail call void @bgInitMapSet(i8 noundef zeroext 0, ptr noundef nonnull @map, i16 noundef zeroext trunc (i64 sub (i64 ptrtoint (ptr @map_end to i64), i64 ptrtoint (ptr @map to i64)) to i16), i8 noundef zeroext 0, i16 noundef zeroext 26624) #2
  tail call void @dmaCopyCGram(ptr noundef nonnull @spr16p, i16 noundef zeroext 128, i16 noundef zeroext 32) #2
  tail call void @setMode(i8 noundef zeroext 1, i8 noundef zeroext 0) #2
  tail call void @bgSetDisable(i8 noundef zeroext 1) #2
  tail call void @bgSetDisable(i8 noundef zeroext 2) #2
  tail call void @setScreenOn() #2
  tail call void @oamInitDynamicSprite(i16 noundef zeroext 0, i16 noundef zeroext 4096, i16 noundef zeroext 0, i16 noundef zeroext 0, i8 noundef zeroext 96) #2
  store i8 0, ptr @i, align 1, !tbaa !5
  br label %1

1:                                                ; preds = %0, %1
  %2 = tail call zeroext i16 @rand() #2
  %3 = urem i16 %2, 240
  %4 = load i8, ptr @i, align 1, !tbaa !5
  %5 = zext i8 %4 to i64
  %6 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %5
  store i16 %3, ptr %6, align 8, !tbaa !8
  %7 = tail call zeroext i16 @rand() #2
  %8 = urem i16 %7, 208
  %9 = load i8, ptr @i, align 1, !tbaa !5
  %10 = zext i8 %9 to i64
  %11 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %10, i32 1
  store i16 %8, ptr %11, align 2, !tbaa !12
  %12 = urem i8 %9, 24
  %13 = zext nneg i8 %12 to i16
  %14 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %10, i32 2
  store i16 %13, ptr %14, align 4, !tbaa !13
  %15 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %10, i32 4
  store i8 1, ptr %15, align 1, !tbaa !14
  %16 = icmp ult i8 %9, 8
  %spec.select = select i1 %16, i8 32, i8 33
  %spec.select5 = select i1 %16, ptr @spr32g, ptr @spr16g
  %17 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %10, i32 3
  store i8 %spec.select, ptr %17, align 2
  %18 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %10, i32 5
  store ptr %spec.select5, ptr %18, align 8
  %19 = add i8 %9, 1
  store i8 %19, ptr @i, align 1, !tbaa !5
  %20 = icmp ult i8 %19, 64
  br i1 %20, label %1, label %.preheader, !llvm.loop !15

.preheader:                                       ; preds = %1, %88
  store i8 0, ptr @i, align 1, !tbaa !5
  br label %21

21:                                               ; preds = %.preheader, %84
  %22 = tail call zeroext i16 @rand() #2
  %23 = and i16 %22, 7
  %24 = icmp eq i16 %23, 7
  br i1 %24, label %25, label %33

25:                                               ; preds = %21
  %26 = load i8, ptr @i, align 1, !tbaa !5
  %27 = zext i8 %26 to i64
  %28 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %27
  %29 = load i16, ptr %28, align 8, !tbaa !8
  %30 = icmp slt i16 %29, 240
  br i1 %30, label %31, label %68

31:                                               ; preds = %25
  %32 = add nsw i16 %29, 2
  store i16 %32, ptr %28, align 8, !tbaa !8
  br label %68

33:                                               ; preds = %21
  %34 = tail call zeroext i16 @rand() #2
  %35 = and i16 %34, 5
  %36 = icmp eq i16 %35, 5
  br i1 %36, label %37, label %45

37:                                               ; preds = %33
  %38 = load i8, ptr @i, align 1, !tbaa !5
  %39 = zext i8 %38 to i64
  %40 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %39
  %41 = load i16, ptr %40, align 8, !tbaa !8
  %42 = icmp sgt i16 %41, 0
  br i1 %42, label %43, label %68

43:                                               ; preds = %37
  %44 = add nsw i16 %41, -2
  store i16 %44, ptr %40, align 8, !tbaa !8
  br label %68

45:                                               ; preds = %33
  %46 = tail call zeroext i16 @rand() #2
  %47 = and i16 %46, 8
  %.not = icmp eq i16 %47, 0
  br i1 %.not, label %56, label %48

48:                                               ; preds = %45
  %49 = load i8, ptr @i, align 1, !tbaa !5
  %50 = zext i8 %49 to i64
  %51 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %50, i32 1
  %52 = load i16, ptr %51, align 2, !tbaa !12
  %53 = icmp slt i16 %52, 208
  br i1 %53, label %54, label %68

54:                                               ; preds = %48
  %55 = add nsw i16 %52, 2
  store i16 %55, ptr %51, align 2, !tbaa !12
  br label %68

56:                                               ; preds = %45
  %57 = tail call zeroext i16 @rand() #2
  %58 = and i16 %57, 3
  %59 = icmp eq i16 %58, 3
  br i1 %59, label %60, label %68

60:                                               ; preds = %56
  %61 = load i8, ptr @i, align 1, !tbaa !5
  %62 = zext i8 %61 to i64
  %63 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %62, i32 1
  %64 = load i16, ptr %63, align 2, !tbaa !12
  %65 = icmp sgt i16 %64, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %60
  %67 = add nsw i16 %64, -2
  store i16 %67, ptr %63, align 2, !tbaa !12
  br label %68

68:                                               ; preds = %43, %37, %56, %66, %60, %48, %54, %25, %31
  %69 = tail call zeroext i16 @rand() #2
  %70 = and i16 %69, 15
  %71 = icmp eq i16 %70, 15
  %.pre = load i8, ptr @i, align 1, !tbaa !5
  br i1 %71, label %72, label %79

72:                                               ; preds = %68
  %73 = zext i8 %.pre to i64
  %74 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %73, i32 2
  %75 = load i16, ptr %74, align 4, !tbaa !13
  %76 = add i16 %75, 1
  %77 = icmp ugt i16 %76, 2
  %spec.store.select = select i1 %77, i16 0, i16 %76
  store i16 %spec.store.select, ptr %74, align 4
  %78 = getelementptr inbounds [128 x %struct.t_sprites], ptr @oambuffer, i64 0, i64 %73, i32 4
  store i8 1, ptr %78, align 1, !tbaa !14
  br label %79

79:                                               ; preds = %72, %68
  %80 = icmp ult i8 %.pre, 8
  %81 = zext i8 %.pre to i16
  br i1 %80, label %82, label %83

82:                                               ; preds = %79
  tail call void @oamDynamic32Draw(i16 noundef zeroext %81) #2
  br label %84

83:                                               ; preds = %79
  tail call void @oamDynamic16Draw(i16 noundef zeroext %81) #2
  br label %84

84:                                               ; preds = %82, %83
  %85 = load i8, ptr @i, align 1, !tbaa !5
  %86 = add i8 %85, 1
  store i8 %86, ptr @i, align 1, !tbaa !5
  %87 = icmp ult i8 %86, 64
  br i1 %87, label %21, label %88, !llvm.loop !17

88:                                               ; preds = %84
  tail call void @oamInitDynamicSpriteEndFrame() #2
  tail call void @WaitForVBlank() #2
  tail call void @oamVramQueueUpdate() #2
  br label %.preheader
}

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

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

declare zeroext i16 @rand() local_unnamed_addr #1

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

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

declare void @oamInitDynamicSpriteEndFrame() local_unnamed_addr #1

declare void @WaitForVBlank() local_unnamed_addr #1

declare void @oamVramQueueUpdate() 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 = { 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, !10, i64 0}
!9 = !{!"", !10, i64 0, !10, i64 2, !10, i64 4, !6, i64 6, !6, i64 7, !11, i64 8, !10, i64 16, !10, i64 18}
!10 = !{!"short", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!9, !10, i64 2}
!13 = !{!9, !10, i64 4}
!14 = !{!9, !6, i64 7}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass