; LLVM IR from Lut1n/ImpGears :: src/ImpGears/Descriptors (ImageIO)

; 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.BitmapFileHeader_Struct = type { i16, i32, i16, i16, i32 }
%union.DibHeader_Union = type { %struct.BitmapInfoHeader_Struct }
%struct.BitmapInfoHeader_Struct = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::shared_ptr.7" = type { %"class.std::__shared_ptr.8" }
%"class.std::__shared_ptr.8" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

declare noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

declare noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

declare noundef i32 @_ZNK3imp5Image8channelsEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp8bmp_saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrINS_5ImageEE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1) #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.BitmapFileHeader_Struct, align 4
  %6 = alloca %union.DibHeader_Union, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.std::basic_ofstream", align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca %"class.std::shared_ptr.7", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 40, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 40, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store ptr %6, ptr %8, align 8, !tbaa !5
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %21, i32 0, i32 0
  store i32 %20, ptr %22, align 4, !tbaa !11
  %23 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %24 = call noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %23)
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 4, !tbaa !14
  %27 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %28 = call noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %29, i32 0, i32 2
  store i32 %28, ptr %30, align 4, !tbaa !15
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %31, i32 0, i32 3
  store i16 1, ptr %32, align 4, !tbaa !16
  %33 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %34 = call noundef i32 @_ZNK3imp5Image8channelsEv(ptr noundef nonnull align 8 dereferenceable(88) %33)
  %35 = mul nsw i32 %34, 8
  %36 = trunc i32 %35 to i16
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %37, i32 0, i32 4
  store i16 %36, ptr %38, align 2, !tbaa !17
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %39, i32 0, i32 5
  store i32 0, ptr %40, align 4, !tbaa !18
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %41, i32 0, i32 6
  store i32 0, ptr %42, align 4, !tbaa !19
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %43, i32 0, i32 7
  store i32 0, ptr %44, align 4, !tbaa !20
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %45, i32 0, i32 8
  store i32 0, ptr %46, align 4, !tbaa !21
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %47, i32 0, i32 9
  store i32 0, ptr %48, align 4, !tbaa !22
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %49, i32 0, i32 10
  store i32 0, ptr %50, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %51 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %6, i32 0, i32 4
  %52 = load i16, ptr %51, align 2, !tbaa !24
  %53 = zext i16 %52 to i32
  %54 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %6, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !24
  %56 = mul nsw i32 %53, %55
  %57 = add nsw i32 %56, 31
  %58 = sdiv i32 %57, 32
  %59 = mul nsw i32 %58, 4
  store i32 %59, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %6, i32 0, i32 2
  %62 = load i32, ptr %61, align 4, !tbaa !24
  %63 = mul nsw i32 %60, %62
  store i32 %63, ptr %10, align 4, !tbaa !9
  %64 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 0
  store i16 16973, ptr %64, align 4, !tbaa !25
  %65 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 4
  store i32 54, ptr %65, align 4, !tbaa !27
  %66 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 4
  %67 = load i32, ptr %66, align 4, !tbaa !27
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = add i32 %67, %68
  %70 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 1
  store i32 %69, ptr %70, align 4, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 512, ptr %11) #7
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %71) #7
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %11, ptr noundef %72, i32 noundef 4)
  %73 = load ptr, ptr %11, align 8, !tbaa !29
  %74 = getelementptr i8, ptr %73, i64 -24
  %75 = load i64, ptr %74, align 8
  %76 = getelementptr inbounds i8, ptr %11, i64 %75
  %77 = invoke noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264) %76)
          to label %78 unwind label %145

78:                                               ; preds = %2
  br i1 %77, label %79, label %196

79:                                               ; preds = %78
  invoke void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i8 noundef signext 66)
          to label %80 unwind label %145

80:                                               ; preds = %79
  invoke void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i8 noundef signext 77)
          to label %81 unwind label %145

81:                                               ; preds = %80
  %82 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !28
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %83)
          to label %84 unwind label %145

84:                                               ; preds = %81
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i16 noundef signext 0)
          to label %85 unwind label %145

85:                                               ; preds = %84
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i16 noundef signext 0)
          to label %86 unwind label %145

86:                                               ; preds = %85
  %87 = getelementptr inbounds %struct.BitmapFileHeader_Struct, ptr %5, i32 0, i32 4
  %88 = load i32, ptr %87, align 4, !tbaa !27
  invoke void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %88)
          to label %89 unwind label %145

89:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store ptr %6, ptr %14, align 8, !tbaa !5
  %90 = load ptr, ptr %14, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %90, i32 0, i32 0
  %92 = load i32, ptr %91, align 4, !tbaa !11
  invoke void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %92)
          to label %93 unwind label %149

93:                                               ; preds = %89
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !14
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %96)
          to label %97 unwind label %149

97:                                               ; preds = %93
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %98, i32 0, i32 2
  %100 = load i32, ptr %99, align 4, !tbaa !15
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %100)
          to label %101 unwind label %149

101:                                              ; preds = %97
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %102, i32 0, i32 3
  %104 = load i16, ptr %103, align 4, !tbaa !16
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i16 noundef signext %104)
          to label %105 unwind label %149

105:                                              ; preds = %101
  %106 = load ptr, ptr %14, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %106, i32 0, i32 4
  %108 = load i16, ptr %107, align 2, !tbaa !17
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i16 noundef signext %108)
          to label %109 unwind label %149

109:                                              ; preds = %105
  %110 = load ptr, ptr %14, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %110, i32 0, i32 5
  %112 = load i32, ptr %111, align 4, !tbaa !18
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %112)
          to label %113 unwind label %149

113:                                              ; preds = %109
  %114 = load ptr, ptr %14, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %114, i32 0, i32 6
  %116 = load i32, ptr %115, align 4, !tbaa !19
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %116)
          to label %117 unwind label %149

117:                                              ; preds = %113
  %118 = load ptr, ptr %14, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %118, i32 0, i32 7
  %120 = load i32, ptr %119, align 4, !tbaa !20
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %120)
          to label %121 unwind label %149

121:                                              ; preds = %117
  %122 = load ptr, ptr %14, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %122, i32 0, i32 8
  %124 = load i32, ptr %123, align 4, !tbaa !21
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %124)
          to label %125 unwind label %149

125:                                              ; preds = %121
  %126 = load ptr, ptr %14, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %126, i32 0, i32 9
  %128 = load i32, ptr %127, align 4, !tbaa !22
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %128)
          to label %129 unwind label %149

129:                                              ; preds = %125
  %130 = load ptr, ptr %14, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %130, i32 0, i32 10
  %132 = load i32, ptr %131, align 4, !tbaa !23
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %11, i32 noundef %132)
          to label %133 unwind label %149

133:                                              ; preds = %129
  %134 = load i32, ptr %9, align 4, !tbaa !9
  %135 = zext i32 %134 to i64
  %136 = call ptr @llvm.stacksave.p0()
  store ptr %136, ptr %15, align 8
  %137 = alloca i8, i64 %135, align 16
  store i64 %135, ptr %16, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %138

138:                                              ; preds = %173, %133
  %139 = load i32, ptr %17, align 4, !tbaa !9
  %140 = load ptr, ptr %14, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.BitmapInfoHeader_Struct, ptr %140, i32 0, i32 2
  %142 = load i32, ptr %141, align 4, !tbaa !15
  %143 = icmp slt i32 %139, %142
  br i1 %143, label %153, label %144

144:                                              ; preds = %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %190

145:                                              ; preds = %86, %85, %84, %81, %80, %79, %2
  %146 = landingpad { ptr, i32 }
          cleanup
  %147 = extractvalue { ptr, i32 } %146, 0
  store ptr %147, ptr %12, align 8
  %148 = extractvalue { ptr, i32 } %146, 1
  store i32 %148, ptr %13, align 4
  br label %197

149:                                              ; preds = %192, %190, %129, %125, %121, %117, %113, %109, %105, %101, %97, %93, %89
  %150 = landingpad { ptr, i32 }
          cleanup
  %151 = extractvalue { ptr, i32 } %150, 0
  store ptr %151, ptr %12, align 8
  %152 = extractvalue { ptr, i32 } %150, 1
  store i32 %152, ptr %13, align 4
  br label %195

153:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #7
  %154 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  invoke void @_ZNK3imp5Image6asGridEv(ptr dead_on_unwind writable sret(%"class.std::shared_ptr.7") align 8 %19, ptr noundef nonnull align 8 dereferenceable(88) %154)
          to label %155 unwind label %176

155:                                              ; preds = %153
  %156 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %19) #7
  %157 = invoke noundef ptr @_ZN3imp4GridILi3EhE4dataEv(ptr noundef nonnull align 8 dereferenceable(128) %156)
          to label %158 unwind label %180

158:                                              ; preds = %155
  %159 = load i32, ptr %17, align 4, !tbaa !9
  %160 = load i32, ptr %9, align 4, !tbaa !9
  %161 = mul nsw i32 %159, %160
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds i8, ptr %157, i64 %162
  call void @_ZNSt12__shared_ptrIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #7
  store ptr %163, ptr %18, align 8, !tbaa !5
  %164 = load i32, ptr %9, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  call void @llvm.memset.p0.i64(ptr align 16 %137, i8 0, i64 %165, i1 false)
  %166 = load ptr, ptr %18, align 8, !tbaa !5
  %167 = load i32, ptr %9, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %137, ptr align 1 %166, i64 %168, i1 false)
  %169 = load i32, ptr %9, align 4, !tbaa !9
  %170 = sext i32 %169 to i64
  %171 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef %137, i64 noundef %170)
          to label %172 unwind label %185

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

173:                                              ; preds = %172
  %174 = load i32, ptr %17, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %17, align 4, !tbaa !9
  br label %138, !llvm.loop !31

176:                                              ; preds = %153
  %177 = landingpad { ptr, i32 }
          cleanup
  %178 = extractvalue { ptr, i32 } %177, 0
  store ptr %178, ptr %12, align 8
  %179 = extractvalue { ptr, i32 } %177, 1
  store i32 %179, ptr %13, align 4
  br label %184

180:                                              ; preds = %155
  %181 = landingpad { ptr, i32 }
          cleanup
  %182 = extractvalue { ptr, i32 } %181, 0
  store ptr %182, ptr %12, align 8
  %183 = extractvalue { ptr, i32 } %181, 1
  store i32 %183, ptr %13, align 4
  call void @_ZNSt12__shared_ptrIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %19) #7
  br label %184

184:                                              ; preds = %180, %176
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #7
  br label %189

185:                                              ; preds = %158
  %186 = landingpad { ptr, i32 }
          cleanup
  %187 = extractvalue { ptr, i32 } %186, 0
  store ptr %187, ptr %12, align 8
  %188 = extractvalue { ptr, i32 } %186, 1
  store i32 %188, ptr %13, align 4
  br label %189

189:                                              ; preds = %185, %184
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %195

190:                                              ; preds = %144
  %191 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %192 unwind label %149

192:                                              ; preds = %190
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv(ptr noundef nonnull align 8 dereferenceable(248) %11)
          to label %193 unwind label %149

193:                                              ; preds = %192
  %194 = load ptr, ptr %15, align 8
  call void @llvm.stackrestore.p0(ptr %194)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %196

195:                                              ; preds = %189, %149
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %197

196:                                              ; preds = %193, %78
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %11) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  ret void

197:                                              ; preds = %195, %145
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %11) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #7
  br label %198

198:                                              ; preds = %197
  %199 = load ptr, ptr %12, align 8
  %200 = load i32, ptr %13, align 4
  %201 = insertvalue { ptr, i32 } poison, ptr %199, 0
  %202 = insertvalue { ptr, i32 } %201, i32 %200, 1
  resume { ptr, i32 } %202
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i8 noundef signext) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i16 noundef signext) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

declare void @_ZNK3imp5Image6asGridEv(ptr dead_on_unwind writable sret(%"class.std::shared_ptr.7") align 8, ptr noundef nonnull align 8 dereferenceable(88)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3imp4GridILi3EhE4dataEv(ptr noundef nonnull align 8 dereferenceable(128)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv(ptr noundef nonnull align 8 dereferenceable(248)) #3 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { nocallback nofree nosync nounwind willreturn }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!"_ZTS23BitmapInfoHeader_Struct", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !10, i64 4}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !13, i64 12}
!17 = !{!12, !13, i64 14}
!18 = !{!12, !10, i64 16}
!19 = !{!12, !10, i64 20}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !10, i64 28}
!22 = !{!12, !10, i64 32}
!23 = !{!12, !10, i64 36}
!24 = !{!7, !7, i64 0}
!25 = !{!26, !13, i64 0}
!26 = !{!"_ZTS23BitmapFileHeader_Struct", !13, i64 0, !10, i64 4, !13, i64 8, !13, i64 10, !10, i64 12}
!27 = !{!26, !10, i64 12}
!28 = !{!26, !10, i64 4}
!29 = !{!30, !30, i64 0}
!30 = !{!"vtable pointer", !8, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


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

%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon }
%union.anon = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::shared_ptr.7" = type { %"class.std::__shared_ptr.8" }
%"class.std::__shared_ptr.8" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

declare noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef i32 @_ZNK3imp5Image8channelsEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3imp8bmp_saveERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrINS_5ImageEE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull %1) local_unnamed_addr #3 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::basic_ofstream", align 8
  %4 = alloca %"class.std::shared_ptr.7", align 8
  %5 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %6 = tail call noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %5)
  %7 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %8 = tail call noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88) %7)
  %9 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  %10 = tail call noundef i32 @_ZNK3imp5Image8channelsEv(ptr noundef nonnull align 8 dereferenceable(88) %9)
  %.tr = trunc i32 %10 to i16
  %11 = shl i16 %.tr, 3
  %12 = zext i16 %11 to i32
  %13 = mul nsw i32 %6, %12
  %14 = add nsw i32 %13, 31
  %15 = sdiv i32 %14, 32
  %16 = shl nsw i32 %15, 2
  %17 = mul nsw i32 %16, %8
  %18 = add i32 %17, 54
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %3) #7
  %19 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #7
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %3, ptr noundef %19, i32 noundef 4)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr i8, ptr %20, i64 -24
  %22 = load i64, ptr %21, align 8
  %23 = getelementptr inbounds i8, ptr %3, i64 %22
  %24 = invoke noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264) %23)
          to label %25 unwind label %50

25:                                               ; preds = %2
  br i1 %24, label %26, label %69

26:                                               ; preds = %25
  invoke void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i8 noundef signext 66)
          to label %27 unwind label %50

27:                                               ; preds = %26
  invoke void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i8 noundef signext 77)
          to label %28 unwind label %50

28:                                               ; preds = %27
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef %18)
          to label %29 unwind label %50

29:                                               ; preds = %28
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i16 noundef signext 0)
          to label %30 unwind label %50

30:                                               ; preds = %29
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i16 noundef signext 0)
          to label %31 unwind label %50

31:                                               ; preds = %30
  invoke void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 54)
          to label %32 unwind label %50

32:                                               ; preds = %31
  invoke void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 40)
          to label %33 unwind label %52

33:                                               ; preds = %32
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef %6)
          to label %34 unwind label %52

34:                                               ; preds = %33
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef %8)
          to label %35 unwind label %52

35:                                               ; preds = %34
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i16 noundef signext 1)
          to label %36 unwind label %52

36:                                               ; preds = %35
  invoke void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i16 noundef signext %11)
          to label %37 unwind label %52

37:                                               ; preds = %36
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %38 unwind label %52

38:                                               ; preds = %37
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %39 unwind label %52

39:                                               ; preds = %38
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %40 unwind label %52

40:                                               ; preds = %39
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %41 unwind label %52

41:                                               ; preds = %40
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %42 unwind label %52

42:                                               ; preds = %41
  invoke void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248) %3, i32 noundef 0)
          to label %43 unwind label %52

43:                                               ; preds = %42
  %44 = zext i32 %16 to i64
  %45 = call ptr @llvm.stacksave.p0()
  %46 = alloca i8, i64 %44, align 16
  %47 = icmp sgt i32 %8, 0
  br i1 %47, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %43
  %48 = sext i32 %16 to i64
  %wide.trip.count = zext nneg i32 %8 to i64
  br label %54

._crit_edge:                                      ; preds = %62, %43
  %49 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %67 unwind label %52

50:                                               ; preds = %31, %30, %29, %28, %27, %26, %2
  %51 = landingpad { ptr, i32 }
          cleanup
  br label %70

52:                                               ; preds = %67, %._crit_edge, %42, %41, %40, %39, %38, %37, %36, %35, %34, %33, %32
  %53 = landingpad { ptr, i32 }
          cleanup
  br label %70

54:                                               ; preds = %.lr.ph, %62
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %62 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  %55 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp5ImageELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %1) #7
  invoke void @_ZNK3imp5Image6asGridEv(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr.7") align 8 %4, ptr noundef nonnull align 8 dereferenceable(88) %55)
          to label %56 unwind label %63

56:                                               ; preds = %54
  %57 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %4) #7
  %58 = call noundef ptr @_ZN3imp4GridILi3EhE4dataEv(ptr noundef nonnull align 8 dereferenceable(128) %57)
  %59 = mul nsw i64 %indvars.iv, %48
  %60 = getelementptr inbounds i8, ptr %58, i64 %59
  call void @_ZNSt12__shared_ptrIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %46, i8 0, i64 %48, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %46, ptr align 1 %60, i64 %48, i1 false)
  %61 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull %46, i64 noundef %48)
          to label %62 unwind label %65

62:                                               ; preds = %56
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %54, !llvm.loop !8

63:                                               ; preds = %54
  %64 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  br label %70

65:                                               ; preds = %56
  %66 = landingpad { ptr, i32 }
          cleanup
  br label %70

67:                                               ; preds = %._crit_edge
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv(ptr noundef nonnull align 8 dereferenceable(248) %3)
          to label %68 unwind label %52

68:                                               ; preds = %67
  call void @llvm.stackrestore.p0(ptr %45)
  br label %69

69:                                               ; preds = %68, %25
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %3) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #7
  ret void

70:                                               ; preds = %52, %65, %63, %50
  %.pn.pn.pn = phi { ptr, i32 } [ %51, %50 ], [ %53, %52 ], [ %66, %65 ], [ %64, %63 ]
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %3) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #7
  resume { ptr, i32 } %.pn.pn.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef zeroext i1 @_ZNKSt9basic_iosIcSt11char_traitsIcEEcvbEv(ptr noundef nonnull align 8 dereferenceable(264)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIcEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i8 noundef signext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIiEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIsEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i16 noundef signext) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5writeIjEvRSt14basic_ofstreamIcSt11char_traitsIcEET_(ptr noundef nonnull align 8 dereferenceable(248), i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #4

declare void @_ZNK3imp5Image6asGridEv(ptr dead_on_unwind writable sret(%"class.std::shared_ptr.7") align 8, ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3imp4GridILi3EhE4dataEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN3imp4GridILi3EhEELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5flushEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass