; LLVM IR from trabucayre/openFPGALoader :: src/spiInterface.ll (ZN12SPIInterface5writeEjPKhjb)

; 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.SPIInterface = type { ptr, i8, i32, i8, i8, i8, %"class.std::__cxx11::basic_string" }

@_ZTISt9exception = external constant ptr

; 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 void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32), i1 noundef zeroext) #3

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

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #4

declare ptr @__cxa_begin_catch(ptr)

declare void @__cxa_end_catch()

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #5

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

29:                                               ; preds = %5
  store i1 false, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %108

30:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 40, ptr %14) #6
  %31 = load i8, ptr %11, align 1, !tbaa !11, !range !15, !noundef !16
  %32 = trunc i8 %31 to i1
  %33 = getelementptr inbounds %class.SPIInterface, ptr %24, i32 0, i32 1
  %34 = load i8, ptr %33, align 8, !tbaa !17
  invoke void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33) %14, ptr noundef %24, i1 noundef zeroext %32, i8 noundef signext %34)
          to label %35 unwind label %45

35:                                               ; preds = %30
  %36 = invoke noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33) %14)
          to label %37 unwind label %45

37:                                               ; preds = %35
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = invoke noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33) %14, i32 noundef %38, ptr noundef %39, i32 noundef %40)
          to label %42 unwind label %45

42:                                               ; preds = %37
  %43 = icmp eq i32 %41, -1
  br i1 %43, label %44, label %49

44:                                               ; preds = %42
  store i8 0, ptr %12, align 1, !tbaa !11
  br label %49

45:                                               ; preds = %37, %35, %30
  %46 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %15, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %16, align 4
  br label %70

49:                                               ; preds = %44, %42
  %50 = getelementptr inbounds %class.SPIInterface, ptr %24, i32 0, i32 3
  %51 = load i8, ptr %50, align 8, !tbaa !22, !range !15, !noundef !16
  %52 = trunc i8 %51 to i1
  br i1 %52, label %53, label %69

53:                                               ; preds = %49
  %54 = load i8, ptr %12, align 1, !tbaa !11, !range !15, !noundef !16
  %55 = trunc i8 %54 to i1
  br i1 %55, label %56, label %69

56:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %57 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %57, ptr %17, align 4, !tbaa !9
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %59 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %59, ptr %18, align 4, !tbaa !9
  %60 = getelementptr inbounds %class.SPIInterface, ptr %24, i32 0, i32 2
  %61 = load i32, ptr %60, align 4, !tbaa !23
  %62 = invoke noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33) %14, ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef %58, ptr noundef nonnull align 4 dereferenceable(4) %18, i32 noundef %61)
          to label %63 unwind label %65

63:                                               ; preds = %56
  %64 = zext i1 %62 to i8
  store i8 %64, ptr %12, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %69

65:                                               ; preds = %56
  %66 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %15, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %70

69:                                               ; preds = %63, %53, %49
  call void @llvm.lifetime.end.p0(i64 40, ptr %14) #6
  br label %85

70:                                               ; preds = %65, %45
  call void @llvm.lifetime.end.p0(i64 40, ptr %14) #6
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %16, align 4
  %73 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #6
  %74 = icmp eq i32 %72, %73
  br i1 %74, label %75, label %110

75:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %76 = load ptr, ptr %15, align 8
  %77 = call ptr @__cxa_begin_catch(ptr %76) #6
  store ptr %77, ptr %19, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #6
  %78 = load ptr, ptr %19, align 8, !tbaa !5
  %79 = load ptr, ptr %78, align 8, !tbaa !13
  %80 = getelementptr inbounds ptr, ptr %79, i64 2
  %81 = load ptr, ptr %80, align 8
  %82 = call noundef ptr %81(ptr noundef nonnull align 8 dereferenceable(8) %78) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef %82, ptr noundef nonnull align 1 dereferenceable(1) %21)
          to label %83 unwind label %98

83:                                               ; preds = %75
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %20, i1 noundef zeroext true)
          to label %84 unwind label %102

84:                                               ; preds = %83
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #6
  store i8 0, ptr %12, align 1, !tbaa !11
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %85

85:                                               ; preds = %84, %69
  call void @llvm.lifetime.start.p0(i64 1, ptr %22) #6
  %86 = load ptr, ptr %24, align 8, !tbaa !13
  %87 = getelementptr inbounds ptr, ptr %86, i64 6
  %88 = load ptr, ptr %87, align 8
  %89 = call noundef zeroext i1 %88(ptr noundef nonnull align 8 dereferenceable(56) %24)
  %90 = zext i1 %89 to i8
  store i8 %90, ptr %22, align 1, !tbaa !11
  %91 = load i8, ptr %12, align 1, !tbaa !11, !range !15, !noundef !16
  %92 = trunc i8 %91 to i1
  br i1 %92, label %93, label %96

93:                                               ; preds = %85
  %94 = load i8, ptr %22, align 1, !tbaa !11, !range !15, !noundef !16
  %95 = trunc i8 %94 to i1
  br label %96

96:                                               ; preds = %93, %85
  %97 = phi i1 [ false, %85 ], [ %95, %93 ]
  store i1 %97, ptr %6, align 1
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %22) #6
  br label %108

98:                                               ; preds = %75
  %99 = landingpad { ptr, i32 }
          cleanup
  %100 = extractvalue { ptr, i32 } %99, 0
  store ptr %100, ptr %15, align 8
  %101 = extractvalue { ptr, i32 } %99, 1
  store i32 %101, ptr %16, align 4
  br label %106

102:                                              ; preds = %83
  %103 = landingpad { ptr, i32 }
          cleanup
  %104 = extractvalue { ptr, i32 } %103, 0
  store ptr %104, ptr %15, align 8
  %105 = extractvalue { ptr, i32 } %103, 1
  store i32 %105, ptr %16, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %20) #6
  br label %106

106:                                              ; preds = %102, %98
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %21) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #6
  invoke void @__cxa_end_catch()
          to label %107 unwind label %116

107:                                              ; preds = %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  br label %110

108:                                              ; preds = %96, %29
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  %109 = load i1, ptr %6, align 1
  ret i1 %109

110:                                              ; preds = %107, %71
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %15, align 8
  %113 = load i32, ptr %16, align 4
  %114 = insertvalue { ptr, i32 } poison, ptr %112, 0
  %115 = insertvalue { ptr, i32 } %114, i32 %113, 1
  resume { ptr, i32 } %115

116:                                              ; preds = %106
  %117 = landingpad { ptr, i32 }
          catch ptr null
  %118 = extractvalue { ptr, i32 } %117, 0
  call void @__clang_call_terminate(ptr %118) #7
  unreachable
}

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 memory(none) }
attributes #5 = { noinline noreturn nounwind uwtable "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 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, !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, !7, i64 8}
!18 = !{!"_ZTS12SPIInterface", !7, i64 8, !10, i64 12, !12, i64 16, !12, i64 17, !12, i64 18, !19, i64 24}
!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 = !{!18, !12, i64 16}
!23 = !{!18, !10, i64 12}


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

@_ZTISt9exception = external constant 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 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 void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32), i1 noundef zeroext) local_unnamed_addr #3

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

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #4

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN12SPIInterface5writeEjPKhjb(ptr noundef nonnull align 8 dereferenceable(56) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %class.SPIFlash, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::__cxx11::basic_string", align 8
  %10 = alloca %"class.std::allocator.0", align 1
  %11 = load ptr, ptr %0, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef zeroext i1 %13(ptr noundef nonnull align 8 dereferenceable(56) %0)
  br i1 %14, label %15, label %59

15:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #6
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load i8, ptr %16, align 8, !tbaa !8
  invoke void @_ZN8SPIFlashC1EP12SPIInterfaceba(ptr noundef nonnull align 8 dereferenceable(33) %6, ptr noundef nonnull %0, i1 noundef zeroext %4, i8 noundef signext %17)
          to label %18 unwind label %27

18:                                               ; preds = %15
  %19 = invoke noundef zeroext i8 @_ZN8SPIFlash15read_status_regEv(ptr noundef nonnull align 8 dereferenceable(33) %6)
          to label %20 unwind label %27

20:                                               ; preds = %18
  %21 = invoke noundef i32 @_ZN8SPIFlash14erase_and_progEiPKhi(ptr noundef nonnull align 8 dereferenceable(33) %6, i32 noundef %1, ptr noundef %2, i32 noundef %3)
          to label %22 unwind label %27

22:                                               ; preds = %20
  %23 = icmp ne i32 %21, -1
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = load i8, ptr %24, align 8, !tbaa !17, !range !18, !noundef !19
  %26 = trunc nuw i8 %25 to i1
  %brmerge.demorgan = and i1 %23, %26
  br i1 %brmerge.demorgan, label %29, label %36

27:                                               ; preds = %20, %18, %15
  %28 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  br label %37

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  store i32 %1, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #6
  store i32 %3, ptr %8, align 4, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %0, i64 12
  %31 = load i32, ptr %30, align 4, !tbaa !21
  %32 = invoke noundef zeroext i1 @_ZN8SPIFlash6verifyERKiPKhS1_i(ptr noundef nonnull align 8 dereferenceable(33) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %8, i32 noundef %31)
          to label %33 unwind label %34

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  br label %36

34:                                               ; preds = %29
  %35 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  br label %37

36:                                               ; preds = %22, %33
  %.1.in = phi i1 [ %32, %33 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  br label %48

37:                                               ; preds = %34, %27
  %.pn = phi { ptr, i32 } [ %35, %34 ], [ %28, %27 ]
  %.017 = extractvalue { ptr, i32 } %.pn, 1
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  %38 = call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #6
  %39 = icmp eq i32 %.017, %38
  br i1 %39, label %40, label %60

40:                                               ; preds = %37
  %.020 = extractvalue { ptr, i32 } %.pn, 0
  %41 = call ptr @__cxa_begin_catch(ptr %.020) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #6
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %44 = load ptr, ptr %43, align 8
  %45 = call noundef ptr %44(ptr noundef nonnull align 8 dereferenceable(8) %41) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef %45, ptr noundef nonnull align 1 dereferenceable(1) %10)
          to label %46 unwind label %54

46:                                               ; preds = %40
  invoke void @_Z10printErrorRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb(ptr noundef nonnull align 8 dereferenceable(32) %9, i1 noundef zeroext true)
          to label %47 unwind label %56

47:                                               ; preds = %46
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #6
  call void @__cxa_end_catch()
  br label %48

48:                                               ; preds = %47, %36
  %.2 = phi i1 [ %.1.in, %36 ], [ false, %47 ]
  %49 = load ptr, ptr %0, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 48
  %51 = load ptr, ptr %50, align 8
  %52 = call noundef zeroext i1 %51(ptr noundef nonnull align 8 dereferenceable(56) %0)
  %53 = and i1 %.2, %52
  br label %59

54:                                               ; preds = %40
  %55 = landingpad { ptr, i32 }
          cleanup
  br label %58

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

58:                                               ; preds = %56, %54
  %.pn24 = phi { ptr, i32 } [ %57, %56 ], [ %55, %54 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #6
  invoke void @__cxa_end_catch()
          to label %60 unwind label %61

59:                                               ; preds = %5, %48
  %.0 = phi i1 [ %53, %48 ], [ false, %5 ]
  ret i1 %.0

60:                                               ; preds = %58, %37
  %.merged = phi { ptr, i32 } [ %.pn, %37 ], [ %.pn24, %58 ]
  resume { ptr, i32 } %.merged

61:                                               ; preds = %58
  %62 = landingpad { ptr, i32 }
          catch ptr null
  %63 = extractvalue { ptr, i32 } %62, 0
  call void @__clang_call_terminate(ptr %63) #7
  unreachable
}

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 = { nofree nosync nounwind memory(none) }
attributes #5 = { noinline noreturn nounwind uwtable "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 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 = !{!9, !10, i64 8}
!9 = !{!"_ZTS12SPIInterface", !10, i64 8, !11, i64 12, !12, i64 16, !12, i64 17, !12, i64 18, !13, i64 24}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!"int", !10, i64 0}
!12 = !{!"bool", !10, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !16, i64 8, !10, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!15 = !{!"any pointer", !10, i64 0}
!16 = !{!"long", !10, i64 0}
!17 = !{!9, !12, i64 16}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!11, !11, i64 0}
!21 = !{!9, !11, i64 12}


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