; LLVM IR from aap/librw :: src/texture.ll (ZN2rw7Texture10streamReadEPNS_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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::Texture" = type { ptr, ptr, %"struct.rw::LLLink", [32 x i8], [32 x i8], i32, i32, %"struct.rw::LLLink" }

@_ZN2rw7Texture9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw7Texture13setMipmappingEi(i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw7Texture13getMipmappingEv() #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw7Texture17getAutoMipmappingEv() #0 align 2

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw7Texture7destroyEv(ptr noundef nonnull align 8 dereferenceable(120)) #4 align 2

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

declare noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw7Texture4readEPKcS2_(ptr noundef, ptr noundef) #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw7Texture10streamReadEPNS_6StreamE(ptr noundef %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca [128 x i8], align 16
  %6 = alloca [128 x i8], align 16
  %7 = alloca %"struct.rw::Error", align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.rw::Error", align 4
  %11 = alloca %"struct.rw::Error", align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr %6) #5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %16, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %17, label %29, label %18

18:                                               ; preds = %1
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %20 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 0
  store i32 0, ptr %20, align 4, !tbaa !9
  %21 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 1
  store i32 -2147483644, ptr %21, align 4, !tbaa !12
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 371) #5
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.7)
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.5, ptr noundef %25) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %27

27:                                               ; preds = %19
  br label %28

28:                                               ; preds = %27
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %135

29:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %30)
  store i32 %31, ptr %9, align 4, !tbaa !13
  %32 = load i32, ptr %9, align 4, !tbaa !13
  %33 = and i32 %32, 61440
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %29
  %36 = load i32, ptr %9, align 4, !tbaa !13
  %37 = and i32 %36, 3840
  %38 = shl i32 %37, 4
  %39 = load i32, ptr %9, align 4, !tbaa !13
  %40 = or i32 %39, %38
  store i32 %40, ptr %9, align 4, !tbaa !13
  br label %41

41:                                               ; preds = %35, %29
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %42, i32 noundef 2, ptr noundef %4, ptr noundef null)
  br i1 %43, label %55, label %44

44:                                               ; preds = %41
  br label %45

45:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %46 = getelementptr inbounds %"struct.rw::Error", ptr %10, i32 0, i32 0
  store i32 0, ptr %46, align 4, !tbaa !9
  %47 = getelementptr inbounds %"struct.rw::Error", ptr %10, i32 0, i32 1
  store i32 -2147483644, ptr %47, align 4, !tbaa !12
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 383) #5
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.10)
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.5, ptr noundef %51) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %53

53:                                               ; preds = %45
  br label %54

54:                                               ; preds = %53
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %134

55:                                               ; preds = %41
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %58 = load i32, ptr %4, align 4, !tbaa !13
  %59 = load ptr, ptr %56, align 8, !tbaa !14
  %60 = getelementptr inbounds ptr, ptr %59, i64 4
  %61 = load ptr, ptr %60, align 8
  %62 = call noundef i32 %61(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef %57, i32 noundef %58)
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %63, i32 noundef 2, ptr noundef %4, ptr noundef null)
  br i1 %64, label %76, label %65

65:                                               ; preds = %55
  br label %66

66:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %67 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 0
  store i32 0, ptr %67, align 4, !tbaa !9
  %68 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 1
  store i32 -2147483644, ptr %68, align 4, !tbaa !12
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 389) #5
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.10)
  %73 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.5, ptr noundef %72) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %74

74:                                               ; preds = %66
  br label %75

75:                                               ; preds = %74
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %134

76:                                               ; preds = %55
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %79 = load i32, ptr %4, align 4, !tbaa !13
  %80 = load ptr, ptr %77, align 8, !tbaa !14
  %81 = getelementptr inbounds ptr, ptr %80, i64 4
  %82 = load ptr, ptr %81, align 8
  %83 = call noundef i32 %82(ptr noundef nonnull align 8 dereferenceable(8) %77, ptr noundef %78, i32 noundef %79)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %84 = call noundef i32 @_ZN2rw7Texture13getMipmappingEv()
  store i32 %84, ptr %12, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %85 = call noundef i32 @_ZN2rw7Texture17getAutoMipmappingEv()
  store i32 %85, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %86 = load i32, ptr %9, align 4, !tbaa !13
  %87 = and i32 %86, 255
  store i32 %87, ptr %14, align 4, !tbaa !13
  %88 = load i32, ptr %14, align 4, !tbaa !13
  %89 = icmp eq i32 %88, 3
  br i1 %89, label %99, label %90

90:                                               ; preds = %76
  %91 = load i32, ptr %14, align 4, !tbaa !13
  %92 = icmp eq i32 %91, 4
  br i1 %92, label %99, label %93

93:                                               ; preds = %90
  %94 = load i32, ptr %14, align 4, !tbaa !13
  %95 = icmp eq i32 %94, 5
  br i1 %95, label %99, label %96

96:                                               ; preds = %93
  %97 = load i32, ptr %14, align 4, !tbaa !13
  %98 = icmp eq i32 %97, 6
  br i1 %98, label %99, label %104

99:                                               ; preds = %96, %93, %90, %76
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef 1)
  %100 = load i32, ptr %9, align 4, !tbaa !13
  %101 = and i32 %100, 65536
  %102 = icmp eq i32 %101, 0
  %103 = zext i1 %102 to i32
  call void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef %103)
  br label %105

104:                                              ; preds = %96
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef 0)
  call void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef 0)
  br label %105

105:                                              ; preds = %104, %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %106 = getelementptr inbounds [128 x i8], ptr %5, i64 0, i64 0
  %107 = getelementptr inbounds [128 x i8], ptr %6, i64 0, i64 0
  %108 = call noundef ptr @_ZN2rw7Texture4readEPKcS2_(ptr noundef %106, ptr noundef %107)
  store ptr %108, ptr %15, align 8, !tbaa !5
  %109 = load i32, ptr %12, align 4, !tbaa !13
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef %109)
  %110 = load i32, ptr %13, align 4, !tbaa !13
  call void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef %110)
  %111 = load ptr, ptr %15, align 8, !tbaa !5
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %105
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw10PluginList10streamSkipEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw7Texture9s_plglistE, ptr noundef %114)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %133

115:                                              ; preds = %105
  %116 = load ptr, ptr %15, align 8, !tbaa !5
  %117 = getelementptr inbounds %"struct.rw::Texture", ptr %116, i32 0, i32 6
  %118 = load i32, ptr %117, align 4, !tbaa !16
  %119 = icmp eq i32 %118, 1
  br i1 %119, label %120, label %125

120:                                              ; preds = %115
  %121 = load i32, ptr %9, align 4, !tbaa !13
  %122 = and i32 %121, 65535
  %123 = load ptr, ptr %15, align 8, !tbaa !5
  %124 = getelementptr inbounds %"struct.rw::Texture", ptr %123, i32 0, i32 5
  store i32 %122, ptr %124, align 8, !tbaa !19
  br label %125

125:                                              ; preds = %120, %115
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = load ptr, ptr %15, align 8, !tbaa !5
  %128 = call noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw7Texture9s_plglistE, ptr noundef %126, ptr noundef %127)
  br i1 %128, label %129, label %131

129:                                              ; preds = %125
  %130 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %130, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %133

131:                                              ; preds = %125
  %132 = load ptr, ptr %15, align 8, !tbaa !5
  call void @_ZN2rw7Texture7destroyEv(ptr noundef nonnull align 8 dereferenceable(120) %132)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %8, align 4
  br label %133

133:                                              ; preds = %131, %129, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %134

134:                                              ; preds = %133, %75, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %135

135:                                              ; preds = %134, %28
  call void @llvm.lifetime.end.p0(i64 128, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %136 = load ptr, ptr %2, align 8
  ret ptr %136
}

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

declare void @_ZN2rw10PluginList10streamSkipEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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, !11, i64 0}
!10 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !8, i64 0}
!16 = !{!17, !11, i64 100}
!17 = !{!"_ZTSN2rw7TextureE", !6, i64 0, !6, i64 8, !18, i64 16, !7, i64 32, !7, i64 64, !11, i64 96, !11, i64 100, !18, i64 104}
!18 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!19 = !{!17, !11, i64 96}


; 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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }

@_ZN2rw7Texture9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw7Texture13setMipmappingEi(i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw7Texture13getMipmappingEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw7Texture17getAutoMipmappingEv() local_unnamed_addr #0 align 2

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw7Texture7destroyEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #4 align 2

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

declare noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw7Texture4readEPKcS2_(ptr noundef, ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw7Texture10streamReadEPNS_6StreamE(ptr noundef %0) local_unnamed_addr #4 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca [128 x i8], align 16
  %4 = alloca [128 x i8], align 16
  %5 = alloca %"struct.rw::Error", align 4
  %6 = alloca %"struct.rw::Error", align 4
  %7 = alloca %"struct.rw::Error", align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %4) #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 = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store i32 0, ptr %5, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, 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.3, ptr noundef nonnull @.str.4, i32 noundef 371) #6
  %13 = load ptr, ptr @stderr, align 8, !tbaa !11
  %14 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.7)
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.5, ptr noundef %14) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %73

16:                                               ; preds = %1
  %17 = tail call noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %18 = and i32 %17, 61440
  %19 = icmp eq i32 %18, 0
  %20 = shl i32 %17, 4
  %21 = and i32 %20, 61440
  %22 = select i1 %19, i32 %21, i32 0
  %23 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef nonnull %0, i32 noundef 2, ptr noundef nonnull %2, ptr noundef null)
  br i1 %23, label %31, label %24

24:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 -2147483644, ptr %25, align 4, !tbaa !10
  %26 = load ptr, ptr @stderr, align 8, !tbaa !11
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 383) #6
  %28 = load ptr, ptr @stderr, align 8, !tbaa !11
  %29 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.10)
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.5, ptr noundef %29) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %73

31:                                               ; preds = %16
  %32 = load i32, ptr %2, align 4, !tbaa !13
  %33 = load ptr, ptr %0, align 8, !tbaa !14
  %34 = getelementptr inbounds i8, ptr %33, i64 32
  %35 = load ptr, ptr %34, align 8
  %36 = call noundef i32 %35(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %3, i32 noundef %32)
  %37 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef nonnull %0, i32 noundef 2, ptr noundef nonnull %2, ptr noundef null)
  br i1 %37, label %45, label %38

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 -2147483644, ptr %39, align 4, !tbaa !10
  %40 = load ptr, ptr @stderr, align 8, !tbaa !11
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef 389) #6
  %42 = load ptr, ptr @stderr, align 8, !tbaa !11
  %43 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.10)
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.5, ptr noundef %43) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %73

45:                                               ; preds = %31
  %46 = load i32, ptr %2, align 4, !tbaa !13
  %47 = load ptr, ptr %0, align 8, !tbaa !14
  %48 = getelementptr inbounds i8, ptr %47, i64 32
  %49 = load ptr, ptr %48, align 8
  %50 = call noundef i32 %49(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull %4, i32 noundef %46)
  %51 = call noundef i32 @_ZN2rw7Texture13getMipmappingEv()
  %52 = call noundef i32 @_ZN2rw7Texture17getAutoMipmappingEv()
  %53 = and i32 %17, 255
  %54 = add nsw i32 %53, -3
  %or.cond5 = icmp ult i32 %54, 4
  br i1 %or.cond5, label %55, label %58

55:                                               ; preds = %45
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef 1)
  %56 = lshr i32 %17, 16
  %.lobit = and i32 %56, 1
  %57 = xor i32 %.lobit, 1
  br label %59

58:                                               ; preds = %45
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef 0)
  br label %59

59:                                               ; preds = %58, %55
  %.sink = phi i32 [ 0, %58 ], [ %57, %55 ]
  call void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef %.sink)
  %60 = call noundef ptr @_ZN2rw7Texture4readEPKcS2_(ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @_ZN2rw7Texture13setMipmappingEi(i32 noundef %51)
  call void @_ZN2rw7Texture17setAutoMipmappingEi(i32 noundef %52)
  %61 = icmp eq ptr %60, null
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  call void @_ZN2rw10PluginList10streamSkipEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw7Texture9s_plglistE, ptr noundef nonnull %0)
  br label %73

63:                                               ; preds = %59
  %64 = getelementptr inbounds i8, ptr %60, i64 100
  %65 = load i32, ptr %64, align 4, !tbaa !16
  %66 = icmp eq i32 %65, 1
  br i1 %66, label %67, label %70

67:                                               ; preds = %63
  %.masked = and i32 %17, 65535
  %68 = or i32 %22, %.masked
  %69 = getelementptr inbounds i8, ptr %60, i64 96
  store i32 %68, ptr %69, align 8, !tbaa !19
  br label %70

70:                                               ; preds = %67, %63
  %71 = call noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw7Texture9s_plglistE, ptr noundef nonnull %0, ptr noundef nonnull %60)
  br i1 %71, label %73, label %72

72:                                               ; preds = %70
  call void @_ZN2rw7Texture7destroyEv(ptr noundef nonnull align 8 dereferenceable(120) %60)
  br label %73

73:                                               ; preds = %24, %38, %70, %72, %62, %9
  %.2 = phi ptr [ null, %9 ], [ null, %38 ], [ null, %24 ], [ null, %62 ], [ null, %72 ], [ %60, %70 ]
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret ptr %.2
}

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

declare void @_ZN2rw10PluginList10streamSkipEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !9, i64 0}
!16 = !{!17, !7, i64 100}
!17 = !{!"_ZTSN2rw7TextureE", !12, i64 0, !12, i64 8, !18, i64 16, !8, i64 32, !8, i64 64, !7, i64 96, !7, i64 100, !18, i64 104}
!18 = !{!"_ZTSN2rw6LLLinkE", !12, i64 0, !12, i64 8}
!19 = !{!17, !7, i64 96}


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