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

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

@viewheight = external dso_local global i32, align 4
@viewwindowx = external dso_local global i32, align 4
@viewwindowy = external dso_local global i32, align 4
@screens = external global [5 x ptr], align 16
@__const.R_FillBackScreen.name1 = external hidden unnamed_addr constant [9 x i8], align 1
@__const.R_FillBackScreen.name2 = external hidden unnamed_addr constant [8 x i8], align 1
@scaledviewwidth = external dso_local global i32, align 4
@gamemode = external global i32, align 4
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1

; 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: nounwind uwtable
define dso_local void @R_FillBackScreen() #1 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [9 x i8], align 1
  %7 = alloca [8 x i8], align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 8, 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 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 9, ptr %6) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %6, ptr align 1 @__const.R_FillBackScreen.name1, i64 9, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %7, ptr align 1 @__const.R_FillBackScreen.name2, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %10 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 320
  br i1 %11, label %12, label %13

12:                                               ; preds = %0
  store i32 1, ptr %9, align 4
  br label %139

13:                                               ; preds = %0
  %14 = load i32, ptr @gamemode, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 2
  br i1 %15, label %16, label %18

16:                                               ; preds = %13
  %17 = getelementptr inbounds [8 x i8], ptr %7, i64 0, i64 0
  store ptr %17, ptr %8, align 8, !tbaa !9
  br label %20

18:                                               ; preds = %13
  %19 = getelementptr inbounds [9 x i8], ptr %6, i64 0, i64 0
  store ptr %19, ptr %8, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %18, %16
  %21 = load ptr, ptr %8, align 8, !tbaa !9
  %22 = call ptr @W_CacheLumpName(ptr noundef %21, i32 noundef 101)
  store ptr %22, ptr %1, align 8, !tbaa !9
  %23 = load ptr, ptr getelementptr inbounds ([5 x ptr], ptr @screens, i64 0, i64 1), align 8, !tbaa !9
  store ptr %23, ptr %2, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %45, %20
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp slt i32 %25, 168
  br i1 %26, label %27, label %48

27:                                               ; preds = %24
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %41, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 5
  br i1 %30, label %31, label %44

31:                                               ; preds = %28
  %32 = load ptr, ptr %2, align 8, !tbaa !9
  %33 = load ptr, ptr %1, align 8, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = and i32 %34, 63
  %36 = shl i32 %35, 6
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %33, i64 %37
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %32, ptr align 1 %38, i64 64, i1 false)
  %39 = load ptr, ptr %2, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %39, i64 64
  store ptr %40, ptr %2, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %31
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !11

44:                                               ; preds = %28
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !5
  br label %24, !llvm.loop !13

48:                                               ; preds = %24
  %49 = call ptr @W_CacheLumpName(ptr noundef @.str.3, i32 noundef 101)
  store ptr %49, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %61, %48
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %54, label %64

54:                                               ; preds = %50
  %55 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = add nsw i32 %55, %56
  %58 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %59 = sub nsw i32 %58, 8
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  call void @V_DrawPatch(i32 noundef %57, i32 noundef %59, i32 noundef 1, ptr noundef %60)
  br label %61

61:                                               ; preds = %54
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = add nsw i32 %62, 8
  store i32 %63, ptr %3, align 4, !tbaa !5
  br label %50, !llvm.loop !14

64:                                               ; preds = %50
  %65 = call ptr @W_CacheLumpName(ptr noundef @.str.4, i32 noundef 101)
  store ptr %65, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %78, %64
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %70, label %81

70:                                               ; preds = %66
  %71 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = add nsw i32 %71, %72
  %74 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %75 = load i32, ptr @viewheight, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  call void @V_DrawPatch(i32 noundef %73, i32 noundef %76, i32 noundef 1, ptr noundef %77)
  br label %78

78:                                               ; preds = %70
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = add nsw i32 %79, 8
  store i32 %80, ptr %3, align 4, !tbaa !5
  br label %66, !llvm.loop !15

81:                                               ; preds = %66
  %82 = call ptr @W_CacheLumpName(ptr noundef @.str.5, i32 noundef 101)
  store ptr %82, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %94, %81
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = load i32, ptr @viewheight, align 4, !tbaa !5
  %86 = icmp slt i32 %84, %85
  br i1 %86, label %87, label %97

87:                                               ; preds = %83
  %88 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %89 = sub nsw i32 %88, 8
  %90 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = add nsw i32 %90, %91
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  call void @V_DrawPatch(i32 noundef %89, i32 noundef %92, i32 noundef 1, ptr noundef %93)
  br label %94

94:                                               ; preds = %87
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = add nsw i32 %95, 8
  store i32 %96, ptr %4, align 4, !tbaa !5
  br label %83, !llvm.loop !16

97:                                               ; preds = %83
  %98 = call ptr @W_CacheLumpName(ptr noundef @.str.6, i32 noundef 101)
  store ptr %98, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %111, %97
  %100 = load i32, ptr %4, align 4, !tbaa !5
  %101 = load i32, ptr @viewheight, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %103, label %114

103:                                              ; preds = %99
  %104 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %105 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %106 = add nsw i32 %104, %105
  %107 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %108 = load i32, ptr %4, align 4, !tbaa !5
  %109 = add nsw i32 %107, %108
  %110 = load ptr, ptr %5, align 8, !tbaa !9
  call void @V_DrawPatch(i32 noundef %106, i32 noundef %109, i32 noundef 1, ptr noundef %110)
  br label %111

111:                                              ; preds = %103
  %112 = load i32, ptr %4, align 4, !tbaa !5
  %113 = add nsw i32 %112, 8
  store i32 %113, ptr %4, align 4, !tbaa !5
  br label %99, !llvm.loop !17

114:                                              ; preds = %99
  %115 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %116 = sub nsw i32 %115, 8
  %117 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 8
  %119 = call ptr @W_CacheLumpName(ptr noundef @.str.7, i32 noundef 101)
  call void @V_DrawPatch(i32 noundef %116, i32 noundef %118, i32 noundef 1, ptr noundef %119)
  %120 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %121 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %122 = add nsw i32 %120, %121
  %123 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %124 = sub nsw i32 %123, 8
  %125 = call ptr @W_CacheLumpName(ptr noundef @.str.8, i32 noundef 101)
  call void @V_DrawPatch(i32 noundef %122, i32 noundef %124, i32 noundef 1, ptr noundef %125)
  %126 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %127 = sub nsw i32 %126, 8
  %128 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %129 = load i32, ptr @viewheight, align 4, !tbaa !5
  %130 = add nsw i32 %128, %129
  %131 = call ptr @W_CacheLumpName(ptr noundef @.str.9, i32 noundef 101)
  call void @V_DrawPatch(i32 noundef %127, i32 noundef %130, i32 noundef 1, ptr noundef %131)
  %132 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %133 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %134 = add nsw i32 %132, %133
  %135 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %136 = load i32, ptr @viewheight, align 4, !tbaa !5
  %137 = add nsw i32 %135, %136
  %138 = call ptr @W_CacheLumpName(ptr noundef @.str.10, i32 noundef 101)
  call void @V_DrawPatch(i32 noundef %134, i32 noundef %137, i32 noundef 1, ptr noundef %138)
  store i32 0, ptr %9, align 4
  br label %139

139:                                              ; preds = %114, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, 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 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  %140 = load i32, ptr %9, align 4
  switch i32 %140, label %142 [
    i32 0, label %141
    i32 1, label %141
  ]

141:                                              ; preds = %139, %139
  ret void

142:                                              ; preds = %139
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

declare void @V_DrawPatch(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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

@viewheight = external dso_local local_unnamed_addr global i32, align 4
@viewwindowx = external dso_local local_unnamed_addr global i32, align 4
@viewwindowy = external dso_local local_unnamed_addr global i32, align 4
@screens = external local_unnamed_addr global [5 x ptr], align 16
@__const.R_FillBackScreen.name1 = external hidden unnamed_addr constant [9 x i8], align 1
@__const.R_FillBackScreen.name2 = external hidden unnamed_addr constant [8 x i8], align 1
@scaledviewwidth = external dso_local local_unnamed_addr global i32, align 4
@gamemode = external local_unnamed_addr global i32, align 4
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [8 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @R_FillBackScreen() local_unnamed_addr #1 {
  %1 = alloca [9 x i8], align 1
  %2 = alloca [8 x i8], align 8
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(9) %1, ptr noundef nonnull align 1 dereferenceable(9) @__const.R_FillBackScreen.name1, i64 9, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = load i64, ptr @__const.R_FillBackScreen.name2, align 1
  store i64 %3, ptr %2, align 8
  %4 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 320
  br i1 %5, label %88, label %6

6:                                                ; preds = %0
  %7 = load i32, ptr @gamemode, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 2
  %. = select i1 %8, ptr %2, ptr %1
  %9 = call ptr @W_CacheLumpName(ptr noundef nonnull %., i32 noundef 101) #4
  %10 = load ptr, ptr getelementptr inbounds (i8, ptr @screens, i64 8), align 8, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %6, %.preheader
  %.02433 = phi i32 [ 0, %6 ], [ %20, %.preheader ]
  %.02832 = phi ptr [ %10, %6 ], [ %19, %.preheader ]
  %11 = shl nuw nsw i32 %.02433, 6
  %12 = and i32 %11, 4032
  %13 = zext nneg i32 %12 to i64
  %14 = getelementptr inbounds i8, ptr %9, i64 %13
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %.02832, ptr noundef nonnull align 1 dereferenceable(64) %14, i64 64, i1 false)
  %15 = getelementptr inbounds i8, ptr %.02832, i64 64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %15, ptr noundef nonnull align 1 dereferenceable(64) %14, i64 64, i1 false)
  %16 = getelementptr inbounds i8, ptr %.02832, i64 128
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %16, ptr noundef nonnull align 1 dereferenceable(64) %14, i64 64, i1 false)
  %17 = getelementptr inbounds i8, ptr %.02832, i64 192
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %17, ptr noundef nonnull align 1 dereferenceable(64) %14, i64 64, i1 false)
  %18 = getelementptr inbounds i8, ptr %.02832, i64 256
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(64) %18, ptr noundef nonnull align 1 dereferenceable(64) %14, i64 64, i1 false)
  %19 = getelementptr inbounds i8, ptr %.02832, i64 320
  %20 = add nuw nsw i32 %.02433, 1
  %exitcond.not = icmp eq i32 %20, 168
  br i1 %exitcond.not, label %21, label %.preheader, !llvm.loop !11

21:                                               ; preds = %.preheader
  %22 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.3, i32 noundef 101) #4
  %23 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %21, %.lr.ph
  %.12634 = phi i32 [ %29, %.lr.ph ], [ 0, %21 ]
  %25 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %26 = add nsw i32 %25, %.12634
  %27 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %28 = add nsw i32 %27, -8
  call void @V_DrawPatch(i32 noundef %26, i32 noundef %28, i32 noundef 1, ptr noundef %22) #4
  %29 = add nuw nsw i32 %.12634, 8
  %30 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %21
  %32 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.4, i32 noundef 101) #4
  %33 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %.lr.ph37, label %._crit_edge38

.lr.ph37:                                         ; preds = %._crit_edge, %.lr.ph37
  %.22735 = phi i32 [ %40, %.lr.ph37 ], [ 0, %._crit_edge ]
  %35 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %36 = add nsw i32 %35, %.22735
  %37 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %38 = load i32, ptr @viewheight, align 4, !tbaa !5
  %39 = add nsw i32 %38, %37
  call void @V_DrawPatch(i32 noundef %36, i32 noundef %39, i32 noundef 1, ptr noundef %32) #4
  %40 = add nuw nsw i32 %.22735, 8
  %41 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %.lr.ph37, label %._crit_edge38, !llvm.loop !14

._crit_edge38:                                    ; preds = %.lr.ph37, %._crit_edge
  %43 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.5, i32 noundef 101) #4
  %44 = load i32, ptr @viewheight, align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 0
  br i1 %45, label %.lr.ph41, label %._crit_edge42

.lr.ph41:                                         ; preds = %._crit_edge38, %.lr.ph41
  %.139 = phi i32 [ %50, %.lr.ph41 ], [ 0, %._crit_edge38 ]
  %46 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %47 = add nsw i32 %46, -8
  %48 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %49 = add nsw i32 %48, %.139
  call void @V_DrawPatch(i32 noundef %47, i32 noundef %49, i32 noundef 1, ptr noundef %43) #4
  %50 = add nuw nsw i32 %.139, 8
  %51 = load i32, ptr @viewheight, align 4, !tbaa !5
  %52 = icmp slt i32 %50, %51
  br i1 %52, label %.lr.ph41, label %._crit_edge42, !llvm.loop !15

._crit_edge42:                                    ; preds = %.lr.ph41, %._crit_edge38
  %53 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.6, i32 noundef 101) #4
  %54 = load i32, ptr @viewheight, align 4, !tbaa !5
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %.lr.ph45, label %._crit_edge46

.lr.ph45:                                         ; preds = %._crit_edge42, %.lr.ph45
  %.243 = phi i32 [ %61, %.lr.ph45 ], [ 0, %._crit_edge42 ]
  %56 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %57 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %58 = add nsw i32 %57, %56
  %59 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %60 = add nsw i32 %59, %.243
  call void @V_DrawPatch(i32 noundef %58, i32 noundef %60, i32 noundef 1, ptr noundef %53) #4
  %61 = add nuw nsw i32 %.243, 8
  %62 = load i32, ptr @viewheight, align 4, !tbaa !5
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %.lr.ph45, label %._crit_edge46, !llvm.loop !16

._crit_edge46:                                    ; preds = %.lr.ph45, %._crit_edge42
  %64 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %65 = add nsw i32 %64, -8
  %66 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %67 = add nsw i32 %66, -8
  %68 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.7, i32 noundef 101) #4
  call void @V_DrawPatch(i32 noundef %65, i32 noundef %67, i32 noundef 1, ptr noundef %68) #4
  %69 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %70 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %71 = add nsw i32 %70, %69
  %72 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %73 = add nsw i32 %72, -8
  %74 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.8, i32 noundef 101) #4
  call void @V_DrawPatch(i32 noundef %71, i32 noundef %73, i32 noundef 1, ptr noundef %74) #4
  %75 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %76 = add nsw i32 %75, -8
  %77 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %78 = load i32, ptr @viewheight, align 4, !tbaa !5
  %79 = add nsw i32 %78, %77
  %80 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.9, i32 noundef 101) #4
  call void @V_DrawPatch(i32 noundef %76, i32 noundef %79, i32 noundef 1, ptr noundef %80) #4
  %81 = load i32, ptr @viewwindowx, align 4, !tbaa !5
  %82 = load i32, ptr @scaledviewwidth, align 4, !tbaa !5
  %83 = add nsw i32 %82, %81
  %84 = load i32, ptr @viewwindowy, align 4, !tbaa !5
  %85 = load i32, ptr @viewheight, align 4, !tbaa !5
  %86 = add nsw i32 %85, %84
  %87 = call ptr @W_CacheLumpName(ptr noundef nonnull @.str.10, i32 noundef 101) #4
  call void @V_DrawPatch(i32 noundef %83, i32 noundef %86, i32 noundef 1, ptr noundef %87) #4
  br label %88

88:                                               ; preds = %0, %._crit_edge46
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %1) #4
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare ptr @W_CacheLumpName(ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @V_DrawPatch(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass