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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%class.R2Image = type { i32, i32, i32, i32, ptr }

@stderr = external global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [43 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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7R2Image7ReadRAWEPKc(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 [4 x i32], align 16
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.25)
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %26, label %22

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

26:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #8
  %27 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 0
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call i64 @fread(ptr noundef %27, i64 noundef 4, i64 noundef 4, ptr noundef %28)
  %30 = icmp ne i64 %29, 4
  br i1 %30, label %31, label %35

31:                                               ; preds = %26
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.79, ptr noundef %33) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %212

35:                                               ; preds = %26
  %36 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 0
  %37 = load i32, ptr %36, align 16, !tbaa !9
  %38 = icmp ne i32 %37, 54321
  br i1 %38, label %39, label %43

39:                                               ; preds = %35
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.80, ptr noundef %41) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %212

43:                                               ; preds = %35
  %44 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 1
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  store i32 %45, ptr %46, align 8, !tbaa !11
  %47 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 2
  %48 = load i32, ptr %47, align 8, !tbaa !9
  %49 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 1
  store i32 %48, ptr %49, align 4, !tbaa !13
  %50 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 3
  %51 = load i32, ptr %50, align 4, !tbaa !9
  %52 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 2
  store i32 %51, ptr %52, align 8, !tbaa !14
  %53 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !14
  %55 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !11
  %57 = mul nsw i32 %54, %56
  %58 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 3
  store i32 %57, ptr %58, align 4, !tbaa !15
  %59 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 3
  %60 = load i32, ptr %59, align 4, !tbaa !15
  %61 = srem i32 %60, 4
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %70

63:                                               ; preds = %43
  %64 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 3
  %65 = load i32, ptr %64, align 4, !tbaa !15
  %66 = sdiv i32 %65, 4
  %67 = add nsw i32 %66, 1
  %68 = mul nsw i32 %67, 4
  %69 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 3
  store i32 %68, ptr %69, align 4, !tbaa !15
  br label %70

70:                                               ; preds = %63, %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #8
  %71 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 3
  %72 = load i32, ptr %71, align 4, !tbaa !15
  %73 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !13
  %75 = mul nsw i32 %72, %74
  store i32 %75, ptr %9, align 4, !tbaa !9
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = call noalias noundef nonnull ptr @_Znam(i64 noundef %77) #9
  %79 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 4
  store ptr %78, ptr %79, align 8, !tbaa !16
  %80 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !16
  %82 = icmp ne ptr %81, null
  br i1 %82, label %86, label %83

83:                                               ; preds = %70
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str.81) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %211

86:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  %87 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %88 = load i32, ptr %87, align 8, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %89, i64 4)
  %91 = extractvalue { i64, i1 } %90, 1
  %92 = extractvalue { i64, i1 } %90, 0
  %93 = select i1 %91, i64 -1, i64 %92
  %94 = call noalias noundef nonnull ptr @_Znam(i64 noundef %93) #9
  store ptr %94, ptr %10, align 8, !tbaa !5
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = icmp ne ptr %95, null
  br i1 %96, label %101, label %97

97:                                               ; preds = %86
  %98 = load ptr, ptr @stderr, align 8, !tbaa !5
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef @.str.82, ptr noundef %99) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %210

101:                                              ; preds = %86
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %187, %101
  %103 = load i32, ptr %11, align 4, !tbaa !9
  %104 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 2
  %105 = load i32, ptr %104, align 8, !tbaa !14
  %106 = icmp slt i32 %103, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %102
  store i32 2, ptr %7, align 4
  br label %190

108:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #8
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %109

109:                                              ; preds = %181, %108
  %110 = load i32, ptr %12, align 4, !tbaa !9
  %111 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !13
  %113 = icmp slt i32 %110, %112
  br i1 %113, label %115, label %114

114:                                              ; preds = %109
  store i32 5, ptr %7, align 4
  br label %184

115:                                              ; preds = %109
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %118 = load i32, ptr %117, align 8, !tbaa !11
  %119 = sext i32 %118 to i64
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = call i64 @fread(ptr noundef %116, i64 noundef 4, i64 noundef %119, ptr noundef %120)
  %122 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %123 = load i32, ptr %122, align 8, !tbaa !11
  %124 = zext i32 %123 to i64
  %125 = icmp ne i64 %121, %124
  br i1 %125, label %126, label %130

126:                                              ; preds = %115
  %127 = load ptr, ptr @stderr, align 8, !tbaa !5
  %128 = load ptr, ptr %5, align 8, !tbaa !5
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %127, ptr noundef @.str.83, ptr noundef %128) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %184

130:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %131 = load i32, ptr %12, align 4, !tbaa !9
  %132 = call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %17, i32 noundef %131)
  store ptr %132, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %133

133:                                              ; preds = %177, %130
  %134 = load i32, ptr %14, align 4, !tbaa !9
  %135 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %136 = load i32, ptr %135, align 8, !tbaa !11
  %137 = icmp slt i32 %134, %136
  br i1 %137, label %139, label %138

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

139:                                              ; preds = %133
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %148, %139
  %141 = load i32, ptr %15, align 4, !tbaa !9
  %142 = load i32, ptr %11, align 4, !tbaa !9
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  br label %151

145:                                              ; preds = %140
  %146 = load ptr, ptr %13, align 8, !tbaa !5
  %147 = getelementptr inbounds i8, ptr %146, i32 1
  store ptr %147, ptr %13, align 8, !tbaa !5
  br label %148

148:                                              ; preds = %145
  %149 = load i32, ptr %15, align 4, !tbaa !9
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %15, align 4, !tbaa !9
  br label %140, !llvm.loop !17

151:                                              ; preds = %144
  %152 = load ptr, ptr %10, align 8, !tbaa !5
  %153 = load i32, ptr %14, align 4, !tbaa !9
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds float, ptr %152, i64 %154
  %156 = load float, ptr %155, align 4, !tbaa !19
  %157 = fmul float %156, 2.550000e+02
  %158 = fptosi float %157 to i32
  %159 = trunc i32 %158 to i8
  %160 = load ptr, ptr %13, align 8, !tbaa !5
  %161 = getelementptr inbounds i8, ptr %160, i32 1
  store ptr %161, ptr %13, align 8, !tbaa !5
  store i8 %159, ptr %160, align 1, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #8
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %16, align 4, !tbaa !9
  br label %164

164:                                              ; preds = %173, %151
  %165 = load i32, ptr %16, align 4, !tbaa !9
  %166 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 2
  %167 = load i32, ptr %166, align 8, !tbaa !14
  %168 = icmp slt i32 %165, %167
  br i1 %168, label %170, label %169

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

170:                                              ; preds = %164
  %171 = load ptr, ptr %13, align 8, !tbaa !5
  %172 = getelementptr inbounds i8, ptr %171, i32 1
  store ptr %172, ptr %13, align 8, !tbaa !5
  br label %173

173:                                              ; preds = %170
  %174 = load i32, ptr %16, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %16, align 4, !tbaa !9
  br label %164, !llvm.loop !22

176:                                              ; preds = %169
  br label %177

177:                                              ; preds = %176
  %178 = load i32, ptr %14, align 4, !tbaa !9
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %14, align 4, !tbaa !9
  br label %133, !llvm.loop !23

180:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  br label %181

181:                                              ; preds = %180
  %182 = load i32, ptr %12, align 4, !tbaa !9
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %12, align 4, !tbaa !9
  br label %109, !llvm.loop !24

184:                                              ; preds = %126, %114
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #8
  %185 = load i32, ptr %7, align 4
  switch i32 %185, label %190 [
    i32 5, label %186
  ]

186:                                              ; preds = %184
  br label %187

187:                                              ; preds = %186
  %188 = load i32, ptr %11, align 4, !tbaa !9
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %11, align 4, !tbaa !9
  br label %102, !llvm.loop !25

190:                                              ; preds = %184, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  %191 = load i32, ptr %7, align 4
  switch i32 %191, label %210 [
    i32 2, label %192
  ]

192:                                              ; preds = %190
  %193 = load ptr, ptr %10, align 8, !tbaa !5
  %194 = icmp eq ptr %193, null
  br i1 %194, label %196, label %195

195:                                              ; preds = %192
  call void @_ZdaPv(ptr noundef %193) #10
  br label %196

196:                                              ; preds = %195, %192
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = call i32 @fclose(ptr noundef %197)
  %199 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 0
  %200 = load i32, ptr %199, align 8, !tbaa !11
  %201 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 1
  %202 = load i32, ptr %201, align 4, !tbaa !13
  %203 = mul nsw i32 %200, %202
  %204 = getelementptr inbounds %class.R2Image, ptr %17, i32 0, i32 2
  %205 = load i32, ptr %204, align 8, !tbaa !14
  %206 = mul nsw i32 %203, %205
  %207 = sext i32 %206 to i64
  %208 = mul i64 %207, 4
  %209 = trunc i64 %208 to i32
  store i32 %209, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %210

210:                                              ; preds = %196, %190, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %211

211:                                              ; preds = %210, %83
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #8
  br label %212

212:                                              ; preds = %211, %39, %31
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br label %213

213:                                              ; preds = %212, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  %214 = load i32, ptr %3, align 4
  ret i32 %214
}

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

declare i32 @fclose(ptr noundef) #5

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #6

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #7 align 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 = { nobuiltin 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 = { 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 = { "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS7R2Image", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}
!24 = distinct !{!24, !18}
!25 = distinct !{!25, !18}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.79 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [43 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: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #2

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

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

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

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  %9 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 4, ptr noundef nonnull %4)
  %.not47 = icmp eq i64 %9, 4
  br i1 %.not47, label %13, label %10

10:                                               ; preds = %8
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.79, ptr noundef %1) #7
  br label %107

13:                                               ; preds = %8
  %14 = load i32, ptr %3, align 16, !tbaa !9
  %.not48 = icmp eq i32 %14, 54321
  br i1 %.not48, label %18, label %15

15:                                               ; preds = %13
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.80, ptr noundef %1) #7
  br label %107

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %3, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %20, ptr %0, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %3, i64 8
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %22, ptr %23, align 4, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %3, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %25, ptr %26, align 8, !tbaa !14
  %27 = mul nsw i32 %25, %20
  %28 = getelementptr inbounds i8, ptr %0, i64 12
  %29 = and i32 %27, 3
  %.not49 = icmp eq i32 %29, 0
  br i1 %.not49, label %34, label %30

30:                                               ; preds = %18
  %31 = sdiv i32 %27, 4
  %32 = shl nsw i32 %31, 2
  %33 = add i32 %32, 4
  br label %34

34:                                               ; preds = %30, %18
  %storemerge = phi i32 [ %33, %30 ], [ %27, %18 ]
  store i32 %storemerge, ptr %28, align 4, !tbaa !15
  %35 = mul nsw i32 %storemerge, %22
  %36 = sext i32 %35 to i64
  %37 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %36) #9
  %38 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %37, ptr %38, align 8, !tbaa !16
  %39 = sext i32 %20 to i64
  %40 = icmp slt i32 %20, 0
  %41 = shl nsw i64 %39, 2
  %42 = select i1 %40, i64 -1, i64 %41
  %43 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %42) #9
  %.not5263 = icmp sgt i32 %25, 0
  %44 = icmp sgt i32 %22, 0
  %or.cond = select i1 %.not5263, i1 %44, i1 false
  br i1 %or.cond, label %.preheader55, label %.critedge54

.preheader55:                                     ; preds = %34, %.critedge
  %45 = phi i32 [ %94, %.critedge ], [ %20, %34 ]
  %46 = phi i32 [ %95, %.critedge ], [ %22, %34 ]
  %indvars.iv75 = phi i32 [ %indvars.iv.next76, %.critedge ], [ 1, %34 ]
  %indvars.iv73 = phi i32 [ %indvars.iv.next74, %.critedge ], [ -1, %34 ]
  %indvars.iv = phi i32 [ %indvars.iv.next, %.critedge ], [ -1, %34 ]
  %.04064 = phi i32 [ %96, %.critedge ], [ 0, %34 ]
  %47 = zext i32 %indvars.iv to i64
  %.not5161 = icmp sgt i32 %46, 0
  br i1 %.not5161, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader55
  %.not66 = icmp eq i32 %.04064, 0
  br i1 %.not66, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %._crit_edge60.split.us.us
  %48 = phi i32 [ %57, %._crit_edge60.split.us.us ], [ %45, %.lr.ph ]
  %.03962.us = phi i32 [ %58, %._crit_edge60.split.us.us ], [ 0, %.lr.ph ]
  %49 = sext i32 %48 to i64
  %50 = tail call i64 @fread(ptr noundef nonnull %43, i64 noundef 4, i64 noundef %49, ptr noundef nonnull %4)
  %51 = load i32, ptr %0, align 8, !tbaa !11
  %52 = zext i32 %51 to i64
  %.not50.us = icmp eq i64 %50, %52
  br i1 %.not50.us, label %53, label %.split.us

53:                                               ; preds = %.lr.ph.split.us
  %54 = tail call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.03962.us)
  %55 = load i32, ptr %0, align 8, !tbaa !11
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %.preheader.us.us, label %._crit_edge60.split.us.us

._crit_edge60.split.us.us:                        ; preds = %.preheader.us.us, %53
  %57 = phi i32 [ %55, %53 ], [ %68, %.preheader.us.us ]
  %58 = add nuw nsw i32 %.03962.us, 1
  %59 = load i32, ptr %23, align 4, !tbaa !13
  %.not51.us = icmp slt i32 %58, %59
  br i1 %.not51.us, label %.lr.ph.split.us, label %.critedge, !llvm.loop !17

.preheader.us.us:                                 ; preds = %53, %.preheader.us.us
  %indvars.iv78 = phi i64 [ %indvars.iv.next79, %.preheader.us.us ], [ 0, %53 ]
  %.03858.us.us = phi ptr [ %scevgep77, %.preheader.us.us ], [ %54, %53 ]
  %scevgep = getelementptr i8, ptr %.03858.us.us, i64 1
  %scevgep70 = getelementptr i8, ptr %scevgep, i64 %47
  %60 = getelementptr inbounds float, ptr %43, i64 %indvars.iv78
  %61 = load float, ptr %60, align 4, !tbaa !19
  %62 = fmul float %61, 2.550000e+02
  %63 = fptosi float %62 to i32
  %64 = trunc i32 %63 to i8
  store i8 %64, ptr %scevgep70, align 1, !tbaa !21
  %65 = load i32, ptr %26, align 8, !tbaa !14
  %scevgep71 = getelementptr i8, ptr %.03858.us.us, i64 2
  %smax = tail call i32 @llvm.smax.i32(i32 %65, i32 %indvars.iv75)
  %66 = add i32 %indvars.iv73, %smax
  %67 = zext i32 %66 to i64
  %scevgep72 = getelementptr i8, ptr %scevgep71, i64 %47
  %scevgep77 = getelementptr i8, ptr %scevgep72, i64 %67
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %68 = load i32, ptr %0, align 8, !tbaa !11
  %69 = sext i32 %68 to i64
  %70 = icmp slt i64 %indvars.iv.next79, %69
  br i1 %70, label %.preheader.us.us, label %._crit_edge60.split.us.us, !llvm.loop !22

.lr.ph.split:                                     ; preds = %.lr.ph, %._crit_edge60.split
  %71 = phi i32 [ %91, %._crit_edge60.split ], [ %45, %.lr.ph ]
  %.03962 = phi i32 [ %92, %._crit_edge60.split ], [ 0, %.lr.ph ]
  %72 = sext i32 %71 to i64
  %73 = tail call i64 @fread(ptr noundef nonnull %43, i64 noundef 4, i64 noundef %72, ptr noundef nonnull %4)
  %74 = load i32, ptr %0, align 8, !tbaa !11
  %75 = zext i32 %74 to i64
  %.not50 = icmp eq i64 %73, %75
  br i1 %.not50, label %76, label %.split.us

76:                                               ; preds = %.lr.ph.split
  %77 = tail call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.03962)
  %78 = load i32, ptr %0, align 8, !tbaa !11
  %79 = icmp sgt i32 %78, 0
  br i1 %79, label %.preheader, label %._crit_edge60.split

.preheader:                                       ; preds = %76, %.preheader
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %.preheader ], [ 0, %76 ]
  %.03858 = phi ptr [ %scevgep83, %.preheader ], [ %77, %76 ]
  %80 = getelementptr inbounds float, ptr %43, i64 %indvars.iv84
  %81 = load float, ptr %80, align 4, !tbaa !19
  %82 = fmul float %81, 2.550000e+02
  %83 = fptosi float %82 to i32
  %84 = trunc i32 %83 to i8
  store i8 %84, ptr %.03858, align 1, !tbaa !21
  %85 = load i32, ptr %26, align 8, !tbaa !14
  %smax82 = tail call i32 @llvm.smax.i32(i32 %85, i32 %indvars.iv75)
  %86 = add i32 %indvars.iv73, %smax82
  %87 = zext i32 %86 to i64
  %scevgep81 = getelementptr i8, ptr %.03858, i64 1
  %scevgep83 = getelementptr i8, ptr %scevgep81, i64 %87
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %88 = load i32, ptr %0, align 8, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = icmp slt i64 %indvars.iv.next85, %89
  br i1 %90, label %.preheader, label %._crit_edge60.split, !llvm.loop !22

._crit_edge60.split:                              ; preds = %.preheader, %76
  %91 = phi i32 [ %78, %76 ], [ %88, %.preheader ]
  %92 = add nuw nsw i32 %.03962, 1
  %93 = load i32, ptr %23, align 4, !tbaa !13
  %.not51 = icmp slt i32 %92, %93
  br i1 %.not51, label %.lr.ph.split, label %.critedge, !llvm.loop !17

.critedge:                                        ; preds = %._crit_edge60.split.us.us, %._crit_edge60.split, %.preheader55
  %94 = phi i32 [ %45, %.preheader55 ], [ %91, %._crit_edge60.split ], [ %57, %._crit_edge60.split.us.us ]
  %95 = phi i32 [ %46, %.preheader55 ], [ %93, %._crit_edge60.split ], [ %59, %._crit_edge60.split.us.us ]
  %96 = add nuw nsw i32 %.04064, 1
  %97 = load i32, ptr %26, align 8, !tbaa !14
  %.not52 = icmp slt i32 %96, %97
  %indvars.iv.next = add nsw i32 %indvars.iv, 1
  %indvars.iv.next74 = add nsw i32 %indvars.iv73, -1
  %indvars.iv.next76 = add nuw i32 %indvars.iv75, 1
  br i1 %.not52, label %.preheader55, label %.critedge54, !llvm.loop !23

.split.us:                                        ; preds = %.lr.ph.split.us, %.lr.ph.split
  %98 = load ptr, ptr @stderr, align 8, !tbaa !5
  %99 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef nonnull @.str.83, ptr noundef %1) #7
  br label %107

.critedge54:                                      ; preds = %.critedge, %34
  tail call void @_ZdaPv(ptr noundef nonnull %43) #10
  %100 = tail call i32 @fclose(ptr noundef nonnull %4)
  %101 = load i32, ptr %0, align 8, !tbaa !11
  %102 = load i32, ptr %23, align 4, !tbaa !13
  %103 = load i32, ptr %26, align 8, !tbaa !14
  %104 = shl i32 %101, 2
  %105 = mul i32 %104, %102
  %106 = mul i32 %105, %103
  br label %107

107:                                              ; preds = %.split.us, %.critedge54, %15, %10
  %.5 = phi i32 [ 0, %10 ], [ 0, %15 ], [ %106, %.critedge54 ], [ 0, %.split.us ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #8
  br label %108

108:                                              ; preds = %107, %5
  %.6 = phi i32 [ %.5, %107 ], [ 0, %5 ]
  ret i32 %.6
}

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #5 align 2

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

attributes #0 = { mustprogress 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 = { nobuiltin 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 = { 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 #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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { cold nounwind }
attributes #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }
attributes #10 = { builtin nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS7R2Image", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}
!16 = !{!12, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !7, i64 0}
!21 = !{!7, !7, i64 0}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18, !24}
!24 = !{!"llvm.loop.unswitch.partial.disable"}


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