; LLVM IR from trabucayre/openFPGALoader :: src/spiFlash.ll (ZN8SPIFlash13sectors_eraseEii)

; 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.ProgressBar = type <{ %"class.std::__cxx11::basic_string", i32, i32, %"class.std::chrono::time_point", i8, i8, [6 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::allocator.0" = type { i8 }
%class.SPIFlash = type <{ ptr, ptr, i8, [3 x i8], i32, ptr, i8, [7 x i8] }>
%struct.flash_t = type <{ %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i8, i8, i8, i8, i8, [3 x i8], i32, i8, [4 x i8], [3 x i8], i32, i16, [2 x i8] }>

@.str.52 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [34 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 dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8SPIFlash13sectors_eraseEii(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %1, i32 noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %class.ProgressBar, align 8
  %13 = alloca %"class.std::__cxx11::basic_string", align 8
  %14 = alloca %"class.std::allocator.0", align 1
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %20 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #5
  store i8 0, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  store i8 1, ptr %8, align 1, !tbaa !11
  %21 = getelementptr inbounds %class.SPIFlash, ptr %20, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %39

24:                                               ; preds = %3
  %25 = getelementptr inbounds %class.SPIFlash, ptr %20, i32 0, i32 5
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = getelementptr inbounds %struct.flash_t, ptr %26, i32 0, i32 4
  %28 = load i8, ptr %27, align 1, !tbaa !15, !range !22, !noundef !23
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store i8 1, ptr %7, align 1, !tbaa !11
  br label %31

31:                                               ; preds = %30, %24
  %32 = getelementptr inbounds %class.SPIFlash, ptr %20, i32 0, i32 5
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds %struct.flash_t, ptr %33, i32 0, i32 3
  %35 = load i8, ptr %34, align 4, !tbaa !24, !range !22, !noundef !23
  %36 = trunc i8 %35 to i1
  br i1 %36, label %38, label %37

37:                                               ; preds = %31
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %38

38:                                               ; preds = %37, %31
  br label %39

39:                                               ; preds = %38, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %40 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %40, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = add nsw i32 %41, %42
  %44 = add nsw i32 %43, 4095
  %45 = and i32 %44, -4096
  store i32 %45, ptr %11, align 4, !tbaa !9
  %46 = load i8, ptr %7, align 1, !tbaa !11, !range !22, !noundef !23
  %47 = trunc i8 %46 to i1
  br i1 %47, label %54, label %48

48:                                               ; preds = %39
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = load i32, ptr %6, align 4, !tbaa !9
  %51 = add nsw i32 %49, %50
  %52 = add nsw i32 %51, 65535
  %53 = and i32 %52, -65536
  store i32 %53, ptr %11, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %48, %39
  call void @llvm.lifetime.start.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %13, ptr noundef @.str.52, ptr noundef nonnull align 1 dereferenceable(1) %14)
          to label %55 unwind label %65

55:                                               ; preds = %54
  %56 = load i32, ptr %11, align 4, !tbaa !9
  %57 = getelementptr inbounds %class.SPIFlash, ptr %20, i32 0, i32 2
  %58 = load i8, ptr %57, align 8, !tbaa !25
  %59 = sext i8 %58 to i32
  %60 = icmp slt i32 %59, 0
  invoke void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50) %12, ptr noundef nonnull align 8 dereferenceable(32) %13, i32 noundef %56, i32 noundef 50, i1 noundef zeroext %60)
          to label %61 unwind label %69

61:                                               ; preds = %55
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #5
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 65536, ptr %17, align 4, !tbaa !9
  %62 = load i8, ptr %8, align 1, !tbaa !11, !range !22, !noundef !23
  %63 = trunc i8 %62 to i1
  br i1 %63, label %74, label %64

64:                                               ; preds = %61
  store i32 4096, ptr %17, align 4, !tbaa !9
  br label %74

65:                                               ; preds = %54
  %66 = landingpad { ptr, i32 }
          cleanup
  %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
  br label %73

69:                                               ; preds = %55
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %15, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %16, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %13) #5
  br label %73

73:                                               ; preds = %69, %65
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %13) #5
  br label %154

74:                                               ; preds = %64, %61
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = load i32, ptr %6, align 4, !tbaa !9
  %78 = add nsw i32 %76, %77
  %79 = add nsw i32 %78, 65535
  %80 = and i32 %79, -65536
  %81 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.53, i32 noundef %75, i32 noundef %80)
          to label %82 unwind label %89

82:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %83 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %83, ptr %18, align 4, !tbaa !9
  br label %84

84:                                               ; preds = %139, %82
  %85 = load i32, ptr %18, align 4, !tbaa !9
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = icmp slt i32 %85, %86
  br i1 %87, label %93, label %88

88:                                               ; preds = %84
  store i32 2, ptr %19, align 4
  br label %143

89:                                               ; preds = %149, %147, %74
  %90 = landingpad { ptr, i32 }
          cleanup
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %15, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %16, align 4
  br label %153

93:                                               ; preds = %84
  %94 = invoke noundef i32 @_ZN8SPIFlash12write_enableEv(ptr noundef nonnull align 8 dereferenceable(33) %20)
          to label %95 unwind label %98

95:                                               ; preds = %93
  %96 = icmp eq i32 %94, -1
  br i1 %96, label %97, label %102

97:                                               ; preds = %95
  store i32 -1, ptr %9, align 4, !tbaa !9
  store i32 2, ptr %19, align 4
  br label %143

98:                                               ; preds = %136, %126, %118, %114, %93
  %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
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %153

102:                                              ; preds = %95
  %103 = load i8, ptr %8, align 1, !tbaa !11, !range !22, !noundef !23
  %104 = trunc i8 %103 to i1
  br i1 %104, label %105, label %114

105:                                              ; preds = %102
  %106 = load i32, ptr %18, align 4, !tbaa !9
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = add nsw i32 %106, %107
  %109 = load i32, ptr %11, align 4, !tbaa !9
  %110 = icmp sgt i32 %108, %109
  br i1 %110, label %111, label %118

111:                                              ; preds = %105
  %112 = load i8, ptr %7, align 1, !tbaa !11, !range !22, !noundef !23
  %113 = trunc i8 %112 to i1
  br i1 %113, label %114, label %118

114:                                              ; preds = %111, %102
  store i32 4096, ptr %17, align 4, !tbaa !9
  %115 = load i32, ptr %18, align 4, !tbaa !9
  %116 = invoke noundef i32 @_ZN8SPIFlash12sector_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %20, i32 noundef %115)
          to label %117 unwind label %98

117:                                              ; preds = %114
  store i32 %116, ptr %9, align 4, !tbaa !9
  br label %122

118:                                              ; preds = %111, %105
  %119 = load i32, ptr %18, align 4, !tbaa !9
  %120 = invoke noundef i32 @_ZN8SPIFlash13block64_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %20, i32 noundef %119)
          to label %121 unwind label %98

121:                                              ; preds = %118
  store i32 %120, ptr %9, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %121, %117
  %123 = load i32, ptr %9, align 4, !tbaa !9
  %124 = icmp eq i32 %123, -1
  br i1 %124, label %125, label %126

125:                                              ; preds = %122
  store i32 2, ptr %19, align 4
  br label %143

126:                                              ; preds = %122
  %127 = getelementptr inbounds %class.SPIFlash, ptr %20, i32 0, i32 1
  %128 = load ptr, ptr %127, align 8, !tbaa !26
  %129 = load ptr, ptr %128, align 8, !tbaa !27
  %130 = getelementptr inbounds ptr, ptr %129, i64 4
  %131 = load ptr, ptr %130, align 8
  %132 = invoke noundef i32 %131(ptr noundef nonnull align 8 dereferenceable(56) %128, i8 noundef zeroext 5, i8 noundef zeroext 1, i8 noundef zeroext 0, i32 noundef 100000, i1 noundef zeroext false)
          to label %133 unwind label %98

133:                                              ; preds = %126
  %134 = icmp eq i32 %132, -1
  br i1 %134, label %135, label %136

135:                                              ; preds = %133
  store i32 -1, ptr %9, align 4, !tbaa !9
  store i32 2, ptr %19, align 4
  br label %143

136:                                              ; preds = %133
  %137 = load i32, ptr %18, align 4, !tbaa !9
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %12, i32 noundef %137, i8 noundef signext 0)
          to label %138 unwind label %98

138:                                              ; preds = %136
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %17, align 4, !tbaa !9
  %141 = load i32, ptr %18, align 4, !tbaa !9
  %142 = add nsw i32 %141, %140
  store i32 %142, ptr %18, align 4, !tbaa !9
  br label %84, !llvm.loop !29

143:                                              ; preds = %135, %125, %97, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %9, align 4, !tbaa !9
  %146 = icmp eq i32 %145, 0
  br i1 %146, label %147, label %149

147:                                              ; preds = %144
  invoke void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50) %12)
          to label %148 unwind label %89

148:                                              ; preds = %147
  br label %151

149:                                              ; preds = %144
  invoke void @_ZN11ProgressBar4failEv(ptr noundef nonnull align 8 dereferenceable(50) %12)
          to label %150 unwind label %89

150:                                              ; preds = %149
  br label %151

151:                                              ; preds = %150, %148
  %152 = load i32, ptr %9, align 4, !tbaa !9
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %12) #5
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  ret i32 %152

153:                                              ; preds = %98, %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %12) #5
  br label %154

154:                                              ; preds = %153, %73
  call void @llvm.lifetime.end.p0(i64 56, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #5
  br label %155

155:                                              ; preds = %154
  %156 = load ptr, ptr %15, align 8
  %157 = load i32, ptr %16, align 4
  %158 = insertvalue { ptr, i32 } poison, ptr %156, 0
  %159 = insertvalue { ptr, i32 } %158, i32 %157, 1
  resume { ptr, i32 } %159
}

declare void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #3

declare i32 @printf(ptr noundef, ...) #3

declare void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50), i32 noundef, i8 noundef signext) #3

declare void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50)) #3

declare void @_ZN11ProgressBar4failEv(ptr noundef nonnull align 8 dereferenceable(50)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50)) unnamed_addr #4 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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, !6, i64 24}
!14 = !{!"_ZTS8SPIFlash", !6, i64 8, !7, i64 16, !10, i64 20, !6, i64 24, !12, i64 32}
!15 = !{!16, !12, i64 69}
!16 = !{!"_ZTS7flash_t", !17, i64 0, !17, i64 32, !10, i64 64, !12, i64 68, !12, i64 69, !12, i64 70, !12, i64 71, !7, i64 72, !20, i64 76, !7, i64 80, !7, i64 81, !20, i64 88, !21, i64 92}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !19, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTS8tb_loc_t", !7, i64 0}
!21 = !{!"short", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!16, !12, i64 68}
!25 = !{!14, !7, i64 16}
!26 = !{!14, !6, i64 8}
!27 = !{!28, !28, i64 0}
!28 = !{!"vtable pointer", !8, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"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.ProgressBar = type <{ %"class.std::__cxx11::basic_string", i32, i32, %"class.std::chrono::time_point", i8, i8, [6 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.std::allocator.0" = type { i8 }

@.str.52 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [34 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 dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8SPIFlash13sectors_eraseEii(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.ProgressBar, align 8
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca %"class.std::allocator.0", align 1
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %.thread66, label %12

.thread66:                                        ; preds = %3
  %9 = add nsw i32 %2, %1
  %10 = add nsw i32 %9, 65535
  %11 = and i32 %10, -65536
  br label %24

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %8, i64 69
  %14 = load i8, ptr %13, align 1, !tbaa !12, !range !19, !noundef !20
  %15 = getelementptr inbounds i8, ptr %8, i64 68
  %16 = load i8, ptr %15, align 4, !tbaa !21, !range !19, !noundef !20
  %17 = trunc nuw i8 %16 to i1
  %18 = trunc nuw i8 %14 to i1
  %19 = add nsw i32 %2, %1
  %20 = add nsw i32 %19, 4095
  %21 = and i32 %20, -4096
  %22 = add nsw i32 %19, 65535
  %23 = and i32 %22, -65536
  %spec.select = select i1 %18, i32 %21, i32 %23
  br label %24

24:                                               ; preds = %12, %.thread66
  %25 = phi i32 [ %11, %.thread66 ], [ %23, %12 ]
  %.13771 = phi i1 [ false, %.thread66 ], [ %18, %12 ]
  %.04170 = phi i1 [ true, %.thread66 ], [ %17, %12 ]
  %26 = phi i32 [ %11, %.thread66 ], [ %spec.select, %12 ]
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull @.str.52, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %27 unwind label %80

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load i8, ptr %28, align 8, !tbaa !22
  %30 = icmp slt i8 %29, 0
  invoke void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50) %4, ptr noundef nonnull align 8 dereferenceable(32) %5, i32 noundef %26, i32 noundef 50, i1 noundef zeroext %30)
          to label %31 unwind label %82

31:                                               ; preds = %27
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  %spec.store.select = select i1 %.04170, i32 65536, i32 4096
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.53, i32 noundef %1, i32 noundef %25)
  %33 = icmp sgt i32 %26, %1
  br i1 %33, label %.lr.ph, label %._crit_edge.thread

.lr.ph:                                           ; preds = %31
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %.04170, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %.13771, label %.lr.ph.split.us.split, label %.lr.ph.split.us.split.us

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us, %51
  %.057.us.us = phi i32 [ %52, %51 ], [ %1, %.lr.ph.split.us ]
  %35 = invoke noundef i32 @_ZN8SPIFlash12write_enableEv(ptr noundef nonnull align 8 dereferenceable(33) %0)
          to label %36 unwind label %.split.us.split.us

36:                                               ; preds = %.lr.ph.split.us.split.us
  %37 = icmp eq i32 %35, -1
  br i1 %37, label %.thread, label %38

38:                                               ; preds = %36
  %39 = invoke noundef i32 @_ZN8SPIFlash13block64_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %.057.us.us)
          to label %40 unwind label %.split.us.split.us

40:                                               ; preds = %38
  %41 = icmp eq i32 %39, -1
  br i1 %41, label %.thread, label %42

42:                                               ; preds = %40
  %43 = load ptr, ptr %34, align 8, !tbaa !23
  %44 = load ptr, ptr %43, align 8, !tbaa !24
  %45 = getelementptr inbounds i8, ptr %44, i64 32
  %46 = load ptr, ptr %45, align 8
  %47 = invoke noundef i32 %46(ptr noundef nonnull align 8 dereferenceable(56) %43, i8 noundef zeroext 5, i8 noundef zeroext 1, i8 noundef zeroext 0, i32 noundef 100000, i1 noundef zeroext false)
          to label %48 unwind label %.split.us.split.us

48:                                               ; preds = %42
  %49 = icmp eq i32 %47, -1
  br i1 %49, label %.thread, label %50

50:                                               ; preds = %48
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %4, i32 noundef %.057.us.us, i8 noundef signext 0)
          to label %51 unwind label %.split.us.split.us

51:                                               ; preds = %50
  %52 = add nsw i32 %spec.store.select, %.057.us.us
  %53 = icmp slt i32 %52, %26
  br i1 %53, label %.lr.ph.split.us.split.us, label %._crit_edge, !llvm.loop !26

.split.us.split.us:                               ; preds = %50, %42, %38, %.lr.ph.split.us.split.us
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %.split.us

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us, %76
  %.057.us = phi i32 [ %77, %76 ], [ %1, %.lr.ph.split.us ]
  %.02956.us = phi i32 [ %.1.us, %76 ], [ 65536, %.lr.ph.split.us ]
  %55 = invoke noundef i32 @_ZN8SPIFlash12write_enableEv(ptr noundef nonnull align 8 dereferenceable(33) %0)
          to label %56 unwind label %.split.us.split

56:                                               ; preds = %.lr.ph.split.us.split
  %57 = icmp eq i32 %55, -1
  br i1 %57, label %.thread, label %58

58:                                               ; preds = %56
  %59 = add nsw i32 %.057.us, %.02956.us
  %60 = icmp sgt i32 %59, %26
  br i1 %60, label %63, label %61

61:                                               ; preds = %58
  %62 = invoke noundef i32 @_ZN8SPIFlash13block64_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %.057.us)
          to label %65 unwind label %.split.us.split

63:                                               ; preds = %58
  %64 = invoke noundef i32 @_ZN8SPIFlash12sector_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %.057.us)
          to label %65 unwind label %.split.us.split

65:                                               ; preds = %63, %61
  %.139.us = phi i32 [ %64, %63 ], [ %62, %61 ]
  %.1.us = phi i32 [ 4096, %63 ], [ %.02956.us, %61 ]
  %66 = icmp eq i32 %.139.us, -1
  br i1 %66, label %.thread, label %67

67:                                               ; preds = %65
  %68 = load ptr, ptr %34, align 8, !tbaa !23
  %69 = load ptr, ptr %68, align 8, !tbaa !24
  %70 = getelementptr inbounds i8, ptr %69, i64 32
  %71 = load ptr, ptr %70, align 8
  %72 = invoke noundef i32 %71(ptr noundef nonnull align 8 dereferenceable(56) %68, i8 noundef zeroext 5, i8 noundef zeroext 1, i8 noundef zeroext 0, i32 noundef 100000, i1 noundef zeroext false)
          to label %73 unwind label %.split.us.split

73:                                               ; preds = %67
  %74 = icmp eq i32 %72, -1
  br i1 %74, label %.thread, label %75

75:                                               ; preds = %73
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %4, i32 noundef %.057.us, i8 noundef signext 0)
          to label %76 unwind label %.split.us.split

76:                                               ; preds = %75
  %77 = add nsw i32 %.1.us, %.057.us
  %78 = icmp slt i32 %77, %26
  br i1 %78, label %.lr.ph.split.us.split, label %._crit_edge, !llvm.loop !26

.split.us.split:                                  ; preds = %75, %67, %63, %61, %.lr.ph.split.us.split
  %79 = landingpad { ptr, i32 }
          cleanup
  br label %.split.us

80:                                               ; preds = %24
  %81 = landingpad { ptr, i32 }
          cleanup
  br label %84

82:                                               ; preds = %27
  %83 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #6
  br label %84

84:                                               ; preds = %82, %80
  %.pn = phi { ptr, i32 } [ %83, %82 ], [ %81, %80 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  br label %109

85:                                               ; preds = %.thread, %._crit_edge.thread
  %86 = landingpad { ptr, i32 }
          cleanup
  br label %.split.us

.lr.ph.split:                                     ; preds = %.lr.ph, %104
  %.057 = phi i32 [ %105, %104 ], [ %1, %.lr.ph ]
  %87 = invoke noundef i32 @_ZN8SPIFlash12write_enableEv(ptr noundef nonnull align 8 dereferenceable(33) %0)
          to label %88 unwind label %.split

88:                                               ; preds = %.lr.ph.split
  %89 = icmp eq i32 %87, -1
  br i1 %89, label %.thread, label %91

.split:                                           ; preds = %103, %95, %91, %.lr.ph.split
  %90 = landingpad { ptr, i32 }
          cleanup
  br label %.split.us

91:                                               ; preds = %88
  %92 = invoke noundef i32 @_ZN8SPIFlash12sector_eraseEi(ptr noundef nonnull align 8 dereferenceable(33) %0, i32 noundef %.057)
          to label %93 unwind label %.split

93:                                               ; preds = %91
  %94 = icmp eq i32 %92, -1
  br i1 %94, label %.thread, label %95

95:                                               ; preds = %93
  %96 = load ptr, ptr %34, align 8, !tbaa !23
  %97 = load ptr, ptr %96, align 8, !tbaa !24
  %98 = getelementptr inbounds i8, ptr %97, i64 32
  %99 = load ptr, ptr %98, align 8
  %100 = invoke noundef i32 %99(ptr noundef nonnull align 8 dereferenceable(56) %96, i8 noundef zeroext 5, i8 noundef zeroext 1, i8 noundef zeroext 0, i32 noundef 100000, i1 noundef zeroext false)
          to label %101 unwind label %.split

101:                                              ; preds = %95
  %102 = icmp eq i32 %100, -1
  br i1 %102, label %.thread, label %103

103:                                              ; preds = %101
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %4, i32 noundef %.057, i8 noundef signext 0)
          to label %104 unwind label %.split

104:                                              ; preds = %103
  %105 = add nsw i32 %.057, 4096
  %106 = icmp slt i32 %105, %26
  br i1 %106, label %.lr.ph.split, label %._crit_edge, !llvm.loop !26

._crit_edge:                                      ; preds = %104, %51, %76
  %.038.lcssa = phi i32 [ %.139.us, %76 ], [ %39, %51 ], [ %92, %104 ]
  %107 = icmp eq i32 %.038.lcssa, 0
  br i1 %107, label %._crit_edge.thread, label %.thread

._crit_edge.thread:                               ; preds = %31, %._crit_edge
  invoke void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50) %4)
          to label %108 unwind label %85

.thread:                                          ; preds = %88, %93, %101, %36, %40, %48, %56, %65, %73, %._crit_edge
  %.24052 = phi i32 [ %.038.lcssa, %._crit_edge ], [ -1, %73 ], [ -1, %65 ], [ -1, %56 ], [ -1, %48 ], [ -1, %40 ], [ -1, %36 ], [ -1, %101 ], [ -1, %93 ], [ -1, %88 ]
  invoke void @_ZN11ProgressBar4failEv(ptr noundef nonnull align 8 dereferenceable(50) %4)
          to label %108 unwind label %85

108:                                              ; preds = %.thread, %._crit_edge.thread
  %.24051 = phi i32 [ %.24052, %.thread ], [ 0, %._crit_edge.thread ]
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %4) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #6
  ret i32 %.24051

.split.us:                                        ; preds = %.split, %.split.us.split.us, %.split.us.split, %85
  %.pn44 = phi { ptr, i32 } [ %86, %85 ], [ %90, %.split ], [ %79, %.split.us.split ], [ %54, %.split.us.split.us ]
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %4) #6
  br label %109

109:                                              ; preds = %.split.us, %84
  %.pn44.pn = phi { ptr, i32 } [ %.pn44, %.split.us ], [ %.pn, %84 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %4) #6
  resume { ptr, i32 } %.pn44.pn
}

declare void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #3

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

declare void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50), i32 noundef, i8 noundef signext) local_unnamed_addr #3

declare void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50)) local_unnamed_addr #3

declare void @_ZN11ProgressBar4failEv(ptr noundef nonnull align 8 dereferenceable(50)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50)) unnamed_addr #5 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 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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { 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, !7, i64 24}
!6 = !{!"_ZTS8SPIFlash", !7, i64 8, !8, i64 16, !10, i64 20, !7, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!13, !11, i64 69}
!13 = !{!"_ZTS7flash_t", !14, i64 0, !14, i64 32, !10, i64 64, !11, i64 68, !11, i64 69, !11, i64 70, !11, i64 71, !8, i64 72, !17, i64 76, !8, i64 80, !8, i64 81, !17, i64 88, !18, i64 92}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!"_ZTS8tb_loc_t", !8, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!13, !11, i64 68}
!22 = !{!6, !8, i64 16}
!23 = !{!6, !7, i64 8}
!24 = !{!25, !25, i64 0}
!25 = !{!"vtable pointer", !9, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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