; LLVM IR from BrunoLevy/learn-fpga :: LiteX/software/Doom/mc1-doom/src (r_segs)

; 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.drawseg_s = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.seg_t = type { ptr, ptr, i32, i32, ptr, ptr, ptr, ptr }
%struct.side_t = type { i32, i32, i16, i16, i16, ptr }
%struct.sector_t = type { i32, i32, i16, i16, i16, i16, i16, i32, ptr, [4 x i32], %struct.degenmobj_t, i32, ptr, ptr, i32, ptr }
%struct.degenmobj_t = type { %struct.thinker_s, i32, i32, i32 }
%struct.thinker_s = type { ptr, ptr, %union.actionf_t }
%union.actionf_t = type { ptr }
%struct.vertex_t = type { i32, i32 }
%struct.line_s = type { ptr, ptr, i32, i32, i16, i16, i16, [2 x i16], [4 x i32], i32, ptr, ptr, i32, ptr }

@curline = external global ptr, align 8
@frontsector = external global ptr, align 8
@backsector = external global ptr, align 8
@texturetranslation = external global ptr, align 8
@extralight = external global i32, align 4
@scalelight = external global [16 x [48 x ptr]], align 16
@walllights = external dso_local global ptr, align 8
@maskedtexturecol = external dso_local global ptr, align 8
@rw_scalestep = external dso_local global i32, align 4
@spryscale = external global i32, align 4
@mfloorclip = external global ptr, align 8
@mceilingclip = external global ptr, align 8
@dc_texturemid = external global i32, align 4
@textureheight = external global ptr, align 8
@viewz = external global i32, align 4
@fixedcolormap = external global ptr, align 8
@dc_colormap = external global ptr, align 8
@dc_x = external global i32, align 4
@centeryfrac = external global i32, align 4
@sprtopscreen = external global i32, align 4
@dc_iscale = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @R_RenderMaskedSegRange(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.drawseg_s, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  store ptr %13, ptr @curline, align 8, !tbaa !5
  %14 = load ptr, ptr @curline, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.seg_t, ptr %14, i32 0, i32 6
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  store ptr %16, ptr @frontsector, align 8, !tbaa !5
  %17 = load ptr, ptr @curline, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.seg_t, ptr %17, i32 0, i32 7
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  store ptr %19, ptr @backsector, align 8, !tbaa !5
  %20 = load ptr, ptr @texturetranslation, align 8, !tbaa !5
  %21 = load ptr, ptr @curline, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.seg_t, ptr %21, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %24 = getelementptr inbounds %struct.side_t, ptr %23, i32 0, i32 4
  %25 = load i16, ptr %24, align 4, !tbaa !17
  %26 = sext i16 %25 to i64
  %27 = getelementptr inbounds i32, ptr %20, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !9
  store i32 %28, ptr %10, align 4, !tbaa !9
  %29 = load ptr, ptr @frontsector, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sector_t, ptr %29, i32 0, i32 4
  %31 = load i16, ptr %30, align 4, !tbaa !20
  %32 = sext i16 %31 to i32
  %33 = ashr i32 %32, 4
  %34 = load i32, ptr @extralight, align 4, !tbaa !9
  %35 = add nsw i32 %33, %34
  store i32 %35, ptr %9, align 4, !tbaa !9
  %36 = load ptr, ptr @curline, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.seg_t, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !24
  %39 = getelementptr inbounds %struct.vertex_t, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !25
  %41 = load ptr, ptr @curline, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.seg_t, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !27
  %44 = getelementptr inbounds %struct.vertex_t, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !25
  %46 = icmp eq i32 %40, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %3
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %9, align 4, !tbaa !9
  br label %66

50:                                               ; preds = %3
  %51 = load ptr, ptr @curline, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.seg_t, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !24
  %54 = getelementptr inbounds %struct.vertex_t, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 4, !tbaa !28
  %56 = load ptr, ptr @curline, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.seg_t, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !27
  %59 = getelementptr inbounds %struct.vertex_t, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 4, !tbaa !28
  %61 = icmp eq i32 %55, %60
  br i1 %61, label %62, label %65

62:                                               ; preds = %50
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %9, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %62, %50
  br label %66

66:                                               ; preds = %65, %47
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store ptr @scalelight, ptr @walllights, align 8, !tbaa !5
  br label %80

70:                                               ; preds = %66
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = icmp sge i32 %71, 16
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store ptr getelementptr inbounds ([16 x [48 x ptr]], ptr @scalelight, i64 0, i64 15), ptr @walllights, align 8, !tbaa !5
  br label %79

74:                                               ; preds = %70
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [16 x [48 x ptr]], ptr @scalelight, i64 0, i64 %76
  %78 = getelementptr inbounds [48 x ptr], ptr %77, i64 0, i64 0
  store ptr %78, ptr @walllights, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %74, %73
  br label %80

80:                                               ; preds = %79, %69
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.drawseg_s, ptr %81, i32 0, i32 11
  %83 = load ptr, ptr %82, align 8, !tbaa !29
  store ptr %83, ptr @maskedtexturecol, align 8, !tbaa !5
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.drawseg_s, ptr %84, i32 0, i32 5
  %86 = load i32, ptr %85, align 8, !tbaa !30
  store i32 %86, ptr @rw_scalestep, align 4, !tbaa !9
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.drawseg_s, ptr %87, i32 0, i32 3
  %89 = load i32, ptr %88, align 8, !tbaa !31
  %90 = load i32, ptr %5, align 4, !tbaa !9
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.drawseg_s, ptr %91, i32 0, i32 1
  %93 = load i32, ptr %92, align 8, !tbaa !32
  %94 = sub nsw i32 %90, %93
  %95 = load i32, ptr @rw_scalestep, align 4, !tbaa !9
  %96 = mul nsw i32 %94, %95
  %97 = add nsw i32 %89, %96
  store i32 %97, ptr @spryscale, align 4, !tbaa !9
  %98 = load ptr, ptr %4, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.drawseg_s, ptr %98, i32 0, i32 10
  %100 = load ptr, ptr %99, align 8, !tbaa !33
  store ptr %100, ptr @mfloorclip, align 8, !tbaa !5
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.drawseg_s, ptr %101, i32 0, i32 9
  %103 = load ptr, ptr %102, align 8, !tbaa !34
  store ptr %103, ptr @mceilingclip, align 8, !tbaa !5
  %104 = load ptr, ptr @curline, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.seg_t, ptr %104, i32 0, i32 5
  %106 = load ptr, ptr %105, align 8, !tbaa !35
  %107 = getelementptr inbounds %struct.line_s, ptr %106, i32 0, i32 4
  %108 = load i16, ptr %107, align 8, !tbaa !36
  %109 = sext i16 %108 to i32
  %110 = and i32 %109, 16
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %139

112:                                              ; preds = %80
  %113 = load ptr, ptr @frontsector, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.sector_t, ptr %113, i32 0, i32 0
  %115 = load i32, ptr %114, align 8, !tbaa !38
  %116 = load ptr, ptr @backsector, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.sector_t, ptr %116, i32 0, i32 0
  %118 = load i32, ptr %117, align 8, !tbaa !38
  %119 = icmp sgt i32 %115, %118
  br i1 %119, label %120, label %124

120:                                              ; preds = %112
  %121 = load ptr, ptr @frontsector, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.sector_t, ptr %121, i32 0, i32 0
  %123 = load i32, ptr %122, align 8, !tbaa !38
  br label %128

124:                                              ; preds = %112
  %125 = load ptr, ptr @backsector, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.sector_t, ptr %125, i32 0, i32 0
  %127 = load i32, ptr %126, align 8, !tbaa !38
  br label %128

128:                                              ; preds = %124, %120
  %129 = phi i32 [ %123, %120 ], [ %127, %124 ]
  store i32 %129, ptr @dc_texturemid, align 4, !tbaa !9
  %130 = load i32, ptr @dc_texturemid, align 4, !tbaa !9
  %131 = load ptr, ptr @textureheight, align 8, !tbaa !5
  %132 = load i32, ptr %10, align 4, !tbaa !9
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds i32, ptr %131, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !9
  %136 = add nsw i32 %130, %135
  %137 = load i32, ptr @viewz, align 4, !tbaa !9
  %138 = sub nsw i32 %136, %137
  store i32 %138, ptr @dc_texturemid, align 4, !tbaa !9
  br label %160

139:                                              ; preds = %80
  %140 = load ptr, ptr @frontsector, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.sector_t, ptr %140, i32 0, i32 1
  %142 = load i32, ptr %141, align 4, !tbaa !39
  %143 = load ptr, ptr @backsector, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.sector_t, ptr %143, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !39
  %146 = icmp slt i32 %142, %145
  br i1 %146, label %147, label %151

147:                                              ; preds = %139
  %148 = load ptr, ptr @frontsector, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.sector_t, ptr %148, i32 0, i32 1
  %150 = load i32, ptr %149, align 4, !tbaa !39
  br label %155

151:                                              ; preds = %139
  %152 = load ptr, ptr @backsector, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.sector_t, ptr %152, i32 0, i32 1
  %154 = load i32, ptr %153, align 4, !tbaa !39
  br label %155

155:                                              ; preds = %151, %147
  %156 = phi i32 [ %150, %147 ], [ %154, %151 ]
  store i32 %156, ptr @dc_texturemid, align 4, !tbaa !9
  %157 = load i32, ptr @dc_texturemid, align 4, !tbaa !9
  %158 = load i32, ptr @viewz, align 4, !tbaa !9
  %159 = sub nsw i32 %157, %158
  store i32 %159, ptr @dc_texturemid, align 4, !tbaa !9
  br label %160

160:                                              ; preds = %155, %128
  %161 = load ptr, ptr @curline, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.seg_t, ptr %161, i32 0, i32 4
  %163 = load ptr, ptr %162, align 8, !tbaa !16
  %164 = getelementptr inbounds %struct.side_t, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 4, !tbaa !40
  %166 = load i32, ptr @dc_texturemid, align 4, !tbaa !9
  %167 = add nsw i32 %166, %165
  store i32 %167, ptr @dc_texturemid, align 4, !tbaa !9
  %168 = load ptr, ptr @fixedcolormap, align 8, !tbaa !5
  %169 = icmp ne ptr %168, null
  br i1 %169, label %170, label %172

170:                                              ; preds = %160
  %171 = load ptr, ptr @fixedcolormap, align 8, !tbaa !5
  store ptr %171, ptr @dc_colormap, align 8, !tbaa !5
  br label %172

172:                                              ; preds = %170, %160
  %173 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %173, ptr @dc_x, align 4, !tbaa !9
  br label %174

174:                                              ; preds = %227, %172
  %175 = load i32, ptr @dc_x, align 4, !tbaa !9
  %176 = load i32, ptr %6, align 4, !tbaa !9
  %177 = icmp sle i32 %175, %176
  br i1 %177, label %178, label %230

178:                                              ; preds = %174
  %179 = load ptr, ptr @maskedtexturecol, align 8, !tbaa !5
  %180 = load i32, ptr @dc_x, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds i16, ptr %179, i64 %181
  %183 = load i16, ptr %182, align 2, !tbaa !41
  %184 = sext i16 %183 to i32
  %185 = icmp ne i32 %184, 32767
  br i1 %185, label %186, label %223

186:                                              ; preds = %178
  %187 = load ptr, ptr @fixedcolormap, align 8, !tbaa !5
  %188 = icmp ne ptr %187, null
  br i1 %188, label %201, label %189

189:                                              ; preds = %186
  %190 = load i32, ptr @spryscale, align 4, !tbaa !9
  %191 = ashr i32 %190, 12
  store i32 %191, ptr %7, align 4, !tbaa !9
  %192 = load i32, ptr %7, align 4, !tbaa !9
  %193 = icmp uge i32 %192, 48
  br i1 %193, label %194, label %195

194:                                              ; preds = %189
  store i32 47, ptr %7, align 4, !tbaa !9
  br label %195

195:                                              ; preds = %194, %189
  %196 = load ptr, ptr @walllights, align 8, !tbaa !5
  %197 = load i32, ptr %7, align 4, !tbaa !9
  %198 = zext i32 %197 to i64
  %199 = getelementptr inbounds ptr, ptr %196, i64 %198
  %200 = load ptr, ptr %199, align 8, !tbaa !5
  store ptr %200, ptr @dc_colormap, align 8, !tbaa !5
  br label %201

201:                                              ; preds = %195, %186
  %202 = load i32, ptr @centeryfrac, align 4, !tbaa !9
  %203 = load i32, ptr @dc_texturemid, align 4, !tbaa !9
  %204 = load i32, ptr @spryscale, align 4, !tbaa !9
  %205 = call i32 @FixedMul(i32 noundef %203, i32 noundef %204)
  %206 = sub nsw i32 %202, %205
  store i32 %206, ptr @sprtopscreen, align 4, !tbaa !9
  %207 = load i32, ptr @spryscale, align 4, !tbaa !9
  %208 = udiv i32 -1, %207
  store i32 %208, ptr @dc_iscale, align 4, !tbaa !9
  %209 = load i32, ptr %10, align 4, !tbaa !9
  %210 = load ptr, ptr @maskedtexturecol, align 8, !tbaa !5
  %211 = load i32, ptr @dc_x, align 4, !tbaa !9
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds i16, ptr %210, i64 %212
  %214 = load i16, ptr %213, align 2, !tbaa !41
  %215 = sext i16 %214 to i32
  %216 = call ptr @R_GetColumn(i32 noundef %209, i32 noundef %215)
  %217 = getelementptr inbounds i8, ptr %216, i64 -3
  store ptr %217, ptr %8, align 8, !tbaa !5
  %218 = load ptr, ptr %8, align 8, !tbaa !5
  call void @R_DrawMaskedColumn(ptr noundef %218)
  %219 = load ptr, ptr @maskedtexturecol, align 8, !tbaa !5
  %220 = load i32, ptr @dc_x, align 4, !tbaa !9
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds i16, ptr %219, i64 %221
  store i16 32767, ptr %222, align 2, !tbaa !41
  br label %223

223:                                              ; preds = %201, %178
  %224 = load i32, ptr @rw_scalestep, align 4, !tbaa !9
  %225 = load i32, ptr @spryscale, align 4, !tbaa !9
  %226 = add nsw i32 %225, %224
  store i32 %226, ptr @spryscale, align 4, !tbaa !9
  br label %227

227:                                              ; preds = %223
  %228 = load i32, ptr @dc_x, align 4, !tbaa !9
  %229 = add nsw i32 %228, 1
  store i32 %229, ptr @dc_x, align 4, !tbaa !9
  br label %174, !llvm.loop !42

230:                                              ; preds = %174
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

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

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

declare ptr @R_GetColumn(i32 noundef, i32 noundef) #3

declare void @R_DrawMaskedColumn(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"drawseg_s", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!14, !6, i64 40}
!14 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!15 = !{!14, !6, i64 48}
!16 = !{!14, !6, i64 24}
!17 = !{!18, !19, i64 12}
!18 = !{!"", !10, i64 0, !10, i64 4, !19, i64 8, !19, i64 10, !19, i64 12, !6, i64 16}
!19 = !{!"short", !7, i64 0}
!20 = !{!21, !19, i64 12}
!21 = !{!"", !10, i64 0, !10, i64 4, !19, i64 8, !19, i64 10, !19, i64 12, !19, i64 14, !19, i64 16, !10, i64 20, !6, i64 24, !7, i64 32, !22, i64 48, !10, i64 88, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120}
!22 = !{!"", !23, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!23 = !{!"thinker_s", !6, i64 0, !6, i64 8, !7, i64 16}
!24 = !{!14, !6, i64 0}
!25 = !{!26, !10, i64 4}
!26 = !{!"", !10, i64 0, !10, i64 4}
!27 = !{!14, !6, i64 8}
!28 = !{!26, !10, i64 0}
!29 = !{!12, !6, i64 56}
!30 = !{!12, !10, i64 24}
!31 = !{!12, !10, i64 16}
!32 = !{!12, !10, i64 8}
!33 = !{!12, !6, i64 48}
!34 = !{!12, !6, i64 40}
!35 = !{!14, !6, i64 32}
!36 = !{!37, !19, i64 24}
!37 = !{!"line_s", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !19, i64 24, !19, i64 26, !19, i64 28, !7, i64 30, !7, i64 36, !10, i64 52, !6, i64 56, !6, i64 64, !10, i64 72, !6, i64 80}
!38 = !{!21, !10, i64 0}
!39 = !{!21, !10, i64 4}
!40 = !{!18, !10, i64 4}
!41 = !{!19, !19, i64 0}
!42 = distinct !{!42, !43}
!43 = !{!"llvm.loop.mustprogress"}


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

@curline = external local_unnamed_addr global ptr, align 8
@frontsector = external local_unnamed_addr global ptr, align 8
@backsector = external local_unnamed_addr global ptr, align 8
@texturetranslation = external local_unnamed_addr global ptr, align 8
@extralight = external local_unnamed_addr global i32, align 4
@scalelight = external global [16 x [48 x ptr]], align 16
@walllights = external dso_local local_unnamed_addr global ptr, align 8
@maskedtexturecol = external dso_local local_unnamed_addr global ptr, align 8
@rw_scalestep = external dso_local local_unnamed_addr global i32, align 4
@spryscale = external local_unnamed_addr global i32, align 4
@mfloorclip = external local_unnamed_addr global ptr, align 8
@mceilingclip = external local_unnamed_addr global ptr, align 8
@dc_texturemid = external local_unnamed_addr global i32, align 4
@textureheight = external local_unnamed_addr global ptr, align 8
@viewz = external local_unnamed_addr global i32, align 4
@fixedcolormap = external local_unnamed_addr global ptr, align 8
@dc_colormap = external local_unnamed_addr global ptr, align 8
@dc_x = external local_unnamed_addr global i32, align 4
@centeryfrac = external local_unnamed_addr global i32, align 4
@sprtopscreen = external local_unnamed_addr global i32, align 4
@dc_iscale = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @R_RenderMaskedSegRange(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  store ptr %4, ptr @curline, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %4, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  store ptr %6, ptr @frontsector, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %4, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  store ptr %8, ptr @backsector, align 8, !tbaa !11
  %9 = load ptr, ptr @texturetranslation, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %4, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %11, i64 12
  %13 = load i16, ptr %12, align 4, !tbaa !16
  %14 = sext i16 %13 to i64
  %15 = getelementptr inbounds i32, ptr %9, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %6, i64 12
  %18 = load i16, ptr %17, align 4, !tbaa !20
  %19 = ashr i16 %18, 4
  %20 = sext i16 %19 to i32
  %21 = load i32, ptr @extralight, align 4, !tbaa !19
  %22 = add nsw i32 %21, %20
  %23 = load ptr, ptr %4, align 8, !tbaa !24
  %24 = getelementptr inbounds i8, ptr %23, i64 4
  %25 = load i32, ptr %24, align 4, !tbaa !25
  %26 = getelementptr inbounds i8, ptr %4, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !27
  %28 = getelementptr inbounds i8, ptr %27, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !25
  %30 = icmp eq i32 %25, %29
  br i1 %30, label %36, label %31

31:                                               ; preds = %3
  %32 = load i32, ptr %23, align 4, !tbaa !28
  %33 = load i32, ptr %27, align 4, !tbaa !28
  %34 = icmp eq i32 %32, %33
  %35 = zext i1 %34 to i32
  br label %36

36:                                               ; preds = %3, %31
  %.sink = phi i32 [ %35, %31 ], [ -1, %3 ]
  %spec.select = add nsw i32 %22, %.sink
  %37 = icmp slt i32 %spec.select, 0
  br i1 %37, label %43, label %38

38:                                               ; preds = %36
  %39 = icmp ugt i32 %spec.select, 15
  br i1 %39, label %43, label %40

40:                                               ; preds = %38
  %41 = zext nneg i32 %spec.select to i64
  %42 = getelementptr inbounds [16 x [48 x ptr]], ptr @scalelight, i64 0, i64 %41
  br label %43

43:                                               ; preds = %38, %36, %40
  %.sink34 = phi ptr [ %42, %40 ], [ @scalelight, %36 ], [ getelementptr inbounds (i8, ptr @scalelight, i64 5760), %38 ]
  store ptr %.sink34, ptr @walllights, align 8, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %0, i64 56
  %45 = load ptr, ptr %44, align 8, !tbaa !29
  store ptr %45, ptr @maskedtexturecol, align 8, !tbaa !11
  %46 = getelementptr inbounds i8, ptr %0, i64 24
  %47 = load i32, ptr %46, align 8, !tbaa !30
  store i32 %47, ptr @rw_scalestep, align 4, !tbaa !19
  %48 = getelementptr inbounds i8, ptr %0, i64 16
  %49 = load i32, ptr %48, align 8, !tbaa !31
  %50 = getelementptr inbounds i8, ptr %0, i64 8
  %51 = load i32, ptr %50, align 8, !tbaa !32
  %52 = sub nsw i32 %1, %51
  %53 = mul nsw i32 %52, %47
  %54 = add nsw i32 %53, %49
  store i32 %54, ptr @spryscale, align 4, !tbaa !19
  %55 = getelementptr inbounds i8, ptr %0, i64 48
  %56 = load ptr, ptr %55, align 8, !tbaa !33
  store ptr %56, ptr @mfloorclip, align 8, !tbaa !11
  %57 = getelementptr inbounds i8, ptr %0, i64 40
  %58 = load ptr, ptr %57, align 8, !tbaa !34
  store ptr %58, ptr @mceilingclip, align 8, !tbaa !11
  %59 = getelementptr inbounds i8, ptr %4, i64 32
  %60 = load ptr, ptr %59, align 8, !tbaa !35
  %61 = getelementptr inbounds i8, ptr %60, i64 24
  %62 = load i16, ptr %61, align 8, !tbaa !36
  %63 = and i16 %62, 16
  %.not = icmp eq i16 %63, 0
  br i1 %.not, label %72, label %64

64:                                               ; preds = %43
  %65 = load i32, ptr %6, align 8, !tbaa !38
  %66 = load i32, ptr %8, align 8, !tbaa !38
  %. = tail call i32 @llvm.smax.i32(i32 %65, i32 %66)
  store i32 %., ptr @dc_texturemid, align 4, !tbaa !19
  %67 = load ptr, ptr @textureheight, align 8, !tbaa !11
  %68 = sext i32 %16 to i64
  %69 = getelementptr inbounds i32, ptr %67, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !19
  %71 = add nsw i32 %70, %.
  br label %77

72:                                               ; preds = %43
  %73 = getelementptr inbounds i8, ptr %6, i64 4
  %74 = load i32, ptr %73, align 4, !tbaa !39
  %75 = getelementptr inbounds i8, ptr %8, i64 4
  %76 = load i32, ptr %75, align 4, !tbaa !39
  %.30 = tail call i32 @llvm.smin.i32(i32 %74, i32 %76)
  br label %77

77:                                               ; preds = %72, %64
  %.30.sink = phi i32 [ %.30, %72 ], [ %71, %64 ]
  %78 = load i32, ptr @viewz, align 4, !tbaa !19
  %79 = sub i32 %.30.sink, %78
  %80 = getelementptr inbounds i8, ptr %11, i64 4
  %81 = load i32, ptr %80, align 4, !tbaa !40
  %82 = add nsw i32 %81, %79
  store i32 %82, ptr @dc_texturemid, align 4, !tbaa !19
  %83 = load ptr, ptr @fixedcolormap, align 8, !tbaa !11
  %.not25 = icmp eq ptr %83, null
  br i1 %.not25, label %85, label %84

84:                                               ; preds = %77
  store ptr %83, ptr @dc_colormap, align 8, !tbaa !11
  br label %85

85:                                               ; preds = %84, %77
  store i32 %1, ptr @dc_x, align 4, !tbaa !19
  %.not2731 = icmp sgt i32 %1, %2
  br i1 %.not2731, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %85, %119
  %86 = phi i32 [ %122, %119 ], [ %47, %85 ]
  %87 = phi i32 [ %124, %119 ], [ %54, %85 ]
  %88 = phi ptr [ %123, %119 ], [ %45, %85 ]
  %storemerge2632 = phi i32 [ %125, %119 ], [ %1, %85 ]
  %89 = sext i32 %storemerge2632 to i64
  %90 = getelementptr inbounds i16, ptr %88, i64 %89
  %91 = load i16, ptr %90, align 2, !tbaa !41
  %.not28 = icmp eq i16 %91, 32767
  br i1 %.not28, label %119, label %92

92:                                               ; preds = %.lr.ph
  %93 = load ptr, ptr @fixedcolormap, align 8, !tbaa !11
  %.not29 = icmp eq ptr %93, null
  br i1 %.not29, label %94, label %100

94:                                               ; preds = %92
  %95 = ashr i32 %87, 12
  %spec.store.select = tail call i32 @llvm.umin.i32(i32 %95, i32 47)
  %96 = load ptr, ptr @walllights, align 8, !tbaa !11
  %97 = zext nneg i32 %spec.store.select to i64
  %98 = getelementptr inbounds ptr, ptr %96, i64 %97
  %99 = load ptr, ptr %98, align 8, !tbaa !11
  store ptr %99, ptr @dc_colormap, align 8, !tbaa !11
  br label %100

100:                                              ; preds = %94, %92
  %101 = load i32, ptr @centeryfrac, align 4, !tbaa !19
  %102 = load i32, ptr @dc_texturemid, align 4, !tbaa !19
  %103 = tail call i32 @FixedMul(i32 noundef %102, i32 noundef %87)
  %104 = sub nsw i32 %101, %103
  store i32 %104, ptr @sprtopscreen, align 4, !tbaa !19
  %105 = load i32, ptr @spryscale, align 4, !tbaa !19
  %106 = udiv i32 -1, %105
  store i32 %106, ptr @dc_iscale, align 4, !tbaa !19
  %107 = load ptr, ptr @maskedtexturecol, align 8, !tbaa !11
  %108 = load i32, ptr @dc_x, align 4, !tbaa !19
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i16, ptr %107, i64 %109
  %111 = load i16, ptr %110, align 2, !tbaa !41
  %112 = sext i16 %111 to i32
  %113 = tail call ptr @R_GetColumn(i32 noundef %16, i32 noundef %112) #4
  %114 = getelementptr inbounds i8, ptr %113, i64 -3
  tail call void @R_DrawMaskedColumn(ptr noundef nonnull %114) #4
  %115 = load ptr, ptr @maskedtexturecol, align 8, !tbaa !11
  %116 = load i32, ptr @dc_x, align 4, !tbaa !19
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds i16, ptr %115, i64 %117
  store i16 32767, ptr %118, align 2, !tbaa !41
  %.pre = load i32, ptr @rw_scalestep, align 4, !tbaa !19
  %.pre33 = load i32, ptr @spryscale, align 4, !tbaa !19
  br label %119

119:                                              ; preds = %100, %.lr.ph
  %120 = phi i32 [ %116, %100 ], [ %storemerge2632, %.lr.ph ]
  %121 = phi i32 [ %.pre33, %100 ], [ %87, %.lr.ph ]
  %122 = phi i32 [ %.pre, %100 ], [ %86, %.lr.ph ]
  %123 = phi ptr [ %115, %100 ], [ %88, %.lr.ph ]
  %124 = add nsw i32 %121, %122
  store i32 %124, ptr @spryscale, align 4, !tbaa !19
  %125 = add nsw i32 %120, 1
  store i32 %125, ptr @dc_x, align 4, !tbaa !19
  %.not27.not = icmp slt i32 %120, %2
  br i1 %.not27.not, label %.lr.ph, label %._crit_edge, !llvm.loop !42

._crit_edge:                                      ; preds = %119, %85
  ret void
}

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

declare ptr @R_GetColumn(i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @R_DrawMaskedColumn(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #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 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"drawseg_s", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !7, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 40}
!13 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!14 = !{!13, !7, i64 48}
!15 = !{!13, !7, i64 24}
!16 = !{!17, !18, i64 12}
!17 = !{!"", !10, i64 0, !10, i64 4, !18, i64 8, !18, i64 10, !18, i64 12, !7, i64 16}
!18 = !{!"short", !8, i64 0}
!19 = !{!10, !10, i64 0}
!20 = !{!21, !18, i64 12}
!21 = !{!"", !10, i64 0, !10, i64 4, !18, i64 8, !18, i64 10, !18, i64 12, !18, i64 14, !18, i64 16, !10, i64 20, !7, i64 24, !8, i64 32, !22, i64 48, !10, i64 88, !7, i64 96, !7, i64 104, !10, i64 112, !7, i64 120}
!22 = !{!"", !23, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!23 = !{!"thinker_s", !7, i64 0, !7, i64 8, !8, i64 16}
!24 = !{!13, !7, i64 0}
!25 = !{!26, !10, i64 4}
!26 = !{!"", !10, i64 0, !10, i64 4}
!27 = !{!13, !7, i64 8}
!28 = !{!26, !10, i64 0}
!29 = !{!6, !7, i64 56}
!30 = !{!6, !10, i64 24}
!31 = !{!6, !10, i64 16}
!32 = !{!6, !10, i64 8}
!33 = !{!6, !7, i64 48}
!34 = !{!6, !7, i64 40}
!35 = !{!13, !7, i64 32}
!36 = !{!37, !18, i64 24}
!37 = !{!"line_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !18, i64 24, !18, i64 26, !18, i64 28, !8, i64 30, !8, i64 36, !10, i64 52, !7, i64 56, !7, i64 64, !10, i64 72, !7, i64 80}
!38 = !{!21, !10, i64 0}
!39 = !{!21, !10, i64 4}
!40 = !{!17, !10, i64 4}
!41 = !{!18, !18, i64 0}
!42 = distinct !{!42, !43}
!43 = !{!"llvm.loop.mustprogress"}


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