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

; 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::Error" = type { i32, i32 }
%"struct.rw::Geometry" = type { %"struct.rw::Object", i32, i16, i32, i32, i32, i32, ptr, ptr, [8 x ptr], ptr, %"struct.rw::MaterialList", ptr, ptr, i32 }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::InstanceDataHeader" = type { i32 }
%"struct.rw::MeshHeader" = type { i32, i16, i16, i32, i32 }
%"struct.rw::ps2::InstanceDataHeader" = type { %"struct.rw::InstanceDataHeader", i32, ptr }
%"struct.rw::ps2::InstanceData" = type { i32, ptr, ptr, ptr }
%"struct.rw::Mesh" = type { ptr, i32, ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii = external hidden unnamed_addr constant [71 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [75 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %"struct.rw::Error", align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.rw::Error", align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca [2 x i32], align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %22, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %23, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %24, label %36, label %25

25:                                               ; preds = %5
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %27 = getelementptr inbounds %"struct.rw::Error", ptr %14, i32 0, i32 0
  store i32 2, ptr %27, align 4, !tbaa !11
  %28 = getelementptr inbounds %"struct.rw::Error", ptr %14, i32 0, i32 1
  store i32 -2147483644, ptr %28, align 4, !tbaa !13
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 88) #7
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.3)
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.2, ptr noundef %32) #7
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %34

34:                                               ; preds = %26
  br label %35

35:                                               ; preds = %34
  store ptr null, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %151

36:                                               ; preds = %5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %37)
  store i32 %38, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %13, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 4
  br i1 %40, label %41, label %53

41:                                               ; preds = %36
  br label %42

42:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %43 = getelementptr inbounds %"struct.rw::Error", ptr %16, i32 0, i32 0
  store i32 2, ptr %43, align 4, !tbaa !11
  %44 = getelementptr inbounds %"struct.rw::Error", ptr %16, i32 0, i32 1
  store i32 -2147483642, ptr %44, align 4, !tbaa !13
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 93) #7
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483642, i32 noundef %48)
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.2, ptr noundef %49) #7
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %16)
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  br label %51

51:                                               ; preds = %42
  br label %52

52:                                               ; preds = %51
  store ptr null, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %151

53:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %54 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 16, i32 noundef 196623, ptr noundef @.str.4)
  store ptr %54, ptr %17, align 8, !tbaa !5
  %55 = load ptr, ptr %17, align 8, !tbaa !5
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds %"struct.rw::Geometry", ptr %56, i32 0, i32 13
  store ptr %55, ptr %57, align 8, !tbaa !14
  %58 = load ptr, ptr %17, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.rw::InstanceDataHeader", ptr %58, i32 0, i32 0
  store i32 4, ptr %59, align 8, !tbaa !19
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.rw::Geometry", ptr %60, i32 0, i32 12
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %53
  br label %67

65:                                               ; preds = %53
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 99, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii) #8
  unreachable

66:                                               ; No predecessors!
  br label %67

67:                                               ; preds = %66, %64
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.rw::Geometry", ptr %68, i32 0, i32 12
  %70 = load ptr, ptr %69, align 8, !tbaa !21
  %71 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %70, i32 0, i32 1
  %72 = load i16, ptr %71, align 4, !tbaa !22
  %73 = zext i16 %72 to i32
  %74 = load ptr, ptr %17, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.rw::ps2::InstanceDataHeader", ptr %74, i32 0, i32 1
  store i32 %73, ptr %75, align 4, !tbaa !24
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.rw::ps2::InstanceDataHeader", ptr %76, i32 0, i32 1
  %78 = load i32, ptr %77, align 4, !tbaa !24
  %79 = zext i32 %78 to i64
  %80 = mul i64 %79, 32
  %81 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %80, i32 noundef 196623, ptr noundef @.str.6)
  %82 = load ptr, ptr %17, align 8, !tbaa !5
  %83 = getelementptr inbounds %"struct.rw::ps2::InstanceDataHeader", ptr %82, i32 0, i32 2
  store ptr %81, ptr %83, align 8, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.rw::Geometry", ptr %84, i32 0, i32 12
  %86 = load ptr, ptr %85, align 8, !tbaa !21
  %87 = call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %86)
  store ptr %87, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %146, %67
  %89 = load i32, ptr %19, align 4, !tbaa !9
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.rw::ps2::InstanceDataHeader", ptr %90, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !24
  %93 = icmp ult i32 %89, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %88
  store i32 6, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  br label %149

95:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = getelementptr inbounds %"struct.rw::ps2::InstanceDataHeader", ptr %96, i32 0, i32 2
  %98 = load ptr, ptr %97, align 8, !tbaa !26
  %99 = load i32, ptr %19, align 4, !tbaa !9
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %98, i64 %100
  store ptr %101, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  %102 = load ptr, ptr %7, align 8, !tbaa !5
  %103 = getelementptr inbounds [2 x i32], ptr %21, i64 0, i64 0
  %104 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %102, ptr noundef %103, i32 noundef 8)
  %105 = getelementptr inbounds [2 x i32], ptr %21, i64 0, i64 0
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = load ptr, ptr %20, align 8, !tbaa !5
  %108 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %107, i32 0, i32 0
  store i32 %106, ptr %108, align 8, !tbaa !27
  %109 = load ptr, ptr %20, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !27
  %112 = add i32 %111, 127
  %113 = zext i32 %112 to i64
  %114 = mul i64 %113, 1
  %115 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %114, i32 noundef 196623, ptr noundef @.str.7)
  %116 = load ptr, ptr %20, align 8, !tbaa !5
  %117 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %116, i32 0, i32 1
  store ptr %115, ptr %117, align 8, !tbaa !29
  %118 = load ptr, ptr %20, align 8, !tbaa !5
  %119 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %118, i32 0, i32 1
  %120 = load ptr, ptr %119, align 8, !tbaa !29
  %121 = ptrtoint ptr %120 to i64
  %122 = add i64 %121, 128
  %123 = sub i64 %122, 1
  %124 = and i64 %123, -128
  %125 = inttoptr i64 %124 to ptr
  %126 = load ptr, ptr %20, align 8, !tbaa !5
  %127 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %126, i32 0, i32 2
  store ptr %125, ptr %127, align 8, !tbaa !30
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = load ptr, ptr %20, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %129, i32 0, i32 2
  %131 = load ptr, ptr %130, align 8, !tbaa !30
  %132 = load ptr, ptr %20, align 8, !tbaa !5
  %133 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %132, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !27
  %135 = load ptr, ptr %128, align 8, !tbaa !31
  %136 = getelementptr inbounds ptr, ptr %135, i64 4
  %137 = load ptr, ptr %136, align 8
  %138 = call noundef i32 %137(ptr noundef nonnull align 8 dereferenceable(8) %128, ptr noundef %131, i32 noundef %134)
  %139 = load ptr, ptr %18, align 8, !tbaa !5
  %140 = getelementptr inbounds %"struct.rw::Mesh", ptr %139, i32 0, i32 2
  %141 = load ptr, ptr %140, align 8, !tbaa !33
  %142 = load ptr, ptr %20, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %142, i32 0, i32 3
  store ptr %141, ptr %143, align 8, !tbaa !35
  %144 = load ptr, ptr %18, align 8, !tbaa !5
  %145 = getelementptr inbounds %"struct.rw::Mesh", ptr %144, i32 1
  store ptr %145, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  br label %146

146:                                              ; preds = %95
  %147 = load i32, ptr %19, align 4, !tbaa !9
  %148 = add i32 %147, 1
  store i32 %148, ptr %19, align 4, !tbaa !9
  br label %88, !llvm.loop !36

149:                                              ; preds = %94
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %150, ptr %6, align 8
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %151

151:                                              ; preds = %149, %52, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  %152 = load ptr, ptr %6, align 8
  ret ptr %152
}

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16)) #6 align 2

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

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 "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 = { inlinehint 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 #5 = { noreturn 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 #6 = { mustprogress 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw5ErrorE", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = !{!15, !6, i64 152}
!15 = !{!"_ZTSN2rw8GeometryE", !16, i64 0, !10, i64 16, !17, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !18, i64 128, !6, i64 144, !6, i64 152, !10, i64 160}
!16 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!17 = !{!"short", !7, i64 0}
!18 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !10, i64 8, !10, i64 12}
!19 = !{!20, !10, i64 0}
!20 = !{!"_ZTSN2rw18InstanceDataHeaderE", !10, i64 0}
!21 = !{!15, !6, i64 144}
!22 = !{!23, !17, i64 4}
!23 = !{!"_ZTSN2rw10MeshHeaderE", !10, i64 0, !17, i64 4, !17, i64 6, !10, i64 8, !10, i64 12}
!24 = !{!25, !10, i64 4}
!25 = !{!"_ZTSN2rw3ps218InstanceDataHeaderE", !20, i64 0, !10, i64 4, !6, i64 8}
!26 = !{!25, !6, i64 8}
!27 = !{!28, !10, i64 0}
!28 = !{!"_ZTSN2rw3ps212InstanceDataE", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!29 = !{!28, !6, i64 8}
!30 = !{!28, !6, i64 16}
!31 = !{!32, !32, i64 0}
!32 = !{!"vtable pointer", !8, i64 0}
!33 = !{!34, !6, i64 16}
!34 = !{!"_ZTSN2rw4MeshE", !6, i64 0, !10, i64 8, !6, i64 16}
!35 = !{!28, !6, i64 24}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::ps2::InstanceData" = type { i32, ptr, ptr, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii = external hidden unnamed_addr constant [71 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [75 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: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii(ptr noundef %0, i32 noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %"struct.rw::Error", align 4
  %7 = alloca %"struct.rw::Error", align 4
  %8 = alloca [2 x i32], align 4
  %9 = tail call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %0, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %9, label %17, label %10

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i32 2, ptr %6, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 -2147483644, ptr %11, align 4, !tbaa !10
  %12 = load ptr, ptr @stderr, align 8, !tbaa !11
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 88) #8
  %14 = load ptr, ptr @stderr, align 8, !tbaa !11
  %15 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.3)
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.2, ptr noundef %15) #8
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  br label %.loopexit

17:                                               ; preds = %5
  %18 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %.not = icmp eq i32 %18, 4
  br i1 %.not, label %26, label %19

19:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  store i32 2, ptr %7, align 4, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 -2147483642, ptr %20, align 4, !tbaa !10
  %21 = load ptr, ptr @stderr, align 8, !tbaa !11
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 93) #8
  %23 = load ptr, ptr @stderr, align 8, !tbaa !11
  %24 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483642, i32 noundef %18)
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.2, ptr noundef %24) #8
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %.loopexit

26:                                               ; preds = %17
  %27 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 16, i32 noundef 196623, ptr noundef nonnull @.str.4)
  %28 = getelementptr inbounds i8, ptr %2, i64 152
  store ptr %27, ptr %28, align 8, !tbaa !13
  store i32 4, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds i8, ptr %2, i64 144
  %30 = load ptr, ptr %29, align 8, !tbaa !20
  %.not36 = icmp eq ptr %30, null
  br i1 %.not36, label %31, label %32

31:                                               ; preds = %26
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 99, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3ps214readNativeDataEPNS_6StreamEiPvii) #9
  unreachable

32:                                               ; preds = %26
  %33 = getelementptr inbounds i8, ptr %30, i64 4
  %34 = load i16, ptr %33, align 4, !tbaa !21
  %35 = zext i16 %34 to i32
  %36 = getelementptr inbounds i8, ptr %27, i64 4
  store i32 %35, ptr %36, align 4, !tbaa !23
  %37 = zext i16 %34 to i64
  %38 = shl nuw nsw i64 %37, 5
  %39 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %38, i32 noundef 196623, ptr noundef nonnull @.str.6)
  %40 = getelementptr inbounds i8, ptr %27, i64 8
  store ptr %39, ptr %40, align 8, !tbaa !25
  %41 = load ptr, ptr %29, align 8, !tbaa !20
  %42 = tail call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %41)
  %43 = load i32, ptr %36, align 4, !tbaa !23
  %.not39 = icmp eq i32 %43, 0
  br i1 %.not39, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %32, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %32 ]
  %.03337 = phi ptr [ %65, %.lr.ph ], [ %42, %32 ]
  %44 = load ptr, ptr %40, align 8, !tbaa !25
  %45 = getelementptr inbounds %"struct.rw::ps2::InstanceData", ptr %44, i64 %indvars.iv
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  %46 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %8, i32 noundef 8)
  %47 = load i32, ptr %8, align 4, !tbaa !26
  store i32 %47, ptr %45, align 8, !tbaa !27
  %48 = add i32 %47, 127
  %49 = zext i32 %48 to i64
  %50 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %49, i32 noundef 196623, ptr noundef nonnull @.str.7)
  %51 = getelementptr inbounds i8, ptr %45, i64 8
  store ptr %50, ptr %51, align 8, !tbaa !29
  %52 = ptrtoint ptr %50 to i64
  %53 = add i64 %52, 127
  %54 = and i64 %53, -128
  %55 = inttoptr i64 %54 to ptr
  %56 = getelementptr inbounds i8, ptr %45, i64 16
  store ptr %55, ptr %56, align 8, !tbaa !30
  %57 = load i32, ptr %45, align 8, !tbaa !27
  %58 = load ptr, ptr %0, align 8, !tbaa !31
  %59 = getelementptr inbounds i8, ptr %58, i64 32
  %60 = load ptr, ptr %59, align 8
  %61 = call noundef i32 %60(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %55, i32 noundef %57)
  %62 = getelementptr inbounds i8, ptr %.03337, i64 16
  %63 = load ptr, ptr %62, align 8, !tbaa !33
  %64 = getelementptr inbounds i8, ptr %45, i64 24
  store ptr %63, ptr %64, align 8, !tbaa !35
  %65 = getelementptr inbounds i8, ptr %.03337, i64 24
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %66 = load i32, ptr %36, align 4, !tbaa !23
  %67 = zext i32 %66 to i64
  %68 = icmp ult i64 %indvars.iv.next, %67
  br i1 %68, label %.lr.ph, label %.loopexit, !llvm.loop !36

.loopexit:                                        ; preds = %.lr.ph, %32, %19, %10
  %.0 = phi ptr [ null, %19 ], [ null, %10 ], [ %0, %32 ], [ %0, %.lr.ph ]
  ret ptr %.0
}

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

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

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) local_unnamed_addr #2

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #6 align 2

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

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 = { 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 = { inlinehint 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 #5 = { noreturn 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 #6 = { mustprogress 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 #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { 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, !7, i64 0}
!6 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !12, i64 152}
!14 = !{!"_ZTSN2rw8GeometryE", !15, i64 0, !7, i64 16, !16, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !12, i64 40, !12, i64 48, !8, i64 56, !12, i64 120, !17, i64 128, !12, i64 144, !12, i64 152, !7, i64 160}
!15 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !12, i64 8}
!16 = !{!"short", !8, i64 0}
!17 = !{!"_ZTSN2rw12MaterialListE", !12, i64 0, !7, i64 8, !7, i64 12}
!18 = !{!19, !7, i64 0}
!19 = !{!"_ZTSN2rw18InstanceDataHeaderE", !7, i64 0}
!20 = !{!14, !12, i64 144}
!21 = !{!22, !16, i64 4}
!22 = !{!"_ZTSN2rw10MeshHeaderE", !7, i64 0, !16, i64 4, !16, i64 6, !7, i64 8, !7, i64 12}
!23 = !{!24, !7, i64 4}
!24 = !{!"_ZTSN2rw3ps218InstanceDataHeaderE", !19, i64 0, !7, i64 4, !12, i64 8}
!25 = !{!24, !12, i64 8}
!26 = !{!7, !7, i64 0}
!27 = !{!28, !7, i64 0}
!28 = !{!"_ZTSN2rw3ps212InstanceDataE", !7, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!29 = !{!28, !12, i64 8}
!30 = !{!28, !12, i64 16}
!31 = !{!32, !32, i64 0}
!32 = !{!"vtable pointer", !9, i64 0}
!33 = !{!34, !12, i64 16}
!34 = !{!"_ZTSN2rw4MeshE", !12, i64 0, !7, i64 8, !12, i64 16}
!35 = !{!28, !12, i64 24}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


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