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

; 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::Skin" = type { i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32 }

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

22:                                               ; preds = %4
  br label %23

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

31:                                               ; preds = %23
  br label %32

32:                                               ; preds = %31
  store ptr null, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %160

33:                                               ; preds = %4
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %34)
  store i32 %35, ptr %12, align 4, !tbaa !9
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = icmp ne i32 %36, 4
  br i1 %37, label %38, label %50

38:                                               ; preds = %33
  br label %39

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

48:                                               ; preds = %39
  br label %49

49:                                               ; preds = %48
  store ptr null, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %160

50:                                               ; preds = %33
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %53 = load ptr, ptr %51, align 8, !tbaa !14
  %54 = getelementptr inbounds ptr, ptr %53, i64 4
  %55 = load ptr, ptr %54, align 8
  %56 = call noundef i32 %55(ptr noundef nonnull align 8 dereferenceable(8) %51, ptr noundef %52, i32 noundef 4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %57 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 112, i32 noundef 196886, ptr noundef @.str.4)
  store ptr %57, ptr %16, align 8, !tbaa !5
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %59, i64 %61
  store ptr %58, ptr %62, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #5
  %63 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 1
  %64 = load i8, ptr %63, align 1, !tbaa !16
  %65 = zext i8 %64 to i32
  %66 = icmp eq i32 %65, 0
  %67 = zext i1 %66 to i8
  store i8 %67, ptr %17, align 1, !tbaa !17
  %68 = load i8, ptr %17, align 1, !tbaa !17, !range !19, !noundef !20
  %69 = trunc i8 %68 to i1
  br i1 %69, label %70, label %78

70:                                               ; preds = %50
  %71 = load ptr, ptr %16, align 8, !tbaa !5
  %72 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %73 = load i8, ptr %72, align 1, !tbaa !16
  %74 = zext i8 %73 to i32
  %75 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %76 = load i8, ptr %75, align 1, !tbaa !16
  %77 = zext i8 %76 to i32
  call void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112) %71, i32 noundef %74, i32 noundef %77, i32 noundef 0)
  br label %86

78:                                               ; preds = %50
  %79 = load ptr, ptr %16, align 8, !tbaa !5
  %80 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 0
  %81 = load i8, ptr %80, align 1, !tbaa !16
  %82 = zext i8 %81 to i32
  %83 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 1
  %84 = load i8, ptr %83, align 1, !tbaa !16
  %85 = zext i8 %84 to i32
  call void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112) %79, i32 noundef %82, i32 noundef %85, i32 noundef 0)
  br label %86

86:                                               ; preds = %78, %70
  %87 = getelementptr inbounds [4 x i8], ptr %10, i64 0, i64 2
  %88 = load i8, ptr %87, align 1, !tbaa !16
  %89 = zext i8 %88 to i32
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.rw::Skin", ptr %90, i32 0, i32 2
  store i32 %89, ptr %91, align 8, !tbaa !21
  %92 = load i8, ptr %17, align 1, !tbaa !17, !range !19, !noundef !20
  %93 = trunc i8 %92 to i1
  br i1 %93, label %106, label %94

94:                                               ; preds = %86
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  %97 = getelementptr inbounds %"struct.rw::Skin", ptr %96, i32 0, i32 3
  %98 = load ptr, ptr %97, align 8, !tbaa !23
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = getelementptr inbounds %"struct.rw::Skin", ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !24
  %102 = load ptr, ptr %95, align 8, !tbaa !14
  %103 = getelementptr inbounds ptr, ptr %102, i64 4
  %104 = load ptr, ptr %103, align 8
  %105 = call noundef i32 %104(ptr noundef nonnull align 8 dereferenceable(8) %95, ptr noundef %98, i32 noundef %101)
  br label %106

106:                                              ; preds = %94, %86
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = getelementptr inbounds %"struct.rw::Skin", ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 8, !tbaa !25
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %121

111:                                              ; preds = %106
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  %113 = load ptr, ptr %16, align 8, !tbaa !5
  %114 = getelementptr inbounds %"struct.rw::Skin", ptr %113, i32 0, i32 4
  %115 = load ptr, ptr %114, align 8, !tbaa !26
  %116 = load ptr, ptr %16, align 8, !tbaa !5
  %117 = getelementptr inbounds %"struct.rw::Skin", ptr %116, i32 0, i32 0
  %118 = load i32, ptr %117, align 8, !tbaa !25
  %119 = mul nsw i32 %118, 64
  %120 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %112, ptr noundef %115, i32 noundef %119)
  br label %121

121:                                              ; preds = %111, %106
  %122 = load i8, ptr %17, align 1, !tbaa !17, !range !19, !noundef !20
  %123 = trunc i8 %122 to i1
  br i1 %123, label %124, label %147

124:                                              ; preds = %121
  %125 = load ptr, ptr %16, align 8, !tbaa !5
  %126 = getelementptr inbounds %"struct.rw::Skin", ptr %125, i32 0, i32 2
  store i32 4, ptr %126, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %127

127:                                              ; preds = %143, %124
  %128 = load i32, ptr %18, align 4, !tbaa !9
  %129 = load ptr, ptr %16, align 8, !tbaa !5
  %130 = getelementptr inbounds %"struct.rw::Skin", ptr %129, i32 0, i32 1
  %131 = load i32, ptr %130, align 4, !tbaa !24
  %132 = icmp slt i32 %128, %131
  br i1 %132, label %134, label %133

133:                                              ; preds = %127
  store i32 6, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %146

134:                                              ; preds = %127
  %135 = load i32, ptr %18, align 4, !tbaa !9
  %136 = trunc i32 %135 to i8
  %137 = load ptr, ptr %16, align 8, !tbaa !5
  %138 = getelementptr inbounds %"struct.rw::Skin", ptr %137, i32 0, i32 3
  %139 = load ptr, ptr %138, align 8, !tbaa !23
  %140 = load i32, ptr %18, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i8, ptr %139, i64 %141
  store i8 %136, ptr %142, align 1, !tbaa !16
  br label %143

143:                                              ; preds = %134
  %144 = load i32, ptr %18, align 4, !tbaa !9
  %145 = add nsw i32 %144, 1
  store i32 %145, ptr %18, align 4, !tbaa !9
  br label %127, !llvm.loop !27

146:                                              ; preds = %133
  br label %147

147:                                              ; preds = %146, %121
  %148 = load i8, ptr %17, align 1, !tbaa !17, !range !19, !noundef !20
  %149 = trunc i8 %148 to i1
  br i1 %149, label %158, label %150

150:                                              ; preds = %147
  %151 = load ptr, ptr %6, align 8, !tbaa !5
  %152 = load ptr, ptr %151, align 8, !tbaa !14
  %153 = getelementptr inbounds ptr, ptr %152, i64 5
  %154 = load ptr, ptr %153, align 8
  call void %154(ptr noundef nonnull align 8 dereferenceable(8) %151, i32 noundef 16, i32 noundef 1)
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  %156 = load ptr, ptr %16, align 8, !tbaa !5
  %157 = call noundef ptr @_ZN2rw17readSkinSplitDataEPNS_6StreamEPNS_4SkinE(ptr noundef %155, ptr noundef %156)
  br label %158

158:                                              ; preds = %150, %147
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %159, ptr %5, align 8
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %160

160:                                              ; preds = %158, %49, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %161 = load ptr, ptr %5, align 8
  ret ptr %161
}

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

declare void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef, i32 noundef) #2

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

declare noundef ptr @_ZN2rw17readSkinSplitDataEPNS_6StreamEPNS_4SkinE(ptr noundef, ptr 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 = { 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, !15, i64 0}
!15 = !{!"vtable pointer", !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!22, !10, i64 8}
!22 = !{!"_ZTSN2rw4SkinE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !10, i64 104}
!23 = !{!22, !6, i64 16}
!24 = !{!22, !10, i64 4}
!25 = !{!22, !10, i64 0}
!26 = !{!22, !6, i64 24}
!27 = distinct !{!27, !28}
!28 = !{!"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 }

@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 [63 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 [78 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 @_ZN2rw3ps214readNativeSkinEPNS_6StreamEiPvi(ptr noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca [4 x i8], align 1
  %6 = alloca %"struct.rw::Error", align 4
  %7 = alloca %"struct.rw::Error", align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  %8 = tail call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %0, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %8, label %16, label %9

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

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

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

25:                                               ; preds = %16
  %26 = load ptr, ptr %0, align 8, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %26, i64 32
  %28 = load ptr, ptr %27, align 8
  %29 = call noundef i32 %28(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %5, i32 noundef 4)
  %30 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef 112, i32 noundef 196886, ptr noundef nonnull @.str.4)
  %31 = sext i32 %3 to i64
  %32 = getelementptr inbounds i8, ptr %2, i64 %31
  store ptr %30, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %5, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !15
  %35 = icmp eq i8 %34, 0
  br i1 %35, label %.thread, label %42

.thread:                                          ; preds = %25
  %36 = load i8, ptr %5, align 1, !tbaa !15
  %37 = zext i8 %36 to i32
  call void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112) %30, i32 noundef %37, i32 noundef %37, i32 noundef 0)
  %38 = getelementptr inbounds i8, ptr %5, i64 2
  %39 = load i8, ptr %38, align 1, !tbaa !15
  %40 = zext i8 %39 to i32
  %41 = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %40, ptr %41, align 8, !tbaa !16
  br label %58

42:                                               ; preds = %25
  %43 = zext i8 %34 to i32
  %44 = load i8, ptr %5, align 1, !tbaa !15
  %45 = zext i8 %44 to i32
  call void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112) %30, i32 noundef %45, i32 noundef %43, i32 noundef 0)
  %46 = getelementptr inbounds i8, ptr %5, i64 2
  %47 = load i8, ptr %46, align 1, !tbaa !15
  %48 = zext i8 %47 to i32
  %49 = getelementptr inbounds i8, ptr %30, i64 8
  store i32 %48, ptr %49, align 8, !tbaa !16
  %50 = getelementptr inbounds i8, ptr %30, i64 16
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = getelementptr inbounds i8, ptr %30, i64 4
  %53 = load i32, ptr %52, align 4, !tbaa !19
  %54 = load ptr, ptr %0, align 8, !tbaa !13
  %55 = getelementptr inbounds i8, ptr %54, i64 32
  %56 = load ptr, ptr %55, align 8
  %57 = call noundef i32 %56(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %51, i32 noundef %53)
  br label %58

58:                                               ; preds = %.thread, %42
  %59 = phi ptr [ %41, %.thread ], [ %49, %42 ]
  %60 = load i32, ptr %30, align 8, !tbaa !20
  %.not38 = icmp eq i32 %60, 0
  br i1 %.not38, label %66, label %61

61:                                               ; preds = %58
  %62 = getelementptr inbounds i8, ptr %30, i64 24
  %63 = load ptr, ptr %62, align 8, !tbaa !21
  %64 = shl nsw i32 %60, 6
  %65 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %63, i32 noundef %64)
  br label %66

66:                                               ; preds = %61, %58
  br i1 %35, label %67, label %.critedge

67:                                               ; preds = %66
  store i32 4, ptr %59, align 8, !tbaa !16
  %68 = getelementptr inbounds i8, ptr %30, i64 4
  %69 = load i32, ptr %68, align 4, !tbaa !19
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %67
  %71 = getelementptr inbounds i8, ptr %30, i64 16
  br label %72

72:                                               ; preds = %.lr.ph, %72
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %72 ]
  %73 = trunc i64 %indvars.iv to i8
  %74 = load ptr, ptr %71, align 8, !tbaa !18
  %75 = getelementptr inbounds i8, ptr %74, i64 %indvars.iv
  store i8 %73, ptr %75, align 1, !tbaa !15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %76 = load i32, ptr %68, align 4, !tbaa !19
  %77 = sext i32 %76 to i64
  %78 = icmp slt i64 %indvars.iv.next, %77
  br i1 %78, label %72, label %.loopexit, !llvm.loop !22

.critedge:                                        ; preds = %66
  %79 = load ptr, ptr %0, align 8, !tbaa !13
  %80 = getelementptr inbounds i8, ptr %79, i64 40
  %81 = load ptr, ptr %80, align 8
  call void %81(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 16, i32 noundef 1)
  %82 = call noundef ptr @_ZN2rw17readSkinSplitDataEPNS_6StreamEPNS_4SkinE(ptr noundef nonnull %0, ptr noundef nonnull %30)
  br label %.loopexit

.loopexit:                                        ; preds = %72, %67, %.critedge, %18, %9
  %.034 = phi ptr [ null, %18 ], [ null, %9 ], [ %0, %.critedge ], [ %0, %67 ], [ %0, %72 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret ptr %.034
}

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

declare void @_ZN2rw4Skin4initEiii(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

declare noundef ptr @_ZN2rw17readSkinSplitDataEPNS_6StreamEPNS_4SkinE(ptr noundef, ptr 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 = { nounwind }
attributes #6 = { cold 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, !14, i64 0}
!14 = !{!"vtable pointer", !9, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !7, i64 8}
!17 = !{!"_ZTSN2rw4SkinE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !7, i64 104}
!18 = !{!17, !12, i64 16}
!19 = !{!17, !7, i64 4}
!20 = !{!17, !7, i64 0}
!21 = !{!17, !12, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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