; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Image.ll (ZN7R2Image7ReadBMPEPKc)

; 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.BMPBITMAPFILEHEADER = type { i16, i32, i16, i16, i32 }
%struct.BMPBITMAPINFOHEADER = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%class.R2Image = type { i32, i32, i32, i32, ptr }

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [89 x i8], align 1
@stderr = external global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.36 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #1

declare void @_Z7RNAbortPKcz(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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7R2Image7ReadBMPEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #4 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.BMPBITMAPFILEHEADER, align 4
  %9 = alloca %struct.BMPBITMAPINFOHEADER, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noalias ptr @fopen(ptr noundef %17, ptr noundef @.str.25)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %25, label %21

21:                                               ; preds = %2
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.26, ptr noundef %23) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %244

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef %26)
  %28 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 0
  store i16 %27, ptr %28, align 4, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %29)
  %31 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 1
  store i32 %30, ptr %31, align 4, !tbaa !13
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef %32)
  %34 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 2
  store i16 %33, ptr %34, align 4, !tbaa !14
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef %35)
  %37 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 3
  store i16 %36, ptr %37, align 2, !tbaa !15
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %38)
  %40 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 4
  store i32 %39, ptr %40, align 4, !tbaa !16
  %41 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 0
  %42 = load i16, ptr %41, align 4, !tbaa !9
  %43 = zext i16 %42 to i32
  %44 = icmp eq i32 %43, 19778
  br i1 %44, label %46, label %45

45:                                               ; preds = %25
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.27, i32 noundef 532, ptr noundef @.str.2)
  br label %46

46:                                               ; preds = %45, %25
  %47 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 4
  %48 = load i32, ptr %47, align 4, !tbaa !16
  %49 = icmp eq i32 %48, 54
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.28, i32 noundef 536, ptr noundef @.str.2)
  br label %51

51:                                               ; preds = %50, %46
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #5
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %52)
  %54 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 0
  store i32 %53, ptr %54, align 4, !tbaa !17
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef %55)
  %57 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  store i32 %56, ptr %57, align 4, !tbaa !19
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef %58)
  %60 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  store i32 %59, ptr %60, align 4, !tbaa !20
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef %61)
  %63 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 3
  store i16 %62, ptr %63, align 4, !tbaa !21
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef %64)
  %66 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 4
  store i16 %65, ptr %66, align 2, !tbaa !22
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %67)
  %69 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 5
  store i32 %68, ptr %69, align 4, !tbaa !23
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %70)
  %72 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  store i32 %71, ptr %72, align 4, !tbaa !24
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef %73)
  %75 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 7
  store i32 %74, ptr %75, align 4, !tbaa !25
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef %76)
  %78 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 8
  store i32 %77, ptr %78, align 4, !tbaa !26
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %79)
  %81 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 9
  store i32 %80, ptr %81, align 4, !tbaa !27
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef %82)
  %84 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 10
  store i32 %83, ptr %84, align 4, !tbaa !28
  %85 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !17
  %87 = icmp eq i32 %86, 40
  br i1 %87, label %89, label %88

88:                                               ; preds = %51
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.29, i32 noundef 553, ptr noundef @.str.2)
  br label %89

89:                                               ; preds = %88, %51
  %90 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !19
  %92 = icmp sgt i32 %91, 0
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.30, i32 noundef 554, ptr noundef @.str.2)
  br label %94

94:                                               ; preds = %93, %89
  %95 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  %96 = load i32, ptr %95, align 4, !tbaa !20
  %97 = icmp sgt i32 %96, 0
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.31, i32 noundef 555, ptr noundef @.str.2)
  br label %99

99:                                               ; preds = %98, %94
  %100 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 3
  %101 = load i16, ptr %100, align 4, !tbaa !21
  %102 = zext i16 %101 to i32
  %103 = icmp eq i32 %102, 1
  br i1 %103, label %105, label %104

104:                                              ; preds = %99
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.32, i32 noundef 556, ptr noundef @.str.2)
  br label %105

105:                                              ; preds = %104, %99
  %106 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 4
  %107 = load i16, ptr %106, align 2, !tbaa !22
  %108 = zext i16 %107 to i32
  %109 = icmp eq i32 %108, 24
  br i1 %109, label %111, label %110

110:                                              ; preds = %105
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.33, i32 noundef 557, ptr noundef @.str.2)
  br label %111

111:                                              ; preds = %110, %105
  %112 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 5
  %113 = load i32, ptr %112, align 4, !tbaa !23
  %114 = zext i32 %113 to i64
  %115 = icmp eq i64 %114, 0
  br i1 %115, label %117, label %116

116:                                              ; preds = %111
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.34, i32 noundef 558, ptr noundef @.str.2)
  br label %117

117:                                              ; preds = %116, %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %118 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !19
  %120 = mul nsw i32 %119, 3
  store i32 %120, ptr %10, align 4, !tbaa !29
  %121 = load i32, ptr %10, align 4, !tbaa !29
  %122 = srem i32 %121, 4
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %129

124:                                              ; preds = %117
  %125 = load i32, ptr %10, align 4, !tbaa !29
  %126 = sdiv i32 %125, 4
  %127 = add nsw i32 %126, 1
  %128 = mul nsw i32 %127, 4
  store i32 %128, ptr %10, align 4, !tbaa !29
  br label %129

129:                                              ; preds = %124, %117
  %130 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  %131 = load i32, ptr %130, align 4, !tbaa !24
  %132 = load i32, ptr %10, align 4, !tbaa !29
  %133 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  %134 = load i32, ptr %133, align 4, !tbaa !20
  %135 = mul i32 %132, %134
  %136 = icmp eq i32 %131, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %129
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.35, i32 noundef 561, ptr noundef @.str.2)
  br label %138

138:                                              ; preds = %137, %129
  %139 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  %140 = load i32, ptr %139, align 4, !tbaa !19
  %141 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  store i32 %140, ptr %141, align 8, !tbaa !30
  %142 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  %143 = load i32, ptr %142, align 4, !tbaa !20
  %144 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 1
  store i32 %143, ptr %144, align 4, !tbaa !32
  %145 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  store i32 3, ptr %145, align 8, !tbaa !33
  %146 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  %147 = load i32, ptr %146, align 8, !tbaa !33
  %148 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %149 = load i32, ptr %148, align 8, !tbaa !30
  %150 = mul nsw i32 %147, %149
  %151 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 3
  store i32 %150, ptr %151, align 4, !tbaa !34
  %152 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 3
  %153 = load i32, ptr %152, align 4, !tbaa !34
  %154 = srem i32 %153, 4
  %155 = icmp ne i32 %154, 0
  br i1 %155, label %156, label %163

156:                                              ; preds = %138
  %157 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 3
  %158 = load i32, ptr %157, align 4, !tbaa !34
  %159 = sdiv i32 %158, 4
  %160 = add nsw i32 %159, 1
  %161 = mul nsw i32 %160, 4
  %162 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 3
  store i32 %161, ptr %162, align 4, !tbaa !34
  br label %163

163:                                              ; preds = %156, %138
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %164 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  %165 = load i32, ptr %164, align 4, !tbaa !24
  store i32 %165, ptr %11, align 4, !tbaa !29
  %166 = load i32, ptr %11, align 4, !tbaa !29
  %167 = sext i32 %166 to i64
  %168 = call noalias noundef nonnull ptr @_Znam(i64 noundef %167) #6
  %169 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 4
  store ptr %168, ptr %169, align 8, !tbaa !35
  %170 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 4
  %171 = load ptr, ptr %170, align 8, !tbaa !35
  %172 = icmp ne ptr %171, null
  br i1 %172, label %178, label %173

173:                                              ; preds = %163
  %174 = load ptr, ptr @stderr, align 8, !tbaa !5
  %175 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %174, ptr noundef @.str.36) #5
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = call i32 @fclose(ptr noundef %176)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %243

178:                                              ; preds = %163
  %179 = load ptr, ptr %6, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 4
  %181 = load i32, ptr %180, align 4, !tbaa !16
  %182 = zext i32 %181 to i64
  %183 = call i32 @fseek(ptr noundef %179, i64 noundef %182, i32 noundef 0)
  %184 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 4
  %185 = load ptr, ptr %184, align 8, !tbaa !35
  %186 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  %187 = load i32, ptr %186, align 4, !tbaa !24
  %188 = zext i32 %187 to i64
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = call i64 @fread(ptr noundef %185, i64 noundef 1, i64 noundef %188, ptr noundef %189)
  %191 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  %192 = load i32, ptr %191, align 4, !tbaa !24
  %193 = zext i32 %192 to i64
  %194 = icmp ne i64 %190, %193
  br i1 %194, label %195, label %199

195:                                              ; preds = %178
  %196 = load ptr, ptr @stderr, align 8, !tbaa !5
  %197 = load ptr, ptr %5, align 8, !tbaa !5
  %198 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %196, ptr noundef @.str.37, ptr noundef %197) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %243

199:                                              ; preds = %178
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !29
  br label %200

200:                                              ; preds = %237, %199
  %201 = load i32, ptr %12, align 4, !tbaa !29
  %202 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 1
  %203 = load i32, ptr %202, align 4, !tbaa !32
  %204 = icmp slt i32 %201, %203
  br i1 %204, label %206, label %205

205:                                              ; preds = %200
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %240

206:                                              ; preds = %200
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %207 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 4
  %208 = load ptr, ptr %207, align 8, !tbaa !35
  %209 = load i32, ptr %12, align 4, !tbaa !29
  %210 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 3
  %211 = load i32, ptr %210, align 4, !tbaa !34
  %212 = mul nsw i32 %209, %211
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds i8, ptr %208, i64 %213
  store ptr %214, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !29
  br label %215

215:                                              ; preds = %233, %206
  %216 = load i32, ptr %14, align 4, !tbaa !29
  %217 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %218 = load i32, ptr %217, align 8, !tbaa !30
  %219 = icmp slt i32 %216, %218
  br i1 %219, label %221, label %220

220:                                              ; preds = %215
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %236

221:                                              ; preds = %215
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  %222 = load ptr, ptr %13, align 8, !tbaa !5
  %223 = load i8, ptr %222, align 1, !tbaa !36
  store i8 %223, ptr %15, align 1, !tbaa !36
  %224 = load ptr, ptr %13, align 8, !tbaa !5
  %225 = getelementptr inbounds i8, ptr %224, i64 2
  %226 = load i8, ptr %225, align 1, !tbaa !36
  %227 = load ptr, ptr %13, align 8, !tbaa !5
  store i8 %226, ptr %227, align 1, !tbaa !36
  %228 = load i8, ptr %15, align 1, !tbaa !36
  %229 = load ptr, ptr %13, align 8, !tbaa !5
  %230 = getelementptr inbounds i8, ptr %229, i64 2
  store i8 %228, ptr %230, align 1, !tbaa !36
  %231 = load ptr, ptr %13, align 8, !tbaa !5
  %232 = getelementptr inbounds i8, ptr %231, i64 3
  store ptr %232, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  br label %233

233:                                              ; preds = %221
  %234 = load i32, ptr %14, align 4, !tbaa !29
  %235 = add nsw i32 %234, 1
  store i32 %235, ptr %14, align 4, !tbaa !29
  br label %215, !llvm.loop !37

236:                                              ; preds = %220
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %237

237:                                              ; preds = %236
  %238 = load i32, ptr %12, align 4, !tbaa !29
  %239 = add nsw i32 %238, 1
  store i32 %239, ptr %12, align 4, !tbaa !29
  br label %200, !llvm.loop !39

240:                                              ; preds = %205
  %241 = load ptr, ptr %6, align 8, !tbaa !5
  %242 = call i32 @fclose(ptr noundef %241)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %243

243:                                              ; preds = %240, %195, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  br label %244

244:                                              ; preds = %243, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %245 = load i32, ptr %3, align 4
  ret i32 %245
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef) #4

declare i32 @fclose(ptr noundef) #2

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #2

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = { builtin allocsize(0) }

!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 = !{!"_ZTS19BMPBITMAPFILEHEADER", !11, i64 0, !12, i64 4, !11, i64 8, !11, i64 10, !12, i64 12}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 4}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 10}
!16 = !{!10, !12, i64 12}
!17 = !{!18, !12, i64 0}
!18 = !{!"_ZTS19BMPBITMAPINFOHEADER", !12, i64 0, !12, i64 4, !12, i64 8, !11, i64 12, !11, i64 14, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36}
!19 = !{!18, !12, i64 4}
!20 = !{!18, !12, i64 8}
!21 = !{!18, !11, i64 12}
!22 = !{!18, !11, i64 14}
!23 = !{!18, !12, i64 16}
!24 = !{!18, !12, i64 20}
!25 = !{!18, !12, i64 24}
!26 = !{!18, !12, i64 28}
!27 = !{!18, !12, i64 32}
!28 = !{!18, !12, i64 36}
!29 = !{!12, !12, i64 0}
!30 = !{!31, !12, i64 0}
!31 = !{!"_ZTS7R2Image", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !6, i64 16}
!32 = !{!31, !12, i64 4}
!33 = !{!31, !12, i64 8}
!34 = !{!31, !12, i64 12}
!35 = !{!31, !6, i64 16}
!36 = !{!7, !7, i64 0}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}
!39 = distinct !{!39, !38}


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

@.str = external hidden unnamed_addr constant [41 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [89 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #0

declare void @_Z7RNAbortPKcz(ptr noundef, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7R2Image7ReadBMPEPKc(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #3 align 2 {
  %3 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.25)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %7

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.26, ptr noundef %1) #4
  br label %102

7:                                                ; preds = %2
  %8 = tail call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %9 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %10 = tail call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %11 = tail call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %12 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %13 = icmp eq i16 %8, 19778
  br i1 %13, label %15, label %14

14:                                               ; preds = %7
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.27, i32 noundef 532, ptr noundef nonnull @.str.2)
  br label %15

15:                                               ; preds = %14, %7
  %16 = icmp eq i32 %12, 54
  br i1 %16, label %18, label %17

17:                                               ; preds = %15
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.28, i32 noundef 536, ptr noundef nonnull @.str.2)
  br label %18

18:                                               ; preds = %17, %15
  %19 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %20 = tail call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %21 = tail call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %22 = tail call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %23 = tail call noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %24 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %25 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %26 = tail call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %27 = tail call noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %28 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %29 = tail call noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef nonnull %3)
  %30 = icmp eq i32 %19, 40
  br i1 %30, label %32, label %31

31:                                               ; preds = %18
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.29, i32 noundef 553, ptr noundef nonnull @.str.2)
  br label %32

32:                                               ; preds = %31, %18
  %33 = icmp sgt i32 %20, 0
  br i1 %33, label %35, label %34

34:                                               ; preds = %32
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.30, i32 noundef 554, ptr noundef nonnull @.str.2)
  br label %35

35:                                               ; preds = %34, %32
  %36 = icmp sgt i32 %21, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %35
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.31, i32 noundef 555, ptr noundef nonnull @.str.2)
  br label %38

38:                                               ; preds = %37, %35
  %39 = icmp eq i16 %22, 1
  br i1 %39, label %41, label %40

40:                                               ; preds = %38
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.32, i32 noundef 556, ptr noundef nonnull @.str.2)
  br label %41

41:                                               ; preds = %40, %38
  %42 = icmp eq i16 %23, 24
  br i1 %42, label %44, label %43

43:                                               ; preds = %41
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.33, i32 noundef 557, ptr noundef nonnull @.str.2)
  br label %44

44:                                               ; preds = %43, %41
  %45 = icmp eq i32 %24, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %44
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.34, i32 noundef 558, ptr noundef nonnull @.str.2)
  br label %47

47:                                               ; preds = %46, %44
  %48 = mul nsw i32 %20, 3
  %49 = and i32 %48, 3
  %.not56 = icmp eq i32 %49, 0
  br i1 %.not56, label %54, label %50

50:                                               ; preds = %47
  %51 = sdiv i32 %48, 4
  %52 = shl nsw i32 %51, 2
  %53 = add i32 %52, 4
  br label %54

54:                                               ; preds = %50, %47
  %.054 = phi i32 [ %53, %50 ], [ %48, %47 ]
  %55 = mul i32 %.054, %21
  %56 = icmp eq i32 %25, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.35, i32 noundef 561, ptr noundef nonnull @.str.2)
  br label %58

58:                                               ; preds = %57, %54
  store i32 %20, ptr %0, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %21, ptr %59, align 4, !tbaa !12
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 3, ptr %60, align 8, !tbaa !13
  %61 = getelementptr inbounds i8, ptr %0, i64 12
  br i1 %.not56, label %66, label %62

62:                                               ; preds = %58
  %63 = sdiv i32 %48, 4
  %64 = shl nsw i32 %63, 2
  %65 = add i32 %64, 4
  br label %66

66:                                               ; preds = %62, %58
  %storemerge = phi i32 [ %65, %62 ], [ %48, %58 ]
  store i32 %storemerge, ptr %61, align 4, !tbaa !14
  %67 = sext i32 %25 to i64
  %68 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %67) #5
  %69 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %68, ptr %69, align 8, !tbaa !15
  %70 = zext i32 %12 to i64
  %71 = tail call i32 @fseek(ptr noundef nonnull %3, i64 noundef %70, i32 noundef 0)
  %72 = load ptr, ptr %69, align 8, !tbaa !15
  %73 = zext i32 %25 to i64
  %74 = tail call i64 @fread(ptr noundef %72, i64 noundef 1, i64 noundef %73, ptr noundef nonnull %3)
  %.not58 = icmp eq i64 %74, %73
  br i1 %.not58, label %.preheader, label %79

.preheader:                                       ; preds = %66
  %75 = load i32, ptr %59, align 4, !tbaa !12
  %76 = icmp sgt i32 %75, 0
  %77 = load i32, ptr %0, align 8
  %78 = icmp sgt i32 %77, 0
  %or.cond = select i1 %76, i1 %78, i1 false
  br i1 %or.cond, label %.lr.ph62.split, label %._crit_edge63

79:                                               ; preds = %66
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  %81 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef nonnull @.str.37, ptr noundef %1) #4
  br label %102

._crit_edge63:                                    ; preds = %._crit_edge, %.preheader
  %82 = tail call i32 @fclose(ptr noundef nonnull %3)
  br label %102

.lr.ph62.split:                                   ; preds = %.preheader, %._crit_edge
  %83 = phi i32 [ %91, %._crit_edge ], [ %75, %.preheader ]
  %84 = phi i32 [ %92, %._crit_edge ], [ %77, %.preheader ]
  %.05361 = phi i32 [ %93, %._crit_edge ], [ 0, %.preheader ]
  %85 = icmp sgt i32 %84, 0
  br i1 %85, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph62.split
  %86 = load ptr, ptr %69, align 8, !tbaa !15
  %87 = load i32, ptr %61, align 4, !tbaa !14
  %88 = mul nsw i32 %87, %.05361
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i8, ptr %86, i64 %89
  br label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i32, ptr %59, align 4, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.lr.ph62.split
  %91 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %83, %.lr.ph62.split ]
  %92 = phi i32 [ %100, %._crit_edge.loopexit ], [ %84, %.lr.ph62.split ]
  %93 = add nuw nsw i32 %.05361, 1
  %94 = icmp slt i32 %93, %91
  br i1 %94, label %.lr.ph62.split, label %._crit_edge63, !llvm.loop !16

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.05160 = phi i32 [ %99, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.05259 = phi ptr [ %98, %.lr.ph ], [ %90, %.lr.ph.preheader ]
  %95 = load i8, ptr %.05259, align 1, !tbaa !19
  %96 = getelementptr inbounds i8, ptr %.05259, i64 2
  %97 = load i8, ptr %96, align 1, !tbaa !19
  store i8 %97, ptr %.05259, align 1, !tbaa !19
  store i8 %95, ptr %96, align 1, !tbaa !19
  %98 = getelementptr inbounds i8, ptr %.05259, i64 3
  %99 = add nuw nsw i32 %.05160, 1
  %100 = load i32, ptr %0, align 8, !tbaa !9
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !20

102:                                              ; preds = %79, %._crit_edge63, %4
  %.1 = phi i32 [ 0, %4 ], [ 0, %79 ], [ 1, %._crit_edge63 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef zeroext i16 @_ZL10WordReadLEP8_IO_FILE(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL11DWordReadLEP8_IO_FILE(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL10LongReadLEP8_IO_FILE(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { nobuiltin allocsize(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 = { "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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { cold nounwind }
attributes #5 = { builtin allocsize(0) }

!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 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !6, i64 16}
!16 = distinct !{!16, !17, !18}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !17}


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