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

; 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.texture_t = type { [8 x i8], i16, i16, i16, [1 x %struct.texpatch_t] }
%struct.texpatch_t = type { i32, i32, i32 }
%struct.patch_t = type { i16, i16, i16, i16, [8 x i32] }

@textures = external dso_local global ptr, align 8
@texturecompositesize = external dso_local global ptr, align 8
@texturecomposite = external dso_local global ptr, align 8
@texturecolumnlump = external dso_local global ptr, align 8
@texturecolumnofs = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [37 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

declare ptr @W_CacheLumpNum(i32 noundef, i32 noundef) #1

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
define dso_local void @R_GenerateLookup(i32 noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %14 = load ptr, ptr @textures, align 8, !tbaa !9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds ptr, ptr %14, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %3, align 8, !tbaa !9
  %19 = load ptr, ptr @texturecomposite, align 8, !tbaa !9
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds ptr, ptr %19, i64 %21
  store ptr null, ptr %22, align 8, !tbaa !9
  %23 = load ptr, ptr @texturecompositesize, align 8, !tbaa !9
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr %23, i64 %25
  store i32 0, ptr %26, align 4, !tbaa !5
  %27 = load ptr, ptr @texturecolumnlump, align 8, !tbaa !9
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds ptr, ptr %27, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  store ptr %31, ptr %11, align 8, !tbaa !9
  %32 = load ptr, ptr @texturecolumnofs, align 8, !tbaa !9
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  store ptr %36, ptr %12, align 8, !tbaa !9
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.texture_t, ptr %37, i32 0, i32 1
  %39 = load i16, ptr %38, align 4, !tbaa !11
  %40 = sext i16 %39 to i64
  %41 = call noalias ptr @malloc(i64 noundef %40) #8
  store ptr %41, ptr %4, align 8, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !9
  %43 = load ptr, ptr %3, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.texture_t, ptr %43, i32 0, i32 1
  %45 = load i16, ptr %44, align 4, !tbaa !11
  %46 = sext i16 %45 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %42, i8 0, i64 %46, i1 false)
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.texture_t, ptr %47, i32 0, i32 4
  %49 = getelementptr inbounds [1 x %struct.texpatch_t], ptr %48, i64 0, i64 0
  store ptr %49, ptr %5, align 8, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !5
  %50 = load ptr, ptr %3, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.texture_t, ptr %50, i32 0, i32 4
  %52 = getelementptr inbounds [1 x %struct.texpatch_t], ptr %51, i64 0, i64 0
  store ptr %52, ptr %5, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %129, %1
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !9
  %56 = getelementptr inbounds %struct.texture_t, ptr %55, i32 0, i32 3
  %57 = load i16, ptr %56, align 4, !tbaa !14
  %58 = sext i16 %57 to i32
  %59 = icmp slt i32 %54, %58
  br i1 %59, label %60, label %134

60:                                               ; preds = %53
  %61 = load ptr, ptr %5, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.texpatch_t, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !15
  %64 = call ptr @W_CacheLumpNum(i32 noundef %63, i32 noundef 101)
  store ptr %64, ptr %6, align 8, !tbaa !9
  %65 = load ptr, ptr %5, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.texpatch_t, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 4, !tbaa !17
  store i32 %67, ptr %8, align 4, !tbaa !5
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.patch_t, ptr %69, i32 0, i32 0
  %71 = load i16, ptr %70, align 4, !tbaa !18
  %72 = sext i16 %71 to i32
  %73 = add nsw i32 %68, %72
  store i32 %73, ptr %9, align 4, !tbaa !5
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = icmp slt i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %60
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %79

77:                                               ; preds = %60
  %78 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %78, ptr %7, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %77, %76
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = load ptr, ptr %3, align 8, !tbaa !9
  %82 = getelementptr inbounds %struct.texture_t, ptr %81, i32 0, i32 1
  %83 = load i16, ptr %82, align 4, !tbaa !11
  %84 = sext i16 %83 to i32
  %85 = icmp sgt i32 %80, %84
  br i1 %85, label %86, label %91

86:                                               ; preds = %79
  %87 = load ptr, ptr %3, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.texture_t, ptr %87, i32 0, i32 1
  %89 = load i16, ptr %88, align 4, !tbaa !11
  %90 = sext i16 %89 to i32
  store i32 %90, ptr %9, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %86, %79
  br label %92

92:                                               ; preds = %125, %91
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = icmp slt i32 %93, %94
  br i1 %95, label %96, label %128

96:                                               ; preds = %92
  %97 = load ptr, ptr %4, align 8, !tbaa !9
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i8, ptr %97, i64 %99
  %101 = load i8, ptr %100, align 1, !tbaa !20
  %102 = add i8 %101, 1
  store i8 %102, ptr %100, align 1, !tbaa !20
  %103 = load ptr, ptr %5, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.texpatch_t, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 4, !tbaa !15
  %106 = trunc i32 %105 to i16
  %107 = load ptr, ptr %11, align 8, !tbaa !9
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i16, ptr %107, i64 %109
  store i16 %106, ptr %110, align 2, !tbaa !21
  %111 = load ptr, ptr %6, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.patch_t, ptr %111, i32 0, i32 4
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = load i32, ptr %8, align 4, !tbaa !5
  %115 = sub nsw i32 %113, %114
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [8 x i32], ptr %112, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = add nsw i32 %118, 3
  %120 = trunc i32 %119 to i16
  %121 = load ptr, ptr %12, align 8, !tbaa !9
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds i16, ptr %121, i64 %123
  store i16 %120, ptr %124, align 2, !tbaa !21
  br label %125

125:                                              ; preds = %96
  %126 = load i32, ptr %7, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %7, align 4, !tbaa !5
  br label %92, !llvm.loop !22

128:                                              ; preds = %92
  br label %129

129:                                              ; preds = %128
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %10, align 4, !tbaa !5
  %132 = load ptr, ptr %5, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.texpatch_t, ptr %132, i32 1
  store ptr %133, ptr %5, align 8, !tbaa !9
  br label %53, !llvm.loop !24

134:                                              ; preds = %53
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %203, %134
  %136 = load i32, ptr %7, align 4, !tbaa !5
  %137 = load ptr, ptr %3, align 8, !tbaa !9
  %138 = getelementptr inbounds %struct.texture_t, ptr %137, i32 0, i32 1
  %139 = load i16, ptr %138, align 4, !tbaa !11
  %140 = sext i16 %139 to i32
  %141 = icmp slt i32 %136, %140
  br i1 %141, label %142, label %206

142:                                              ; preds = %135
  %143 = load ptr, ptr %4, align 8, !tbaa !9
  %144 = load i32, ptr %7, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds i8, ptr %143, i64 %145
  %147 = load i8, ptr %146, align 1, !tbaa !20
  %148 = icmp ne i8 %147, 0
  br i1 %148, label %155, label %149

149:                                              ; preds = %142
  %150 = load ptr, ptr %3, align 8, !tbaa !9
  %151 = getelementptr inbounds %struct.texture_t, ptr %150, i32 0, i32 0
  %152 = getelementptr inbounds [8 x i8], ptr %151, i64 0, i64 0
  %153 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %152)
  %154 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %154) #7
  store i32 1, ptr %13, align 4
  br label %208

155:                                              ; preds = %142
  %156 = load ptr, ptr %4, align 8, !tbaa !9
  %157 = load i32, ptr %7, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds i8, ptr %156, i64 %158
  %160 = load i8, ptr %159, align 1, !tbaa !20
  %161 = zext i8 %160 to i32
  %162 = icmp sgt i32 %161, 1
  br i1 %162, label %163, label %202

163:                                              ; preds = %155
  %164 = load ptr, ptr %11, align 8, !tbaa !9
  %165 = load i32, ptr %7, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i16, ptr %164, i64 %166
  store i16 -1, ptr %167, align 2, !tbaa !21
  %168 = load ptr, ptr @texturecompositesize, align 8, !tbaa !9
  %169 = load i32, ptr %2, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds i32, ptr %168, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = trunc i32 %172 to i16
  %174 = load ptr, ptr %12, align 8, !tbaa !9
  %175 = load i32, ptr %7, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds i16, ptr %174, i64 %176
  store i16 %173, ptr %177, align 2, !tbaa !21
  %178 = load ptr, ptr @texturecompositesize, align 8, !tbaa !9
  %179 = load i32, ptr %2, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds i32, ptr %178, i64 %180
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = load ptr, ptr %3, align 8, !tbaa !9
  %184 = getelementptr inbounds %struct.texture_t, ptr %183, i32 0, i32 2
  %185 = load i16, ptr %184, align 2, !tbaa !25
  %186 = sext i16 %185 to i32
  %187 = sub nsw i32 65536, %186
  %188 = icmp sgt i32 %182, %187
  br i1 %188, label %189, label %191

189:                                              ; preds = %163
  %190 = load i32, ptr %2, align 4, !tbaa !5
  call void (ptr, ...) @I_Error(ptr noundef @.str.2, i32 noundef %190) #9
  unreachable

191:                                              ; preds = %163
  %192 = load ptr, ptr %3, align 8, !tbaa !9
  %193 = getelementptr inbounds %struct.texture_t, ptr %192, i32 0, i32 2
  %194 = load i16, ptr %193, align 2, !tbaa !25
  %195 = sext i16 %194 to i32
  %196 = load ptr, ptr @texturecompositesize, align 8, !tbaa !9
  %197 = load i32, ptr %2, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds i32, ptr %196, i64 %198
  %200 = load i32, ptr %199, align 4, !tbaa !5
  %201 = add nsw i32 %200, %195
  store i32 %201, ptr %199, align 4, !tbaa !5
  br label %202

202:                                              ; preds = %191, %155
  br label %203

203:                                              ; preds = %202
  %204 = load i32, ptr %7, align 4, !tbaa !5
  %205 = add nsw i32 %204, 1
  store i32 %205, ptr %7, align 4, !tbaa !5
  br label %135, !llvm.loop !26

206:                                              ; preds = %135
  %207 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %207) #7
  store i32 0, ptr %13, align 4
  br label %208

208:                                              ; preds = %206, %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  %209 = load i32, ptr %13, align 4
  switch i32 %209, label %211 [
    i32 0, label %210
    i32 1, label %210
  ]

210:                                              ; preds = %208, %208
  ret void

211:                                              ; preds = %208
  unreachable
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { noreturn "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 allocsize(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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { noreturn }

!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, !13, i64 8}
!12 = !{!"", !7, i64 0, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 12}
!15 = !{!16, !6, i64 8}
!16 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8}
!17 = !{!16, !6, i64 0}
!18 = !{!19, !13, i64 0}
!19 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !7, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!13, !13, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!12, !13, i64 10}
!26 = distinct !{!26, !23}


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

@textures = external dso_local local_unnamed_addr global ptr, align 8
@texturecompositesize = external dso_local local_unnamed_addr global ptr, align 8
@texturecomposite = external dso_local local_unnamed_addr global ptr, align 8
@texturecolumnlump = external dso_local local_unnamed_addr global ptr, align 8
@texturecolumnofs = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [37 x i8], align 1

declare ptr @W_CacheLumpNum(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: noreturn
declare void @I_Error(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @R_GenerateLookup(i32 noundef %0) local_unnamed_addr #2 {
  %2 = load ptr, ptr @textures, align 8, !tbaa !5
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds ptr, ptr %2, i64 %3
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr @texturecomposite, align 8, !tbaa !5
  %7 = getelementptr inbounds ptr, ptr %6, i64 %3
  store ptr null, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr @texturecompositesize, align 8, !tbaa !5
  %9 = getelementptr inbounds i32, ptr %8, i64 %3
  store i32 0, ptr %9, align 4, !tbaa !9
  %10 = load ptr, ptr @texturecolumnlump, align 8, !tbaa !5
  %11 = getelementptr inbounds ptr, ptr %10, i64 %3
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr @texturecolumnofs, align 8, !tbaa !5
  %14 = getelementptr inbounds ptr, ptr %13, i64 %3
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %5, i64 8
  %17 = load i16, ptr %16, align 4, !tbaa !11
  %18 = sext i16 %17 to i64
  %calloc = tail call ptr @calloc(i64 1, i64 %18)
  %19 = getelementptr inbounds i8, ptr %5, i64 12
  %20 = load i16, ptr %19, align 4, !tbaa !14
  %21 = icmp sgt i16 %20, 0
  br i1 %21, label %.lr.ph68.preheader, label %.preheader

.lr.ph68.preheader:                               ; preds = %1
  %22 = ptrtoint ptr %15 to i64
  %23 = ptrtoint ptr %12 to i64
  %24 = getelementptr inbounds i8, ptr %5, i64 16
  %25 = sub i64 %22, %23
  %diff.check = icmp ult i64 %25, 8
  br label %.lr.ph68

.preheader.loopexit:                              ; preds = %._crit_edge
  %.pre = load i16, ptr %16, align 4, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %1
  %26 = phi i16 [ %.pre, %.preheader.loopexit ], [ %17, %1 ]
  %27 = icmp sgt i16 %26, 0
  br i1 %27, label %.lr.ph70, label %._crit_edge71

.lr.ph70:                                         ; preds = %.preheader
  %28 = load ptr, ptr @texturecompositesize, align 8
  %29 = getelementptr inbounds i32, ptr %28, i64 %3
  %30 = getelementptr inbounds i8, ptr %5, i64 10
  br label %94

.lr.ph68:                                         ; preds = %.lr.ph68.preheader, %._crit_edge
  %.066 = phi ptr [ %90, %._crit_edge ], [ %24, %.lr.ph68.preheader ]
  %.05665 = phi i32 [ %89, %._crit_edge ], [ 0, %.lr.ph68.preheader ]
  %31 = getelementptr inbounds i8, ptr %.066, i64 8
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = tail call ptr @W_CacheLumpNum(i32 noundef %32, i32 noundef 101) #7
  %34 = load i32, ptr %.066, align 4, !tbaa !17
  %35 = load i16, ptr %33, align 4, !tbaa !18
  %36 = sext i16 %35 to i32
  %37 = add nsw i32 %34, %36
  %. = tail call i32 @llvm.smax.i32(i32 %34, i32 0)
  %38 = load i16, ptr %16, align 4, !tbaa !11
  %39 = sext i16 %38 to i32
  %.057 = tail call i32 @llvm.smin.i32(i32 %37, i32 %39)
  %40 = icmp slt i32 %., %.057
  br i1 %40, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph68
  %41 = load i32, ptr %31, align 4, !tbaa !15
  %42 = trunc i32 %41 to i16
  %43 = getelementptr inbounds i8, ptr %33, i64 8
  %44 = zext nneg i32 %. to i64
  %45 = sext i32 %34 to i64
  %wide.trip.count = zext nneg i32 %.057 to i64
  %46 = sub nsw i64 %wide.trip.count, %44
  %min.iters.check = icmp ult i64 %46, 4
  %or.cond = select i1 %min.iters.check, i1 true, i1 %diff.check
  br i1 %or.cond, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %46, -4
  %ind.end = add nsw i64 %n.vec, %44
  %broadcast.splatinsert = insertelement <4 x i16> poison, i16 %42, i64 0
  %broadcast.splat = shufflevector <4 x i16> %broadcast.splatinsert, <4 x i16> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = add i64 %index, %44
  %47 = getelementptr inbounds i8, ptr %calloc, i64 %offset.idx
  %wide.load = load <4 x i8>, ptr %47, align 1, !tbaa !20
  %48 = add <4 x i8> %wide.load, <i8 1, i8 1, i8 1, i8 1>
  store <4 x i8> %48, ptr %47, align 1, !tbaa !20
  %49 = getelementptr inbounds i16, ptr %12, i64 %offset.idx
  store <4 x i16> %broadcast.splat, ptr %49, align 2, !tbaa !21
  %50 = sub nsw i64 %offset.idx, %45
  %51 = getelementptr inbounds [8 x i32], ptr %43, i64 0, i64 %50
  %wide.load77 = load <4 x i32>, ptr %51, align 4, !tbaa !9
  %52 = trunc <4 x i32> %wide.load77 to <4 x i16>
  %53 = add <4 x i16> %52, <i16 3, i16 3, i16 3, i16 3>
  %54 = getelementptr inbounds i16, ptr %15, i64 %offset.idx
  store <4 x i16> %53, ptr %54, align 2, !tbaa !21
  %index.next = add nuw i64 %index, 4
  %55 = icmp eq i64 %index.next, %n.vec
  br i1 %55, label %middle.block, label %vector.body, !llvm.loop !22

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %46, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ %44, %.lr.ph ], [ %ind.end, %middle.block ]
  %56 = sub nsw i64 %wide.trip.count, %indvars.iv.ph
  %xtraiter = and i64 %56, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %57 = getelementptr inbounds i8, ptr %calloc, i64 %indvars.iv.ph
  %58 = load i8, ptr %57, align 1, !tbaa !20
  %59 = add i8 %58, 1
  store i8 %59, ptr %57, align 1, !tbaa !20
  %60 = getelementptr inbounds i16, ptr %12, i64 %indvars.iv.ph
  store i16 %42, ptr %60, align 2, !tbaa !21
  %61 = sub nsw i64 %indvars.iv.ph, %45
  %62 = getelementptr inbounds [8 x i32], ptr %43, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !9
  %64 = trunc i32 %63 to i16
  %65 = add i16 %64, 3
  %66 = getelementptr inbounds i16, ptr %15, i64 %indvars.iv.ph
  store i16 %65, ptr %66, align 2, !tbaa !21
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %67 = add nsw i64 %wide.trip.count, -1
  %68 = icmp eq i64 %indvars.iv.ph, %67
  br i1 %68, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %69 = getelementptr inbounds i8, ptr %calloc, i64 %indvars.iv
  %70 = load i8, ptr %69, align 1, !tbaa !20
  %71 = add i8 %70, 1
  store i8 %71, ptr %69, align 1, !tbaa !20
  %72 = getelementptr inbounds i16, ptr %12, i64 %indvars.iv
  store i16 %42, ptr %72, align 2, !tbaa !21
  %73 = sub nsw i64 %indvars.iv, %45
  %74 = getelementptr inbounds [8 x i32], ptr %43, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !9
  %76 = trunc i32 %75 to i16
  %77 = add i16 %76, 3
  %78 = getelementptr inbounds i16, ptr %15, i64 %indvars.iv
  store i16 %77, ptr %78, align 2, !tbaa !21
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %79 = getelementptr inbounds i8, ptr %calloc, i64 %indvars.iv.next
  %80 = load i8, ptr %79, align 1, !tbaa !20
  %81 = add i8 %80, 1
  store i8 %81, ptr %79, align 1, !tbaa !20
  %82 = getelementptr inbounds i16, ptr %12, i64 %indvars.iv.next
  store i16 %42, ptr %82, align 2, !tbaa !21
  %83 = sub nsw i64 %indvars.iv.next, %45
  %84 = getelementptr inbounds [8 x i32], ptr %43, i64 0, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !9
  %86 = trunc i32 %85 to i16
  %87 = add i16 %86, 3
  %88 = getelementptr inbounds i16, ptr %15, i64 %indvars.iv.next
  store i16 %87, ptr %88, align 2, !tbaa !21
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge, label %scalar.ph, !llvm.loop !26

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %.lr.ph68
  %89 = add nuw nsw i32 %.05665, 1
  %90 = getelementptr inbounds i8, ptr %.066, i64 12
  %91 = load i16, ptr %19, align 4, !tbaa !14
  %92 = sext i16 %91 to i32
  %93 = icmp slt i32 %89, %92
  br i1 %93, label %.lr.ph68, label %.preheader.loopexit, !llvm.loop !27

94:                                               ; preds = %.lr.ph70, %112
  %95 = phi i16 [ %26, %.lr.ph70 ], [ %113, %112 ]
  %indvars.iv73 = phi i64 [ 0, %.lr.ph70 ], [ %indvars.iv.next74, %112 ]
  %96 = getelementptr inbounds i8, ptr %calloc, i64 %indvars.iv73
  %97 = load i8, ptr %96, align 1, !tbaa !20
  switch i8 %97, label %100 [
    i8 0, label %98
    i8 1, label %112
  ]

98:                                               ; preds = %94
  %99 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %5)
  tail call void @free(ptr noundef nonnull %calloc) #7
  br label %116

100:                                              ; preds = %94
  %101 = getelementptr inbounds i16, ptr %12, i64 %indvars.iv73
  store i16 -1, ptr %101, align 2, !tbaa !21
  %102 = load i32, ptr %29, align 4, !tbaa !9
  %103 = trunc i32 %102 to i16
  %104 = getelementptr inbounds i16, ptr %15, i64 %indvars.iv73
  store i16 %103, ptr %104, align 2, !tbaa !21
  %105 = load i16, ptr %30, align 2, !tbaa !28
  %106 = sext i16 %105 to i32
  %107 = sub nsw i32 65536, %106
  %108 = icmp sgt i32 %102, %107
  br i1 %108, label %109, label %110

109:                                              ; preds = %100
  tail call void (ptr, ...) @I_Error(ptr noundef nonnull @.str.2, i32 noundef %0) #8
  unreachable

110:                                              ; preds = %100
  %111 = add nsw i32 %102, %106
  store i32 %111, ptr %29, align 4, !tbaa !9
  %.pre76 = load i16, ptr %16, align 4, !tbaa !11
  br label %112

112:                                              ; preds = %94, %110
  %113 = phi i16 [ %95, %94 ], [ %.pre76, %110 ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %114 = sext i16 %113 to i64
  %115 = icmp slt i64 %indvars.iv.next74, %114
  br i1 %115, label %94, label %._crit_edge71, !llvm.loop !29

._crit_edge71:                                    ; preds = %112, %.preheader
  tail call void @free(ptr noundef %calloc) #7
  br label %116

116:                                              ; preds = %._crit_edge71, %98
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

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

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #6

attributes #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 = { noreturn "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 = { nofree nounwind "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #7 = { nounwind }
attributes #8 = { noreturn 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, !13, i64 8}
!12 = !{!"", !7, i64 0, !13, i64 8, !13, i64 10, !13, i64 12, !7, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 12}
!15 = !{!16, !10, i64 8}
!16 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!17 = !{!16, !10, i64 0}
!18 = !{!19, !13, i64 0}
!19 = !{!"", !13, i64 0, !13, i64 2, !13, i64 4, !13, i64 6, !7, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!13, !13, i64 0}
!22 = distinct !{!22, !23, !24, !25}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !23, !24}
!27 = distinct !{!27, !23}
!28 = !{!12, !13, i64 10}
!29 = distinct !{!29, !23}


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