; LLVM IR from BrunoLevy/learn-fpga :: FemtoRV/FIRMWARE/EXAMPLES (ST_NICCC)

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

@cur_byte_address = external dso_local global i32, align 4
@wireframe = external dso_local global i32, align 4
@cmap = external dso_local global [16 x i16], align 16
@X = external dso_local global [255 x i16], align 16
@Y = external dso_local global [255 x i16], align 16
@poly = external dso_local global [30 x i32], align 16
@colormapped = external dso_local global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @next_byte() #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i16 @next_word() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @read_frame() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %3 = alloca i16, align 2
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca i8, align 1
  %17 = alloca i16, align 2
  %18 = alloca i16, align 2
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #4
  %19 = call zeroext i8 @next_byte()
  store i8 %19, ptr %2, align 1, !tbaa !5
  %20 = load i8, ptr %2, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = and i32 %21, 2
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %77

24:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 2, ptr %3) #4
  %25 = call zeroext i16 @next_word()
  store i16 %25, ptr %3, align 2, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 15, ptr %4, align 4, !tbaa !10
  br label %26

26:                                               ; preds = %73, %24
  %27 = load i32, ptr %4, align 4, !tbaa !10
  %28 = icmp sge i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %76

30:                                               ; preds = %26
  %31 = load i16, ptr %3, align 2, !tbaa !8
  %32 = zext i16 %31 to i32
  %33 = load i32, ptr %4, align 4, !tbaa !10
  %34 = shl i32 1, %33
  %35 = and i32 %32, %34
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %72

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %38 = call zeroext i16 @next_word()
  %39 = zext i16 %38 to i32
  store i32 %39, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %40 = load i32, ptr %5, align 4, !tbaa !10
  %41 = and i32 %40, 7
  store i32 %41, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %42 = load i32, ptr %5, align 4, !tbaa !10
  %43 = and i32 %42, 112
  %44 = ashr i32 %43, 4
  store i32 %44, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %45 = load i32, ptr %5, align 4, !tbaa !10
  %46 = and i32 %45, 1792
  %47 = ashr i32 %46, 8
  store i32 %47, ptr %8, align 4, !tbaa !10
  %48 = load i32, ptr %6, align 4, !tbaa !10
  %49 = shl i32 %48, 2
  %50 = load i32, ptr %7, align 4, !tbaa !10
  %51 = shl i32 %50, 8
  %52 = or i32 %49, %51
  %53 = load i32, ptr %8, align 4, !tbaa !10
  %54 = shl i32 %53, 13
  %55 = or i32 %52, %54
  %56 = trunc i32 %55 to i16
  %57 = load i32, ptr %4, align 4, !tbaa !10
  %58 = sub nsw i32 15, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [16 x i16], ptr @cmap, i64 0, i64 %59
  store i16 %56, ptr %60, align 2, !tbaa !8
  %61 = load i32, ptr %4, align 4, !tbaa !10
  %62 = sub nsw i32 15, %61
  %63 = load i32, ptr %8, align 4, !tbaa !10
  %64 = shl i32 %63, 5
  %65 = trunc i32 %64 to i8
  %66 = load i32, ptr %7, align 4, !tbaa !10
  %67 = shl i32 %66, 5
  %68 = trunc i32 %67 to i8
  %69 = load i32, ptr %6, align 4, !tbaa !10
  %70 = shl i32 %69, 5
  %71 = trunc i32 %70 to i8
  call void @FGA_setpalette(i32 noundef %62, i8 noundef zeroext %65, i8 noundef zeroext %68, i8 noundef zeroext %71)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %72

72:                                               ; preds = %37, %30
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %4, align 4, !tbaa !10
  %75 = add nsw i32 %74, -1
  store i32 %75, ptr %4, align 4, !tbaa !10
  br label %26, !llvm.loop !12

76:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #4
  br label %77

77:                                               ; preds = %76, %0
  call void (...) @GL_wait_vbl()
  %78 = load i32, ptr @wireframe, align 4, !tbaa !10
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %81

80:                                               ; preds = %77
  call void (...) @GL_clear()
  br label %88

81:                                               ; preds = %77
  %82 = load i8, ptr %2, align 1, !tbaa !5
  %83 = zext i8 %82 to i32
  %84 = and i32 %83, 1
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %87

86:                                               ; preds = %81
  br label %87

87:                                               ; preds = %86, %81
  br label %88

88:                                               ; preds = %87, %80
  %89 = load i8, ptr %2, align 1, !tbaa !5
  %90 = zext i8 %89 to i32
  %91 = and i32 %90, 4
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %122

93:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %94 = call zeroext i8 @next_byte()
  store i8 %94, ptr %9, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !10
  br label %95

95:                                               ; preds = %118, %93
  %96 = load i32, ptr %10, align 4, !tbaa !10
  %97 = load i8, ptr %9, align 1, !tbaa !5
  %98 = zext i8 %97 to i32
  %99 = icmp slt i32 %96, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %121

101:                                              ; preds = %95
  %102 = call zeroext i8 @next_byte()
  %103 = zext i8 %102 to i16
  %104 = load i32, ptr %10, align 4, !tbaa !10
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [255 x i16], ptr @X, i64 0, i64 %105
  store i16 %103, ptr %106, align 2, !tbaa !8
  %107 = call zeroext i8 @next_byte()
  %108 = zext i8 %107 to i16
  %109 = load i32, ptr %10, align 4, !tbaa !10
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [255 x i16], ptr @Y, i64 0, i64 %110
  store i16 %108, ptr %111, align 2, !tbaa !8
  %112 = load i32, ptr %10, align 4, !tbaa !10
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [255 x i16], ptr @X, i64 0, i64 %113
  %115 = load i32, ptr %10, align 4, !tbaa !10
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [255 x i16], ptr @Y, i64 0, i64 %116
  call void @map_vertex(ptr noundef %114, ptr noundef %117)
  br label %118

118:                                              ; preds = %101
  %119 = load i32, ptr %10, align 4, !tbaa !10
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %10, align 4, !tbaa !10
  br label %95, !llvm.loop !14

121:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  br label %122

122:                                              ; preds = %121, %88
  br label %123

123:                                              ; preds = %228, %122
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %124 = call zeroext i8 @next_byte()
  store i8 %124, ptr %11, align 1, !tbaa !5
  %125 = load i8, ptr %11, align 1, !tbaa !5
  %126 = zext i8 %125 to i32
  %127 = icmp eq i32 %126, 255
  br i1 %127, label %128, label %129

128:                                              ; preds = %123
  store i32 8, ptr %12, align 4
  br label %226

129:                                              ; preds = %123
  %130 = load i8, ptr %11, align 1, !tbaa !5
  %131 = zext i8 %130 to i32
  %132 = icmp eq i32 %131, 254
  br i1 %132, label %133, label %141

133:                                              ; preds = %129
  br label %134

134:                                              ; preds = %138, %133
  %135 = load i32, ptr @cur_byte_address, align 4, !tbaa !10
  %136 = and i32 %135, 65535
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %140

138:                                              ; preds = %134
  %139 = call zeroext i8 @next_byte()
  br label %134, !llvm.loop !15

140:                                              ; preds = %134
  store i32 1, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %226

141:                                              ; preds = %129
  %142 = load i8, ptr %11, align 1, !tbaa !5
  %143 = zext i8 %142 to i32
  %144 = icmp eq i32 %143, 253
  br i1 %144, label %145, label %146

145:                                              ; preds = %141
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %226

146:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #4
  %147 = load i8, ptr %11, align 1, !tbaa !5
  %148 = zext i8 %147 to i32
  %149 = and i32 %148, 15
  %150 = trunc i32 %149 to i8
  store i8 %150, ptr %13, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #4
  %151 = load i8, ptr %11, align 1, !tbaa !5
  %152 = zext i8 %151 to i32
  %153 = ashr i32 %152, 4
  %154 = trunc i32 %153 to i8
  store i8 %154, ptr %14, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %155

155:                                              ; preds = %206, %146
  %156 = load i32, ptr %15, align 4, !tbaa !10
  %157 = load i8, ptr %13, align 1, !tbaa !5
  %158 = zext i8 %157 to i32
  %159 = icmp slt i32 %156, %158
  br i1 %159, label %161, label %160

160:                                              ; preds = %155
  store i32 12, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %209

161:                                              ; preds = %155
  %162 = load i8, ptr %2, align 1, !tbaa !5
  %163 = zext i8 %162 to i32
  %164 = and i32 %163, 4
  %165 = icmp ne i32 %164, 0
  br i1 %165, label %166, label %187

166:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #4
  %167 = call zeroext i8 @next_byte()
  store i8 %167, ptr %16, align 1, !tbaa !5
  %168 = load i8, ptr %16, align 1, !tbaa !5
  %169 = zext i8 %168 to i64
  %170 = getelementptr inbounds [255 x i16], ptr @X, i64 0, i64 %169
  %171 = load i16, ptr %170, align 2, !tbaa !8
  %172 = sext i16 %171 to i32
  %173 = load i32, ptr %15, align 4, !tbaa !10
  %174 = mul nsw i32 2, %173
  %175 = sext i32 %174 to i64
  %176 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %175
  store i32 %172, ptr %176, align 4, !tbaa !10
  %177 = load i8, ptr %16, align 1, !tbaa !5
  %178 = zext i8 %177 to i64
  %179 = getelementptr inbounds [255 x i16], ptr @Y, i64 0, i64 %178
  %180 = load i16, ptr %179, align 2, !tbaa !8
  %181 = sext i16 %180 to i32
  %182 = load i32, ptr %15, align 4, !tbaa !10
  %183 = mul nsw i32 2, %182
  %184 = add nsw i32 %183, 1
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %185
  store i32 %181, ptr %186, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #4
  br label %205

187:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 2, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #4
  %188 = call zeroext i8 @next_byte()
  %189 = zext i8 %188 to i16
  store i16 %189, ptr %17, align 2, !tbaa !8
  %190 = call zeroext i8 @next_byte()
  %191 = zext i8 %190 to i16
  store i16 %191, ptr %18, align 2, !tbaa !8
  call void @map_vertex(ptr noundef %17, ptr noundef %18)
  %192 = load i16, ptr %17, align 2, !tbaa !8
  %193 = sext i16 %192 to i32
  %194 = load i32, ptr %15, align 4, !tbaa !10
  %195 = mul nsw i32 2, %194
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %196
  store i32 %193, ptr %197, align 4, !tbaa !10
  %198 = load i16, ptr %18, align 2, !tbaa !8
  %199 = sext i16 %198 to i32
  %200 = load i32, ptr %15, align 4, !tbaa !10
  %201 = mul nsw i32 2, %200
  %202 = add nsw i32 %201, 1
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %203
  store i32 %199, ptr %204, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #4
  br label %205

205:                                              ; preds = %187, %166
  br label %206

206:                                              ; preds = %205
  %207 = load i32, ptr %15, align 4, !tbaa !10
  %208 = add nsw i32 %207, 1
  store i32 %208, ptr %15, align 4, !tbaa !10
  br label %155, !llvm.loop !16

209:                                              ; preds = %160
  %210 = load i8, ptr %13, align 1, !tbaa !5
  %211 = zext i8 %210 to i32
  %212 = load i32, ptr @colormapped, align 4, !tbaa !10
  %213 = icmp ne i32 %212, 0
  br i1 %213, label %214, label %217

214:                                              ; preds = %209
  %215 = load i8, ptr %14, align 1, !tbaa !5
  %216 = zext i8 %215 to i32
  br label %223

217:                                              ; preds = %209
  %218 = load i8, ptr %14, align 1, !tbaa !5
  %219 = zext i8 %218 to i64
  %220 = getelementptr inbounds [16 x i16], ptr @cmap, i64 0, i64 %219
  %221 = load i16, ptr %220, align 2, !tbaa !8
  %222 = zext i16 %221 to i32
  br label %223

223:                                              ; preds = %217, %214
  %224 = phi i32 [ %216, %214 ], [ %222, %217 ]
  %225 = trunc i32 %224 to i16
  call void @GL_fill_poly(i32 noundef %211, ptr noundef @poly, i16 noundef zeroext %225)
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #4
  store i32 0, ptr %12, align 4
  br label %226

226:                                              ; preds = %223, %145, %140, %128
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  %227 = load i32, ptr %12, align 4
  switch i32 %227, label %230 [
    i32 0, label %228
    i32 8, label %229
  ]

228:                                              ; preds = %226
  br label %123

229:                                              ; preds = %226
  store i32 1, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %230

230:                                              ; preds = %229, %226
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #4
  %231 = load i32, ptr %1, align 4
  ret i32 %231
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @FGA_setpalette(i32 noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #2

declare void @GL_wait_vbl(...) #3

declare void @GL_clear(...) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @map_vertex(ptr noundef, ptr noundef) #2

declare void @GL_fill_poly(i32 noundef, ptr noundef, i16 noundef zeroext) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


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

@cur_byte_address = external dso_local local_unnamed_addr global i32, align 4
@wireframe = external dso_local local_unnamed_addr global i32, align 4
@cmap = external dso_local local_unnamed_addr global [16 x i16], align 16
@X = external dso_local global [255 x i16], align 16
@Y = external dso_local global [255 x i16], align 16
@poly = external dso_local global [30 x i32], align 16
@colormapped = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @next_byte() local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @read_frame() local_unnamed_addr #0 {
  %1 = alloca i16, align 2
  %2 = alloca i16, align 2
  %3 = tail call zeroext i8 @next_byte()
  %4 = zext i8 %3 to i32
  %5 = and i32 %4, 2
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.loopexit63, label %6

6:                                                ; preds = %0
  %7 = tail call zeroext i16 @next_word()
  %8 = zext i16 %7 to i32
  br label %9

9:                                                ; preds = %6, %34
  %indvars.iv = phi i64 [ 15, %6 ], [ %indvars.iv.next, %34 ]
  %10 = trunc nuw nsw i64 %indvars.iv to i32
  %11 = shl nuw i32 1, %10
  %12 = and i32 %11, %8
  %.not55 = icmp eq i32 %12, 0
  br i1 %.not55, label %34, label %13

13:                                               ; preds = %9
  %14 = tail call zeroext i16 @next_word()
  %15 = zext i16 %14 to i32
  %16 = lshr i32 %15, 4
  %17 = lshr i32 %15, 8
  %18 = shl nuw nsw i32 %15, 2
  %19 = and i32 %18, 28
  %20 = shl nuw nsw i32 %16, 8
  %21 = and i32 %20, 1792
  %22 = or disjoint i32 %19, %21
  %23 = shl nuw nsw i32 %17, 13
  %24 = or disjoint i32 %22, %23
  %25 = trunc i32 %24 to i16
  %26 = sub nuw nsw i64 15, %indvars.iv
  %27 = getelementptr inbounds [16 x i16], ptr @cmap, i64 0, i64 %26
  store i16 %25, ptr %27, align 2, !tbaa !5
  %28 = shl nuw nsw i32 %17, 5
  %29 = trunc i32 %28 to i8
  %30 = shl nuw nsw i32 %16, 5
  %31 = trunc i32 %30 to i8
  %.tr = trunc i16 %14 to i8
  %32 = shl i8 %.tr, 5
  %33 = trunc nuw nsw i64 %26 to i32
  tail call void @FGA_setpalette(i32 noundef %33, i8 noundef zeroext %29, i8 noundef zeroext %31, i8 noundef zeroext %32)
  br label %34

34:                                               ; preds = %9, %13
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not91 = icmp eq i64 %indvars.iv, 0
  br i1 %.not91, label %.loopexit63, label %9, !llvm.loop !9

.loopexit63:                                      ; preds = %34, %0
  tail call void (...) @GL_wait_vbl() #4
  %35 = load i32, ptr @wireframe, align 4, !tbaa !11
  %.not51 = icmp eq i32 %35, 0
  br i1 %.not51, label %37, label %36

36:                                               ; preds = %.loopexit63
  tail call void (...) @GL_clear() #4
  br label %37

37:                                               ; preds = %.loopexit63, %36
  %38 = and i32 %4, 4
  %.not52 = icmp eq i32 %38, 0
  br i1 %.not52, label %.split.us, label %39

39:                                               ; preds = %37
  %40 = tail call zeroext i8 @next_byte()
  %.not70 = icmp eq i8 %40, 0
  br i1 %.not70, label %.split.preheader, label %.lr.ph.preheader

.split.preheader:                                 ; preds = %.lr.ph, %39
  br label %.split

.lr.ph.preheader:                                 ; preds = %39
  %wide.trip.count = zext i8 %40 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv78 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next79, %.lr.ph ]
  %41 = tail call zeroext i8 @next_byte()
  %42 = zext i8 %41 to i16
  %43 = getelementptr inbounds [255 x i16], ptr @X, i64 0, i64 %indvars.iv78
  store i16 %42, ptr %43, align 2, !tbaa !5
  %44 = tail call zeroext i8 @next_byte()
  %45 = zext i8 %44 to i16
  %46 = getelementptr inbounds [255 x i16], ptr @Y, i64 0, i64 %indvars.iv78
  store i16 %45, ptr %46, align 2, !tbaa !5
  tail call void @map_vertex(ptr noundef nonnull %43, ptr noundef nonnull %46)
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next79, %wide.trip.count
  br i1 %exitcond.not, label %.split.preheader, label %.lr.ph, !llvm.loop !13

.split.us:                                        ; preds = %37, %59
  %47 = call zeroext i8 @next_byte()
  switch i8 %47, label %48 [
    i8 -1, label %.thread.loopexit98
    i8 -2, label %.preheader
    i8 -3, label %.thread
  ]

48:                                               ; preds = %.split.us
  %49 = and i8 %47, 15
  %50 = lshr i8 %47, 4
  %51 = zext nneg i8 %49 to i32
  %.not72 = icmp eq i8 %49, 0
  br i1 %.not72, label %._crit_edge.split.us.us, label %.lr.ph67.us.preheader

.lr.ph67.us.preheader:                            ; preds = %48
  %wide.trip.count89 = zext nneg i8 %49 to i64
  br label %.lr.ph67.us

._crit_edge.split.us.us:                          ; preds = %.lr.ph67.us, %48
  %52 = load i32, ptr @colormapped, align 4, !tbaa !11
  %.not53.us = icmp eq i32 %52, 0
  br i1 %.not53.us, label %55, label %53

53:                                               ; preds = %._crit_edge.split.us.us
  %54 = zext nneg i8 %50 to i16
  br label %59

55:                                               ; preds = %._crit_edge.split.us.us
  %56 = zext nneg i8 %50 to i64
  %57 = getelementptr inbounds [16 x i16], ptr @cmap, i64 0, i64 %56
  %58 = load i16, ptr %57, align 2, !tbaa !5
  br label %59

59:                                               ; preds = %55, %53
  %60 = phi i16 [ %54, %53 ], [ %58, %55 ]
  call void @GL_fill_poly(i32 noundef %51, ptr noundef nonnull @poly, i16 noundef zeroext %60) #4
  br label %.split.us

.lr.ph67.us:                                      ; preds = %.lr.ph67.us.preheader, %.lr.ph67.us
  %indvars.iv86 = phi i64 [ 0, %.lr.ph67.us.preheader ], [ %indvars.iv.next87, %.lr.ph67.us ]
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %2) #4
  %61 = call zeroext i8 @next_byte()
  %62 = zext i8 %61 to i16
  store i16 %62, ptr %1, align 2, !tbaa !5
  %63 = call zeroext i8 @next_byte()
  %64 = zext i8 %63 to i16
  store i16 %64, ptr %2, align 2, !tbaa !5
  call void @map_vertex(ptr noundef nonnull %1, ptr noundef nonnull %2)
  %65 = load i16, ptr %1, align 2, !tbaa !5
  %66 = sext i16 %65 to i32
  %67 = shl nuw nsw i64 %indvars.iv86, 1
  %68 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %67
  store i32 %66, ptr %68, align 8, !tbaa !11
  %69 = load i16, ptr %2, align 2, !tbaa !5
  %70 = sext i16 %69 to i32
  %71 = or disjoint i64 %67, 1
  %72 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %71
  store i32 %70, ptr %72, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %1) #4
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond90.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count89
  br i1 %exitcond90.not, label %._crit_edge.split.us.us, label %.lr.ph67.us, !llvm.loop !14

.split:                                           ; preds = %.split.preheader, %102
  %73 = tail call zeroext i8 @next_byte()
  switch i8 %73, label %79 [
    i8 -1, label %.thread.loopexit99
    i8 -2, label %.preheader
    i8 -3, label %.thread
  ]

.preheader:                                       ; preds = %.split, %.split.us
  %74 = load i32, ptr @cur_byte_address, align 4, !tbaa !11
  %75 = and i32 %74, 65535
  %.not5468 = icmp eq i32 %75, 0
  br i1 %.not5468, label %.thread, label %.lr.ph69

.lr.ph69:                                         ; preds = %.preheader, %.lr.ph69
  %76 = call zeroext i8 @next_byte()
  %77 = load i32, ptr @cur_byte_address, align 4, !tbaa !11
  %78 = and i32 %77, 65535
  %.not54 = icmp eq i32 %78, 0
  br i1 %.not54, label %.thread, label %.lr.ph69, !llvm.loop !15

79:                                               ; preds = %.split
  %80 = and i8 %73, 15
  %81 = lshr i8 %73, 4
  %82 = zext nneg i8 %80 to i32
  %.not71 = icmp eq i8 %80, 0
  br i1 %.not71, label %._crit_edge.split, label %.lr.ph67.preheader

.lr.ph67.preheader:                               ; preds = %79
  %wide.trip.count84 = zext nneg i8 %80 to i64
  br label %.lr.ph67

._crit_edge.split:                                ; preds = %.lr.ph67, %79
  %83 = load i32, ptr @colormapped, align 4, !tbaa !11
  %.not53 = icmp eq i32 %83, 0
  br i1 %.not53, label %98, label %96

.lr.ph67:                                         ; preds = %.lr.ph67.preheader, %.lr.ph67
  %indvars.iv81 = phi i64 [ 0, %.lr.ph67.preheader ], [ %indvars.iv.next82, %.lr.ph67 ]
  %84 = tail call zeroext i8 @next_byte()
  %85 = zext i8 %84 to i64
  %86 = getelementptr inbounds [255 x i16], ptr @X, i64 0, i64 %85
  %87 = load i16, ptr %86, align 2, !tbaa !5
  %88 = sext i16 %87 to i32
  %89 = shl nuw nsw i64 %indvars.iv81, 1
  %90 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %89
  store i32 %88, ptr %90, align 8, !tbaa !11
  %91 = getelementptr inbounds [255 x i16], ptr @Y, i64 0, i64 %85
  %92 = load i16, ptr %91, align 2, !tbaa !5
  %93 = sext i16 %92 to i32
  %94 = or disjoint i64 %89, 1
  %95 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %94
  store i32 %93, ptr %95, align 4, !tbaa !11
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond85.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count84
  br i1 %exitcond85.not, label %._crit_edge.split, label %.lr.ph67, !llvm.loop !14

96:                                               ; preds = %._crit_edge.split
  %97 = zext nneg i8 %81 to i16
  br label %102

98:                                               ; preds = %._crit_edge.split
  %99 = zext nneg i8 %81 to i64
  %100 = getelementptr inbounds [16 x i16], ptr @cmap, i64 0, i64 %99
  %101 = load i16, ptr %100, align 2, !tbaa !5
  br label %102

102:                                              ; preds = %96, %98
  %103 = phi i16 [ %97, %96 ], [ %101, %98 ]
  tail call void @GL_fill_poly(i32 noundef %82, ptr noundef nonnull @poly, i16 noundef zeroext %103) #4
  br label %.split

.thread.loopexit98:                               ; preds = %.split.us
  br label %.thread

.thread.loopexit99:                               ; preds = %.split
  br label %.thread

.thread:                                          ; preds = %.lr.ph69, %.split, %.split.us, %.thread.loopexit99, %.thread.loopexit98, %.preheader
  %.2 = phi i32 [ 1, %.preheader ], [ 1, %.thread.loopexit98 ], [ 1, %.thread.loopexit99 ], [ 0, %.split.us ], [ 0, %.split ], [ 1, %.lr.ph69 ]
  ret i32 %.2
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @FGA_setpalette(i32 noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

declare void @GL_wait_vbl(...) local_unnamed_addr #3

declare void @GL_clear(...) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @map_vertex(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @GL_fill_poly(i32 noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}


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