; LLVM IR from BrunoLevy/learn-fpga :: FemtoRV/TUTORIALS/FROM_BLINKER_TO_RISCV/FIRMWARE (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"

@spi_addr = external dso_local global i32, align 4
@cmap = external dso_local global [16 x i32], align 16
@X = external dso_local global [255 x i8], align 16
@Y = external dso_local global [255 x i8], align 16
@poly = external dso_local global [30 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @GL_fillpoly(i32 noundef, ptr noundef) #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 i8 @next_spi_byte() #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
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #3
  %17 = call zeroext i8 @next_spi_byte()
  store i8 %17, ptr %2, align 1, !tbaa !5
  %18 = load i8, ptr %2, align 1, !tbaa !5
  %19 = zext i8 %18 to i32
  %20 = and i32 %19, 2
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %72

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

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

27:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %71

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

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %36 = call zeroext i16 @next_spi_word()
  %37 = zext i16 %36 to i32
  store i32 %37, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %38 = load i32, ptr %5, align 4, !tbaa !10
  %39 = and i32 %38, 7
  store i32 %39, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %40 = load i32, ptr %5, align 4, !tbaa !10
  %41 = and i32 %40, 112
  %42 = ashr i32 %41, 4
  store i32 %42, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %43 = load i32, ptr %5, align 4, !tbaa !10
  %44 = and i32 %43, 1792
  %45 = ashr i32 %44, 8
  store i32 %45, ptr %8, align 4, !tbaa !10
  %46 = load i32, ptr %6, align 4, !tbaa !10
  %47 = mul nsw i32 %46, 6
  %48 = sdiv i32 %47, 8
  store i32 %48, ptr %6, align 4, !tbaa !10
  %49 = load i32, ptr %7, align 4, !tbaa !10
  %50 = mul nsw i32 %49, 6
  %51 = sdiv i32 %50, 8
  store i32 %51, ptr %7, align 4, !tbaa !10
  %52 = load i32, ptr %8, align 4, !tbaa !10
  %53 = mul nsw i32 %52, 6
  %54 = sdiv i32 %53, 8
  store i32 %54, ptr %8, align 4, !tbaa !10
  %55 = load i32, ptr %6, align 4, !tbaa !10
  %56 = add nsw i32 16, %55
  %57 = load i32, ptr %7, align 4, !tbaa !10
  %58 = load i32, ptr %8, align 4, !tbaa !10
  %59 = mul nsw i32 6, %58
  %60 = add nsw i32 %57, %59
  %61 = mul nsw i32 6, %60
  %62 = add nsw i32 %56, %61
  %63 = load i32, ptr %4, align 4, !tbaa !10
  %64 = sub nsw i32 15, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [16 x i32], ptr @cmap, i64 0, i64 %65
  store i32 %62, ptr %66, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %67

67:                                               ; preds = %35, %28
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %4, align 4, !tbaa !10
  %70 = add nsw i32 %69, -1
  store i32 %70, ptr %4, align 4, !tbaa !10
  br label %24, !llvm.loop !12

71:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 2, ptr %3) #3
  br label %72

72:                                               ; preds = %71, %0
  %73 = load i8, ptr %2, align 1, !tbaa !5
  %74 = zext i8 %73 to i32
  %75 = and i32 %74, 1
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %78

77:                                               ; preds = %72
  br label %78

78:                                               ; preds = %77, %72
  %79 = load i8, ptr %2, align 1, !tbaa !5
  %80 = zext i8 %79 to i32
  %81 = and i32 %80, 4
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %106

83:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  %84 = call zeroext i8 @next_spi_byte()
  store i8 %84, ptr %9, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !10
  br label %85

85:                                               ; preds = %102, %83
  %86 = load i32, ptr %10, align 4, !tbaa !10
  %87 = load i8, ptr %9, align 1, !tbaa !5
  %88 = zext i8 %87 to i32
  %89 = icmp slt i32 %86, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %105

91:                                               ; preds = %85
  %92 = call zeroext i8 @next_spi_byte()
  %93 = call zeroext i8 @map_x(i8 noundef zeroext %92)
  %94 = load i32, ptr %10, align 4, !tbaa !10
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [255 x i8], ptr @X, i64 0, i64 %95
  store i8 %93, ptr %96, align 1, !tbaa !5
  %97 = call zeroext i8 @next_spi_byte()
  %98 = call zeroext i8 @map_y(i8 noundef zeroext %97)
  %99 = load i32, ptr %10, align 4, !tbaa !10
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [255 x i8], ptr @Y, i64 0, i64 %100
  store i8 %98, ptr %101, align 1, !tbaa !5
  br label %102

102:                                              ; preds = %91
  %103 = load i32, ptr %10, align 4, !tbaa !10
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %10, align 4, !tbaa !10
  br label %85, !llvm.loop !14

105:                                              ; preds = %90
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  br label %106

106:                                              ; preds = %105, %78
  br label %107

107:                                              ; preds = %201, %106
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  %108 = call zeroext i8 @next_spi_byte()
  store i8 %108, ptr %11, align 1, !tbaa !5
  %109 = load i8, ptr %11, align 1, !tbaa !5
  %110 = zext i8 %109 to i32
  %111 = icmp eq i32 %110, 255
  br i1 %111, label %112, label %113

112:                                              ; preds = %107
  store i32 8, ptr %12, align 4
  br label %199

113:                                              ; preds = %107
  %114 = load i8, ptr %11, align 1, !tbaa !5
  %115 = zext i8 %114 to i32
  %116 = icmp eq i32 %115, 254
  br i1 %116, label %117, label %126

117:                                              ; preds = %113
  %118 = load i32, ptr @spi_addr, align 4, !tbaa !10
  %119 = sub i32 %118, 1048576
  store i32 %119, ptr @spi_addr, align 4, !tbaa !10
  %120 = load i32, ptr @spi_addr, align 4, !tbaa !10
  %121 = and i32 %120, -65536
  store i32 %121, ptr @spi_addr, align 4, !tbaa !10
  %122 = load i32, ptr @spi_addr, align 4, !tbaa !10
  %123 = add i32 %122, 65536
  store i32 %123, ptr @spi_addr, align 4, !tbaa !10
  %124 = load i32, ptr @spi_addr, align 4, !tbaa !10
  %125 = add i32 %124, 1048576
  store i32 %125, ptr @spi_addr, align 4, !tbaa !10
  store i32 1, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %199

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

130:                                              ; preds = %126
  store i32 0, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %199

131:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #3
  %132 = load i8, ptr %11, align 1, !tbaa !5
  %133 = zext i8 %132 to i32
  %134 = and i32 %133, 15
  %135 = trunc i32 %134 to i8
  store i8 %135, ptr %13, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  %136 = load i8, ptr %11, align 1, !tbaa !5
  %137 = zext i8 %136 to i32
  %138 = ashr i32 %137, 4
  %139 = trunc i32 %138 to i8
  store i8 %139, ptr %14, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %140

140:                                              ; preds = %189, %131
  %141 = load i32, ptr %15, align 4, !tbaa !10
  %142 = load i8, ptr %13, align 1, !tbaa !5
  %143 = zext i8 %142 to i32
  %144 = icmp slt i32 %141, %143
  br i1 %144, label %146, label %145

145:                                              ; preds = %140
  store i32 10, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %192

146:                                              ; preds = %140
  %147 = load i8, ptr %2, align 1, !tbaa !5
  %148 = zext i8 %147 to i32
  %149 = and i32 %148, 4
  %150 = icmp ne i32 %149, 0
  br i1 %150, label %151, label %172

151:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #3
  %152 = call zeroext i8 @next_spi_byte()
  store i8 %152, ptr %16, align 1, !tbaa !5
  %153 = load i8, ptr %16, align 1, !tbaa !5
  %154 = zext i8 %153 to i64
  %155 = getelementptr inbounds [255 x i8], ptr @X, i64 0, i64 %154
  %156 = load i8, ptr %155, align 1, !tbaa !5
  %157 = zext i8 %156 to i32
  %158 = load i32, ptr %15, align 4, !tbaa !10
  %159 = mul nsw i32 2, %158
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %160
  store i32 %157, ptr %161, align 4, !tbaa !10
  %162 = load i8, ptr %16, align 1, !tbaa !5
  %163 = zext i8 %162 to i64
  %164 = getelementptr inbounds [255 x i8], ptr @Y, i64 0, i64 %163
  %165 = load i8, ptr %164, align 1, !tbaa !5
  %166 = zext i8 %165 to i32
  %167 = load i32, ptr %15, align 4, !tbaa !10
  %168 = mul nsw i32 2, %167
  %169 = add nsw i32 %168, 1
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %170
  store i32 %166, ptr %171, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #3
  br label %188

172:                                              ; preds = %146
  %173 = call zeroext i8 @next_spi_byte()
  %174 = call zeroext i8 @map_x(i8 noundef zeroext %173)
  %175 = zext i8 %174 to i32
  %176 = load i32, ptr %15, align 4, !tbaa !10
  %177 = mul nsw i32 2, %176
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %178
  store i32 %175, ptr %179, align 4, !tbaa !10
  %180 = call zeroext i8 @next_spi_byte()
  %181 = call zeroext i8 @map_y(i8 noundef zeroext %180)
  %182 = zext i8 %181 to i32
  %183 = load i32, ptr %15, align 4, !tbaa !10
  %184 = mul nsw i32 2, %183
  %185 = add nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %186
  store i32 %182, ptr %187, align 4, !tbaa !10
  br label %188

188:                                              ; preds = %172, %151
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %15, align 4, !tbaa !10
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %15, align 4, !tbaa !10
  br label %140, !llvm.loop !15

192:                                              ; preds = %145
  %193 = load i8, ptr %14, align 1, !tbaa !5
  %194 = zext i8 %193 to i64
  %195 = getelementptr inbounds [16 x i32], ptr @cmap, i64 0, i64 %194
  %196 = load i32, ptr %195, align 4, !tbaa !10
  call void @GL_setcolor(i32 noundef %196)
  %197 = load i8, ptr %13, align 1, !tbaa !5
  %198 = zext i8 %197 to i32
  call void @GL_fillpoly(i32 noundef %198, ptr noundef @poly)
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  store i32 0, ptr %12, align 4
  br label %199

199:                                              ; preds = %192, %130, %117, %112
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  %200 = load i32, ptr %12, align 4
  switch i32 %200, label %203 [
    i32 0, label %201
    i32 8, label %202
  ]

201:                                              ; preds = %199
  br label %107

202:                                              ; preds = %199
  store i32 1, ptr %1, align 4
  store i32 1, ptr %12, align 4
  br label %203

203:                                              ; preds = %202, %199
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #3
  %204 = load i32, ptr %1, align 4
  ret i32 %204
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @map_x(i8 noundef zeroext) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @map_y(i8 noundef zeroext) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @GL_setcolor(i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @next_spi_word() #2

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


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

@spi_addr = external dso_local local_unnamed_addr global i32, align 4
@cmap = external dso_local local_unnamed_addr global [16 x i32], align 16
@X = external dso_local local_unnamed_addr global [255 x i8], align 16
@Y = external dso_local local_unnamed_addr global [255 x i8], align 16
@poly = external dso_local global [30 x i32], align 16

; Function Attrs: nounwind uwtable
declare dso_local void @GL_fillpoly(i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

4:                                                ; preds = %0
  %5 = tail call zeroext i16 @next_spi_word()
  %6 = zext i16 %5 to i32
  br label %7

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

11:                                               ; preds = %7
  %12 = tail call zeroext i16 @next_spi_word()
  %13 = zext i16 %12 to i32
  %14 = and i32 %13, 7
  %15 = lshr i32 %13, 4
  %16 = and i32 %15, 7
  %17 = lshr i32 %13, 8
  %18 = and i32 %17, 7
  %19 = mul nuw nsw i32 %14, 6
  %20 = lshr i32 %19, 3
  %21 = mul nuw nsw i32 %16, 6
  %22 = lshr i32 %21, 3
  %23 = mul nuw nsw i32 %18, 6
  %24 = lshr i32 %23, 3
  %25 = or disjoint i32 %20, 16
  %26 = mul nuw nsw i32 %24, 6
  %27 = add nuw nsw i32 %26, %22
  %28 = mul nuw nsw i32 %27, 6
  %29 = add nuw nsw i32 %25, %28
  %30 = sub nuw nsw i64 15, %indvars.iv
  %31 = getelementptr inbounds [16 x i32], ptr @cmap, i64 0, i64 %30
  store i32 %29, ptr %31, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %7, %11
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %.not82 = icmp eq i64 %indvars.iv, 0
  br i1 %.not82, label %.loopexit55, label %7, !llvm.loop !9

.loopexit55:                                      ; preds = %32, %0
  %33 = and i32 %2, 4
  %.not47 = icmp eq i32 %33, 0
  br i1 %.not47, label %.split.us, label %34

34:                                               ; preds = %.loopexit55
  %35 = tail call zeroext i8 @next_spi_byte()
  %.not62 = icmp eq i8 %35, 0
  br i1 %.not62, label %.split.preheader, label %.lr.ph.preheader

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

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv69 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next70, %.lr.ph ]
  %36 = tail call zeroext i8 @next_spi_byte()
  %37 = tail call zeroext i8 @map_x(i8 noundef zeroext %36)
  %38 = getelementptr inbounds [255 x i8], ptr @X, i64 0, i64 %indvars.iv69
  store i8 %37, ptr %38, align 1, !tbaa !11
  %39 = tail call zeroext i8 @next_spi_byte()
  %40 = tail call zeroext i8 @map_y(i8 noundef zeroext %39)
  %41 = getelementptr inbounds [255 x i8], ptr @Y, i64 0, i64 %indvars.iv69
  store i8 %40, ptr %41, align 1, !tbaa !11
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next70, %wide.trip.count
  br i1 %exitcond.not, label %.split.preheader, label %.lr.ph, !llvm.loop !12

.split.us:                                        ; preds = %.loopexit55, %._crit_edge.split.us.us
  %42 = tail call zeroext i8 @next_spi_byte()
  switch i8 %42, label %43 [
    i8 -1, label %.thread.loopexit88
    i8 -2, label %.split61.us
    i8 -3, label %.thread
  ]

43:                                               ; preds = %.split.us
  %44 = and i8 %42, 15
  %45 = lshr i8 %42, 4
  %46 = zext nneg i8 %44 to i32
  %.not64 = icmp eq i8 %44, 0
  br i1 %.not64, label %._crit_edge.split.us.us, label %.lr.ph59.us.preheader

.lr.ph59.us.preheader:                            ; preds = %43
  %wide.trip.count80 = zext nneg i8 %44 to i64
  br label %.lr.ph59.us

._crit_edge.split.us.us:                          ; preds = %.lr.ph59.us, %43
  %47 = zext nneg i8 %45 to i64
  %48 = getelementptr inbounds [16 x i32], ptr @cmap, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  tail call void @GL_setcolor(i32 noundef %49)
  tail call void @GL_fillpoly(i32 noundef %46, ptr noundef nonnull @poly)
  br label %.split.us

.lr.ph59.us:                                      ; preds = %.lr.ph59.us.preheader, %.lr.ph59.us
  %indvars.iv77 = phi i64 [ 0, %.lr.ph59.us.preheader ], [ %indvars.iv.next78, %.lr.ph59.us ]
  %50 = tail call zeroext i8 @next_spi_byte()
  %51 = tail call zeroext i8 @map_x(i8 noundef zeroext %50)
  %52 = zext i8 %51 to i32
  %53 = shl nuw nsw i64 %indvars.iv77, 1
  %54 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %53
  store i32 %52, ptr %54, align 8, !tbaa !5
  %55 = tail call zeroext i8 @next_spi_byte()
  %56 = tail call zeroext i8 @map_y(i8 noundef zeroext %55)
  %57 = zext i8 %56 to i32
  %58 = or disjoint i64 %53, 1
  %59 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %58
  store i32 %57, ptr %59, align 4, !tbaa !5
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count80
  br i1 %exitcond81.not, label %._crit_edge.split.us.us, label %.lr.ph59.us, !llvm.loop !13

.split:                                           ; preds = %.split.preheader, %._crit_edge.split
  %60 = tail call zeroext i8 @next_spi_byte()
  switch i8 %60, label %64 [
    i8 -1, label %.thread.loopexit89
    i8 -2, label %.split61.us
    i8 -3, label %.thread
  ]

.split61.us:                                      ; preds = %.split, %.split.us
  %61 = load i32, ptr @spi_addr, align 4, !tbaa !5
  %62 = and i32 %61, -65536
  %63 = add i32 %62, 65536
  store i32 %63, ptr @spi_addr, align 4, !tbaa !5
  br label %.thread

64:                                               ; preds = %.split
  %65 = and i8 %60, 15
  %66 = lshr i8 %60, 4
  %67 = zext nneg i8 %65 to i32
  %.not63 = icmp eq i8 %65, 0
  br i1 %.not63, label %._crit_edge.split, label %.lr.ph59.preheader

.lr.ph59.preheader:                               ; preds = %64
  %wide.trip.count75 = zext nneg i8 %65 to i64
  br label %.lr.ph59

.lr.ph59:                                         ; preds = %.lr.ph59.preheader, %.lr.ph59
  %indvars.iv72 = phi i64 [ 0, %.lr.ph59.preheader ], [ %indvars.iv.next73, %.lr.ph59 ]
  %68 = tail call zeroext i8 @next_spi_byte()
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds [255 x i8], ptr @X, i64 0, i64 %69
  %71 = load i8, ptr %70, align 1, !tbaa !11
  %72 = zext i8 %71 to i32
  %73 = shl nuw nsw i64 %indvars.iv72, 1
  %74 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %73
  store i32 %72, ptr %74, align 8, !tbaa !5
  %75 = getelementptr inbounds [255 x i8], ptr @Y, i64 0, i64 %69
  %76 = load i8, ptr %75, align 1, !tbaa !11
  %77 = zext i8 %76 to i32
  %78 = or disjoint i64 %73, 1
  %79 = getelementptr inbounds [30 x i32], ptr @poly, i64 0, i64 %78
  store i32 %77, ptr %79, align 4, !tbaa !5
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %exitcond76.not = icmp eq i64 %indvars.iv.next73, %wide.trip.count75
  br i1 %exitcond76.not, label %._crit_edge.split, label %.lr.ph59, !llvm.loop !13

._crit_edge.split:                                ; preds = %.lr.ph59, %64
  %80 = zext nneg i8 %66 to i64
  %81 = getelementptr inbounds [16 x i32], ptr @cmap, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  tail call void @GL_setcolor(i32 noundef %82)
  tail call void @GL_fillpoly(i32 noundef %67, ptr noundef nonnull @poly)
  br label %.split

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

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

.thread:                                          ; preds = %.split, %.split.us, %.thread.loopexit89, %.thread.loopexit88, %.split61.us
  %.2 = phi i32 [ 1, %.split61.us ], [ 1, %.thread.loopexit88 ], [ 1, %.thread.loopexit89 ], [ 0, %.split.us ], [ 0, %.split ]
  ret i32 %.2
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @map_x(i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i8 @map_y(i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @GL_setcolor(i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i16 @next_spi_word() local_unnamed_addr #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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