; LLVM IR from aap/librw :: src/gl/gl3raster.ll (ZN2rw3gl313rasterToImageEPNS_6RasterE)

; 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::Raster" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, i32, i32 }
%"struct.rw::gl3::Gl3Raster" = type { i32, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i32, i32, ptr, ptr }
%"struct.rw::Image" = type { i32, i32, i32, i32, i32, i32, ptr, ptr }

@_ZN2rw3gl318nativeRasterOffsetE = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #2

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

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

declare noundef ptr @_ZN2rw5Image6createEiii(i32 noundef, i32 noundef, i32 noundef) #2

declare void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef, ptr noundef) #2

declare void @_ZN2rw23conv_RGB888_from_RGB888EPhS0_(ptr noundef, ptr noundef) #2

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

declare void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96), i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3gl313rasterToImageEPNS_6RasterE(ptr noundef %0) #4 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %"struct.rw::Error", align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca %"struct.rw::Error", align 4
  %12 = alloca %"struct.rw::Error", align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = 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 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 0, ptr %6, align 1, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.rw::Raster", ptr %21, i32 0, i32 9
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %28

25:                                               ; preds = %1
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %26, i32 noundef 0, i32 noundef 2)
  store i8 1, ptr %6, align 1, !tbaa !9
  br label %28

28:                                               ; preds = %25, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load i32, ptr @_ZN2rw3gl318nativeRasterOffsetE, align 4, !tbaa !14
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %29, i64 %31
  store ptr %32, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.rw::gl3::Gl3Raster", ptr %33, i32 0, i32 5
  %35 = load i8, ptr %34, align 4, !tbaa !15, !range !17, !noundef !18
  %36 = trunc i8 %35 to i1
  br i1 %36, label %37, label %48

37:                                               ; preds = %28
  br label %38

38:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %39 = getelementptr inbounds %"struct.rw::Error", ptr %8, i32 0, i32 0
  store i32 2816, ptr %39, align 4, !tbaa !19
  %40 = getelementptr inbounds %"struct.rw::Error", ptr %8, i32 0, i32 1
  store i32 -2147483638, ptr %40, align 4, !tbaa !21
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 748) #5
  %43 = load ptr, ptr @stderr, align 8, !tbaa !5
  %44 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.2, ptr noundef %44) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %46

46:                                               ; preds = %38
  br label %47

47:                                               ; preds = %46
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %198

48:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.rw::Raster", ptr %49, i32 0, i32 4
  %51 = load i32, ptr %50, align 8, !tbaa !22
  %52 = and i32 %51, 3840
  switch i32 %52, label %56 [
    i32 256, label %53
    i32 1280, label %54
    i32 1536, label %55
    i32 2560, label %57
    i32 512, label %57
    i32 768, label %57
    i32 1024, label %57
  ]

53:                                               ; preds = %48
  store i32 16, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw27conv_ARGB1555_from_RGBA5551EPhS0_, ptr %10, align 8, !tbaa !5
  br label %68

54:                                               ; preds = %48
  store i32 32, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_, ptr %10, align 8, !tbaa !5
  br label %68

55:                                               ; preds = %48
  store i32 24, ptr %4, align 4, !tbaa !14
  store ptr @_ZN2rw23conv_RGB888_from_RGB888EPhS0_, ptr %10, align 8, !tbaa !5
  br label %68

56:                                               ; preds = %48
  br label %57

57:                                               ; preds = %56, %48, %48, %48, %48
  br label %58

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %59 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 0
  store i32 2816, ptr %59, align 4, !tbaa !19
  %60 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 1
  store i32 -2147483638, ptr %60, align 4, !tbaa !21
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 772) #5
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.2, ptr noundef %64) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %66

66:                                               ; preds = %58
  br label %67

67:                                               ; preds = %66
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %197

68:                                               ; preds = %55, %54, %53
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.rw::Raster", ptr %69, i32 0, i32 4
  %71 = load i32, ptr %70, align 8, !tbaa !22
  %72 = and i32 %71, 16384
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %80, label %74

74:                                               ; preds = %68
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.rw::Raster", ptr %75, i32 0, i32 4
  %77 = load i32, ptr %76, align 8, !tbaa !22
  %78 = and i32 %77, 8192
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %91

80:                                               ; preds = %74, %68
  br label %81

81:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %82 = getelementptr inbounds %"struct.rw::Error", ptr %12, i32 0, i32 0
  store i32 2816, ptr %82, align 4, !tbaa !19
  %83 = getelementptr inbounds %"struct.rw::Error", ptr %12, i32 0, i32 1
  store i32 -2147483638, ptr %83, align 4, !tbaa !21
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 778) #5
  %86 = load ptr, ptr @stderr, align 8, !tbaa !5
  %87 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %86, ptr noundef @.str.2, ptr noundef %87) #5
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %89

89:                                               ; preds = %81
  br label %90

90:                                               ; preds = %89
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %197

91:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.rw::Raster", ptr %92, i32 0, i32 5
  %94 = load i32, ptr %93, align 4, !tbaa !23
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %"struct.rw::Raster", ptr %95, i32 0, i32 6
  %97 = load i32, ptr %96, align 8, !tbaa !24
  %98 = load i32, ptr %4, align 4, !tbaa !14
  %99 = call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %94, i32 noundef %97, i32 noundef %98)
  store ptr %99, ptr %5, align 8, !tbaa !5
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %100)
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %"struct.rw::Image", ptr %101, i32 0, i32 6
  %103 = load ptr, ptr %102, align 8, !tbaa !25
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %"struct.rw::Image", ptr %104, i32 0, i32 2
  %106 = load i32, ptr %105, align 8, !tbaa !27
  %107 = sub nsw i32 %106, 1
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %"struct.rw::Image", ptr %108, i32 0, i32 5
  %110 = load i32, ptr %109, align 4, !tbaa !28
  %111 = mul nsw i32 %107, %110
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds i8, ptr %103, i64 %112
  store ptr %113, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.rw::Raster", ptr %114, i32 0, i32 9
  %116 = load ptr, ptr %115, align 8, !tbaa !11
  store ptr %116, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %117 = load ptr, ptr %5, align 8, !tbaa !5
  %118 = getelementptr inbounds %"struct.rw::Image", ptr %117, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !29
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %"struct.rw::Raster", ptr %120, i32 0, i32 5
  %122 = load i32, ptr %121, align 4, !tbaa !23
  %123 = icmp eq i32 %119, %122
  br i1 %123, label %124, label %125

124:                                              ; preds = %91
  br label %127

125:                                              ; preds = %91
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 790, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE) #6
  unreachable

126:                                              ; No predecessors!
  br label %127

127:                                              ; preds = %126, %124
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = getelementptr inbounds %"struct.rw::Image", ptr %128, i32 0, i32 2
  %130 = load i32, ptr %129, align 8, !tbaa !27
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %"struct.rw::Raster", ptr %131, i32 0, i32 6
  %133 = load i32, ptr %132, align 8, !tbaa !24
  %134 = icmp eq i32 %130, %133
  br i1 %134, label %135, label %136

135:                                              ; preds = %127
  br label %138

136:                                              ; preds = %127
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 791, ptr noundef @__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE) #6
  unreachable

137:                                              ; No predecessors!
  br label %138

138:                                              ; preds = %137, %135
  store i32 0, ptr %18, align 4, !tbaa !14
  br label %139

139:                                              ; preds = %187, %138
  %140 = load i32, ptr %18, align 4, !tbaa !14
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = getelementptr inbounds %"struct.rw::Image", ptr %141, i32 0, i32 2
  %143 = load i32, ptr %142, align 8, !tbaa !27
  %144 = icmp slt i32 %140, %143
  br i1 %144, label %145, label %190

145:                                              ; preds = %139
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %146 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %146, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %147 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %147, ptr %20, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !14
  br label %148

148:                                              ; preds = %170, %145
  %149 = load i32, ptr %17, align 4, !tbaa !14
  %150 = load ptr, ptr %5, align 8, !tbaa !5
  %151 = getelementptr inbounds %"struct.rw::Image", ptr %150, i32 0, i32 1
  %152 = load i32, ptr %151, align 4, !tbaa !29
  %153 = icmp slt i32 %149, %152
  br i1 %153, label %154, label %173

154:                                              ; preds = %148
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = load ptr, ptr %20, align 8, !tbaa !5
  call void %155(ptr noundef %156, ptr noundef %157)
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %159 = getelementptr inbounds %"struct.rw::Image", ptr %158, i32 0, i32 4
  %160 = load i32, ptr %159, align 8, !tbaa !30
  %161 = load ptr, ptr %19, align 8, !tbaa !5
  %162 = sext i32 %160 to i64
  %163 = getelementptr inbounds i8, ptr %161, i64 %162
  store ptr %163, ptr %19, align 8, !tbaa !5
  %164 = load ptr, ptr %7, align 8, !tbaa !5
  %165 = getelementptr inbounds %"struct.rw::gl3::Gl3Raster", ptr %164, i32 0, i32 3
  %166 = load i32, ptr %165, align 4, !tbaa !31
  %167 = load ptr, ptr %20, align 8, !tbaa !5
  %168 = sext i32 %166 to i64
  %169 = getelementptr inbounds i8, ptr %167, i64 %168
  store ptr %169, ptr %20, align 8, !tbaa !5
  br label %170

170:                                              ; preds = %154
  %171 = load i32, ptr %17, align 4, !tbaa !14
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %17, align 4, !tbaa !14
  br label %148, !llvm.loop !32

173:                                              ; preds = %148
  %174 = load ptr, ptr %5, align 8, !tbaa !5
  %175 = getelementptr inbounds %"struct.rw::Image", ptr %174, i32 0, i32 5
  %176 = load i32, ptr %175, align 4, !tbaa !28
  %177 = load ptr, ptr %15, align 8, !tbaa !5
  %178 = sext i32 %176 to i64
  %179 = sub i64 0, %178
  %180 = getelementptr inbounds i8, ptr %177, i64 %179
  store ptr %180, ptr %15, align 8, !tbaa !5
  %181 = load ptr, ptr %3, align 8, !tbaa !5
  %182 = getelementptr inbounds %"struct.rw::Raster", ptr %181, i32 0, i32 8
  %183 = load i32, ptr %182, align 8, !tbaa !34
  %184 = load ptr, ptr %16, align 8, !tbaa !5
  %185 = sext i32 %183 to i64
  %186 = getelementptr inbounds i8, ptr %184, i64 %185
  store ptr %186, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  br label %187

187:                                              ; preds = %173
  %188 = load i32, ptr %18, align 4, !tbaa !14
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %18, align 4, !tbaa !14
  br label %139, !llvm.loop !35

190:                                              ; preds = %139
  %191 = load i8, ptr %6, align 1, !tbaa !9, !range !17, !noundef !18
  %192 = trunc i8 %191 to i1
  br i1 %192, label %193, label %195

193:                                              ; preds = %190
  %194 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %194, i32 noundef 0)
  br label %195

195:                                              ; preds = %193, %190
  %196 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %196, ptr %2, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %197

197:                                              ; preds = %195, %90, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %198

198:                                              ; preds = %197, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %199 = load ptr, ptr %2, align 8
  ret ptr %199
}

declare void @_ZN2rw27conv_ARGB1555_from_RGBA5551EPhS0_(ptr noundef, ptr noundef) #2

declare void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40)) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 40}
!12 = !{!"_ZTSN2rw6RasterE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !6, i64 80, !13, i64 88, !13, i64 92}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !10, i64 20}
!16 = !{!"_ZTSN2rw3gl39Gl3RasterE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !10, i64 20, !10, i64 21, !10, i64 22, !7, i64 23, !7, i64 24, !7, i64 25, !7, i64 26, !13, i64 28, !13, i64 32, !6, i64 40, !6, i64 48}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !13, i64 0}
!20 = !{!"_ZTSN2rw5ErrorE", !13, i64 0, !13, i64 4}
!21 = !{!20, !13, i64 4}
!22 = !{!12, !13, i64 16}
!23 = !{!12, !13, i64 20}
!24 = !{!12, !13, i64 24}
!25 = !{!26, !6, i64 24}
!26 = !{!"_ZTSN2rw5ImageE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !6, i64 24, !6, i64 32}
!27 = !{!26, !13, i64 8}
!28 = !{!26, !13, i64 20}
!29 = !{!26, !13, i64 4}
!30 = !{!26, !13, i64 16}
!31 = !{!16, !13, i64 12}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = !{!12, !13, i64 32}
!35 = distinct !{!35, !33}


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

@_ZN2rw3gl318nativeRasterOffsetE = external dso_local local_unnamed_addr global i32, align 4
@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 [64 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE = external hidden unnamed_addr constant [40 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #2

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

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

declare noundef ptr @_ZN2rw5Image6createEiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw23conv_RGB888_from_RGB888EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw3gl313rasterToImageEPNS_6RasterE(ptr noundef %0) local_unnamed_addr #4 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = alloca %"struct.rw::Error", align 4
  %4 = alloca %"struct.rw::Error", align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %1
  %9 = tail call noundef ptr @_ZN2rw6Raster4lockEii(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0, i32 noundef 2)
  br label %10

10:                                               ; preds = %8, %1
  %11 = load i32, ptr @_ZN2rw3gl318nativeRasterOffsetE, align 4, !tbaa !11
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i8, ptr %0, i64 %12
  %14 = getelementptr inbounds i8, ptr %13, i64 20
  %15 = load i8, ptr %14, align 4, !tbaa !12, !range !15, !noundef !16
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %17, label %24

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

24:                                               ; preds = %10
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  %26 = load i32, ptr %25, align 8, !tbaa !21
  %27 = and i32 %26, 3840
  %28 = add nsw i32 %27, -256
  %29 = lshr exact i32 %28, 8
  switch i32 %29, label %32 [
    i32 0, label %39
    i32 4, label %30
    i32 5, label %31
  ]

30:                                               ; preds = %24
  br label %39

31:                                               ; preds = %24
  br label %39

32:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  store i32 2816, ptr %3, align 4, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 -2147483638, ptr %33, align 4, !tbaa !19
  %34 = load ptr, ptr @stderr, align 8, !tbaa !20
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 772) #6
  %36 = load ptr, ptr @stderr, align 8, !tbaa !20
  %37 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.2, ptr noundef %37) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  br label %104

39:                                               ; preds = %24, %31, %30
  %.048 = phi ptr [ @_ZN2rw23conv_RGB888_from_RGB888EPhS0_, %31 ], [ @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_, %30 ], [ @_ZN2rw27conv_ARGB1555_from_RGBA5551EPhS0_, %24 ]
  %.047 = phi i32 [ 24, %31 ], [ 32, %30 ], [ 16, %24 ]
  %40 = and i32 %26, 24576
  %or.cond = icmp eq i32 %40, 0
  br i1 %or.cond, label %48, label %41

41:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  store i32 2816, ptr %4, align 4, !tbaa !17
  %42 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 -2147483638, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr @stderr, align 8, !tbaa !20
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 778) #6
  %45 = load ptr, ptr @stderr, align 8, !tbaa !20
  %46 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483638)
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.2, ptr noundef %46) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %104

48:                                               ; preds = %39
  %49 = getelementptr inbounds i8, ptr %0, i64 20
  %50 = load i32, ptr %49, align 4, !tbaa !22
  %51 = getelementptr inbounds i8, ptr %0, i64 24
  %52 = load i32, ptr %51, align 8, !tbaa !23
  %53 = tail call noundef ptr @_ZN2rw5Image6createEiii(i32 noundef %50, i32 noundef %52, i32 noundef %.047)
  tail call void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40) %53)
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = getelementptr inbounds i8, ptr %53, i64 20
  %56 = getelementptr inbounds i8, ptr %53, i64 4
  %57 = load i32, ptr %56, align 4, !tbaa !24
  %58 = load i32, ptr %49, align 4, !tbaa !22
  %59 = icmp eq i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %48
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 790, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE) #7
  unreachable

61:                                               ; preds = %48
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %53, i64 24
  %64 = load ptr, ptr %63, align 8, !tbaa !26
  %65 = load i32, ptr %54, align 8, !tbaa !27
  %66 = add nsw i32 %65, -1
  %67 = load i32, ptr %55, align 4, !tbaa !28
  %68 = mul nsw i32 %66, %67
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds i8, ptr %64, i64 %69
  %71 = load i32, ptr %51, align 8, !tbaa !23
  %72 = icmp eq i32 %65, %71
  br i1 %72, label %.preheader51, label %78

.preheader51:                                     ; preds = %61
  %73 = icmp sgt i32 %65, 0
  br i1 %73, label %.preheader.lr.ph, label %._crit_edge58

.preheader.lr.ph:                                 ; preds = %.preheader51
  %74 = getelementptr inbounds i8, ptr %53, i64 16
  %75 = getelementptr inbounds i8, ptr %13, i64 12
  %76 = getelementptr inbounds i8, ptr %0, i64 32
  %77 = icmp sgt i32 %57, 0
  br i1 %77, label %.preheader, label %._crit_edge58

78:                                               ; preds = %61
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 791, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN2rw3gl313rasterToImageEPNS_6RasterE) #7
  unreachable

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %79 = phi i32 [ %92, %._crit_edge ], [ %65, %.preheader.lr.ph ]
  %80 = phi i32 [ %93, %._crit_edge ], [ %67, %.preheader.lr.ph ]
  %81 = phi i32 [ %94, %._crit_edge ], [ %57, %.preheader.lr.ph ]
  %.04257 = phi i32 [ %101, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.04456 = phi ptr [ %100, %._crit_edge ], [ %62, %.preheader.lr.ph ]
  %.04555 = phi ptr [ %97, %._crit_edge ], [ %70, %.preheader.lr.ph ]
  %82 = icmp sgt i32 %81, 0
  br i1 %82, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.054 = phi ptr [ %88, %.lr.ph ], [ %.04456, %.preheader ]
  %.04153 = phi ptr [ %85, %.lr.ph ], [ %.04555, %.preheader ]
  %.04352 = phi i32 [ %89, %.lr.ph ], [ 0, %.preheader ]
  tail call void %.048(ptr noundef %.04153, ptr noundef %.054), !callees !29
  %83 = load i32, ptr %74, align 8, !tbaa !30
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %.04153, i64 %84
  %86 = load i32, ptr %75, align 4, !tbaa !31
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %.054, i64 %87
  %89 = add nuw nsw i32 %.04352, 1
  %90 = load i32, ptr %56, align 4, !tbaa !24
  %91 = icmp slt i32 %89, %90
  br i1 %91, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !32

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %55, align 4, !tbaa !28
  %.pre60 = load i32, ptr %54, align 8, !tbaa !27
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %92 = phi i32 [ %.pre60, %._crit_edge.loopexit ], [ %79, %.preheader ]
  %93 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %80, %.preheader ]
  %94 = phi i32 [ %90, %._crit_edge.loopexit ], [ %81, %.preheader ]
  %95 = sext i32 %93 to i64
  %96 = sub nsw i64 0, %95
  %97 = getelementptr inbounds i8, ptr %.04555, i64 %96
  %98 = load i32, ptr %76, align 8, !tbaa !34
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i8, ptr %.04456, i64 %99
  %101 = add nuw nsw i32 %.04257, 1
  %102 = icmp slt i32 %101, %92
  br i1 %102, label %.preheader, label %._crit_edge58, !llvm.loop !35

._crit_edge58:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %.preheader51
  br i1 %7, label %103, label %104

103:                                              ; preds = %._crit_edge58
  tail call void @_ZN2rw6Raster6unlockEi(ptr noundef nonnull align 8 dereferenceable(96) %0, i32 noundef 0)
  br label %104

104:                                              ; preds = %32, %41, %103, %._crit_edge58, %17
  %.1 = phi ptr [ null, %17 ], [ null, %32 ], [ null, %41 ], [ %53, %103 ], [ %53, %._crit_edge58 ]
  ret ptr %.1
}

declare void @_ZN2rw27conv_ARGB1555_from_RGBA5551EPhS0_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN2rw5Image8allocateEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 #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 }
attributes #7 = { 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, !10, i64 40}
!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 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 20}
!13 = !{!"_ZTSN2rw3gl39Gl3RasterE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !14, i64 20, !14, i64 21, !14, i64 22, !8, i64 23, !8, i64 24, !8, i64 25, !8, i64 26, !7, i64 28, !7, i64 32, !10, i64 40, !10, i64 48}
!14 = !{!"bool", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !7, i64 0}
!18 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!19 = !{!18, !7, i64 4}
!20 = !{!10, !10, i64 0}
!21 = !{!6, !7, i64 16}
!22 = !{!6, !7, i64 20}
!23 = !{!6, !7, i64 24}
!24 = !{!25, !7, i64 4}
!25 = !{!"_ZTSN2rw5ImageE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32}
!26 = !{!25, !10, i64 24}
!27 = !{!25, !7, i64 8}
!28 = !{!25, !7, i64 20}
!29 = !{ptr @_ZN2rw23conv_RGB888_from_RGB888EPhS0_, ptr @_ZN2rw27conv_ARGB1555_from_RGBA5551EPhS0_, ptr @_ZN2rw27conv_RGBA8888_from_RGBA8888EPhS0_}
!30 = !{!25, !7, i64 16}
!31 = !{!13, !7, i64 12}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = !{!6, !7, i64 32}
!35 = distinct !{!35, !33, !36}
!36 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: CalledValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass