; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (apg_bmp)

; 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._bmp_file_header_t = type <{ [2 x i8], i32, i16, i16, i32 }>
%struct._bmp_dib_BITMAPINFOHEADER_t = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [3 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 void @free(ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; 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) #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @apg_bmp_write(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #5 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca %struct._bmp_file_header_t, align 1
  %20 = alloca %struct._bmp_dib_BITMAPINFOHEADER_t, align 1
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i64, align 8
  %24 = alloca [4 x i8], align 1
  %25 = alloca [4 x i8], align 1
  %26 = alloca [4 x i8], align 1
  %27 = alloca i32, align 4
  %28 = alloca i64, align 8
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %38, label %37

37:                                               ; preds = %34, %5
  store i32 0, ptr %6, align 4
  br label %270

38:                                               ; preds = %34
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = icmp eq i32 0, %39
  br i1 %40, label %44, label %41

41:                                               ; preds = %38
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = icmp eq i32 0, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %41, %38
  store i32 0, ptr %6, align 4
  br label %270

45:                                               ; preds = %41
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = call i64 @llvm.abs.i64(i64 %47, i1 true)
  %49 = icmp sgt i64 %48, 65536
  br i1 %49, label %55, label %50

50:                                               ; preds = %45
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = call i64 @llvm.abs.i64(i64 %52, i1 true)
  %54 = icmp sgt i64 %53, 65536
  br i1 %54, label %55, label %56

55:                                               ; preds = %50, %45
  store i32 0, ptr %6, align 4
  br label %270

56:                                               ; preds = %50
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 3
  br i1 %58, label %59, label %63

59:                                               ; preds = %56
  %60 = load i32, ptr %11, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 4
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i32 0, ptr %6, align 4
  br label %270

63:                                               ; preds = %59, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = call i64 @llvm.abs.i64(i64 %65, i1 true)
  %67 = trunc i64 %66 to i32
  store i32 %67, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %68 = load i32, ptr %9, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = call i64 @llvm.abs.i64(i64 %69, i1 true)
  %71 = trunc i64 %70 to i32
  store i32 %71, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %72 = load i32, ptr %13, align 4, !tbaa !9
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = mul i32 %72, %73
  %75 = zext i32 %74 to i64
  store i64 %75, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %76 = load i64, ptr %14, align 8, !tbaa !11
  %77 = urem i64 %76, 4
  %78 = icmp eq i64 0, %77
  br i1 %78, label %79, label %80

79:                                               ; preds = %63
  br label %84

80:                                               ; preds = %63
  %81 = load i64, ptr %14, align 8, !tbaa !11
  %82 = urem i64 %81, 4
  %83 = sub i64 4, %82
  br label %84

84:                                               ; preds = %80, %79
  %85 = phi i64 [ 0, %79 ], [ %83, %80 ]
  store i64 %85, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %86 = load i64, ptr %14, align 8, !tbaa !11
  %87 = load i64, ptr %15, align 8, !tbaa !11
  %88 = add i64 %86, %87
  store i64 %88, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #8
  %89 = load i64, ptr %16, align 8, !tbaa !11
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = mul i64 %89, %91
  store i64 %92, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #8
  store i64 52, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 14, ptr %19) #8
  %93 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 0
  %94 = getelementptr inbounds [2 x i8], ptr %93, i64 0, i64 0
  store i8 66, ptr %94, align 1, !tbaa !13
  %95 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 0
  %96 = getelementptr inbounds [2 x i8], ptr %95, i64 0, i64 1
  store i8 77, ptr %96, align 1, !tbaa !13
  %97 = load i64, ptr %17, align 8, !tbaa !11
  %98 = trunc i64 %97 to i32
  %99 = add i32 66, %98
  %100 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 1
  store i32 %99, ptr %100, align 1, !tbaa !14
  %101 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 2
  store i16 0, ptr %101, align 1, !tbaa !17
  %102 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 3
  store i16 0, ptr %102, align 1, !tbaa !18
  %103 = getelementptr inbounds %struct._bmp_file_header_t, ptr %19, i32 0, i32 4
  store i32 66, ptr %103, align 1, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 52, ptr %20) #8
  %104 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 0
  store i32 40, ptr %104, align 1, !tbaa !20
  %105 = load i32, ptr %9, align 4, !tbaa !9
  %106 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 1
  store i32 %105, ptr %106, align 1, !tbaa !22
  %107 = load i32, ptr %10, align 4, !tbaa !9
  %108 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 2
  store i32 %107, ptr %108, align 1, !tbaa !23
  %109 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 3
  store i16 1, ptr %109, align 1, !tbaa !24
  %110 = load i32, ptr %11, align 4, !tbaa !9
  %111 = icmp eq i32 3, %110
  %112 = zext i1 %111 to i64
  %113 = select i1 %111, i32 24, i32 32
  %114 = trunc i32 %113 to i16
  %115 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 4
  store i16 %114, ptr %115, align 1, !tbaa !25
  %116 = load i32, ptr %11, align 4, !tbaa !9
  %117 = icmp eq i32 3, %116
  %118 = zext i1 %117 to i64
  %119 = select i1 %117, i32 0, i32 3
  %120 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 5
  store i32 %119, ptr %120, align 1, !tbaa !26
  %121 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 6
  store i32 0, ptr %121, align 1, !tbaa !27
  %122 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 7
  store i32 0, ptr %122, align 1, !tbaa !28
  %123 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 8
  store i32 0, ptr %123, align 1, !tbaa !29
  %124 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 9
  store i32 0, ptr %124, align 1, !tbaa !30
  %125 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 10
  store i32 0, ptr %125, align 1, !tbaa !31
  %126 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 11
  store i32 -16777216, ptr %126, align 1, !tbaa !32
  %127 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 12
  store i32 16711680, ptr %127, align 1, !tbaa !33
  %128 = getelementptr inbounds %struct._bmp_dib_BITMAPINFOHEADER_t, ptr %20, i32 0, i32 13
  store i32 65280, ptr %128, align 1, !tbaa !34
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #8
  %129 = load i64, ptr %17, align 8, !tbaa !11
  %130 = call noalias ptr @malloc(i64 noundef %129) #9
  store ptr %130, ptr %21, align 8, !tbaa !5
  %131 = load ptr, ptr %21, align 8, !tbaa !5
  %132 = icmp ne ptr %131, null
  br i1 %132, label %134, label %133

133:                                              ; preds = %84
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %269

134:                                              ; preds = %84
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #8
  store i64 0, ptr %23, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  call void @llvm.memset.p0.i64(ptr align 1 %24, i8 0, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  call void @llvm.memset.p0.i64(ptr align 1 %25, i8 0, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #8
  call void @llvm.memset.p0.i64(ptr align 1 %26, i8 0, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #8
  store i32 0, ptr %27, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %226, %134
  %136 = load i32, ptr %27, align 4, !tbaa !9
  %137 = load i32, ptr %12, align 4, !tbaa !9
  %138 = icmp ult i32 %136, %137
  br i1 %138, label %140, label %139

139:                                              ; preds = %135
  store i32 2, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #8
  br label %229

140:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %141 = load i32, ptr %12, align 4, !tbaa !9
  %142 = sub i32 %141, 1
  %143 = load i32, ptr %27, align 4, !tbaa !9
  %144 = sub i32 %142, %143
  %145 = load i32, ptr %11, align 4, !tbaa !9
  %146 = mul i32 %144, %145
  %147 = load i32, ptr %13, align 4, !tbaa !9
  %148 = mul i32 %146, %147
  %149 = zext i32 %148 to i64
  store i64 %149, ptr %28, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #8
  store i32 0, ptr %29, align 4, !tbaa !9
  br label %150

150:                                              ; preds = %210, %140
  %151 = load i32, ptr %29, align 4, !tbaa !9
  %152 = load i32, ptr %13, align 4, !tbaa !9
  %153 = icmp ult i32 %151, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %150
  store i32 5, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #8
  br label %213

155:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #8
  store i32 0, ptr %30, align 4, !tbaa !9
  br label %156

156:                                              ; preds = %170, %155
  %157 = load i32, ptr %30, align 4, !tbaa !9
  %158 = load i32, ptr %11, align 4, !tbaa !9
  %159 = icmp ult i32 %157, %158
  br i1 %159, label %161, label %160

160:                                              ; preds = %156
  store i32 8, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #8
  br label %173

161:                                              ; preds = %156
  %162 = load ptr, ptr %8, align 8, !tbaa !5
  %163 = load i64, ptr %28, align 8, !tbaa !11
  %164 = add i64 %163, 1
  store i64 %164, ptr %28, align 8, !tbaa !11
  %165 = getelementptr inbounds i8, ptr %162, i64 %163
  %166 = load i8, ptr %165, align 1, !tbaa !13
  %167 = load i32, ptr %30, align 4, !tbaa !9
  %168 = zext i32 %167 to i64
  %169 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 %168
  store i8 %166, ptr %169, align 1, !tbaa !13
  br label %170

170:                                              ; preds = %161
  %171 = load i32, ptr %30, align 4, !tbaa !9
  %172 = add i32 %171, 1
  store i32 %172, ptr %30, align 4, !tbaa !9
  br label %156, !llvm.loop !35

173:                                              ; preds = %160
  %174 = load i32, ptr %11, align 4, !tbaa !9
  %175 = icmp eq i32 3, %174
  br i1 %175, label %176, label %186

176:                                              ; preds = %173
  %177 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 2
  %178 = load i8, ptr %177, align 1, !tbaa !13
  %179 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 0
  store i8 %178, ptr %179, align 1, !tbaa !13
  %180 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 1
  %181 = load i8, ptr %180, align 1, !tbaa !13
  %182 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 1
  store i8 %181, ptr %182, align 1, !tbaa !13
  %183 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 0
  %184 = load i8, ptr %183, align 1, !tbaa !13
  %185 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 2
  store i8 %184, ptr %185, align 1, !tbaa !13
  br label %199

186:                                              ; preds = %173
  %187 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 3
  %188 = load i8, ptr %187, align 1, !tbaa !13
  %189 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 0
  store i8 %188, ptr %189, align 1, !tbaa !13
  %190 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 2
  %191 = load i8, ptr %190, align 1, !tbaa !13
  %192 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 1
  store i8 %191, ptr %192, align 1, !tbaa !13
  %193 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 1
  %194 = load i8, ptr %193, align 1, !tbaa !13
  %195 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 2
  store i8 %194, ptr %195, align 1, !tbaa !13
  %196 = getelementptr inbounds [4 x i8], ptr %25, i64 0, i64 0
  %197 = load i8, ptr %196, align 1, !tbaa !13
  %198 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 3
  store i8 %197, ptr %198, align 1, !tbaa !13
  br label %199

199:                                              ; preds = %186, %176
  %200 = load ptr, ptr %21, align 8, !tbaa !5
  %201 = load i64, ptr %23, align 8, !tbaa !11
  %202 = getelementptr inbounds i8, ptr %200, i64 %201
  %203 = getelementptr inbounds [4 x i8], ptr %26, i64 0, i64 0
  %204 = load i32, ptr %11, align 4, !tbaa !9
  %205 = zext i32 %204 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %202, ptr align 1 %203, i64 %205, i1 false)
  %206 = load i32, ptr %11, align 4, !tbaa !9
  %207 = zext i32 %206 to i64
  %208 = load i64, ptr %23, align 8, !tbaa !11
  %209 = add i64 %208, %207
  store i64 %209, ptr %23, align 8, !tbaa !11
  br label %210

210:                                              ; preds = %199
  %211 = load i32, ptr %29, align 4, !tbaa !9
  %212 = add i32 %211, 1
  store i32 %212, ptr %29, align 4, !tbaa !9
  br label %150, !llvm.loop !37

213:                                              ; preds = %154
  %214 = load i64, ptr %15, align 8, !tbaa !11
  %215 = icmp ugt i64 %214, 0
  br i1 %215, label %216, label %225

216:                                              ; preds = %213
  %217 = load ptr, ptr %21, align 8, !tbaa !5
  %218 = load i64, ptr %23, align 8, !tbaa !11
  %219 = getelementptr inbounds i8, ptr %217, i64 %218
  %220 = getelementptr inbounds [4 x i8], ptr %24, i64 0, i64 0
  %221 = load i64, ptr %15, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %219, ptr align 1 %220, i64 %221, i1 false)
  %222 = load i64, ptr %15, align 8, !tbaa !11
  %223 = load i64, ptr %23, align 8, !tbaa !11
  %224 = add i64 %223, %222
  store i64 %224, ptr %23, align 8, !tbaa !11
  br label %225

225:                                              ; preds = %216, %213
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  br label %226

226:                                              ; preds = %225
  %227 = load i32, ptr %27, align 4, !tbaa !9
  %228 = add i32 %227, 1
  store i32 %228, ptr %27, align 4, !tbaa !9
  br label %135, !llvm.loop !38

229:                                              ; preds = %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #8
  %230 = load ptr, ptr %7, align 8, !tbaa !5
  %231 = call noalias ptr @fopen(ptr noundef %230, ptr noundef @.str)
  store ptr %231, ptr %31, align 8, !tbaa !5
  %232 = load ptr, ptr %31, align 8, !tbaa !5
  %233 = icmp ne ptr %232, null
  br i1 %233, label %236, label %234

234:                                              ; preds = %229
  %235 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %235) #8
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %265

236:                                              ; preds = %229
  %237 = load ptr, ptr %31, align 8, !tbaa !5
  %238 = call i64 @fwrite(ptr noundef %19, i64 noundef 14, i64 noundef 1, ptr noundef %237)
  %239 = icmp ne i64 1, %238
  br i1 %239, label %240, label %244

240:                                              ; preds = %236
  %241 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %241) #8
  %242 = load ptr, ptr %31, align 8, !tbaa !5
  %243 = call i32 @fclose(ptr noundef %242)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %265

244:                                              ; preds = %236
  %245 = load ptr, ptr %31, align 8, !tbaa !5
  %246 = call i64 @fwrite(ptr noundef %20, i64 noundef 52, i64 noundef 1, ptr noundef %245)
  %247 = icmp ne i64 1, %246
  br i1 %247, label %248, label %252

248:                                              ; preds = %244
  %249 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %249) #8
  %250 = load ptr, ptr %31, align 8, !tbaa !5
  %251 = call i32 @fclose(ptr noundef %250)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %265

252:                                              ; preds = %244
  %253 = load ptr, ptr %21, align 8, !tbaa !5
  %254 = load i64, ptr %17, align 8, !tbaa !11
  %255 = load ptr, ptr %31, align 8, !tbaa !5
  %256 = call i64 @fwrite(ptr noundef %253, i64 noundef %254, i64 noundef 1, ptr noundef %255)
  %257 = icmp ne i64 1, %256
  br i1 %257, label %258, label %262

258:                                              ; preds = %252
  %259 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %259) #8
  %260 = load ptr, ptr %31, align 8, !tbaa !5
  %261 = call i32 @fclose(ptr noundef %260)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %265

262:                                              ; preds = %252
  %263 = load ptr, ptr %31, align 8, !tbaa !5
  %264 = call i32 @fclose(ptr noundef %263)
  store i32 0, ptr %22, align 4
  br label %265

265:                                              ; preds = %262, %258, %248, %240, %234
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #8
  %266 = load i32, ptr %22, align 4
  switch i32 %266, label %269 [
    i32 0, label %267
  ]

267:                                              ; preds = %265
  %268 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %268) #8
  store i32 1, ptr %6, align 4
  store i32 1, ptr %22, align 4
  br label %269

269:                                              ; preds = %267, %265, %133
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 52, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 14, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  br label %270

270:                                              ; preds = %269, %62, %55, %44, %37
  %271 = load i32, ptr %6, align 4
  ret i32 %271
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #6

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #7

declare i32 @fclose(ptr noundef) #7

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { "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 #8 = { nounwind }
attributes #9 = { nounwind 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 2}
!15 = !{!"_bmp_file_header_t", !7, i64 0, !10, i64 2, !16, i64 6, !16, i64 8, !10, i64 10}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !16, i64 6}
!18 = !{!15, !16, i64 8}
!19 = !{!15, !10, i64 10}
!20 = !{!21, !10, i64 0}
!21 = !{!"_bmp_dib_BITMAPINFOHEADER_t", !10, i64 0, !10, i64 4, !10, i64 8, !16, i64 12, !16, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48}
!22 = !{!21, !10, i64 4}
!23 = !{!21, !10, i64 8}
!24 = !{!21, !16, i64 12}
!25 = !{!21, !16, i64 14}
!26 = !{!21, !10, i64 16}
!27 = !{!21, !10, i64 20}
!28 = !{!21, !10, i64 24}
!29 = !{!21, !10, i64 28}
!30 = !{!21, !10, i64 32}
!31 = !{!21, !10, i64 36}
!32 = !{!21, !10, i64 40}
!33 = !{!21, !10, i64 44}
!34 = !{!21, !10, i64 48}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}
!37 = distinct !{!37, !36}
!38 = distinct !{!38, !36}


; 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._bmp_file_header_t = type <{ [2 x i8], i32, i16, i16, i32 }>
%struct._bmp_dib_BITMAPINFOHEADER_t = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [3 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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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) #4

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @apg_bmp_write(ptr noundef readonly %0, ptr noundef readonly %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #5 {
  %6 = alloca %struct._bmp_file_header_t, align 1
  %7 = alloca %struct._bmp_dib_BITMAPINFOHEADER_t, align 4
  %.sroa.028 = alloca i32, align 4
  %.sroa.0197 = alloca i32, align 4
  %.sroa.0 = alloca i32, align 4
  %8 = icmp ne ptr %0, null
  %9 = icmp ne ptr %1, null
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %10, label %95

10:                                               ; preds = %5
  %11 = icmp eq i32 %2, 0
  %12 = icmp eq i32 %3, 0
  %or.cond3 = or i1 %11, %12
  br i1 %or.cond3, label %95, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @llvm.abs.i32(i32 %2, i1 false)
  %15 = icmp ugt i32 %14, 65536
  br i1 %15, label %95, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @llvm.abs.i32(i32 %3, i1 false)
  %18 = icmp ugt i32 %17, 65536
  %19 = add i32 %4, -5
  %or.cond5 = icmp ult i32 %19, -2
  %or.cond107 = or i1 %18, %or.cond5
  br i1 %or.cond107, label %95, label %20

20:                                               ; preds = %16
  %21 = mul nuw nsw i32 %14, %4
  %22 = zext nneg i32 %21 to i64
  %23 = and i64 %22, 3
  %24 = icmp eq i64 %23, 0
  %25 = sub nuw nsw i64 4, %23
  %26 = select i1 %24, i64 0, i64 %25
  %27 = add nuw nsw i64 %26, %22
  %28 = zext nneg i32 %17 to i64
  %29 = mul nuw nsw i64 %27, %28
  call void @llvm.lifetime.start.p0(i64 14, ptr nonnull %6) #8
  store i8 66, ptr %6, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %6, i64 1
  store i8 77, ptr %30, align 1, !tbaa !5
  %31 = trunc i64 %29 to i32
  %32 = add i32 %31, 66
  %33 = getelementptr inbounds i8, ptr %6, i64 2
  store i32 %32, ptr %33, align 1, !tbaa !8
  %34 = getelementptr inbounds i8, ptr %6, i64 6
  store i16 0, ptr %34, align 1, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %6, i64 8
  store i16 0, ptr %35, align 1, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %6, i64 10
  store i32 66, ptr %36, align 1, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 52, ptr nonnull %7) #8
  store i32 40, ptr %7, align 4, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 %2, ptr %37, align 4, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %3, ptr %38, align 4, !tbaa !18
  %39 = getelementptr inbounds i8, ptr %7, i64 12
  store i16 1, ptr %39, align 4, !tbaa !19
  %40 = icmp eq i32 %4, 3
  %41 = select i1 %40, i16 24, i16 32
  %42 = getelementptr inbounds i8, ptr %7, i64 14
  store i16 %41, ptr %42, align 2, !tbaa !20
  %43 = select i1 %40, i32 0, i32 3
  %44 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %43, ptr %44, align 4, !tbaa !21
  %45 = getelementptr inbounds i8, ptr %7, i64 20
  %46 = getelementptr inbounds i8, ptr %7, i64 40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(20) %45, i8 0, i64 20, i1 false)
  store i32 -16777216, ptr %46, align 4, !tbaa !22
  %47 = getelementptr inbounds i8, ptr %7, i64 44
  store i32 16711680, ptr %47, align 4, !tbaa !23
  %48 = getelementptr inbounds i8, ptr %7, i64 48
  store i32 65280, ptr %48, align 4, !tbaa !24
  %49 = tail call noalias ptr @malloc(i64 noundef %29) #9
  %.not = icmp eq ptr %49, null
  br i1 %.not, label %.critedge, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.sroa.028)
  store i32 0, ptr %.sroa.028, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.sroa.0197)
  store i32 0, ptr %.sroa.0197, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %.sroa.0)
  store i32 0, ptr %.sroa.0, align 4
  %50 = zext nneg i32 %4 to i64
  br i1 %40, label %.preheader.lr.ph.us.us.us.preheader, label %.preheader.lr.ph.us.us149.preheader

.preheader.lr.ph.us.us.us.preheader:              ; preds = %.lr.ph.split.us
  %.sroa.0197.2.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0197, i64 2
  %.sroa.0197.1.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0197, i64 1
  %.sroa.0.1.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 1
  %.sroa.0.2.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 2
  br label %.preheader.lr.ph.us.us.us

.preheader.lr.ph.us.us.us:                        ; preds = %.preheader.lr.ph.us.us.us.preheader, %59
  %indvars.iv180 = phi i64 [ 0, %.preheader.lr.ph.us.us.us.preheader ], [ %indvars.iv.next181, %59 ]
  %.088130.us.us.us = phi i64 [ 0, %.preheader.lr.ph.us.us.us.preheader ], [ %.290.us.us.us, %59 ]
  %51 = trunc nuw nsw i64 %indvars.iv180 to i32
  %52 = xor i32 %51, -1
  %53 = add nsw i32 %17, %52
  %54 = mul i32 %21, %53
  %55 = zext i32 %54 to i64
  br label %.preheader.us.us.us.us.us

56:                                               ; preds = %._crit_edge115.split.us.split.us.us.us.us
  %57 = getelementptr inbounds i8, ptr %49, i64 %62
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %57, ptr noundef nonnull align 4 dereferenceable(1) %.sroa.028, i64 %25, i1 false)
  %58 = add i64 %62, %25
  br label %59

59:                                               ; preds = %._crit_edge115.split.us.split.us.us.us.us, %56
  %.290.us.us.us = phi i64 [ %58, %56 ], [ %62, %._crit_edge115.split.us.split.us.us.us.us ]
  %indvars.iv.next181 = add nuw nsw i64 %indvars.iv180, 1
  %exitcond184.not = icmp eq i64 %indvars.iv.next181, %28
  br i1 %exitcond184.not, label %._crit_edge, label %.preheader.lr.ph.us.us.us, !llvm.loop !25

.preheader.us.us.us.us.us:                        ; preds = %.preheader.us.us.us.us.us, %.preheader.lr.ph.us.us.us
  %.084114.us.us.us.us.us = phi i32 [ 0, %.preheader.lr.ph.us.us.us ], [ %63, %.preheader.us.us.us.us.us ]
  %.085113.us.us.us.us.us = phi i64 [ %55, %.preheader.lr.ph.us.us.us ], [ %60, %.preheader.us.us.us.us.us ]
  %.189112.us.us.us.us.us = phi i64 [ %.088130.us.us.us, %.preheader.lr.ph.us.us.us ], [ %62, %.preheader.us.us.us.us.us ]
  %scevgep175 = getelementptr i8, ptr %1, i64 %.085113.us.us.us.us.us
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %.sroa.0197, ptr align 1 %scevgep175, i64 %50, i1 false), !tbaa !5
  %60 = add i64 %.085113.us.us.us.us.us, 3
  %.sroa.0197.2..sroa.0197.2..sroa.0197.2.212 = load i8, ptr %.sroa.0197.2.sroa_idx, align 2, !tbaa !5
  store i8 %.sroa.0197.2..sroa.0197.2..sroa.0197.2.212, ptr %.sroa.0, align 4, !tbaa !5
  %.sroa.0197.1..sroa.0197.1..sroa.0197.1.206 = load i8, ptr %.sroa.0197.1.sroa_idx, align 1, !tbaa !5
  store i8 %.sroa.0197.1..sroa.0197.1..sroa.0197.1.206, ptr %.sroa.0.1.sroa_idx, align 1, !tbaa !5
  %.sroa.0197.0..sroa.0197.0..sroa.0197.0.200 = load i8, ptr %.sroa.0197, align 4, !tbaa !5
  store i8 %.sroa.0197.0..sroa.0197.0..sroa.0197.0.200, ptr %.sroa.0.2.sroa_idx, align 2, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %49, i64 %.189112.us.us.us.us.us
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %61, ptr nonnull align 4 %.sroa.0, i64 %50, i1 false)
  %62 = add i64 %.189112.us.us.us.us.us, %50
  %63 = add nuw nsw i32 %.084114.us.us.us.us.us, 1
  %exitcond179.not = icmp eq i32 %63, %14
  br i1 %exitcond179.not, label %._crit_edge115.split.us.split.us.us.us.us, label %.preheader.us.us.us.us.us, !llvm.loop !27

._crit_edge115.split.us.split.us.us.us.us:        ; preds = %.preheader.us.us.us.us.us
  br i1 %24, label %59, label %56

.preheader.lr.ph.us.us149.preheader:              ; preds = %.lr.ph.split.us
  %64 = zext nneg i32 %4 to i64
  br label %.preheader.lr.ph.us.us149

.preheader.lr.ph.us.us149:                        ; preds = %.preheader.lr.ph.us.us149.preheader, %73
  %indvars.iv = phi i64 [ 0, %.preheader.lr.ph.us.us149.preheader ], [ %indvars.iv.next, %73 ]
  %.088130.us.us151 = phi i64 [ 0, %.preheader.lr.ph.us.us149.preheader ], [ %.290.us.us152, %73 ]
  %65 = trunc nuw nsw i64 %indvars.iv to i32
  %66 = xor i32 %65, -1
  %67 = add nsw i32 %17, %66
  %68 = mul i32 %21, %67
  %69 = zext i32 %68 to i64
  br label %.preheader.us117.us.us

70:                                               ; preds = %._crit_edge115.split.split.us.us.us
  %71 = getelementptr inbounds i8, ptr %49, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %71, ptr noundef nonnull align 4 dereferenceable(1) %.sroa.028, i64 %25, i1 false)
  %72 = add i64 %77, %25
  br label %73

73:                                               ; preds = %._crit_edge115.split.split.us.us.us, %70
  %.290.us.us152 = phi i64 [ %72, %70 ], [ %77, %._crit_edge115.split.split.us.us.us ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond170.not = icmp eq i64 %indvars.iv.next, %28
  br i1 %exitcond170.not, label %._crit_edge, label %.preheader.lr.ph.us.us149, !llvm.loop !25

.preheader.us117.us.us:                           ; preds = %.preheader.us117.us.us, %.preheader.lr.ph.us.us149
  %.084114.us118.us.us = phi i32 [ 0, %.preheader.lr.ph.us.us149 ], [ %78, %.preheader.us117.us.us ]
  %.085113.us119.us.us = phi i64 [ %69, %.preheader.lr.ph.us.us149 ], [ %74, %.preheader.us117.us.us ]
  %.189112.us120.us.us = phi i64 [ %.088130.us.us151, %.preheader.lr.ph.us.us149 ], [ %77, %.preheader.us117.us.us ]
  %scevgep = getelementptr i8, ptr %1, i64 %.085113.us119.us.us
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %.sroa.0197, ptr align 1 %scevgep, i64 %50, i1 false), !tbaa !5
  %74 = add i64 %.085113.us119.us.us, %64
  %.sroa.0197.0.234235 = load i32, ptr %.sroa.0197, align 4, !tbaa !5
  %75 = tail call i32 @llvm.bswap.i32(i32 %.sroa.0197.0.234235)
  store i32 %75, ptr %.sroa.0, align 4, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %49, i64 %.189112.us120.us.us
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %76, ptr nonnull align 4 %.sroa.0, i64 %50, i1 false)
  %77 = add i64 %.189112.us120.us.us, %50
  %78 = add nuw nsw i32 %.084114.us118.us.us, 1
  %exitcond.not = icmp eq i32 %78, %14
  br i1 %exitcond.not, label %._crit_edge115.split.split.us.us.us, label %.preheader.us117.us.us, !llvm.loop !27

._crit_edge115.split.split.us.us.us:              ; preds = %.preheader.us117.us.us
  br i1 %24, label %73, label %70

._crit_edge:                                      ; preds = %73, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.sroa.0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.sroa.0197)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %.sroa.028)
  %79 = tail call noalias ptr @fopen(ptr noundef nonnull %0, ptr noundef nonnull @.str)
  %.not102 = icmp eq ptr %79, null
  br i1 %.not102, label %80, label %81

80:                                               ; preds = %._crit_edge
  tail call void @free(ptr noundef %49) #8
  br label %.critedge

81:                                               ; preds = %._crit_edge
  %82 = call i64 @fwrite(ptr noundef nonnull %6, i64 noundef 14, i64 noundef 1, ptr noundef nonnull %79)
  %.not103 = icmp eq i64 %82, 1
  br i1 %.not103, label %85, label %83

83:                                               ; preds = %81
  tail call void @free(ptr noundef %49) #8
  %84 = tail call i32 @fclose(ptr noundef nonnull %79)
  br label %.critedge

85:                                               ; preds = %81
  %86 = call i64 @fwrite(ptr noundef nonnull %7, i64 noundef 52, i64 noundef 1, ptr noundef nonnull %79)
  %.not104 = icmp eq i64 %86, 1
  br i1 %.not104, label %89, label %87

87:                                               ; preds = %85
  tail call void @free(ptr noundef %49) #8
  %88 = tail call i32 @fclose(ptr noundef nonnull %79)
  br label %.critedge

89:                                               ; preds = %85
  %90 = tail call i64 @fwrite(ptr noundef nonnull %49, i64 noundef %29, i64 noundef 1, ptr noundef nonnull %79)
  %.not105 = icmp eq i64 %90, 1
  br i1 %.not105, label %93, label %91

91:                                               ; preds = %89
  tail call void @free(ptr noundef %49) #8
  %92 = tail call i32 @fclose(ptr noundef nonnull %79)
  br label %.critedge

93:                                               ; preds = %89
  %94 = tail call i32 @fclose(ptr noundef nonnull %79)
  tail call void @free(ptr noundef %49) #8
  br label %.critedge

.critedge:                                        ; preds = %83, %87, %91, %80, %20, %93
  %.1 = phi i32 [ 1, %93 ], [ 0, %20 ], [ 0, %80 ], [ 0, %91 ], [ 0, %87 ], [ 0, %83 ]
  call void @llvm.lifetime.end.p0(i64 52, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 14, ptr nonnull %6) #8
  br label %95

95:                                               ; preds = %13, %16, %10, %5, %.critedge
  %.2 = phi i32 [ %.1, %.critedge ], [ 0, %5 ], [ 0, %10 ], [ 0, %16 ], [ 0, %13 ]
  ret i32 %.2
}

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #7

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.bswap.i32(i32) #7

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { nounwind 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 2}
!9 = !{!"_bmp_file_header_t", !6, i64 0, !10, i64 2, !11, i64 6, !11, i64 8, !10, i64 10}
!10 = !{!"int", !6, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = !{!9, !11, i64 6}
!13 = !{!9, !11, i64 8}
!14 = !{!9, !10, i64 10}
!15 = !{!16, !10, i64 0}
!16 = !{!"_bmp_dib_BITMAPINFOHEADER_t", !10, i64 0, !10, i64 4, !10, i64 8, !11, i64 12, !11, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48}
!17 = !{!16, !10, i64 4}
!18 = !{!16, !10, i64 8}
!19 = !{!16, !11, i64 12}
!20 = !{!16, !11, i64 14}
!21 = !{!16, !10, i64 16}
!22 = !{!16, !10, i64 40}
!23 = !{!16, !10, i64 44}
!24 = !{!16, !10, i64 48}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass