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

; 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.39 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [42 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 @_ZNK7R2Image8WriteRAWEPKc(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 ptr, align 8
  %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
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noalias ptr @fopen(ptr noundef %17, ptr noundef @.str.39)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %25, label %21

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

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #8
  store i32 54321, ptr %8, align 4, !tbaa !9
  %26 = getelementptr inbounds i32, ptr %8, i64 1
  %27 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !11
  store i32 %28, ptr %26, align 4, !tbaa !9
  %29 = getelementptr inbounds i32, ptr %8, i64 2
  %30 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !13
  store i32 %31, ptr %29, align 4, !tbaa !9
  %32 = getelementptr inbounds i32, ptr %8, i64 3
  %33 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !14
  store i32 %34, ptr %32, align 4, !tbaa !9
  %35 = getelementptr inbounds [4 x i32], ptr %8, i64 0, i64 0
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call i64 @fwrite(ptr noundef %35, i64 noundef 4, i64 noundef 4, ptr noundef %36)
  %38 = icmp ne i64 %37, 4
  br i1 %38, label %39, label %43

39:                                               ; preds = %25
  %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.84, ptr noundef %41) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %171

43:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %44 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !11
  %46 = sext i32 %45 to i64
  %47 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %46, i64 4)
  %48 = extractvalue { i64, i1 } %47, 1
  %49 = extractvalue { i64, i1 } %47, 0
  %50 = select i1 %48, i64 -1, i64 %49
  %51 = call noalias noundef nonnull ptr @_Znam(i64 noundef %50) #9
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %58, label %54

54:                                               ; preds = %43
  %55 = load ptr, ptr @stderr, align 8, !tbaa !5
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %55, ptr noundef @.str.82, ptr noundef %56) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %170

58:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %147, %58
  %60 = load i32, ptr %10, align 4, !tbaa !9
  %61 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !14
  %63 = icmp slt i32 %60, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %59
  store i32 2, ptr %7, align 4
  br label %150

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

66:                                               ; preds = %141, %65
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 1
  %69 = load i32, ptr %68, align 4, !tbaa !13
  %70 = icmp slt i32 %67, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %66
  store i32 5, ptr %7, align 4
  br label %144

72:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %73 = load i32, ptr %11, align 4, !tbaa !9
  %74 = call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %16, i32 noundef %73)
  store ptr %74, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %75

75:                                               ; preds = %119, %72
  %76 = load i32, ptr %13, align 4, !tbaa !9
  %77 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %78 = load i32, ptr %77, align 8, !tbaa !11
  %79 = icmp slt i32 %76, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %75
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %122

81:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %90, %81
  %83 = load i32, ptr %14, align 4, !tbaa !9
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = icmp slt i32 %83, %84
  br i1 %85, label %87, label %86

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

87:                                               ; preds = %82
  %88 = load ptr, ptr %12, align 8, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %88, i32 1
  store ptr %89, ptr %12, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %87
  %91 = load i32, ptr %14, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %14, align 4, !tbaa !9
  br label %82, !llvm.loop !15

93:                                               ; preds = %86
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %94, i32 1
  store ptr %95, ptr %12, align 8, !tbaa !5
  %96 = load i8, ptr %94, align 1, !tbaa !17
  %97 = zext i8 %96 to i32
  %98 = sitofp i32 %97 to float
  %99 = fdiv float %98, 2.550000e+02
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = load i32, ptr %13, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds float, ptr %100, i64 %102
  store float %99, ptr %103, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %104 = load i32, ptr %10, align 4, !tbaa !9
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %15, align 4, !tbaa !9
  br label %106

106:                                              ; preds = %115, %93
  %107 = load i32, ptr %15, align 4, !tbaa !9
  %108 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  %109 = load i32, ptr %108, align 8, !tbaa !14
  %110 = icmp slt i32 %107, %109
  br i1 %110, label %112, label %111

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

112:                                              ; preds = %106
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  %114 = getelementptr inbounds i8, ptr %113, i32 1
  store ptr %114, ptr %12, align 8, !tbaa !5
  br label %115

115:                                              ; preds = %112
  %116 = load i32, ptr %15, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %15, align 4, !tbaa !9
  br label %106, !llvm.loop !20

118:                                              ; preds = %111
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %13, align 4, !tbaa !9
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %13, align 4, !tbaa !9
  br label %75, !llvm.loop !21

122:                                              ; preds = %80
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %125 = load i32, ptr %124, align 8, !tbaa !11
  %126 = sext i32 %125 to i64
  %127 = load ptr, ptr %6, align 8, !tbaa !5
  %128 = call i64 @fwrite(ptr noundef %123, i64 noundef 4, i64 noundef %126, ptr noundef %127)
  %129 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %130 = load i32, ptr %129, align 8, !tbaa !11
  %131 = zext i32 %130 to i64
  %132 = icmp ne i64 %128, %131
  br i1 %132, label %133, label %137

133:                                              ; preds = %122
  %134 = load ptr, ptr @stderr, align 8, !tbaa !5
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %134, ptr noundef @.str.85, ptr noundef %135) #8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %138

137:                                              ; preds = %122
  store i32 0, ptr %7, align 4
  br label %138

138:                                              ; preds = %137, %133
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  %139 = load i32, ptr %7, align 4
  switch i32 %139, label %144 [
    i32 0, label %140
  ]

140:                                              ; preds = %138
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %11, align 4, !tbaa !9
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %11, align 4, !tbaa !9
  br label %66, !llvm.loop !22

144:                                              ; preds = %138, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  %145 = load i32, ptr %7, align 4
  switch i32 %145, label %150 [
    i32 5, label %146
  ]

146:                                              ; preds = %144
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %10, align 4, !tbaa !9
  %149 = add nsw i32 %148, 1
  store i32 %149, ptr %10, align 4, !tbaa !9
  br label %59, !llvm.loop !23

150:                                              ; preds = %144, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  %151 = load i32, ptr %7, align 4
  switch i32 %151, label %170 [
    i32 2, label %152
  ]

152:                                              ; preds = %150
  %153 = load ptr, ptr %9, align 8, !tbaa !5
  %154 = icmp eq ptr %153, null
  br i1 %154, label %156, label %155

155:                                              ; preds = %152
  call void @_ZdaPv(ptr noundef %153) #10
  br label %156

156:                                              ; preds = %155, %152
  %157 = load ptr, ptr %6, align 8, !tbaa !5
  %158 = call i32 @fclose(ptr noundef %157)
  %159 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 0
  %160 = load i32, ptr %159, align 8, !tbaa !11
  %161 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 1
  %162 = load i32, ptr %161, align 4, !tbaa !13
  %163 = mul nsw i32 %160, %162
  %164 = getelementptr inbounds %class.R2Image, ptr %16, i32 0, i32 2
  %165 = load i32, ptr %164, align 8, !tbaa !14
  %166 = mul nsw i32 %163, %165
  %167 = sext i32 %166 to i64
  %168 = mul i64 %167, 4
  %169 = trunc i64 %168 to i32
  store i32 %169, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %170

170:                                              ; preds = %156, %150, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %171

171:                                              ; preds = %170, %39
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #8
  br label %172

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

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

declare i32 @fclose(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

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

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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = distinct !{!20, !16}
!21 = distinct !{!21, !16}
!22 = distinct !{!22, !16}
!23 = distinct !{!23, !16}


; 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.39 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.78 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [42 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 @_ZNK7R2Image8WriteRAWEPKc(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.39)
  %.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 %112

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #8
  store i32 54321, ptr %3, align 16, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %3, i64 4
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load <2 x i32>, ptr %0, align 8, !tbaa !9
  store <2 x i32> %11, ptr %9, align 4, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %3, i64 12
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i32, ptr %13, align 8, !tbaa !11
  store i32 %14, ptr %12, align 4, !tbaa !9
  %15 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4, i64 noundef 4, ptr noundef nonnull %4)
  %.not49 = icmp eq i64 %15, 4
  br i1 %.not49, label %19, label %16

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

19:                                               ; preds = %8
  %20 = load i32, ptr %0, align 8, !tbaa !13
  %21 = sext i32 %20 to i64
  %22 = icmp slt i32 %20, 0
  %23 = shl nsw i64 %21, 2
  %24 = select i1 %22, i64 -1, i64 %23
  %25 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %24) #9
  %26 = load i32, ptr %13, align 8, !tbaa !11
  %.not5266 = icmp sgt i32 %26, 0
  %27 = load i32, ptr %10, align 4
  %28 = icmp sgt i32 %27, 0
  %or.cond = select i1 %.not5266, i1 %28, i1 false
  br i1 %or.cond, label %.preheader57, label %.critedge56

.preheader57:                                     ; preds = %19, %.critedge54
  %29 = phi i32 [ %99, %.critedge54 ], [ %27, %19 ]
  %indvars.iv78 = phi i32 [ %indvars.iv.next79, %.critedge54 ], [ 1, %19 ]
  %indvars.iv76 = phi i32 [ %indvars.iv.next77, %.critedge54 ], [ -1, %19 ]
  %indvars.iv = phi i32 [ %indvars.iv.next, %.critedge54 ], [ -1, %19 ]
  %.04067 = phi i32 [ %100, %.critedge54 ], [ 0, %19 ]
  %30 = zext i32 %indvars.iv to i64
  %.not5164 = icmp sgt i32 %29, 0
  br i1 %.not5164, label %.lr.ph, label %.critedge54

.lr.ph:                                           ; preds = %.preheader57
  %.not69 = icmp eq i32 %.04067, 0
  br i1 %.not69, label %.lr.ph.split, label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph, %34
  %.03965.us = phi i32 [ %35, %34 ], [ 0, %.lr.ph ]
  %31 = tail call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.03965.us)
  %32 = load i32, ptr %0, align 8, !tbaa !13
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.preheader.lr.ph.us, label %.critedge.us

34:                                               ; preds = %.critedge.us
  %35 = add nuw nsw i32 %.03965.us, 1
  %36 = load i32, ptr %10, align 4, !tbaa !14
  %.not51.us = icmp slt i32 %35, %36
  br i1 %.not51.us, label %.lr.ph.split.us, label %.critedge54, !llvm.loop !15

.critedge.us.loopexit.unr-lcssa:                  ; preds = %.preheader.us.us, %.preheader.lr.ph.us
  %indvars.iv81.unr = phi i64 [ 0, %.preheader.lr.ph.us ], [ %indvars.iv.next82.3, %.preheader.us.us ]
  %.03860.us.us.unr = phi ptr [ %31, %.preheader.lr.ph.us ], [ %scevgep80.3, %.preheader.us.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.critedge.us, label %.preheader.us.us.epil

.preheader.us.us.epil:                            ; preds = %.critedge.us.loopexit.unr-lcssa, %.preheader.us.us.epil
  %indvars.iv81.epil = phi i64 [ %indvars.iv.next82.epil, %.preheader.us.us.epil ], [ %indvars.iv81.unr, %.critedge.us.loopexit.unr-lcssa ]
  %.03860.us.us.epil = phi ptr [ %scevgep80.epil, %.preheader.us.us.epil ], [ %.03860.us.us.unr, %.critedge.us.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.us.epil ], [ 0, %.critedge.us.loopexit.unr-lcssa ]
  %scevgep.epil = getelementptr i8, ptr %.03860.us.us.epil, i64 1
  %scevgep73.epil = getelementptr i8, ptr %scevgep.epil, i64 %30
  %37 = load i8, ptr %scevgep73.epil, align 1, !tbaa !17
  %38 = uitofp i8 %37 to float
  %39 = fdiv float %38, 2.550000e+02
  %40 = getelementptr inbounds float, ptr %25, i64 %indvars.iv81.epil
  store float %39, ptr %40, align 4, !tbaa !18
  %scevgep74.epil = getelementptr i8, ptr %.03860.us.us.epil, i64 2
  %scevgep75.epil = getelementptr i8, ptr %scevgep74.epil, i64 %30
  %scevgep80.epil = getelementptr i8, ptr %scevgep75.epil, i64 %47
  %indvars.iv.next82.epil = add nuw nsw i64 %indvars.iv81.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.critedge.us, label %.preheader.us.us.epil, !llvm.loop !20

.critedge.us:                                     ; preds = %.critedge.us.loopexit.unr-lcssa, %.preheader.us.us.epil, %.lr.ph.split.us
  %41 = sext i32 %32 to i64
  %42 = tail call i64 @fwrite(ptr noundef nonnull %25, i64 noundef 4, i64 noundef %41, ptr noundef nonnull %4)
  %43 = load i32, ptr %0, align 8, !tbaa !13
  %44 = zext i32 %43 to i64
  %.not50.us = icmp eq i64 %42, %44
  br i1 %.not50.us, label %34, label %.split.us

.preheader.lr.ph.us:                              ; preds = %.lr.ph.split.us
  %45 = load i32, ptr %13, align 8, !tbaa !11
  %smax = tail call i32 @llvm.smax.i32(i32 %45, i32 %indvars.iv78)
  %46 = add i32 %indvars.iv76, %smax
  %47 = zext i32 %46 to i64
  %wide.trip.count = zext nneg i32 %32 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %48 = icmp ult i32 %32, 4
  br i1 %48, label %.critedge.us.loopexit.unr-lcssa, label %.preheader.lr.ph.us.new

.preheader.lr.ph.us.new:                          ; preds = %.preheader.lr.ph.us
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.preheader.us.us

.preheader.us.us:                                 ; preds = %.preheader.us.us, %.preheader.lr.ph.us.new
  %indvars.iv81 = phi i64 [ 0, %.preheader.lr.ph.us.new ], [ %indvars.iv.next82.3, %.preheader.us.us ]
  %.03860.us.us = phi ptr [ %31, %.preheader.lr.ph.us.new ], [ %scevgep80.3, %.preheader.us.us ]
  %niter = phi i64 [ 0, %.preheader.lr.ph.us.new ], [ %niter.next.3, %.preheader.us.us ]
  %scevgep = getelementptr i8, ptr %.03860.us.us, i64 1
  %scevgep73 = getelementptr i8, ptr %scevgep, i64 %30
  %49 = load i8, ptr %scevgep73, align 1, !tbaa !17
  %50 = uitofp i8 %49 to float
  %51 = fdiv float %50, 2.550000e+02
  %52 = getelementptr inbounds float, ptr %25, i64 %indvars.iv81
  store float %51, ptr %52, align 4, !tbaa !18
  %scevgep74 = getelementptr i8, ptr %.03860.us.us, i64 2
  %scevgep75 = getelementptr i8, ptr %scevgep74, i64 %30
  %scevgep80 = getelementptr i8, ptr %scevgep75, i64 %47
  %indvars.iv.next82 = or disjoint i64 %indvars.iv81, 1
  %scevgep.1 = getelementptr i8, ptr %scevgep80, i64 1
  %scevgep73.1 = getelementptr i8, ptr %scevgep.1, i64 %30
  %53 = load i8, ptr %scevgep73.1, align 1, !tbaa !17
  %54 = uitofp i8 %53 to float
  %55 = fdiv float %54, 2.550000e+02
  %56 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next82
  store float %55, ptr %56, align 4, !tbaa !18
  %scevgep74.1 = getelementptr i8, ptr %scevgep80, i64 2
  %scevgep75.1 = getelementptr i8, ptr %scevgep74.1, i64 %30
  %scevgep80.1 = getelementptr i8, ptr %scevgep75.1, i64 %47
  %indvars.iv.next82.1 = or disjoint i64 %indvars.iv81, 2
  %scevgep.2 = getelementptr i8, ptr %scevgep80.1, i64 1
  %scevgep73.2 = getelementptr i8, ptr %scevgep.2, i64 %30
  %57 = load i8, ptr %scevgep73.2, align 1, !tbaa !17
  %58 = uitofp i8 %57 to float
  %59 = fdiv float %58, 2.550000e+02
  %60 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next82.1
  store float %59, ptr %60, align 4, !tbaa !18
  %scevgep74.2 = getelementptr i8, ptr %scevgep80.1, i64 2
  %scevgep75.2 = getelementptr i8, ptr %scevgep74.2, i64 %30
  %scevgep80.2 = getelementptr i8, ptr %scevgep75.2, i64 %47
  %indvars.iv.next82.2 = or disjoint i64 %indvars.iv81, 3
  %scevgep.3 = getelementptr i8, ptr %scevgep80.2, i64 1
  %scevgep73.3 = getelementptr i8, ptr %scevgep.3, i64 %30
  %61 = load i8, ptr %scevgep73.3, align 1, !tbaa !17
  %62 = uitofp i8 %61 to float
  %63 = fdiv float %62, 2.550000e+02
  %64 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next82.2
  store float %63, ptr %64, align 4, !tbaa !18
  %scevgep74.3 = getelementptr i8, ptr %scevgep80.2, i64 2
  %scevgep75.3 = getelementptr i8, ptr %scevgep74.3, i64 %30
  %scevgep80.3 = getelementptr i8, ptr %scevgep75.3, i64 %47
  %indvars.iv.next82.3 = add nuw nsw i64 %indvars.iv81, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.critedge.us.loopexit.unr-lcssa, label %.preheader.us.us, !llvm.loop !22

65:                                               ; preds = %.critedge
  %66 = add nuw nsw i32 %.03965, 1
  %67 = load i32, ptr %10, align 4, !tbaa !14
  %.not51 = icmp slt i32 %66, %67
  br i1 %.not51, label %.lr.ph.split, label %.critedge54, !llvm.loop !15

.lr.ph.split:                                     ; preds = %.lr.ph, %65
  %.03965 = phi i32 [ %66, %65 ], [ 0, %.lr.ph ]
  %68 = tail call noundef ptr @_ZNK7R2Image6PixelsEi(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %.03965)
  %69 = load i32, ptr %0, align 8, !tbaa !13
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.preheader.lr.ph, label %.critedge

.preheader.lr.ph:                                 ; preds = %.lr.ph.split
  %71 = load i32, ptr %13, align 8, !tbaa !11
  %smax85 = tail call i32 @llvm.smax.i32(i32 %71, i32 %indvars.iv78)
  %72 = add i32 %indvars.iv76, %smax85
  %73 = zext i32 %72 to i64
  %wide.trip.count90 = zext nneg i32 %69 to i64
  %xtraiter102 = and i64 %wide.trip.count90, 3
  %74 = icmp ult i32 %69, 4
  br i1 %74, label %.critedge.loopexit.unr-lcssa, label %.preheader.lr.ph.new

.preheader.lr.ph.new:                             ; preds = %.preheader.lr.ph
  %unroll_iter105 = and i64 %wide.trip.count90, 2147483644
  br label %.preheader

.preheader:                                       ; preds = %.preheader, %.preheader.lr.ph.new
  %indvars.iv87 = phi i64 [ 0, %.preheader.lr.ph.new ], [ %indvars.iv.next88.3, %.preheader ]
  %.03860 = phi ptr [ %68, %.preheader.lr.ph.new ], [ %scevgep86.3, %.preheader ]
  %niter106 = phi i64 [ 0, %.preheader.lr.ph.new ], [ %niter106.next.3, %.preheader ]
  %75 = load i8, ptr %.03860, align 1, !tbaa !17
  %76 = uitofp i8 %75 to float
  %77 = fdiv float %76, 2.550000e+02
  %78 = getelementptr inbounds float, ptr %25, i64 %indvars.iv87
  store float %77, ptr %78, align 4, !tbaa !18
  %scevgep84 = getelementptr i8, ptr %.03860, i64 1
  %scevgep86 = getelementptr i8, ptr %scevgep84, i64 %73
  %indvars.iv.next88 = or disjoint i64 %indvars.iv87, 1
  %79 = load i8, ptr %scevgep86, align 1, !tbaa !17
  %80 = uitofp i8 %79 to float
  %81 = fdiv float %80, 2.550000e+02
  %82 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next88
  store float %81, ptr %82, align 4, !tbaa !18
  %scevgep84.1 = getelementptr i8, ptr %scevgep86, i64 1
  %scevgep86.1 = getelementptr i8, ptr %scevgep84.1, i64 %73
  %indvars.iv.next88.1 = or disjoint i64 %indvars.iv87, 2
  %83 = load i8, ptr %scevgep86.1, align 1, !tbaa !17
  %84 = uitofp i8 %83 to float
  %85 = fdiv float %84, 2.550000e+02
  %86 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next88.1
  store float %85, ptr %86, align 4, !tbaa !18
  %scevgep84.2 = getelementptr i8, ptr %scevgep86.1, i64 1
  %scevgep86.2 = getelementptr i8, ptr %scevgep84.2, i64 %73
  %indvars.iv.next88.2 = or disjoint i64 %indvars.iv87, 3
  %87 = load i8, ptr %scevgep86.2, align 1, !tbaa !17
  %88 = uitofp i8 %87 to float
  %89 = fdiv float %88, 2.550000e+02
  %90 = getelementptr inbounds float, ptr %25, i64 %indvars.iv.next88.2
  store float %89, ptr %90, align 4, !tbaa !18
  %scevgep84.3 = getelementptr i8, ptr %scevgep86.2, i64 1
  %scevgep86.3 = getelementptr i8, ptr %scevgep84.3, i64 %73
  %indvars.iv.next88.3 = add nuw nsw i64 %indvars.iv87, 4
  %niter106.next.3 = add i64 %niter106, 4
  %niter106.ncmp.3 = icmp eq i64 %niter106.next.3, %unroll_iter105
  br i1 %niter106.ncmp.3, label %.critedge.loopexit.unr-lcssa, label %.preheader, !llvm.loop !22

.critedge.loopexit.unr-lcssa:                     ; preds = %.preheader, %.preheader.lr.ph
  %indvars.iv87.unr = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next88.3, %.preheader ]
  %.03860.unr = phi ptr [ %68, %.preheader.lr.ph ], [ %scevgep86.3, %.preheader ]
  %lcmp.mod104.not = icmp eq i64 %xtraiter102, 0
  br i1 %lcmp.mod104.not, label %.critedge, label %.preheader.epil

.preheader.epil:                                  ; preds = %.critedge.loopexit.unr-lcssa, %.preheader.epil
  %indvars.iv87.epil = phi i64 [ %indvars.iv.next88.epil, %.preheader.epil ], [ %indvars.iv87.unr, %.critedge.loopexit.unr-lcssa ]
  %.03860.epil = phi ptr [ %scevgep86.epil, %.preheader.epil ], [ %.03860.unr, %.critedge.loopexit.unr-lcssa ]
  %epil.iter103 = phi i64 [ %epil.iter103.next, %.preheader.epil ], [ 0, %.critedge.loopexit.unr-lcssa ]
  %91 = load i8, ptr %.03860.epil, align 1, !tbaa !17
  %92 = uitofp i8 %91 to float
  %93 = fdiv float %92, 2.550000e+02
  %94 = getelementptr inbounds float, ptr %25, i64 %indvars.iv87.epil
  store float %93, ptr %94, align 4, !tbaa !18
  %scevgep84.epil = getelementptr i8, ptr %.03860.epil, i64 1
  %scevgep86.epil = getelementptr i8, ptr %scevgep84.epil, i64 %73
  %indvars.iv.next88.epil = add nuw nsw i64 %indvars.iv87.epil, 1
  %epil.iter103.next = add i64 %epil.iter103, 1
  %epil.iter103.cmp.not = icmp eq i64 %epil.iter103.next, %xtraiter102
  br i1 %epil.iter103.cmp.not, label %.critedge, label %.preheader.epil, !llvm.loop !23

.critedge:                                        ; preds = %.critedge.loopexit.unr-lcssa, %.preheader.epil, %.lr.ph.split
  %95 = sext i32 %69 to i64
  %96 = tail call i64 @fwrite(ptr noundef nonnull %25, i64 noundef 4, i64 noundef %95, ptr noundef nonnull %4)
  %97 = load i32, ptr %0, align 8, !tbaa !13
  %98 = zext i32 %97 to i64
  %.not50 = icmp eq i64 %96, %98
  br i1 %.not50, label %65, label %.split.us

.critedge54:                                      ; preds = %34, %65, %.preheader57
  %99 = phi i32 [ %29, %.preheader57 ], [ %67, %65 ], [ %36, %34 ]
  %100 = add nuw nsw i32 %.04067, 1
  %101 = load i32, ptr %13, align 8, !tbaa !11
  %.not52 = icmp slt i32 %100, %101
  %indvars.iv.next = add nsw i32 %indvars.iv, 1
  %indvars.iv.next77 = add nsw i32 %indvars.iv76, -1
  %indvars.iv.next79 = add nuw i32 %indvars.iv78, 1
  br i1 %.not52, label %.preheader57, label %.critedge56, !llvm.loop !24

.split.us:                                        ; preds = %.critedge.us, %.critedge
  %102 = load ptr, ptr @stderr, align 8, !tbaa !5
  %103 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %102, ptr noundef nonnull @.str.85, ptr noundef %1) #7
  br label %111

.critedge56:                                      ; preds = %.critedge54, %19
  tail call void @_ZdaPv(ptr noundef nonnull %25) #10
  %104 = tail call i32 @fclose(ptr noundef nonnull %4)
  %105 = load i32, ptr %0, align 8, !tbaa !13
  %106 = load i32, ptr %10, align 4, !tbaa !14
  %107 = load i32, ptr %13, align 8, !tbaa !11
  %108 = shl i32 %105, 2
  %109 = mul i32 %108, %106
  %110 = mul i32 %109, %107
  br label %111

111:                                              ; preds = %.split.us, %.critedge56, %16
  %.6 = phi i32 [ 0, %16 ], [ %110, %.critedge56 ], [ 0, %.split.us ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #8
  br label %112

112:                                              ; preds = %111, %5
  %.7 = phi i32 [ %.6, %111 ], [ 0, %5 ]
  ret i32 %.7
}

; 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: 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: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; 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 8}
!12 = !{!"_ZTS7R2Image", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!12, !10, i64 0}
!14 = !{!12, !10, i64 4}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.unroll.disable"}
!22 = distinct !{!22, !16}
!23 = distinct !{!23, !21}
!24 = distinct !{!24, !16, !25}
!25 = !{!"llvm.loop.unswitch.partial.disable"}


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