; LLVM IR from aap/librw :: src/raster.ll (ZN2rw6Raster27convertTexToCurrentPlatformEPS0_)

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

@_ZN2rw8platformE = external global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #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: 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 @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw6Raster21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_i(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Raster27convertTexToCurrentPlatformEPS0_(ptr noundef %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::Raster", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %1
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %22, ptr %2, align 8
  br label %163

23:                                               ; preds = %1
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.rw::Raster", ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 8, !tbaa !9
  %27 = icmp eq i32 %26, 8
  br i1 %27, label %28, label %31

28:                                               ; preds = %23
  %29 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %30 = icmp eq i32 %29, 9
  br i1 %30, label %39, label %31

31:                                               ; preds = %28, %23
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.rw::Raster", ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = icmp eq i32 %34, 9
  br i1 %35, label %36, label %41

36:                                               ; preds = %31
  %37 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %38 = icmp eq i32 %37, 8
  br i1 %38, label %39, label %41

39:                                               ; preds = %36, %28
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %40, ptr %2, align 8
  br label %163

41:                                               ; preds = %36, %31
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.rw::Raster", ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !9
  %45 = icmp eq i32 %44, 8
  br i1 %45, label %51, label %46

46:                                               ; preds = %41
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.rw::Raster", ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = icmp eq i32 %49, 9
  br i1 %50, label %51, label %66

51:                                               ; preds = %46, %41
  %52 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %53 = icmp eq i32 %52, 12
  br i1 %53, label %54, label %66

54:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call noundef ptr @_ZN2rwL10d3d_to_gl3EPNS_6RasterE(ptr noundef %55)
  store ptr %56, ptr %4, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %62

59:                                               ; preds = %54
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %60)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %61, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %63

62:                                               ; preds = %54
  store i32 0, ptr %5, align 4
  br label %63

63:                                               ; preds = %62, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %64 = load i32, ptr %5, align 4
  switch i32 %64, label %165 [
    i32 0, label %65
    i32 1, label %163
  ]

65:                                               ; preds = %63
  br label %111

66:                                               ; preds = %51, %46
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::Raster", ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 8, !tbaa !9
  %70 = icmp eq i32 %69, 5
  br i1 %70, label %71, label %89

71:                                               ; preds = %66
  %72 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %73 = icmp eq i32 %72, 9
  br i1 %73, label %77, label %74

74:                                               ; preds = %71
  %75 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %76 = icmp eq i32 %75, 8
  br i1 %76, label %77, label %89

77:                                               ; preds = %74, %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call noundef ptr @_ZN2rwL11xbox_to_d3dEPNS_6RasterE(ptr noundef %78)
  store ptr %79, ptr %6, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %85

82:                                               ; preds = %77
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %83)
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %84, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %86

85:                                               ; preds = %77
  store i32 0, ptr %5, align 4
  br label %86

86:                                               ; preds = %85, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %87 = load i32, ptr %5, align 4
  switch i32 %87, label %165 [
    i32 0, label %88
    i32 1, label %163
  ]

88:                                               ; preds = %86
  br label %110

89:                                               ; preds = %74, %66
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.rw::Raster", ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 8, !tbaa !9
  %93 = icmp eq i32 %92, 5
  br i1 %93, label %94, label %109

94:                                               ; preds = %89
  %95 = load i32, ptr @_ZN2rw8platformE, align 4, !tbaa !12
  %96 = icmp eq i32 %95, 12
  br i1 %96, label %97, label %109

97:                                               ; preds = %94
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = call noundef ptr @_ZN2rwL11xbox_to_gl3EPNS_6RasterE(ptr noundef %98)
  store ptr %99, ptr %7, align 8, !tbaa !5
  %100 = load ptr, ptr %7, align 8, !tbaa !5
  %101 = icmp ne ptr %100, null
  br i1 %101, label %102, label %105

102:                                              ; preds = %97
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %103)
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %104, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %106

105:                                              ; preds = %97
  store i32 0, ptr %5, align 4
  br label %106

106:                                              ; preds = %105, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %107 = load i32, ptr %5, align 4
  switch i32 %107, label %165 [
    i32 0, label %108
    i32 1, label %163
  ]

108:                                              ; preds = %106
  br label %109

109:                                              ; preds = %108, %94, %89
  br label %110

110:                                              ; preds = %109, %88
  br label %111

111:                                              ; preds = %110, %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = call noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96) %112)
  store ptr %113, ptr %12, align 8, !tbaa !5
  %114 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %114, i1 noundef zeroext false)
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = call noundef i32 @_ZN2rw6Raster21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_i(ptr noundef %115, i32 noundef 4, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11, i32 noundef 0)
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  %118 = getelementptr inbounds %"struct.rw::Raster", ptr %117, i32 0, i32 4
  %119 = load i32, ptr %118, align 8, !tbaa !13
  %120 = and i32 %119, 36864
  %121 = load i32, ptr %11, align 4, !tbaa !12
  %122 = or i32 %121, %120
  store i32 %122, ptr %11, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %123 = load i32, ptr %8, align 4, !tbaa !12
  %124 = load i32, ptr %9, align 4, !tbaa !12
  %125 = load i32, ptr %10, align 4, !tbaa !12
  %126 = load i32, ptr %11, align 4, !tbaa !12
  %127 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %123, i32 noundef %124, i32 noundef %125, i32 noundef %126, i32 noundef 0)
  store ptr %127, ptr %13, align 8, !tbaa !5
  %128 = load ptr, ptr %13, align 8, !tbaa !5
  %129 = load ptr, ptr %12, align 8, !tbaa !5
  %130 = call noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96) %128, ptr noundef %129, i32 noundef 0)
  %131 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %131)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = call noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96) %132)
  store i32 %133, ptr %14, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 1, ptr %15, align 4, !tbaa !12
  br label %134

134:                                              ; preds = %156, %111
  %135 = load i32, ptr %15, align 4, !tbaa !12
  %136 = load i32, ptr %14, align 4, !tbaa !12
  %137 = icmp slt i32 %135, %136
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %159

139:                                              ; preds = %134
  %140 = load ptr, ptr %3, align 8, !tbaa !5
  %141 = load i32, ptr %15, align 4, !tbaa !12
  %142 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %140, i32 noundef %141, i32 noundef 2)
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = call noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96) %143)
  store ptr %144, ptr %12, align 8, !tbaa !5
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %145, i1 noundef zeroext false)
  %146 = load ptr, ptr %13, align 8, !tbaa !5
  %147 = load i32, ptr %15, align 4, !tbaa !12
  %148 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %146, i32 noundef %147, i32 noundef 5)
  %149 = load ptr, ptr %13, align 8, !tbaa !5
  %150 = load ptr, ptr %12, align 8, !tbaa !5
  %151 = call noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96) %149, ptr noundef %150, i32 noundef 0)
  %152 = load ptr, ptr %13, align 8, !tbaa !5
  %153 = load i32, ptr %15, align 4, !tbaa !12
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %152, i32 noundef %153)
  %154 = load ptr, ptr %3, align 8, !tbaa !5
  %155 = load i32, ptr %15, align 4, !tbaa !12
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %154, i32 noundef %155)
  br label %156

156:                                              ; preds = %139
  %157 = load i32, ptr %15, align 4, !tbaa !12
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %15, align 4, !tbaa !12
  br label %134, !llvm.loop !14

159:                                              ; preds = %138
  %160 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %160)
  %161 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %161, ptr %3, align 8, !tbaa !5
  %162 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %162, ptr %2, align 8
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %163

163:                                              ; preds = %159, %106, %86, %63, %39, %21
  %164 = load ptr, ptr %2, align 8
  ret ptr %164

165:                                              ; preds = %106, %86, %63
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL10d3d_to_gl3EPNS_6RasterE(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN2rwL11xbox_to_d3dEPNS_6RasterE(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL11xbox_to_gl3EPNS_6RasterE(ptr noundef) #2

declare void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40), i1 noundef zeroext) #3

declare void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"_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, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !6, i64 80, !11, i64 88, !11, i64 92}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"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"

@_ZN2rw8platformE = external local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) 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: 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 @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw6Raster21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_i(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96), ptr noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw6Raster27convertTexToCurrentPlatformEPS0_(ptr noundef %0) local_unnamed_addr #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = load i32, ptr @_ZN2rw8platformE, align 4
  %8 = icmp eq i32 %6, %7
  br i1 %8, label %51, label %9

9:                                                ; preds = %1
  %10 = icmp eq i32 %6, 8
  %11 = icmp eq i32 %7, 9
  %or.cond = and i1 %10, %11
  br i1 %or.cond, label %51, label %12

12:                                               ; preds = %9
  %13 = icmp eq i32 %6, 9
  %14 = icmp eq i32 %7, 8
  %or.cond3 = and i1 %13, %14
  br i1 %or.cond3, label %51, label %15

15:                                               ; preds = %12
  %.old4 = icmp eq i32 %7, 12
  br i1 %10, label %17, label %16

16:                                               ; preds = %15
  %or.cond5 = and i1 %13, %.old4
  br i1 %or.cond5, label %18, label %21

17:                                               ; preds = %15
  br i1 %.old4, label %18, label %.thread

18:                                               ; preds = %16, %17
  %19 = tail call noundef ptr @_ZN2rwL10d3d_to_gl3EPNS_6RasterE(ptr noundef nonnull %0)
  %.not68.not = icmp eq ptr %19, null
  br i1 %.not68.not, label %.thread, label %20

20:                                               ; preds = %18
  tail call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br label %51

21:                                               ; preds = %16
  %22 = icmp eq i32 %6, 5
  br i1 %22, label %23, label %.thread

23:                                               ; preds = %21
  %24 = and i32 %7, -2
  %or.cond8 = icmp eq i32 %24, 8
  br i1 %or.cond8, label %25, label %28

25:                                               ; preds = %23
  %26 = tail call noundef ptr @_ZN2rwL11xbox_to_d3dEPNS_6RasterE(ptr noundef nonnull %0)
  %.not67.not = icmp eq ptr %26, null
  br i1 %.not67.not, label %.thread, label %27

27:                                               ; preds = %25
  tail call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br label %51

28:                                               ; preds = %23
  br i1 %.old4, label %29, label %.thread

29:                                               ; preds = %28
  %30 = tail call noundef ptr @_ZN2rwL11xbox_to_gl3EPNS_6RasterE(ptr noundef nonnull %0)
  %.not.not = icmp eq ptr %30, null
  br i1 %.not.not, label %.thread, label %31

31:                                               ; preds = %29
  tail call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  br label %51

.thread:                                          ; preds = %29, %17, %21, %25, %18, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %32 = tail call noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  tail call void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %32, i1 noundef zeroext false)
  %33 = call noundef i32 @_ZN2rw6Raster21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_i(ptr noundef nonnull %32, i32 noundef 4, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef nonnull %5, i32 noundef 0)
  %34 = getelementptr inbounds i8, ptr %0, i64 16
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = and i32 %35, 36864
  %37 = load i32, ptr %5, align 4, !tbaa !12
  %38 = or i32 %37, %36
  store i32 %38, ptr %5, align 4, !tbaa !12
  %39 = load i32, ptr %2, align 4, !tbaa !12
  %40 = load i32, ptr %3, align 4, !tbaa !12
  %41 = load i32, ptr %4, align 4, !tbaa !12
  %42 = call noundef ptr @_ZN2rw6Raster6createEiiiii(i32 noundef %39, i32 noundef %40, i32 noundef %41, i32 noundef %38, i32 noundef 0)
  %43 = call noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96) %42, ptr noundef nonnull %32, i32 noundef 0)
  call void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %32)
  %44 = call noundef i32 @_ZN2rw6Raster12getNumLevelsEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.thread
  call void @_ZN2rw6Raster7destroyEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %51

.lr.ph:                                           ; preds = %.thread, %.lr.ph
  %.081 = phi i32 [ %50, %.lr.ph ], [ 1, %.thread ]
  %46 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.081, i32 noundef 2)
  %47 = call noundef ptr @_ZN2rw6Raster7toImageEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  call void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40) %47, i1 noundef zeroext false)
  %48 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %42, i32 noundef %.081, i32 noundef 5)
  %49 = call noundef ptr @_ZN2rw6Raster12setFromImageEPNS_5ImageEi(ptr noundef nonnull align 8 dereferenceable(96) %42, ptr noundef nonnull %47, i32 noundef 0)
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %42, i32 noundef %.081)
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef %.081)
  %50 = add nuw nsw i32 %.081, 1
  %exitcond.not = icmp eq i32 %50, %44
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

51:                                               ; preds = %31, %27, %20, %9, %12, %1, %._crit_edge
  %.3 = phi ptr [ %19, %20 ], [ %42, %._crit_edge ], [ %26, %27 ], [ %30, %31 ], [ %0, %1 ], [ %0, %12 ], [ %0, %9 ]
  ret ptr %.3
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL10d3d_to_gl3EPNS_6RasterE(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZN2rwL11xbox_to_d3dEPNS_6RasterE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZN2rwL11xbox_to_gl3EPNS_6RasterE(ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw5Image11unpalettizeEb(ptr noundef nonnull align 8 dereferenceable(40), i1 noundef zeroext) local_unnamed_addr #3

declare void @_ZN2rw5Image7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"_ZTSN2rw6RasterE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !7, i64 68, !7, i64 72, !10, i64 80, !7, i64 88, !7, i64 92}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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