; LLVM IR from aap/librw :: src/ps2/ps2raster.ll (ZN2rw3ps218writeNativeTextureEPNS_7TextureEPNS_6StreamE)

; 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.rw::ps2::StreamRasterExt" = type { i32, i32, i32, i16, i16, i64, i32, i32, i64, i64, i32, i32, i32, i32 }
%"struct.rw::Texture" = type { ptr, ptr, %"struct.rw::LLLink", [32 x i8], [32 x i8], i32, i32, %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::ps2::Ps2Raster" = type { i64, i32, i16, i8, i8, i64, i64, i32, i32, i32, i8, ptr, i32 }
%"struct.rw::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }
%"struct.rw::ps2::Ps2Raster::PixelPtr" = type { ptr, i32, i32 }

@_ZN2rw3ps218nativeRasterOffsetE = external dso_local global i32, align 4

; 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: mustprogress uwtable
define dso_local void @_ZN2rw3ps218writeNativeTextureEPNS_7TextureEPNS_6StreamE(ptr noundef %0, ptr noundef %1) #1 {
  %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 %"struct.rw::ps2::StreamRasterExt", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.rw::Texture", ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %12, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = load i32, ptr @_ZN2rw3ps218nativeRasterOffsetE, align 4, !tbaa !13
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %13, i64 %15
  store ptr %16, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %17, i32 noundef 1, i32 noundef 8)
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %19, i32 noundef 3298128)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.rw::Texture", ptr %22, i32 0, i32 5
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %21, i32 noundef %24)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.rw::Texture", ptr %26, i32 0, i32 3
  %28 = getelementptr inbounds [32 x i8], ptr %27, i64 0, i64 0
  %29 = call i64 @strlen(ptr noundef %28) #5
  %30 = add i64 %29, 4
  %31 = and i64 %30, -4
  %32 = trunc i64 %31 to i32
  store i32 %32, ptr %7, align 4, !tbaa !13
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !13
  %35 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %33, i32 noundef 2, i32 noundef %34)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.rw::Texture", ptr %37, i32 0, i32 3
  %39 = getelementptr inbounds [32 x i8], ptr %38, i64 0, i64 0
  %40 = load i32, ptr %7, align 4, !tbaa !13
  %41 = load ptr, ptr %36, align 8, !tbaa !15
  %42 = getelementptr inbounds ptr, ptr %41, i64 3
  %43 = load ptr, ptr %42, align 8
  %44 = call noundef i32 %43(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef %39, i32 noundef %40)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.rw::Texture", ptr %45, i32 0, i32 4
  %47 = getelementptr inbounds [32 x i8], ptr %46, i64 0, i64 0
  %48 = call i64 @strlen(ptr noundef %47) #5
  %49 = add i64 %48, 4
  %50 = and i64 %49, -4
  %51 = trunc i64 %50 to i32
  store i32 %51, ptr %7, align 4, !tbaa !13
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !13
  %54 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %52, i32 noundef 2, i32 noundef %53)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.rw::Texture", ptr %56, i32 0, i32 4
  %58 = getelementptr inbounds [32 x i8], ptr %57, i64 0, i64 0
  %59 = load i32, ptr %7, align 4, !tbaa !13
  %60 = load ptr, ptr %55, align 8, !tbaa !15
  %61 = getelementptr inbounds ptr, ptr %60, i64 3
  %62 = load ptr, ptr %61, align 8
  %63 = call noundef i32 %62(ptr noundef nonnull align 8 dereferenceable(8) %55, ptr noundef %58, i32 noundef %59)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %64, i32 0, i32 7
  %66 = load i32, ptr %65, align 8, !tbaa !17
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %67, i32 0, i32 8
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = add i32 %66, %69
  store i32 %70, ptr %8, align 4, !tbaa !13
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load i32, ptr %8, align 4, !tbaa !13
  %73 = add nsw i32 88, %72
  %74 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %71, i32 noundef 1, i32 noundef %73)
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %75, i32 noundef 1, i32 noundef 64)
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #4
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.rw::Raster", ptr %77, i32 0, i32 5
  %79 = load i32, ptr %78, align 4, !tbaa !22
  %80 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 0
  store i32 %79, ptr %80, align 8, !tbaa !24
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Raster", ptr %81, i32 0, i32 6
  %83 = load i32, ptr %82, align 8, !tbaa !26
  %84 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 1
  store i32 %83, ptr %84, align 4, !tbaa !27
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %"struct.rw::Raster", ptr %85, i32 0, i32 7
  %87 = load i32, ptr %86, align 4, !tbaa !28
  %88 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 2
  store i32 %87, ptr %88, align 8, !tbaa !29
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %"struct.rw::Raster", ptr %89, i32 0, i32 4
  %91 = load i32, ptr %90, align 8, !tbaa !30
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.rw::Raster", ptr %92, i32 0, i32 1
  %94 = load i32, ptr %93, align 4, !tbaa !31
  %95 = or i32 %91, %94
  %96 = trunc i32 %95 to i16
  %97 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 3
  store i16 %96, ptr %97, align 4, !tbaa !32
  %98 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 4
  store i16 0, ptr %98, align 2, !tbaa !33
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %99, i32 0, i32 10
  %101 = load i8, ptr %100, align 4, !tbaa !34
  %102 = sext i8 %101 to i32
  %103 = icmp eq i32 %102, 2
  br i1 %103, label %104, label %111

104:                                              ; preds = %2
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %"struct.rw::Raster", ptr %105, i32 0, i32 7
  %107 = load i32, ptr %106, align 4, !tbaa !28
  %108 = icmp eq i32 %107, 8
  br i1 %108, label %109, label %111

109:                                              ; preds = %104
  %110 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 4
  store i16 1, ptr %110, align 2, !tbaa !33
  br label %111

111:                                              ; preds = %109, %104, %2
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %112, i32 0, i32 10
  %114 = load i8, ptr %113, align 4, !tbaa !34
  %115 = sext i8 %114 to i32
  %116 = and i32 %115, 1
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %120

118:                                              ; preds = %111
  %119 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 4
  store i16 2, ptr %119, align 2, !tbaa !33
  br label %120

120:                                              ; preds = %118, %111
  %121 = load ptr, ptr %6, align 8, !tbaa !5
  %122 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %121, i32 0, i32 0
  %123 = load i64, ptr %122, align 8, !tbaa !35
  %124 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 5
  store i64 %123, ptr %124, align 8, !tbaa !36
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %125, i32 0, i32 1
  %127 = load i32, ptr %126, align 8, !tbaa !37
  %128 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 6
  store i32 %127, ptr %128, align 8, !tbaa !38
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %129, i32 0, i32 3
  %131 = load i8, ptr %130, align 2, !tbaa !39
  %132 = zext i8 %131 to i32
  %133 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 7
  store i32 %132, ptr %133, align 4, !tbaa !40
  %134 = load ptr, ptr %6, align 8, !tbaa !5
  %135 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %134, i32 0, i32 5
  %136 = load i64, ptr %135, align 8, !tbaa !41
  %137 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 8
  store i64 %136, ptr %137, align 8, !tbaa !42
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %138, i32 0, i32 6
  %140 = load i64, ptr %139, align 8, !tbaa !43
  %141 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 9
  store i64 %140, ptr %141, align 8, !tbaa !44
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %142, i32 0, i32 7
  %144 = load i32, ptr %143, align 8, !tbaa !17
  %145 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 10
  store i32 %144, ptr %145, align 8, !tbaa !45
  %146 = load ptr, ptr %6, align 8, !tbaa !5
  %147 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %146, i32 0, i32 8
  %148 = load i32, ptr %147, align 4, !tbaa !21
  %149 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 11
  store i32 %148, ptr %149, align 4, !tbaa !46
  %150 = load ptr, ptr %6, align 8, !tbaa !5
  %151 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %150, i32 0, i32 9
  %152 = load i32, ptr %151, align 8, !tbaa !47
  %153 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 12
  store i32 %152, ptr %153, align 8, !tbaa !48
  %154 = load ptr, ptr %6, align 8, !tbaa !5
  %155 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %154, i32 0, i32 2
  %156 = load i16, ptr %155, align 4, !tbaa !49
  %157 = zext i16 %156 to i32
  %158 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 13
  store i32 %157, ptr %158, align 4, !tbaa !50
  %159 = load ptr, ptr %4, align 8, !tbaa !5
  %160 = load ptr, ptr %159, align 8, !tbaa !15
  %161 = getelementptr inbounds ptr, ptr %160, i64 3
  %162 = load ptr, ptr %161, align 8
  %163 = call noundef i32 %162(ptr noundef nonnull align 8 dereferenceable(8) %159, ptr noundef %9, i32 noundef 64)
  %164 = load ptr, ptr %4, align 8, !tbaa !5
  %165 = load i32, ptr %8, align 4, !tbaa !13
  %166 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %164, i32 noundef 1, i32 noundef %165)
  %167 = getelementptr inbounds %"struct.rw::ps2::StreamRasterExt", ptr %9, i32 0, i32 4
  %168 = load i16, ptr %167, align 2, !tbaa !33
  %169 = sext i16 %168 to i32
  %170 = icmp slt i32 %169, 2
  br i1 %170, label %171, label %181

171:                                              ; preds = %120
  %172 = load ptr, ptr %4, align 8, !tbaa !5
  %173 = load ptr, ptr %5, align 8, !tbaa !5
  %174 = getelementptr inbounds %"struct.rw::Raster", ptr %173, i32 0, i32 9
  %175 = load ptr, ptr %174, align 8, !tbaa !51
  %176 = load i32, ptr %8, align 4, !tbaa !13
  %177 = load ptr, ptr %172, align 8, !tbaa !15
  %178 = getelementptr inbounds ptr, ptr %177, i64 3
  %179 = load ptr, ptr %178, align 8
  %180 = call noundef i32 %179(ptr noundef nonnull align 8 dereferenceable(8) %172, ptr noundef %175, i32 noundef %176)
  br label %207

181:                                              ; preds = %120
  %182 = load ptr, ptr %4, align 8, !tbaa !5
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = getelementptr inbounds %"struct.rw::Raster", ptr %183, i32 0, i32 11
  %185 = load ptr, ptr %184, align 8, !tbaa !52
  %186 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster::PixelPtr", ptr %185, i32 0, i32 0
  %187 = load ptr, ptr %186, align 8, !tbaa !53
  %188 = load ptr, ptr %6, align 8, !tbaa !5
  %189 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %188, i32 0, i32 7
  %190 = load i32, ptr %189, align 8, !tbaa !17
  %191 = load ptr, ptr %182, align 8, !tbaa !15
  %192 = getelementptr inbounds ptr, ptr %191, i64 3
  %193 = load ptr, ptr %192, align 8
  %194 = call noundef i32 %193(ptr noundef nonnull align 8 dereferenceable(8) %182, ptr noundef %187, i32 noundef %190)
  %195 = load ptr, ptr %4, align 8, !tbaa !5
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  %197 = getelementptr inbounds %"struct.rw::Raster", ptr %196, i32 0, i32 10
  %198 = load ptr, ptr %197, align 8, !tbaa !55
  %199 = getelementptr inbounds i8, ptr %198, i64 -80
  %200 = load ptr, ptr %6, align 8, !tbaa !5
  %201 = getelementptr inbounds %"struct.rw::ps2::Ps2Raster", ptr %200, i32 0, i32 8
  %202 = load i32, ptr %201, align 4, !tbaa !21
  %203 = load ptr, ptr %195, align 8, !tbaa !15
  %204 = getelementptr inbounds ptr, ptr %203, i64 3
  %205 = load ptr, ptr %204, align 8
  %206 = call noundef i32 %205(ptr noundef nonnull align 8 dereferenceable(8) %195, ptr noundef %199, i32 noundef %202)
  br label %207

207:                                              ; preds = %181, %171
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) #2

declare noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN2rw7TextureE", !6, i64 0, !6, i64 8, !11, i64 16, !7, i64 32, !7, i64 64, !12, i64 96, !12, i64 100, !11, i64 104}
!11 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 96}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !12, i64 32}
!18 = !{!"_ZTSN2rw3ps29Ps2RasterE", !19, i64 0, !12, i64 8, !20, i64 12, !7, i64 14, !7, i64 15, !19, i64 16, !19, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !7, i64 44, !6, i64 48, !12, i64 56}
!19 = !{!"long", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!18, !12, i64 36}
!22 = !{!23, !12, i64 20}
!23 = !{!"_ZTSN2rw6RasterE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !12, i64 64, !12, i64 68, !12, i64 72, !6, i64 80, !12, i64 88, !12, i64 92}
!24 = !{!25, !12, i64 0}
!25 = !{!"_ZTSN2rw3ps215StreamRasterExtE", !12, i64 0, !12, i64 4, !12, i64 8, !20, i64 12, !20, i64 14, !19, i64 16, !12, i64 24, !12, i64 28, !19, i64 32, !19, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60}
!26 = !{!23, !12, i64 24}
!27 = !{!25, !12, i64 4}
!28 = !{!23, !12, i64 28}
!29 = !{!25, !12, i64 8}
!30 = !{!23, !12, i64 16}
!31 = !{!23, !12, i64 4}
!32 = !{!25, !20, i64 12}
!33 = !{!25, !20, i64 14}
!34 = !{!18, !7, i64 44}
!35 = !{!18, !19, i64 0}
!36 = !{!25, !19, i64 16}
!37 = !{!18, !12, i64 8}
!38 = !{!25, !12, i64 24}
!39 = !{!18, !7, i64 14}
!40 = !{!25, !12, i64 28}
!41 = !{!18, !19, i64 16}
!42 = !{!25, !19, i64 32}
!43 = !{!18, !19, i64 24}
!44 = !{!25, !19, i64 40}
!45 = !{!25, !12, i64 48}
!46 = !{!25, !12, i64 52}
!47 = !{!18, !12, i64 40}
!48 = !{!25, !12, i64 56}
!49 = !{!18, !20, i64 12}
!50 = !{!25, !12, i64 60}
!51 = !{!23, !6, i64 40}
!52 = !{!23, !6, i64 56}
!53 = !{!54, !6, i64 0}
!54 = !{!"_ZTSN2rw3ps29Ps2Raster8PixelPtrE", !6, i64 0, !12, i64 8, !12, i64 12}
!55 = !{!23, !6, i64 48}


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

%"struct.rw::ps2::StreamRasterExt" = type { i32, i32, i32, i16, i16, i64, i32, i32, i64, i64, i32, i32, i32, i32 }

@_ZN2rw3ps218nativeRasterOffsetE = external dso_local local_unnamed_addr global i32, align 4

; 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: mustprogress uwtable
define dso_local void @_ZN2rw3ps218writeNativeTextureEPNS_7TextureEPNS_6StreamE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca %"struct.rw::ps2::StreamRasterExt", align 8
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = load i32, ptr @_ZN2rw3ps218nativeRasterOffsetE, align 4, !tbaa !12
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i8, ptr %4, i64 %6
  %8 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %1, i32 noundef 1, i32 noundef 8)
  %9 = tail call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 3298128)
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = tail call noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %11)
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %13) #4
  %15 = trunc i64 %14 to i32
  %16 = and i32 %15, -4
  %17 = add i32 %16, 4
  %18 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 2, i32 noundef %17)
  %19 = load ptr, ptr %1, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %19, i64 24
  %21 = load ptr, ptr %20, align 8
  %22 = tail call noundef i32 %21(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %13, i32 noundef %17)
  %23 = getelementptr inbounds i8, ptr %0, i64 64
  %24 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %23) #4
  %25 = trunc i64 %24 to i32
  %26 = and i32 %25, -4
  %27 = add i32 %26, 4
  %28 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 2, i32 noundef %27)
  %29 = load ptr, ptr %1, align 8, !tbaa !14
  %30 = getelementptr inbounds i8, ptr %29, i64 24
  %31 = load ptr, ptr %30, align 8
  %32 = tail call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %23, i32 noundef %27)
  %33 = getelementptr inbounds i8, ptr %7, i64 32
  %34 = load i32, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds i8, ptr %7, i64 36
  %36 = load i32, ptr %35, align 4, !tbaa !20
  %37 = add i32 %36, %34
  %38 = add nsw i32 %37, 88
  %39 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef %38)
  %40 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef 64)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #5
  %41 = getelementptr inbounds i8, ptr %4, i64 20
  %42 = load <2 x i32>, ptr %41, align 4, !tbaa !12
  store <2 x i32> %42, ptr %3, align 8, !tbaa !12
  %43 = getelementptr inbounds i8, ptr %4, i64 28
  %44 = load i32, ptr %43, align 4, !tbaa !21
  %45 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %44, ptr %45, align 8, !tbaa !23
  %46 = getelementptr inbounds i8, ptr %4, i64 16
  %47 = load i32, ptr %46, align 8, !tbaa !25
  %48 = getelementptr inbounds i8, ptr %4, i64 4
  %49 = load i32, ptr %48, align 4, !tbaa !26
  %50 = or i32 %49, %47
  %51 = trunc i32 %50 to i16
  %52 = getelementptr inbounds i8, ptr %3, i64 12
  store i16 %51, ptr %52, align 4, !tbaa !27
  %53 = getelementptr inbounds i8, ptr %3, i64 14
  store i16 0, ptr %53, align 2, !tbaa !28
  %54 = getelementptr inbounds i8, ptr %7, i64 44
  %55 = load i8, ptr %54, align 4, !tbaa !29
  %56 = icmp eq i8 %55, 2
  br i1 %56, label %57, label %59

57:                                               ; preds = %2
  %58 = icmp eq i32 %44, 8
  br i1 %58, label %.thread.sink.split, label %.thread

59:                                               ; preds = %2
  %60 = and i8 %55, 1
  %.not = icmp eq i8 %60, 0
  br i1 %.not, label %.thread, label %.thread.sink.split

.thread.sink.split:                               ; preds = %59, %57
  %.sink = phi i16 [ 1, %57 ], [ 2, %59 ]
  store i16 %.sink, ptr %53, align 2, !tbaa !28
  br label %.thread

.thread:                                          ; preds = %.thread.sink.split, %57, %59
  %61 = load i64, ptr %7, align 8, !tbaa !30
  %62 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 %61, ptr %62, align 8, !tbaa !31
  %63 = getelementptr inbounds i8, ptr %7, i64 8
  %64 = load i32, ptr %63, align 8, !tbaa !32
  %65 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %64, ptr %65, align 8, !tbaa !33
  %66 = getelementptr inbounds i8, ptr %7, i64 14
  %67 = load i8, ptr %66, align 2, !tbaa !34
  %68 = zext i8 %67 to i32
  %69 = getelementptr inbounds i8, ptr %3, i64 28
  store i32 %68, ptr %69, align 4, !tbaa !35
  %70 = getelementptr inbounds i8, ptr %7, i64 16
  %71 = getelementptr inbounds i8, ptr %3, i64 32
  %72 = load <2 x i64>, ptr %70, align 8, !tbaa !36
  store <2 x i64> %72, ptr %71, align 8, !tbaa !36
  %73 = getelementptr inbounds i8, ptr %3, i64 48
  %74 = load <2 x i32>, ptr %33, align 8, !tbaa !12
  store <2 x i32> %74, ptr %73, align 8, !tbaa !12
  %75 = getelementptr inbounds i8, ptr %7, i64 40
  %76 = load i32, ptr %75, align 8, !tbaa !37
  %77 = getelementptr inbounds i8, ptr %3, i64 56
  store i32 %76, ptr %77, align 8, !tbaa !38
  %78 = getelementptr inbounds i8, ptr %7, i64 12
  %79 = load i16, ptr %78, align 4, !tbaa !39
  %80 = zext i16 %79 to i32
  %81 = getelementptr inbounds i8, ptr %3, i64 60
  store i32 %80, ptr %81, align 4, !tbaa !40
  %82 = load ptr, ptr %1, align 8, !tbaa !14
  %83 = getelementptr inbounds i8, ptr %82, i64 24
  %84 = load ptr, ptr %83, align 8
  %85 = call noundef i32 %84(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %3, i32 noundef 64)
  %86 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef %37)
  %87 = load i16, ptr %53, align 2, !tbaa !28
  %88 = icmp slt i16 %87, 2
  br i1 %88, label %89, label %96

89:                                               ; preds = %.thread
  %90 = getelementptr inbounds i8, ptr %4, i64 40
  %91 = load ptr, ptr %90, align 8, !tbaa !41
  %92 = load ptr, ptr %1, align 8, !tbaa !14
  %93 = getelementptr inbounds i8, ptr %92, i64 24
  %94 = load ptr, ptr %93, align 8
  %95 = call noundef i32 %94(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %91, i32 noundef %37)
  br label %113

96:                                               ; preds = %.thread
  %97 = getelementptr inbounds i8, ptr %4, i64 56
  %98 = load ptr, ptr %97, align 8, !tbaa !42
  %99 = load ptr, ptr %98, align 8, !tbaa !43
  %100 = load i32, ptr %33, align 8, !tbaa !16
  %101 = load ptr, ptr %1, align 8, !tbaa !14
  %102 = getelementptr inbounds i8, ptr %101, i64 24
  %103 = load ptr, ptr %102, align 8
  %104 = call noundef i32 %103(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef %99, i32 noundef %100)
  %105 = getelementptr inbounds i8, ptr %4, i64 48
  %106 = load ptr, ptr %105, align 8, !tbaa !45
  %107 = getelementptr inbounds i8, ptr %106, i64 -80
  %108 = load i32, ptr %35, align 4, !tbaa !20
  %109 = load ptr, ptr %1, align 8, !tbaa !14
  %110 = getelementptr inbounds i8, ptr %109, i64 24
  %111 = load ptr, ptr %110, align 8
  %112 = call noundef i32 %111(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %107, i32 noundef %108)
  br label %113

113:                                              ; preds = %96, %89
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  ret void
}

declare noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare noundef i32 @_ZN2rw6Stream8writeU32Ej(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #5 = { 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 = !{!"_ZTSN2rw7TextureE", !7, i64 0, !7, i64 8, !10, i64 16, !8, i64 32, !8, i64 64, !11, i64 96, !11, i64 100, !10, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN2rw6LLLinkE", !7, i64 0, !7, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!6, !11, i64 96}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !9, i64 0}
!16 = !{!17, !11, i64 32}
!17 = !{!"_ZTSN2rw3ps29Ps2RasterE", !18, i64 0, !11, i64 8, !19, i64 12, !8, i64 14, !8, i64 15, !18, i64 16, !18, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !8, i64 44, !7, i64 48, !11, i64 56}
!18 = !{!"long", !8, i64 0}
!19 = !{!"short", !8, i64 0}
!20 = !{!17, !11, i64 36}
!21 = !{!22, !11, i64 28}
!22 = !{!"_ZTSN2rw6RasterE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !7, i64 80, !11, i64 88, !11, i64 92}
!23 = !{!24, !11, i64 8}
!24 = !{!"_ZTSN2rw3ps215StreamRasterExtE", !11, i64 0, !11, i64 4, !11, i64 8, !19, i64 12, !19, i64 14, !18, i64 16, !11, i64 24, !11, i64 28, !18, i64 32, !18, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60}
!25 = !{!22, !11, i64 16}
!26 = !{!22, !11, i64 4}
!27 = !{!24, !19, i64 12}
!28 = !{!24, !19, i64 14}
!29 = !{!17, !8, i64 44}
!30 = !{!17, !18, i64 0}
!31 = !{!24, !18, i64 16}
!32 = !{!17, !11, i64 8}
!33 = !{!24, !11, i64 24}
!34 = !{!17, !8, i64 14}
!35 = !{!24, !11, i64 28}
!36 = !{!18, !18, i64 0}
!37 = !{!17, !11, i64 40}
!38 = !{!24, !11, i64 56}
!39 = !{!17, !19, i64 12}
!40 = !{!24, !11, i64 60}
!41 = !{!22, !7, i64 40}
!42 = !{!22, !7, i64 56}
!43 = !{!44, !7, i64 0}
!44 = !{!"_ZTSN2rw3ps29Ps2Raster8PixelPtrE", !7, i64 0, !11, i64 8, !11, i64 12}
!45 = !{!22, !7, i64 48}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass