; LLVM IR from trabucayre/openFPGALoader :: src/gowin.ll (ZN5Gowin15programExtFlashEjb)

; 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.SPIFlash = type <{ ptr, ptr, i8, [3 x i8], i32, ptr, i8, [7 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator.0" = type { i8 }
%class.Device = type <{ ptr, ptr, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i8, i8, i8, i8 }>
%class.Gowin = type { %class.Device.base, %class.SPIInterface, %"class.std::unique_ptr", %"class.std::unique_ptr", %"class.std::unique_ptr", i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32 }
%class.Device.base = type <{ ptr, ptr, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i8, i8, i8 }>
%class.SPIInterface = type { ptr, i8, i32, i8, i8, i8, %"class.std::__cxx11::basic_string" }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.68" }
%"struct.std::_Head_base.68" = type { ptr }

@_ZTISt13runtime_error = external constant ptr
@.str.583 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.584 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.585 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.586 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.587 = external hidden unnamed_addr constant [36 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: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr)

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

declare void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32), i1 noundef zeroext) #3

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Gowin14displayReadRegEPKcj(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN5Gowin13readStatusRegEv(ptr noundef nonnull align 8 dereferenceable(192)) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Gowin15programExtFlashEjb(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, i1 noundef zeroext %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %class.SPIFlash, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca [256 x i8], align 16
  %13 = alloca i8, align 1
  %14 = alloca %"class.std::__cxx11::basic_string", align 8
  %15 = alloca %"class.std::allocator.0", align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.std::__cxx11::basic_string", align 8
  %19 = alloca %"class.std::allocator.0", align 1
  %20 = alloca %"class.std::__cxx11::basic_string", align 8
  %21 = alloca %"class.std::allocator.0", align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %22 = zext i1 %2 to i8
  store i8 %22, ptr %6, align 1, !tbaa !11
  %23 = load ptr, ptr %4, align 8
  %24 = call noundef i32 @_ZN5Gowin13readStatusRegEv(ptr noundef nonnull align 8 dereferenceable(192) %23)
  call void @_ZN5Gowin14displayReadRegEPKcj(ptr noundef nonnull align 8 dereferenceable(192) %23, ptr noundef @.str.583, i32 noundef %24)
  %25 = load ptr, ptr %23, align 8, !tbaa !13
  %26 = getelementptr inbounds ptr, ptr %25, i64 16
  %27 = load ptr, ptr %26, align 8
  %28 = call noundef zeroext i1 %27(ptr noundef nonnull align 8 dereferenceable(192) %23)
  br i1 %28, label %36, label %29

29:                                               ; preds = %3
  %30 = call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef @.str.584)
          to label %31 unwind label %32

31:                                               ; preds = %29
  call void @__cxa_throw(ptr %30, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #6
  unreachable

32:                                               ; preds = %29
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %7, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %8, align 4
  call void @__cxa_free_exception(ptr %30) #5
  br label %144

36:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #5
  %37 = getelementptr inbounds i8, ptr %23, i64 88
  %38 = load i8, ptr %6, align 1, !tbaa !11, !range !15, !noundef !16
  %39 = trunc i8 %38 to i1
  %40 = getelementptr inbounds %class.Device, ptr %23, i32 0, i32 6
  %41 = load i8, ptr %40, align 1, !tbaa !17, !range !15, !noundef !16
  %42 = trunc i8 %41 to i1
  br i1 %42, label %43, label %44

43:                                               ; preds = %36
  br label %50

44:                                               ; preds = %36
  %45 = getelementptr inbounds %class.Device, ptr %23, i32 0, i32 7
  %46 = load i8, ptr %45, align 2, !tbaa !23, !range !15, !noundef !16
  %47 = trunc i8 %46 to i1
  %48 = zext i1 %47 to i64
  %49 = select i1 %47, i32 -1, i32 0
  br label %50

50:                                               ; preds = %44, %43
  %51 = phi i32 [ 1, %43 ], [ %49, %44 ]
  %52 = trunc i32 %51 to i8
  call void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33) %9, ptr noundef %37, i1 noundef zeroext %39, i8 noundef signext %52)
  call void @_ZN8SPIFlash5resetEv(ptr noundef nonnull align 8 dereferenceable(33) %9)
  call void @_ZN8SPIFlash7read_idEv(ptr noundef nonnull align 8 dereferenceable(33) %9)
  %53 = call noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33) %9)
  call void @_ZN8SPIFlash18display_status_regEh(ptr noundef nonnull align 8 dereferenceable(33) %9, i8 noundef zeroext %53)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %54 = getelementptr inbounds %class.Gowin, ptr %23, i32 0, i32 2
  %55 = call noundef ptr @_ZNKSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %54) #5
  %56 = call noundef ptr @_ZNK21ConfigBitstreamParser7getDataEv(ptr noundef nonnull align 8 dereferenceable(160) %55)
  store ptr %56, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %57 = getelementptr inbounds %class.Gowin, ptr %23, i32 0, i32 2
  %58 = call noundef ptr @_ZNKSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %57) #5
  %59 = call noundef i32 @_ZN21ConfigBitstreamParser9getLengthEv(ptr noundef nonnull align 8 dereferenceable(160) %58)
  store i32 %59, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 256, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  store i8 1, ptr %13, align 1, !tbaa !11
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = sdiv i32 %62, 8
  %64 = call noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33) %9, i32 noundef %60, ptr noundef %61, i32 noundef %63)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %81

66:                                               ; preds = %50
  %67 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %68 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %67, i64 noundef 256, ptr noundef @.str.585) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %14) #5
  %69 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %15) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef %69, ptr noundef nonnull align 1 dereferenceable(1) %15)
          to label %70 unwind label %72

70:                                               ; preds = %66
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %14, i1 noundef zeroext true)
          to label %71 unwind label %76

71:                                               ; preds = %70
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %15) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  store i8 0, ptr %13, align 1, !tbaa !11
  br label %81

72:                                               ; preds = %66
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %7, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %8, align 4
  br label %80

76:                                               ; preds = %70
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %7, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %8, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %14) #5
  br label %80

80:                                               ; preds = %76, %72
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %15) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %14) #5
  br label %143

81:                                               ; preds = %71, %50
  %82 = load i8, ptr %13, align 1, !tbaa !11, !range !15, !noundef !16
  %83 = trunc i8 %82 to i1
  br i1 %83, label %84, label %111

84:                                               ; preds = %81
  %85 = getelementptr inbounds %class.Device, ptr %23, i32 0, i32 5
  %86 = load i8, ptr %85, align 4, !tbaa !24, !range !15, !noundef !16
  %87 = trunc i8 %86 to i1
  br i1 %87, label %88, label %111

88:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %89 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %89, ptr %16, align 4, !tbaa !9
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = sdiv i32 %91, 8
  store i32 %92, ptr %17, align 4, !tbaa !9
  %93 = call noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33) %9, ptr noundef nonnull align 4 dereferenceable(4) %16, ptr noundef %90, ptr noundef nonnull align 4 dereferenceable(4) %17, i32 noundef 256)
  %94 = xor i1 %93, true
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br i1 %94, label %95, label %110

95:                                               ; preds = %88
  %96 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %97 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %96, i64 noundef 256, ptr noundef @.str.586) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  %98 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %18, ptr noundef %98, ptr noundef nonnull align 1 dereferenceable(1) %19)
          to label %99 unwind label %101

99:                                               ; preds = %95
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %18, i1 noundef zeroext true)
          to label %100 unwind label %105

100:                                              ; preds = %99
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %18) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  store i8 0, ptr %13, align 1, !tbaa !11
  br label %110

101:                                              ; preds = %95
  %102 = landingpad { ptr, i32 }
          cleanup
  %103 = extractvalue { ptr, i32 } %102, 0
  store ptr %103, ptr %7, align 8
  %104 = extractvalue { ptr, i32 } %102, 1
  store i32 %104, ptr %8, align 4
  br label %109

105:                                              ; preds = %99
  %106 = landingpad { ptr, i32 }
          cleanup
  %107 = extractvalue { ptr, i32 } %106, 0
  store ptr %107, ptr %7, align 8
  %108 = extractvalue { ptr, i32 } %106, 1
  store i32 %108, ptr %8, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %18) #5
  br label %109

109:                                              ; preds = %105, %101
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  br label %143

110:                                              ; preds = %100, %88
  br label %111

111:                                              ; preds = %110, %84, %81
  %112 = load ptr, ptr %23, align 8, !tbaa !13
  %113 = getelementptr inbounds ptr, ptr %112, i64 17
  %114 = load ptr, ptr %113, align 8
  %115 = call noundef zeroext i1 %114(ptr noundef nonnull align 8 dereferenceable(192) %23)
  br i1 %115, label %131, label %116

116:                                              ; preds = %111
  %117 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  %118 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %117, i64 noundef 256, ptr noundef @.str.587) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #5
  %119 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef %119, ptr noundef nonnull align 1 dereferenceable(1) %21)
          to label %120 unwind label %122

120:                                              ; preds = %116
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %20, i1 noundef zeroext true)
          to label %121 unwind label %126

121:                                              ; preds = %120
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  store i8 0, ptr %13, align 1, !tbaa !11
  br label %131

122:                                              ; preds = %116
  %123 = landingpad { ptr, i32 }
          cleanup
  %124 = extractvalue { ptr, i32 } %123, 0
  store ptr %124, ptr %7, align 8
  %125 = extractvalue { ptr, i32 } %123, 1
  store i32 %125, ptr %8, align 4
  br label %130

126:                                              ; preds = %120
  %127 = landingpad { ptr, i32 }
          cleanup
  %128 = extractvalue { ptr, i32 } %127, 0
  store ptr %128, ptr %7, align 8
  %129 = extractvalue { ptr, i32 } %127, 1
  store i32 %129, ptr %8, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #5
  br label %130

130:                                              ; preds = %126, %122
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #5
  br label %143

131:                                              ; preds = %121, %111
  %132 = load i8, ptr %13, align 1, !tbaa !11, !range !15, !noundef !16
  %133 = trunc i8 %132 to i1
  br i1 %133, label %142, label %134

134:                                              ; preds = %131
  %135 = call ptr @__cxa_allocate_exception(i64 16) #5
  %136 = getelementptr inbounds [256 x i8], ptr %12, i64 0, i64 0
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %135, ptr noundef %136)
          to label %137 unwind label %138

137:                                              ; preds = %134
  call void @__cxa_throw(ptr %135, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #6
  unreachable

138:                                              ; preds = %134
  %139 = landingpad { ptr, i32 }
          cleanup
  %140 = extractvalue { ptr, i32 } %139, 0
  store ptr %140, ptr %7, align 8
  %141 = extractvalue { ptr, i32 } %139, 1
  store i32 %141, ptr %8, align 4
  call void @__cxa_free_exception(ptr %135) #5
  br label %143

142:                                              ; preds = %131
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #5
  ret void

143:                                              ; preds = %138, %130, %109, %80
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #5
  br label %144

144:                                              ; preds = %143, %32
  %145 = load ptr, ptr %7, align 8
  %146 = load i32, ptr %8, align 4
  %147 = insertvalue { ptr, i32 } poison, ptr %145, 0
  %148 = insertvalue { ptr, i32 } %147, i32 %146, 1
  resume { ptr, i32 } %148
}

declare void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i1 noundef zeroext, i8 noundef signext) unnamed_addr #3

declare void @_ZN8SPIFlash5resetEv(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #3

declare void @_ZN8SPIFlash7read_idEv(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #3

declare void @_ZN8SPIFlash18display_status_regEh(ptr noundef nonnull align 8 dereferenceable(33), i8 noundef zeroext) #3

declare noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33)) #3

declare noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i32 noundef) #3

declare noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #3

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

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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind "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 = { nounwind }
attributes #6 = { noreturn }

!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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !12, i64 85}
!18 = !{!"_ZTS6Device", !6, i64 8, !19, i64 16, !19, i64 48, !22, i64 80, !12, i64 84, !12, i64 85, !12, i64 86}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!"_ZTSN6Device9prog_modeE", !7, i64 0}
!23 = !{!18, !12, i64 86}
!24 = !{!18, !12, i64 84}


; 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.SPIFlash = type <{ ptr, ptr, i8, [3 x i8], i32, ptr, i8, [7 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator.0" = type { i8 }

@_ZTISt13runtime_error = external constant ptr
@.str.583 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.584 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.585 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.586 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.587 = external hidden unnamed_addr constant [36 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #3

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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

declare void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32), i1 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5Gowin14displayReadRegEPKcj(ptr noundef nonnull align 8 dereferenceable(192), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN5Gowin13readStatusRegEv(ptr noundef nonnull align 8 dereferenceable(192)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Gowin15programExtFlashEjb(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.SPIFlash, align 8
  %5 = alloca [256 x i8], align 16
  %6 = alloca %"class.std::__cxx11::basic_string", align 8
  %7 = alloca %"class.std::allocator.0", align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::__cxx11::basic_string", align 8
  %11 = alloca %"class.std::allocator.0", align 1
  %12 = alloca %"class.std::__cxx11::basic_string", align 8
  %13 = alloca %"class.std::allocator.0", align 1
  %14 = tail call noundef i32 @_ZN5Gowin13readStatusRegEv(ptr noundef nonnull align 8 dereferenceable(192) %0)
  tail call void @_ZN5Gowin14displayReadRegEPKcj(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef nonnull @.str.583, i32 noundef %14)
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 128
  %17 = load ptr, ptr %16, align 8
  %18 = tail call noundef zeroext i1 %17(ptr noundef nonnull align 8 dereferenceable(192) %0)
  br i1 %18, label %24, label %19

19:                                               ; preds = %3
  %20 = tail call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull @.str.584)
          to label %21 unwind label %22

21:                                               ; preds = %19
  tail call void @__cxa_throw(ptr nonnull %20, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #7
  unreachable

22:                                               ; preds = %19
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %20) #6
  br label %86

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #6
  %25 = getelementptr inbounds i8, ptr %0, i64 88
  %26 = getelementptr inbounds i8, ptr %0, i64 85
  %27 = load i8, ptr %26, align 1, !tbaa !8, !range !17, !noundef !18
  %28 = trunc nuw i8 %27 to i1
  %29 = getelementptr inbounds i8, ptr %0, i64 86
  %30 = load i8, ptr %29, align 2, !range !17
  %31 = sub nsw i8 0, %30
  %32 = select i1 %28, i8 1, i8 %31
  call void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33) %4, ptr noundef nonnull %25, i1 noundef zeroext %2, i8 noundef signext %32)
  call void @_ZN8SPIFlash5resetEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
  call void @_ZN8SPIFlash7read_idEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
  %33 = call noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33) %4)
  call void @_ZN8SPIFlash18display_status_regEh(ptr noundef nonnull align 8 dereferenceable(33) %4, i8 noundef zeroext %33)
  %34 = getelementptr inbounds i8, ptr %0, i64 144
  %35 = call noundef ptr @_ZNKSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %34) #6
  %36 = call noundef ptr @_ZNK21ConfigBitstreamParser7getDataEv(ptr noundef nonnull align 8 dereferenceable(160) %35)
  %37 = call noundef ptr @_ZNKSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %34) #6
  %38 = call noundef i32 @_ZN21ConfigBitstreamParser9getLengthEv(ptr noundef nonnull align 8 dereferenceable(160) %37)
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %5) #6
  %39 = sdiv i32 %38, 8
  %40 = call noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33) %4, i32 noundef %1, ptr noundef %36, i32 noundef %39)
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %50, label %41

41:                                               ; preds = %24
  %42 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 256, ptr noundef nonnull @.str.585) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull %5, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %43 unwind label %44

43:                                               ; preds = %41
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %6, i1 noundef zeroext true)
          to label %49 unwind label %46

44:                                               ; preds = %41
  %45 = landingpad { ptr, i32 }
          cleanup
  br label %48

46:                                               ; preds = %43
  %47 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #6
  br label %48

48:                                               ; preds = %46, %44
  %.pn = phi { ptr, i32 } [ %47, %46 ], [ %45, %44 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  br label %85

49:                                               ; preds = %43
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #6
  br label %65

50:                                               ; preds = %24
  %51 = getelementptr inbounds i8, ptr %0, i64 84
  %52 = load i8, ptr %51, align 4, !tbaa !19, !range !17, !noundef !18
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %54, label %65

54:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  store i32 %1, ptr %8, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #6
  store i32 %39, ptr %9, align 4, !tbaa !20
  %55 = call noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33) %4, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef %36, ptr noundef nonnull align 4 dereferenceable(4) %9, i32 noundef 256)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  br i1 %55, label %65, label %56

56:                                               ; preds = %54
  %57 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 256, ptr noundef nonnull @.str.586) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %10) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %11) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull %5, ptr noundef nonnull align 1 dereferenceable(1) %11)
          to label %58 unwind label %60

58:                                               ; preds = %56
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %10, i1 noundef zeroext true)
          to label %59 unwind label %62

59:                                               ; preds = %58
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #6
  br label %65

60:                                               ; preds = %56
  %61 = landingpad { ptr, i32 }
          cleanup
  br label %64

62:                                               ; preds = %58
  %63 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #6
  br label %64

64:                                               ; preds = %62, %60
  %.pn20 = phi { ptr, i32 } [ %63, %62 ], [ %61, %60 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %11) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %10) #6
  br label %85

65:                                               ; preds = %49, %54, %59, %50
  %.1 = phi i1 [ false, %59 ], [ true, %54 ], [ true, %50 ], [ false, %49 ]
  %66 = load ptr, ptr %0, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 136
  %68 = load ptr, ptr %67, align 8
  %69 = call noundef zeroext i1 %68(ptr noundef nonnull align 8 dereferenceable(192) %0)
  br i1 %69, label %78, label %70

70:                                               ; preds = %65
  %71 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 256, ptr noundef nonnull @.str.587) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %12) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %13) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %13) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull %5, ptr noundef nonnull align 1 dereferenceable(1) %13)
          to label %72 unwind label %73

72:                                               ; preds = %70
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %12, i1 noundef zeroext true)
          to label %.thread29 unwind label %75

.thread29:                                        ; preds = %72
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %13) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %12) #6
  br label %79

73:                                               ; preds = %70
  %74 = landingpad { ptr, i32 }
          cleanup
  br label %77

75:                                               ; preds = %72
  %76 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #6
  br label %77

77:                                               ; preds = %75, %73
  %.pn22 = phi { ptr, i32 } [ %76, %75 ], [ %74, %73 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %13) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %13) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %12) #6
  br label %85

78:                                               ; preds = %65
  br i1 %.1, label %84, label %79

79:                                               ; preds = %.thread29, %78
  %80 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %80, ptr noundef nonnull %5)
          to label %81 unwind label %82

81:                                               ; preds = %79
  call void @__cxa_throw(ptr nonnull %80, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #7
  unreachable

82:                                               ; preds = %79
  %83 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %80) #6
  br label %85

84:                                               ; preds = %78
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #6
  ret void

85:                                               ; preds = %82, %77, %64, %48
  %.pn24 = phi { ptr, i32 } [ %83, %82 ], [ %.pn22, %77 ], [ %.pn20, %64 ], [ %.pn, %48 ]
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #6
  br label %86

86:                                               ; preds = %85, %22
  %.pn24.pn = phi { ptr, i32 } [ %.pn24, %85 ], [ %23, %22 ]
  resume { ptr, i32 } %.pn24.pn
}

declare void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i1 noundef zeroext, i8 noundef signext) unnamed_addr #3

declare void @_ZN8SPIFlash5resetEv(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #3

declare void @_ZN8SPIFlash7read_idEv(ptr noundef nonnull align 8 dereferenceable(33)) unnamed_addr #3

declare void @_ZN8SPIFlash18display_status_regEh(ptr noundef nonnull align 8 dereferenceable(33), i8 noundef zeroext) local_unnamed_addr #3

declare noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #3

declare noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

declare noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #3

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

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 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind "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 = { 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!9, !16, i64 85}
!9 = !{!"_ZTS6Device", !10, i64 8, !12, i64 16, !12, i64 48, !15, i64 80, !16, i64 84, !16, i64 85, !16, i64 86}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !11, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!14 = !{!"long", !11, i64 0}
!15 = !{!"_ZTSN6Device9prog_modeE", !11, i64 0}
!16 = !{!"bool", !11, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!9, !16, i64 84}
!20 = !{!21, !21, i64 0}
!21 = !{!"int", !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass