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

; 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.26 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.39 = 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

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

; 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, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK7R2Image8WriteBMPEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #3 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 ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  %16 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = icmp eq i32 %17, 3
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef @.str, ptr noundef @.str.38, i32 noundef 610, ptr noundef @.str.2)
  br label %20

20:                                               ; preds = %19, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call noalias ptr @fopen(ptr noundef %21, ptr noundef @.str.39)
  store ptr %22, ptr %6, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %29, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.26, ptr noundef %27) #4
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %179

29:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %30 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 0
  store i16 19778, ptr %30, align 4, !tbaa !12
  %31 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 1
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = mul nsw i32 %32, %34
  %36 = add nsw i32 54, %35
  %37 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 1
  store i32 %36, ptr %37, align 4, !tbaa !17
  %38 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 2
  store i16 0, ptr %38, align 4, !tbaa !18
  %39 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 3
  store i16 0, ptr %39, align 2, !tbaa !19
  %40 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 4
  store i32 54, ptr %40, align 4, !tbaa !20
  %41 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 0
  %42 = load i16, ptr %41, align 4, !tbaa !12
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext %42, ptr noundef %43)
  %44 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !17
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %45, ptr noundef %46)
  %47 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 2
  %48 = load i16, ptr %47, align 4, !tbaa !18
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext %48, ptr noundef %49)
  %50 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 3
  %51 = load i16, ptr %50, align 2, !tbaa !19
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext %51, ptr noundef %52)
  %53 = getelementptr inbounds %struct.BMPBITMAPFILEHEADER, ptr %8, i32 0, i32 4
  %54 = load i32, ptr %53, align 4, !tbaa !20
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %54, ptr noundef %55)
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #4
  %56 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 0
  store i32 40, ptr %56, align 4, !tbaa !21
  %57 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !23
  %59 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  store i32 %58, ptr %59, align 4, !tbaa !24
  %60 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !16
  %62 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  store i32 %61, ptr %62, align 4, !tbaa !25
  %63 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 3
  store i16 1, ptr %63, align 4, !tbaa !26
  %64 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 4
  store i16 24, ptr %64, align 2, !tbaa !27
  %65 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 5
  store i32 0, ptr %65, align 4, !tbaa !28
  %66 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 3
  %67 = load i32, ptr %66, align 4, !tbaa !15
  %68 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  %69 = load i32, ptr %68, align 4, !tbaa !25
  %70 = mul i32 %67, %69
  %71 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  store i32 %70, ptr %71, align 4, !tbaa !29
  %72 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 7
  store i32 2925, ptr %72, align 4, !tbaa !30
  %73 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 8
  store i32 2925, ptr %73, align 4, !tbaa !31
  %74 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 9
  store i32 0, ptr %74, align 4, !tbaa !32
  %75 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 10
  store i32 0, ptr %75, align 4, !tbaa !33
  %76 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 0
  %77 = load i32, ptr %76, align 4, !tbaa !21
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %77, ptr noundef %78)
  %79 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 1
  %80 = load i32, ptr %79, align 4, !tbaa !24
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %80, ptr noundef %81)
  %82 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 2
  %83 = load i32, ptr %82, align 4, !tbaa !25
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %83, ptr noundef %84)
  %85 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 3
  %86 = load i16, ptr %85, align 4, !tbaa !26
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext %86, ptr noundef %87)
  %88 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 4
  %89 = load i16, ptr %88, align 2, !tbaa !27
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext %89, ptr noundef %90)
  %91 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 5
  %92 = load i32, ptr %91, align 4, !tbaa !28
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %92, ptr noundef %93)
  %94 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 6
  %95 = load i32, ptr %94, align 4, !tbaa !29
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %95, ptr noundef %96)
  %97 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 7
  %98 = load i32, ptr %97, align 4, !tbaa !30
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %98, ptr noundef %99)
  %100 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 8
  %101 = load i32, ptr %100, align 4, !tbaa !31
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %101, ptr noundef %102)
  %103 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 9
  %104 = load i32, ptr %103, align 4, !tbaa !32
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %104, ptr noundef %105)
  %106 = getelementptr inbounds %struct.BMPBITMAPINFOHEADER, ptr %9, i32 0, i32 10
  %107 = load i32, ptr %106, align 4, !tbaa !33
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %107, ptr noundef %108)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %109 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 3
  %110 = load i32, ptr %109, align 4, !tbaa !15
  %111 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 0
  %112 = load i32, ptr %111, align 8, !tbaa !23
  %113 = mul nsw i32 %112, 3
  %114 = sub nsw i32 %110, %113
  store i32 %114, ptr %10, align 4, !tbaa !34
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !34
  br label %115

115:                                              ; preds = %173, %29
  %116 = load i32, ptr %11, align 4, !tbaa !34
  %117 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 1
  %118 = load i32, ptr %117, align 4, !tbaa !16
  %119 = icmp slt i32 %116, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %115
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %176

121:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %122 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 4
  %123 = load ptr, ptr %122, align 8, !tbaa !35
  %124 = load i32, ptr %11, align 4, !tbaa !34
  %125 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 3
  %126 = load i32, ptr %125, align 4, !tbaa !15
  %127 = mul nsw i32 %124, %126
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds i8, ptr %123, i64 %128
  store ptr %129, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !34
  br label %130

130:                                              ; preds = %157, %121
  %131 = load i32, ptr %13, align 4, !tbaa !34
  %132 = getelementptr inbounds %class.R2Image, ptr %15, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !23
  %134 = icmp slt i32 %131, %133
  br i1 %134, label %136, label %135

135:                                              ; preds = %130
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %160

136:                                              ; preds = %130
  %137 = load ptr, ptr %12, align 8, !tbaa !5
  %138 = getelementptr inbounds i8, ptr %137, i64 2
  %139 = load i8, ptr %138, align 1, !tbaa !36
  %140 = zext i8 %139 to i32
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = call i32 @fputc(i32 noundef %140, ptr noundef %141)
  %143 = load ptr, ptr %12, align 8, !tbaa !5
  %144 = getelementptr inbounds i8, ptr %143, i64 1
  %145 = load i8, ptr %144, align 1, !tbaa !36
  %146 = zext i8 %145 to i32
  %147 = load ptr, ptr %6, align 8, !tbaa !5
  %148 = call i32 @fputc(i32 noundef %146, ptr noundef %147)
  %149 = load ptr, ptr %12, align 8, !tbaa !5
  %150 = getelementptr inbounds i8, ptr %149, i64 0
  %151 = load i8, ptr %150, align 1, !tbaa !36
  %152 = zext i8 %151 to i32
  %153 = load ptr, ptr %6, align 8, !tbaa !5
  %154 = call i32 @fputc(i32 noundef %152, ptr noundef %153)
  %155 = load ptr, ptr %12, align 8, !tbaa !5
  %156 = getelementptr inbounds i8, ptr %155, i64 3
  store ptr %156, ptr %12, align 8, !tbaa !5
  br label %157

157:                                              ; preds = %136
  %158 = load i32, ptr %13, align 4, !tbaa !34
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %13, align 4, !tbaa !34
  br label %130, !llvm.loop !37

160:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !34
  br label %161

161:                                              ; preds = %169, %160
  %162 = load i32, ptr %14, align 4, !tbaa !34
  %163 = load i32, ptr %10, align 4, !tbaa !34
  %164 = icmp slt i32 %162, %163
  br i1 %164, label %166, label %165

165:                                              ; preds = %161
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %172

166:                                              ; preds = %161
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = call i32 @fputc(i32 noundef 0, ptr noundef %167)
  br label %169

169:                                              ; preds = %166
  %170 = load i32, ptr %14, align 4, !tbaa !34
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %14, align 4, !tbaa !34
  br label %161, !llvm.loop !39

172:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %11, align 4, !tbaa !34
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %11, align 4, !tbaa !34
  br label %115, !llvm.loop !40

176:                                              ; preds = %120
  %177 = load ptr, ptr %6, align 8, !tbaa !5
  %178 = call i32 @fclose(ptr noundef %177)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %179

179:                                              ; preds = %176, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %180 = load i32, ptr %3, align 4
  ret i32 %180
}

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

declare i32 @fclose(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef, ptr noundef) #3

declare i32 @fputc(i32 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"_ZTS19BMPBITMAPFILEHEADER", !14, i64 0, !11, i64 4, !14, i64 8, !14, i64 10, !11, i64 12}
!14 = !{!"short", !7, i64 0}
!15 = !{!10, !11, i64 12}
!16 = !{!10, !11, i64 4}
!17 = !{!13, !11, i64 4}
!18 = !{!13, !14, i64 8}
!19 = !{!13, !14, i64 10}
!20 = !{!13, !11, i64 12}
!21 = !{!22, !11, i64 0}
!22 = !{!"_ZTS19BMPBITMAPINFOHEADER", !11, i64 0, !11, i64 4, !11, i64 8, !14, i64 12, !14, i64 14, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!23 = !{!10, !11, i64 0}
!24 = !{!22, !11, i64 4}
!25 = !{!22, !11, i64 8}
!26 = !{!22, !14, i64 12}
!27 = !{!22, !14, i64 14}
!28 = !{!22, !11, i64 16}
!29 = !{!22, !11, i64 20}
!30 = !{!22, !11, i64 24}
!31 = !{!22, !11, i64 28}
!32 = !{!22, !11, i64 32}
!33 = !{!22, !11, i64 36}
!34 = !{!11, !11, i64 0}
!35 = !{!10, !6, i64 16}
!36 = !{!7, !7, i64 0}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}
!39 = distinct !{!39, !38}
!40 = distinct !{!40, !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.26 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZNK7R2Image8WriteBMPEPKc(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = icmp eq i32 %4, 3
  br i1 %5, label %7, label %6

6:                                                ; preds = %2
  tail call void (ptr, ...) @_Z7RNAbortPKcz(ptr noundef nonnull @.str, ptr noundef nonnull @.str.38, i32 noundef 610, ptr noundef nonnull @.str.2)
  br label %7

7:                                                ; preds = %6, %2
  %8 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.39)
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %12

9:                                                ; preds = %7
  %10 = load ptr, ptr @stderr, align 8, !tbaa !11
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.26, ptr noundef %1) #3
  br label %86

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = mul nsw i32 %16, %14
  %18 = add nsw i32 %17, 54
  tail call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext 19778, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %18, ptr noundef nonnull %8)
  tail call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext 0, ptr noundef nonnull %8)
  tail call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext 0, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef 54, ptr noundef nonnull %8)
  %19 = load i32, ptr %0, align 8, !tbaa !14
  %20 = load i32, ptr %15, align 4, !tbaa !13
  %21 = load i32, ptr %13, align 4, !tbaa !12
  %22 = mul i32 %21, %20
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef 40, ptr noundef nonnull %8)
  tail call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %19, ptr noundef nonnull %8)
  tail call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef %20, ptr noundef nonnull %8)
  tail call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext 1, ptr noundef nonnull %8)
  tail call void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext 24, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef 0, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef %22, ptr noundef nonnull %8)
  tail call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef 2925, ptr noundef nonnull %8)
  tail call void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef 2925, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef 0, ptr noundef nonnull %8)
  tail call void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef 0, ptr noundef nonnull %8)
  %23 = load i32, ptr %13, align 4, !tbaa !12
  %24 = load i32, ptr %0, align 8, !tbaa !14
  %.neg = mul i32 %24, -3
  %25 = add i32 %.neg, %23
  %.fr57 = freeze i32 %25
  %26 = load i32, ptr %15, align 4, !tbaa !13
  %27 = icmp sgt i32 %26, 0
  br i1 %27, label %.lr.ph53, label %._crit_edge54

.lr.ph53:                                         ; preds = %12
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = icmp sgt i32 %.fr57, 0
  br i1 %29, label %.lr.ph53.split.us, label %.lr.ph53.split

.lr.ph53.split.us:                                ; preds = %.lr.ph53, %._crit_edge.us
  %.04451.us = phi i32 [ %54, %._crit_edge.us ], [ 0, %.lr.ph53 ]
  %30 = load i32, ptr %0, align 8, !tbaa !14
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph.us.preheader, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.lr.ph.us, %.lr.ph53.split.us
  br label %.preheader.us

.lr.ph.us.preheader:                              ; preds = %.lr.ph53.split.us
  %32 = load ptr, ptr %28, align 8, !tbaa !15
  %33 = load i32, ptr %13, align 4, !tbaa !12
  %34 = mul nsw i32 %33, %.04451.us
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i8, ptr %32, i64 %35
  br label %.lr.ph.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %.preheader.us
  %.049.us = phi i32 [ %38, %.preheader.us ], [ 0, %.preheader.us.preheader ]
  %37 = tail call i32 @fputc(i32 noundef 0, ptr noundef %8)
  %38 = add nuw nsw i32 %.049.us, 1
  %exitcond.not = icmp eq i32 %38, %.fr57
  br i1 %exitcond.not, label %._crit_edge.us, label %.preheader.us, !llvm.loop !16

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %.lr.ph.us
  %.04248.us = phi i32 [ %51, %.lr.ph.us ], [ 0, %.lr.ph.us.preheader ]
  %.04347.us = phi ptr [ %50, %.lr.ph.us ], [ %36, %.lr.ph.us.preheader ]
  %39 = getelementptr inbounds i8, ptr %.04347.us, i64 2
  %40 = load i8, ptr %39, align 1, !tbaa !18
  %41 = zext i8 %40 to i32
  %42 = tail call i32 @fputc(i32 noundef %41, ptr noundef %8)
  %43 = getelementptr inbounds i8, ptr %.04347.us, i64 1
  %44 = load i8, ptr %43, align 1, !tbaa !18
  %45 = zext i8 %44 to i32
  %46 = tail call i32 @fputc(i32 noundef %45, ptr noundef %8)
  %47 = load i8, ptr %.04347.us, align 1, !tbaa !18
  %48 = zext i8 %47 to i32
  %49 = tail call i32 @fputc(i32 noundef %48, ptr noundef %8)
  %50 = getelementptr inbounds i8, ptr %.04347.us, i64 3
  %51 = add nuw nsw i32 %.04248.us, 1
  %52 = load i32, ptr %0, align 8, !tbaa !14
  %53 = icmp slt i32 %51, %52
  br i1 %53, label %.lr.ph.us, label %.preheader.us.preheader, !llvm.loop !19

._crit_edge.us:                                   ; preds = %.preheader.us
  %54 = add nuw nsw i32 %.04451.us, 1
  %55 = load i32, ptr %15, align 4, !tbaa !13
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %.lr.ph53.split.us, label %._crit_edge54, !llvm.loop !20

.lr.ph53.split:                                   ; preds = %.lr.ph53
  %57 = icmp sgt i32 %24, 0
  br i1 %57, label %.lr.ph53.split.split, label %._crit_edge54

._crit_edge54:                                    ; preds = %.preheader, %._crit_edge.us, %.lr.ph53.split, %12
  %58 = tail call i32 @fclose(ptr noundef %8)
  br label %86

.lr.ph53.split.split:                             ; preds = %.lr.ph53.split, %.preheader
  %59 = phi i32 [ %67, %.preheader ], [ %26, %.lr.ph53.split ]
  %60 = phi i32 [ %68, %.preheader ], [ %24, %.lr.ph53.split ]
  %.04451 = phi i32 [ %69, %.preheader ], [ 0, %.lr.ph53.split ]
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph53.split.split
  %62 = load ptr, ptr %28, align 8, !tbaa !15
  %63 = load i32, ptr %13, align 4, !tbaa !12
  %64 = mul nsw i32 %63, %.04451
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %62, i64 %65
  br label %.lr.ph

.preheader.loopexit:                              ; preds = %.lr.ph
  %.pre = load i32, ptr %15, align 4, !tbaa !13
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.lr.ph53.split.split
  %67 = phi i32 [ %.pre, %.preheader.loopexit ], [ %59, %.lr.ph53.split.split ]
  %68 = phi i32 [ %84, %.preheader.loopexit ], [ %60, %.lr.ph53.split.split ]
  %69 = add nuw nsw i32 %.04451, 1
  %70 = icmp slt i32 %69, %67
  br i1 %70, label %.lr.ph53.split.split, label %._crit_edge54, !llvm.loop !21

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.04248 = phi i32 [ %83, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.04347 = phi ptr [ %82, %.lr.ph ], [ %66, %.lr.ph.preheader ]
  %71 = getelementptr inbounds i8, ptr %.04347, i64 2
  %72 = load i8, ptr %71, align 1, !tbaa !18
  %73 = zext i8 %72 to i32
  %74 = tail call i32 @fputc(i32 noundef %73, ptr noundef %8)
  %75 = getelementptr inbounds i8, ptr %.04347, i64 1
  %76 = load i8, ptr %75, align 1, !tbaa !18
  %77 = zext i8 %76 to i32
  %78 = tail call i32 @fputc(i32 noundef %77, ptr noundef %8)
  %79 = load i8, ptr %.04347, align 1, !tbaa !18
  %80 = zext i8 %79 to i32
  %81 = tail call i32 @fputc(i32 noundef %80, ptr noundef %8)
  %82 = getelementptr inbounds i8, ptr %.04347, i64 3
  %83 = add nuw nsw i32 %.04248, 1
  %84 = load i32, ptr %0, align 8, !tbaa !14
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %.lr.ph, label %.preheader.loopexit, !llvm.loop !19

86:                                               ; preds = %._crit_edge54, %9
  %.045 = phi i32 [ 1, %._crit_edge54 ], [ 0, %9 ]
  ret i32 %.045
}

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

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11WordWriteLEtP8_IO_FILE(i16 noundef zeroext, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL12DWordWriteLEjP8_IO_FILE(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL11LongWriteLEiP8_IO_FILE(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fputc(i32 noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { cold 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 8}
!6 = !{!"_ZTS7R2Image", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !7, i64 12}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !10, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!8, !8, i64 0}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !17, !22}
!22 = !{!"llvm.loop.unswitch.partial.disable"}


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