; LLVM IR from achilles288/robot-monitor-graphics :: src/base/bitmap.ll (ZN3rmg6Bitmap5pasteERKS0_ss)

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

%"class.rmg::Bitmap" = type { i16, i16, i8, ptr }

@__const._ZN3rmg6Bitmap5pasteERKS0_ss.lut = external hidden unnamed_addr constant [16 x i8], align 16

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6BitmapC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap11toGrayscaleEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap5toRGBEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap6toRGBAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg6Bitmap5pasteERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3) #3 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i16, align 2
  %8 = alloca i16, align 2
  %9 = alloca [16 x i8], align 16
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca %"class.rmg::Bitmap", align 8
  %14 = alloca %"class.rmg::Bitmap", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca %"class.rmg::Bitmap", align 8
  %18 = alloca %"class.rmg::Bitmap", align 8
  %19 = alloca %"class.rmg::Bitmap", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i16 %2, ptr %7, align 2, !tbaa !9
  store i16 %3, ptr %8, align 2, !tbaa !9
  %20 = load ptr, ptr %5, align 8
  %21 = load i16, ptr %7, align 2, !tbaa !9
  %22 = sext i16 %21 to i32
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.rmg::Bitmap", ptr %23, i32 0, i32 0
  %25 = load i16, ptr %24, align 8, !tbaa !11
  %26 = zext i16 %25 to i32
  %27 = add nsw i32 %22, %26
  %28 = icmp slt i32 %27, 1
  br i1 %28, label %52, label %29

29:                                               ; preds = %4
  %30 = load i16, ptr %7, align 2, !tbaa !9
  %31 = sext i16 %30 to i32
  %32 = getelementptr inbounds %"class.rmg::Bitmap", ptr %20, i32 0, i32 0
  %33 = load i16, ptr %32, align 8, !tbaa !11
  %34 = zext i16 %33 to i32
  %35 = icmp sge i32 %31, %34
  br i1 %35, label %52, label %36

36:                                               ; preds = %29
  %37 = load i16, ptr %8, align 2, !tbaa !9
  %38 = sext i16 %37 to i32
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.rmg::Bitmap", ptr %39, i32 0, i32 1
  %41 = load i16, ptr %40, align 2, !tbaa !13
  %42 = zext i16 %41 to i32
  %43 = add nsw i32 %38, %42
  %44 = icmp slt i32 %43, 1
  br i1 %44, label %52, label %45

45:                                               ; preds = %36
  %46 = load i16, ptr %8, align 2, !tbaa !9
  %47 = sext i16 %46 to i32
  %48 = getelementptr inbounds %"class.rmg::Bitmap", ptr %20, i32 0, i32 1
  %49 = load i16, ptr %48, align 2, !tbaa !13
  %50 = zext i16 %49 to i32
  %51 = icmp sge i32 %47, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %45, %36, %29, %4
  br label %202

53:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const._ZN3rmg6Bitmap5pasteERKS0_ss.lut, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %54 = getelementptr inbounds %"class.rmg::Bitmap", ptr %20, i32 0, i32 2
  %55 = load i8, ptr %54, align 4, !tbaa !14
  %56 = zext i8 %55 to i32
  %57 = sub nsw i32 %56, 1
  %58 = mul nsw i32 %57, 4
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.rmg::Bitmap", ptr %59, i32 0, i32 2
  %61 = load i8, ptr %60, align 4, !tbaa !14
  %62 = zext i8 %61 to i32
  %63 = add nsw i32 %58, %62
  %64 = sub nsw i32 %63, 1
  %65 = trunc i32 %64 to i8
  store i8 %65, ptr %10, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %66 = load i8, ptr %10, align 1, !tbaa !15
  %67 = zext i8 %66 to i64
  %68 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !15
  %70 = zext i8 %69 to i32
  %71 = and i32 %70, 15
  %72 = trunc i32 %71 to i8
  store i8 %72, ptr %11, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  %73 = load i8, ptr %10, align 1, !tbaa !15
  %74 = zext i8 %73 to i64
  %75 = getelementptr inbounds [16 x i8], ptr %9, i64 0, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !15
  %77 = zext i8 %76 to i32
  %78 = and i32 %77, 240
  %79 = trunc i32 %78 to i8
  store i8 %79, ptr %12, align 1, !tbaa !15
  %80 = load i8, ptr %11, align 1, !tbaa !15
  %81 = zext i8 %80 to i32
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %114

83:                                               ; preds = %53
  %84 = load i8, ptr %12, align 1, !tbaa !15
  %85 = zext i8 %84 to i32
  %86 = icmp eq i32 %85, 16
  br i1 %86, label %87, label %91

87:                                               ; preds = %83
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = load i16, ptr %7, align 2, !tbaa !9
  %90 = load i16, ptr %8, align 2, !tbaa !9
  call void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %88, i16 noundef signext %89, i16 noundef signext %90)
  br label %113

91:                                               ; preds = %83
  %92 = load i8, ptr %12, align 1, !tbaa !15
  %93 = zext i8 %92 to i32
  %94 = icmp eq i32 %93, 32
  br i1 %94, label %95, label %99

95:                                               ; preds = %91
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = load i16, ptr %7, align 2, !tbaa !9
  %98 = load i16, ptr %8, align 2, !tbaa !9
  call void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %96, i16 noundef signext %97, i16 noundef signext %98)
  br label %112

99:                                               ; preds = %91
  %100 = load i8, ptr %12, align 1, !tbaa !15
  %101 = zext i8 %100 to i32
  %102 = icmp eq i32 %101, 48
  br i1 %102, label %103, label %107

103:                                              ; preds = %99
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = load i16, ptr %7, align 2, !tbaa !9
  %106 = load i16, ptr %8, align 2, !tbaa !9
  call void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %104, i16 noundef signext %105, i16 noundef signext %106)
  br label %111

107:                                              ; preds = %99
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = load i16, ptr %7, align 2, !tbaa !9
  %110 = load i16, ptr %8, align 2, !tbaa !9
  call void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %108, i16 noundef signext %109, i16 noundef signext %110)
  br label %111

111:                                              ; preds = %107, %103
  br label %112

112:                                              ; preds = %111, %95
  br label %113

113:                                              ; preds = %112, %87
  br label %201

114:                                              ; preds = %53
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  call void @_ZN3rmg6BitmapC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  %115 = load i8, ptr %11, align 1, !tbaa !15
  %116 = zext i8 %115 to i32
  %117 = icmp eq i32 %116, 1
  br i1 %117, label %118, label %126

118:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNK3rmg6Bitmap11toGrayscaleEv(ptr dead_on_unwind writable sret(%"class.rmg::Bitmap") align 8 %14, ptr noundef nonnull align 8 dereferenceable(16) %119)
          to label %120 unwind label %122

120:                                              ; preds = %118
  %121 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %14) #4
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  br label %165

122:                                              ; preds = %118
  %123 = landingpad { ptr, i32 }
          cleanup
  %124 = extractvalue { ptr, i32 } %123, 0
  store ptr %124, ptr %15, align 8
  %125 = extractvalue { ptr, i32 } %123, 1
  store i32 %125, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  br label %200

126:                                              ; preds = %114
  %127 = load i8, ptr %11, align 1, !tbaa !15
  %128 = zext i8 %127 to i32
  %129 = icmp eq i32 %128, 2
  br i1 %129, label %130, label %138

130:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind writable sret(%"class.rmg::Bitmap") align 8 %17, ptr noundef nonnull align 8 dereferenceable(16) %131)
          to label %132 unwind label %134

132:                                              ; preds = %130
  %133 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %17) #4
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  br label %164

134:                                              ; preds = %130
  %135 = landingpad { ptr, i32 }
          cleanup
  %136 = extractvalue { ptr, i32 } %135, 0
  store ptr %136, ptr %15, align 8
  %137 = extractvalue { ptr, i32 } %135, 1
  store i32 %137, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  br label %200

138:                                              ; preds = %126
  %139 = load i8, ptr %11, align 1, !tbaa !15
  %140 = zext i8 %139 to i32
  %141 = icmp eq i32 %140, 3
  br i1 %141, label %142, label %150

142:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #4
  %143 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNK3rmg6Bitmap5toRGBEv(ptr dead_on_unwind writable sret(%"class.rmg::Bitmap") align 8 %18, ptr noundef nonnull align 8 dereferenceable(16) %143)
          to label %144 unwind label %146

144:                                              ; preds = %142
  %145 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %18) #4
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %18) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  br label %163

146:                                              ; preds = %142
  %147 = landingpad { ptr, i32 }
          cleanup
  %148 = extractvalue { ptr, i32 } %147, 0
  store ptr %148, ptr %15, align 8
  %149 = extractvalue { ptr, i32 } %147, 1
  store i32 %149, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #4
  br label %200

150:                                              ; preds = %138
  %151 = load i8, ptr %11, align 1, !tbaa !15
  %152 = zext i8 %151 to i32
  %153 = icmp eq i32 %152, 4
  br i1 %153, label %154, label %162

154:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #4
  %155 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNK3rmg6Bitmap6toRGBAEv(ptr dead_on_unwind writable sret(%"class.rmg::Bitmap") align 8 %19, ptr noundef nonnull align 8 dereferenceable(16) %155)
          to label %156 unwind label %158

156:                                              ; preds = %154
  %157 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %19) #4
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #4
  br label %162

158:                                              ; preds = %154
  %159 = landingpad { ptr, i32 }
          cleanup
  %160 = extractvalue { ptr, i32 } %159, 0
  store ptr %160, ptr %15, align 8
  %161 = extractvalue { ptr, i32 } %159, 1
  store i32 %161, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #4
  br label %200

162:                                              ; preds = %156, %150
  br label %163

163:                                              ; preds = %162, %144
  br label %164

164:                                              ; preds = %163, %132
  br label %165

165:                                              ; preds = %164, %120
  %166 = load i8, ptr %12, align 1, !tbaa !15
  %167 = zext i8 %166 to i32
  %168 = icmp eq i32 %167, 16
  br i1 %168, label %169, label %177

169:                                              ; preds = %165
  %170 = load i16, ptr %7, align 2, !tbaa !9
  %171 = load i16, ptr %8, align 2, !tbaa !9
  invoke void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %13, i16 noundef signext %170, i16 noundef signext %171)
          to label %172 unwind label %173

172:                                              ; preds = %169
  br label %199

173:                                              ; preds = %193, %189, %181, %169
  %174 = landingpad { ptr, i32 }
          cleanup
  %175 = extractvalue { ptr, i32 } %174, 0
  store ptr %175, ptr %15, align 8
  %176 = extractvalue { ptr, i32 } %174, 1
  store i32 %176, ptr %16, align 4
  br label %200

177:                                              ; preds = %165
  %178 = load i8, ptr %12, align 1, !tbaa !15
  %179 = zext i8 %178 to i32
  %180 = icmp eq i32 %179, 32
  br i1 %180, label %181, label %185

181:                                              ; preds = %177
  %182 = load i16, ptr %7, align 2, !tbaa !9
  %183 = load i16, ptr %8, align 2, !tbaa !9
  invoke void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %13, i16 noundef signext %182, i16 noundef signext %183)
          to label %184 unwind label %173

184:                                              ; preds = %181
  br label %198

185:                                              ; preds = %177
  %186 = load i8, ptr %12, align 1, !tbaa !15
  %187 = zext i8 %186 to i32
  %188 = icmp eq i32 %187, 48
  br i1 %188, label %189, label %193

189:                                              ; preds = %185
  %190 = load i16, ptr %7, align 2, !tbaa !9
  %191 = load i16, ptr %8, align 2, !tbaa !9
  invoke void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %13, i16 noundef signext %190, i16 noundef signext %191)
          to label %192 unwind label %173

192:                                              ; preds = %189
  br label %197

193:                                              ; preds = %185
  %194 = load i16, ptr %7, align 2, !tbaa !9
  %195 = load i16, ptr %8, align 2, !tbaa !9
  invoke void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %13, i16 noundef signext %194, i16 noundef signext %195)
          to label %196 unwind label %173

196:                                              ; preds = %193
  br label %197

197:                                              ; preds = %196, %192
  br label %198

198:                                              ; preds = %197, %184
  br label %199

199:                                              ; preds = %198, %172
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  br label %201

200:                                              ; preds = %173, %158, %146, %134, %122
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %203

201:                                              ; preds = %199, %113
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %202

202:                                              ; preds = %201, %52
  ret void

203:                                              ; preds = %200
  %204 = load ptr, ptr %15, align 8
  %205 = load i32, ptr %16, align 4
  %206 = insertvalue { ptr, i32 } poison, ptr %204, 0
  %207 = insertvalue { ptr, i32 } %206, i32 %205, 1
  resume { ptr, i32 } %207
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) #2 align 2

declare void @_ZN3rmg6BitmapD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 = { 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 #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, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN3rmg6BitmapE", !10, i64 0, !10, i64 2, !7, i64 4, !6, i64 8}
!13 = !{!12, !10, i64 2}
!14 = !{!12, !7, i64 4}
!15 = !{!7, !7, i64 0}


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

%"class.rmg::Bitmap" = type { i16, i16, i8, ptr }

@__const._ZN3rmg6Bitmap5pasteERKS0_ss.lut = external hidden unnamed_addr constant [16 x i8], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6BitmapC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap11toGrayscaleEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap5toRGBEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3rmg6Bitmap6toRGBAEv(ptr dead_on_unwind noalias writable sret(%"class.rmg::Bitmap") align 8, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg6Bitmap5pasteERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.rmg::Bitmap", align 8
  %6 = alloca %"class.rmg::Bitmap", align 8
  %7 = alloca %"class.rmg::Bitmap", align 8
  %8 = alloca %"class.rmg::Bitmap", align 8
  %9 = alloca %"class.rmg::Bitmap", align 8
  %10 = sext i16 %2 to i32
  %11 = load i16, ptr %1, align 8, !tbaa !5
  %12 = zext i16 %11 to i32
  %13 = add nsw i32 %12, %10
  %14 = icmp sgt i32 %13, 0
  %15 = load i16, ptr %0, align 8
  %16 = zext i16 %15 to i32
  %.not = icmp slt i32 %10, %16
  %or.cond = select i1 %14, i1 %.not, i1 false
  br i1 %or.cond, label %17, label %74

17:                                               ; preds = %4
  %18 = sext i16 %3 to i32
  %19 = getelementptr inbounds i8, ptr %1, i64 2
  %20 = load i16, ptr %19, align 2, !tbaa !11
  %21 = zext i16 %20 to i32
  %22 = add nsw i32 %21, %18
  %23 = icmp sgt i32 %22, 0
  %24 = getelementptr inbounds i8, ptr %0, i64 2
  %25 = load i16, ptr %24, align 2
  %26 = zext i16 %25 to i32
  %.not50 = icmp slt i32 %18, %26
  %or.cond55 = select i1 %23, i1 %.not50, i1 false
  br i1 %or.cond55, label %27, label %74

27:                                               ; preds = %17
  %28 = getelementptr inbounds i8, ptr %0, i64 4
  %29 = load i8, ptr %28, align 4, !tbaa !12
  %30 = shl i8 %29, 2
  %31 = getelementptr inbounds i8, ptr %1, i64 4
  %32 = load i8, ptr %31, align 4, !tbaa !12
  %33 = add i8 %30, -5
  %34 = add i8 %33, %32
  %35 = zext i8 %34 to i64
  %36 = getelementptr inbounds [16 x i8], ptr @__const._ZN3rmg6Bitmap5pasteERKS0_ss.lut, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = and i8 %37, 15
  %39 = and i8 %37, -16
  %40 = icmp eq i8 %38, 0
  br i1 %40, label %41, label %46

41:                                               ; preds = %27
  switch i8 %39, label %45 [
    i8 16, label %42
    i8 32, label %43
    i8 48, label %44
  ]

42:                                               ; preds = %41
  tail call void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3)
  br label %74

43:                                               ; preds = %41
  tail call void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3)
  br label %74

44:                                               ; preds = %41
  tail call void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3)
  br label %74

45:                                               ; preds = %41
  tail call void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i16 noundef signext %2, i16 noundef signext %3)
  br label %74

46:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #3
  call void @_ZN3rmg6BitmapC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  switch i8 %38, label %67 [
    i8 1, label %47
    i8 2, label %52
    i8 3, label %57
    i8 4, label %62
  ]

47:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #3
  invoke void @_ZNK3rmg6Bitmap11toGrayscaleEv(ptr dead_on_unwind nonnull writable sret(%"class.rmg::Bitmap") align 8 %6, ptr noundef nonnull align 8 dereferenceable(16) %1)
          to label %48 unwind label %50

48:                                               ; preds = %47
  %49 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #3
  br label %67

50:                                               ; preds = %47
  %51 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #3
  br label %73

52:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #3
  invoke void @_ZNK3rmg6Bitmap4toGAEv(ptr dead_on_unwind nonnull writable sret(%"class.rmg::Bitmap") align 8 %7, ptr noundef nonnull align 8 dereferenceable(16) %1)
          to label %53 unwind label %55

53:                                               ; preds = %52
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #3
  br label %67

55:                                               ; preds = %52
  %56 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #3
  br label %73

57:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #3
  invoke void @_ZNK3rmg6Bitmap5toRGBEv(ptr dead_on_unwind nonnull writable sret(%"class.rmg::Bitmap") align 8 %8, ptr noundef nonnull align 8 dereferenceable(16) %1)
          to label %58 unwind label %60

58:                                               ; preds = %57
  %59 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %8) #3
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #3
  br label %67

60:                                               ; preds = %57
  %61 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #3
  br label %73

62:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #3
  invoke void @_ZNK3rmg6Bitmap6toRGBAEv(ptr dead_on_unwind nonnull writable sret(%"class.rmg::Bitmap") align 8 %9, ptr noundef nonnull align 8 dereferenceable(16) %1)
          to label %63 unwind label %65

63:                                               ; preds = %62
  %64 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3rmg6BitmapaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #3
  br label %67

65:                                               ; preds = %62
  %66 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #3
  br label %73

67:                                               ; preds = %46, %53, %63, %58, %48
  switch i8 %39, label %71 [
    i8 16, label %68
    i8 32, label %69
    i8 48, label %70
  ]

68:                                               ; preds = %67
  call void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %5, i16 noundef signext %2, i16 noundef signext %3)
  br label %72

69:                                               ; preds = %67
  call void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %5, i16 noundef signext %2, i16 noundef signext %3)
  br label %72

70:                                               ; preds = %67
  call void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %5, i16 noundef signext %2, i16 noundef signext %3)
  br label %72

71:                                               ; preds = %67
  call void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %5, i16 noundef signext %2, i16 noundef signext %3)
  br label %72

72:                                               ; preds = %69, %71, %70, %68
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  br label %74

73:                                               ; preds = %65, %60, %55, %50
  %.pn = phi { ptr, i32 } [ %51, %50 ], [ %56, %55 ], [ %61, %60 ], [ %66, %65 ]
  call void @_ZN3rmg6BitmapD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #3
  resume { ptr, i32 } %.pn

74:                                               ; preds = %72, %43, %45, %44, %42, %4, %17
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap9pasteGrayERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap7pasteGAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap8pasteRGBERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3rmg6Bitmap9pasteRGBAERKS0_ss(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16), i16 noundef signext, i16 noundef signext) local_unnamed_addr #1 align 2

declare void @_ZN3rmg6BitmapD1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 = !{!"_ZTSN3rmg6BitmapE", !7, i64 0, !7, i64 2, !8, i64 4, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !8, i64 4}
!13 = !{!8, !8, i64 0}


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