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

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

@finecosine = external dso_local global ptr, align 8
@projection = external dso_local global i32, align 4
@centerxfrac = external dso_local global i32, align 4
@viewwidth = external global i32, align 4
@xtoviewangle = external dso_local global [321 x i32], align 16
@centerx = external dso_local global i32, align 4
@colormaps = external global ptr, align 8
@setsizeneeded = external dso_local global i32, align 4
@setblocks = external dso_local global i32, align 4
@scaledviewwidth = external global i32, align 4
@viewheight = external global i32, align 4
@centery = external dso_local global i32, align 4
@centeryfrac = external dso_local global i32, align 4
@colfunc = external dso_local global ptr, align 8
@pspritescale = external global i32, align 4
@pspriteiscale = external global i32, align 4
@screenheightarray = external global [320 x i16], align 16
@yslope = external global [200 x i32], align 16
@distscale = external global [320 x i32], align 16
@scalelight = external dso_local global [16 x [48 x ptr]], align 16

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

declare i32 @FixedDiv(i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @R_InitTextureMapping() #3

; Function Attrs: nounwind uwtable
define dso_local void @R_ExecuteSetViewSize() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr @setsizeneeded, align 4, !tbaa !5
  %7 = load i32, ptr @setblocks, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 11
  br i1 %8, label %9, label %10

9:                                                ; preds = %0
  store i32 320, ptr @scaledviewwidth, align 4, !tbaa !5
  store i32 200, ptr @viewheight, align 4, !tbaa !5
  br label %26

10:                                               ; preds = %0
  %11 = load i32, ptr @setblocks, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 10
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  store i32 320, ptr @scaledviewwidth, align 4, !tbaa !5
  store i32 168, ptr @viewheight, align 4, !tbaa !5
  br label %25

14:                                               ; preds = %10
  %15 = load i32, ptr @setblocks, align 4, !tbaa !5
  %16 = mul nsw i32 %15, 320
  %17 = sdiv i32 %16, 10
  store i32 %17, ptr @scaledviewwidth, align 4, !tbaa !5
  %18 = load i32, ptr @setblocks, align 4, !tbaa !5
  %19 = mul nsw i32 %18, 168
  %20 = sdiv i32 %19, 10
  store i32 %20, ptr @viewheight, align 4, !tbaa !5
  %21 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %22 = and i32 %21, -8
  store i32 %22, ptr @scaledviewwidth, align 4, !tbaa !5
  %23 = load i32, ptr @viewheight, align 4, !tbaa !5
  %24 = and i32 %23, -8
  store i32 %24, ptr @viewheight, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %14, %13
  br label %26

26:                                               ; preds = %25, %9
  %27 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  store i32 %27, ptr @viewwidth, align 4, !tbaa !5
  %28 = load i32, ptr @viewheight, align 4, !tbaa !5
  %29 = sdiv i32 %28, 2
  store i32 %29, ptr @centery, align 4, !tbaa !5
  %30 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %31 = sdiv i32 %30, 2
  store i32 %31, ptr @centerx, align 4, !tbaa !5
  %32 = load i32, ptr @centerx, align 4, !tbaa !5
  %33 = shl i32 %32, 16
  store i32 %33, ptr @centerxfrac, align 4, !tbaa !5
  %34 = load i32, ptr @centery, align 4, !tbaa !5
  %35 = shl i32 %34, 16
  store i32 %35, ptr @centeryfrac, align 4, !tbaa !5
  %36 = load i32, ptr @centerxfrac, align 4, !tbaa !5
  store i32 %36, ptr @projection, align 4, !tbaa !5
  store ptr @R_DrawColumn, ptr @colfunc, align 8, !tbaa !9
  %37 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %38 = load i32, ptr @viewheight, align 4, !tbaa !5
  call void @R_InitBuffer(i32 noundef %37, i32 noundef %38)
  call void @R_InitTextureMapping()
  %39 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %40 = mul nsw i32 65536, %39
  %41 = sdiv i32 %40, 320
  store i32 %41, ptr @pspritescale, align 4, !tbaa !5
  %42 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %43 = sdiv i32 20971520, %42
  store i32 %43, ptr @pspriteiscale, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %54, %26
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %48, label %57

48:                                               ; preds = %44
  %49 = load i32, ptr @viewheight, align 4, !tbaa !5
  %50 = trunc i32 %49 to i16
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [320 x i16], ptr @screenheightarray, i64 0, i64 %52
  store i16 %50, ptr %53, align 2, !tbaa !11
  br label %54

54:                                               ; preds = %48
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %3, align 4, !tbaa !5
  br label %44, !llvm.loop !13

57:                                               ; preds = %44
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %79, %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = load i32, ptr @viewheight, align 4, !tbaa !5
  %61 = icmp slt i32 %59, %60
  br i1 %61, label %62, label %82

62:                                               ; preds = %58
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = load i32, ptr @viewheight, align 4, !tbaa !5
  %65 = sdiv i32 %64, 2
  %66 = sub nsw i32 %63, %65
  %67 = shl i32 %66, 16
  %68 = add nsw i32 %67, 32768
  store i32 %68, ptr %2, align 4, !tbaa !5
  %69 = load i32, ptr %2, align 4, !tbaa !5
  %70 = call i32 @llvm.abs.i32(i32 %69, i1 true)
  store i32 %70, ptr %2, align 4, !tbaa !5
  %71 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %72 = sdiv i32 %71, 2
  %73 = mul nsw i32 %72, 65536
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = call i32 @FixedDiv(i32 noundef %73, i32 noundef %74)
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [200 x i32], ptr @yslope, i64 0, i64 %77
  store i32 %75, ptr %78, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %62
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %3, align 4, !tbaa !5
  br label %58, !llvm.loop !15

82:                                               ; preds = %58
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %103, %82
  %84 = load i32, ptr %3, align 4, !tbaa !5
  %85 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %87, label %106

87:                                               ; preds = %83
  %88 = load ptr, ptr @finecosine, align 8, !tbaa !9
  %89 = load i32, ptr %3, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [321 x i32], ptr @xtoviewangle, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = lshr i32 %92, 19
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds i32, ptr %88, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = call i32 @llvm.abs.i32(i32 %96, i1 true)
  store i32 %97, ptr %1, align 4, !tbaa !5
  %98 = load i32, ptr %1, align 4, !tbaa !5
  %99 = call i32 @FixedDiv(i32 noundef 65536, i32 noundef %98)
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [320 x i32], ptr @distscale, i64 0, i64 %101
  store i32 %99, ptr %102, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %87
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %3, align 4, !tbaa !5
  br label %83, !llvm.loop !16

106:                                              ; preds = %83
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %150, %106
  %108 = load i32, ptr %3, align 4, !tbaa !5
  %109 = icmp slt i32 %108, 16
  br i1 %109, label %110, label %153

110:                                              ; preds = %107
  %111 = load i32, ptr %3, align 4, !tbaa !5
  %112 = sub nsw i32 15, %111
  %113 = mul nsw i32 %112, 2
  %114 = mul nsw i32 %113, 32
  %115 = sdiv i32 %114, 16
  store i32 %115, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %146, %110
  %117 = load i32, ptr %4, align 4, !tbaa !5
  %118 = icmp slt i32 %117, 48
  br i1 %118, label %119, label %149

119:                                              ; preds = %116
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = load i32, ptr %4, align 4, !tbaa !5
  %122 = mul nsw i32 %121, 320
  %123 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %124 = sdiv i32 %122, %123
  %125 = sdiv i32 %124, 2
  %126 = sub nsw i32 %120, %125
  store i32 %126, ptr %5, align 4, !tbaa !5
  %127 = load i32, ptr %5, align 4, !tbaa !5
  %128 = icmp slt i32 %127, 0
  br i1 %128, label %129, label %130

129:                                              ; preds = %119
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %130

130:                                              ; preds = %129, %119
  %131 = load i32, ptr %5, align 4, !tbaa !5
  %132 = icmp sge i32 %131, 32
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  store i32 31, ptr %5, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %133, %130
  %135 = load ptr, ptr @colormaps, align 8, !tbaa !9
  %136 = load i32, ptr %5, align 4, !tbaa !5
  %137 = mul nsw i32 %136, 256
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds i8, ptr %135, i64 %138
  %140 = load i32, ptr %3, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [16 x [48 x ptr]], ptr @scalelight, i64 0, i64 %141
  %143 = load i32, ptr %4, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [48 x ptr], ptr %142, i64 0, i64 %144
  store ptr %139, ptr %145, align 8, !tbaa !9
  br label %146

146:                                              ; preds = %134
  %147 = load i32, ptr %4, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %4, align 4, !tbaa !5
  br label %116, !llvm.loop !17

149:                                              ; preds = %116
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %3, align 4, !tbaa !5
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %3, align 4, !tbaa !5
  br label %107, !llvm.loop !18

153:                                              ; preds = %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

declare void @R_DrawColumn() #2

declare void @R_InitBuffer(i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}


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

@finecosine = external dso_local local_unnamed_addr global ptr, align 8
@projection = external dso_local local_unnamed_addr global i32, align 4
@centerxfrac = external dso_local local_unnamed_addr global i32, align 4
@viewwidth = external local_unnamed_addr global i32, align 4
@xtoviewangle = external dso_local local_unnamed_addr global [321 x i32], align 16
@centerx = external dso_local local_unnamed_addr global i32, align 4
@colormaps = external local_unnamed_addr global ptr, align 8
@setsizeneeded = external dso_local local_unnamed_addr global i32, align 4
@setblocks = external dso_local local_unnamed_addr global i32, align 4
@scaledviewwidth = external local_unnamed_addr global i32, align 4
@viewheight = external local_unnamed_addr global i32, align 4
@centery = external dso_local local_unnamed_addr global i32, align 4
@centeryfrac = external dso_local local_unnamed_addr global i32, align 4
@colfunc = external dso_local local_unnamed_addr global ptr, align 8
@pspritescale = external local_unnamed_addr global i32, align 4
@pspriteiscale = external local_unnamed_addr global i32, align 4
@screenheightarray = external local_unnamed_addr global [320 x i16], align 16
@yslope = external local_unnamed_addr global [200 x i32], align 16
@distscale = external local_unnamed_addr global [320 x i32], align 16
@scalelight = external dso_local local_unnamed_addr global [16 x [48 x ptr]], align 16

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #0

declare i32 @FixedDiv(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @R_InitTextureMapping() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @R_ExecuteSetViewSize() local_unnamed_addr #2 {
  store i32 0, ptr @setsizeneeded, align 4, !tbaa !5
  %1 = load i32, ptr @setblocks, align 4, !tbaa !5
  switch i32 %1, label %4 [
    i32 11, label %2
    i32 10, label %3
  ]

2:                                                ; preds = %0
  store i32 320, ptr @scaledviewwidth, align 4, !tbaa !5
  br label %9

3:                                                ; preds = %0
  store i32 320, ptr @scaledviewwidth, align 4, !tbaa !5
  br label %9

4:                                                ; preds = %0
  %5 = shl nsw i32 %1, 5
  %6 = mul nsw i32 %1, 168
  %7 = sdiv i32 %6, 10
  store i32 %5, ptr @scaledviewwidth, align 4, !tbaa !5
  %8 = and i32 %7, -8
  br label %9

9:                                                ; preds = %3, %4, %2
  %.sink = phi i32 [ 168, %3 ], [ %8, %4 ], [ 200, %2 ]
  %10 = phi i32 [ 320, %3 ], [ %5, %4 ], [ 320, %2 ]
  store i32 %.sink, ptr @viewheight, align 4, !tbaa !5
  store i32 %10, ptr @viewwidth, align 4, !tbaa !5
  %11 = ashr exact i32 %.sink, 1
  store i32 %11, ptr @centery, align 4, !tbaa !5
  %12 = ashr exact i32 %10, 1
  store i32 %12, ptr @centerx, align 4, !tbaa !5
  %13 = shl i32 %10, 15
  store i32 %13, ptr @centerxfrac, align 4, !tbaa !5
  %14 = shl i32 %.sink, 15
  store i32 %14, ptr @centeryfrac, align 4, !tbaa !5
  store i32 %13, ptr @projection, align 4, !tbaa !5
  store ptr @R_DrawColumn, ptr @colfunc, align 8, !tbaa !9
  tail call void @R_InitBuffer(i32 noundef %10, i32 noundef %.sink) #4
  tail call void @R_InitTextureMapping()
  %15 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %16 = shl nsw i32 %15, 16
  %17 = sdiv i32 %16, 320
  store i32 %17, ptr @pspritescale, align 4, !tbaa !5
  %18 = sdiv i32 20971520, %15
  store i32 %18, ptr @pspriteiscale, align 4, !tbaa !5
  %19 = icmp sgt i32 %15, 0
  %.pre = load i32, ptr @viewheight, align 4, !tbaa !5
  br i1 %19, label %.lr.ph, label %.preheader33

.lr.ph:                                           ; preds = %9
  %20 = trunc i32 %.pre to i16
  %wide.trip.count = zext nneg i32 %15 to i64
  %min.iters.check = icmp ult i32 %15, 16
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %wide.trip.count, 2147483632
  %broadcast.splatinsert = insertelement <8 x i16> poison, i16 %20, i64 0
  %broadcast.splat = shufflevector <8 x i16> %broadcast.splatinsert, <8 x i16> poison, <8 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %21 = getelementptr inbounds [320 x i16], ptr @screenheightarray, i64 0, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <8 x i16> %broadcast.splat, ptr %21, align 16, !tbaa !11
  store <8 x i16> %broadcast.splat, ptr %22, align 16, !tbaa !11
  %index.next = add nuw i64 %index, 16
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader33, label %scalar.ph.preheader

.preheader33:                                     ; preds = %scalar.ph, %middle.block, %9
  %24 = icmp sgt i32 %.pre, 0
  br i1 %24, label %.lr.ph36, label %.preheader32

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %25 = getelementptr inbounds [320 x i16], ptr @screenheightarray, i64 0, i64 %indvars.iv
  store i16 %20, ptr %25, align 2, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader33, label %scalar.ph, !llvm.loop !17

.preheader32.loopexit:                            ; preds = %.lr.ph36
  %.pre57 = load i32, ptr @viewwidth, align 4, !tbaa !5
  br label %.preheader32

.preheader32:                                     ; preds = %.preheader32.loopexit, %.preheader33
  %26 = phi i32 [ %.pre57, %.preheader32.loopexit ], [ %15, %.preheader33 ]
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph38, label %.preheader

.lr.ph36:                                         ; preds = %.preheader33, %.lr.ph36
  %indvars.iv43 = phi i64 [ %indvars.iv.next44, %.lr.ph36 ], [ 0, %.preheader33 ]
  %28 = phi i32 [ %39, %.lr.ph36 ], [ %.pre, %.preheader33 ]
  %.neg30 = sdiv i32 %28, -2
  %29 = trunc nuw nsw i64 %indvars.iv43 to i32
  %30 = add i32 %.neg30, %29
  %31 = shl i32 %30, 16
  %32 = or disjoint i32 %31, 32768
  %33 = tail call i32 @llvm.abs.i32(i32 %32, i1 true)
  %34 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %35 = sdiv i32 %34, 2
  %36 = shl nsw i32 %35, 16
  %37 = tail call i32 @FixedDiv(i32 noundef %36, i32 noundef %33) #4
  %38 = getelementptr inbounds [200 x i32], ptr @yslope, i64 0, i64 %indvars.iv43
  store i32 %37, ptr %38, align 4, !tbaa !5
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %39 = load i32, ptr @viewheight, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next44, %40
  br i1 %41, label %.lr.ph36, label %.preheader32.loopexit, !llvm.loop !18

.preheader:                                       ; preds = %.lr.ph38, %.preheader32
  %.lcssa = phi i32 [ %26, %.preheader32 ], [ %53, %.lr.ph38 ]
  %42 = load ptr, ptr @colormaps, align 8, !tbaa !9
  br label %56

.lr.ph38:                                         ; preds = %.preheader32, %.lr.ph38
  %indvars.iv46 = phi i64 [ %indvars.iv.next47, %.lr.ph38 ], [ 0, %.preheader32 ]
  %43 = load ptr, ptr @finecosine, align 8, !tbaa !9
  %44 = getelementptr inbounds [321 x i32], ptr @xtoviewangle, i64 0, i64 %indvars.iv46
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = lshr i32 %45, 19
  %47 = zext nneg i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %43, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = tail call i32 @llvm.abs.i32(i32 %49, i1 true)
  %51 = tail call i32 @FixedDiv(i32 noundef 65536, i32 noundef %50) #4
  %52 = getelementptr inbounds [320 x i32], ptr @distscale, i64 0, i64 %indvars.iv46
  store i32 %51, ptr %52, align 4, !tbaa !5
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %53 = load i32, ptr @viewwidth, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = icmp slt i64 %indvars.iv.next47, %54
  br i1 %55, label %.lr.ph38, label %.preheader, !llvm.loop !19

56:                                               ; preds = %.preheader, %69
  %indvars.iv53 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next54, %69 ]
  %indvars.iv53.tr = trunc i64 %indvars.iv53 to i32
  %57 = shl i32 %indvars.iv53.tr, 6
  %58 = sub i32 960, %57
  %59 = lshr exact i32 %58, 4
  br label %60

60:                                               ; preds = %56, %60
  %indvars.iv49 = phi i64 [ 0, %56 ], [ %indvars.iv.next50, %60 ]
  %61 = trunc i64 %indvars.iv49 to i32
  %62 = mul i32 %61, 320
  %63 = sdiv i32 %62, %.lcssa
  %.neg.lhs.trunc = trunc i32 %63 to i16
  %.neg31 = sdiv i16 %.neg.lhs.trunc, -2
  %.neg.sext = sext i16 %.neg31 to i32
  %64 = add nsw i32 %59, %.neg.sext
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %64, i32 0)
  %spec.store.select1 = tail call i32 @llvm.umin.i32(i32 %spec.store.select, i32 31)
  %65 = shl nuw nsw i32 %spec.store.select1, 8
  %66 = zext nneg i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %42, i64 %66
  %68 = getelementptr inbounds [16 x [48 x ptr]], ptr @scalelight, i64 0, i64 %indvars.iv53, i64 %indvars.iv49
  store ptr %67, ptr %68, align 8, !tbaa !9
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond52.not = icmp eq i64 %indvars.iv.next50, 48
  br i1 %exitcond52.not, label %69, label %60, !llvm.loop !20

69:                                               ; preds = %60
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, 16
  br i1 %exitcond56.not, label %70, label %56, !llvm.loop !21

70:                                               ; preds = %69
  ret void
}

declare void @R_DrawColumn() #1

declare void @R_InitBuffer(i32 noundef, i32 noundef) local_unnamed_addr #1

; 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.umin.i32(i32, i32) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 = { 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14, !15, !16}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !14, !16, !15}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass