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

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

@__const._ZN5Gowin10writeFLASHEjPKhib.tx = external hidden unnamed_addr constant [4 x i8], align 1
@__const._ZN5Gowin10writeFLASHEjPKhib.bufvalues = external hidden unnamed_addr constant [24 x i8], align 16
@.str.647 = external hidden unnamed_addr constant [12 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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 @_ZN4Jtag9set_stateENS_10tapState_tEh(ptr noundef nonnull align 8 dereferenceable(193), i32 noundef, i8 noundef zeroext) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192), i8 noundef zeroext) #2 align 2

declare void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193), i32 noundef) #4

declare noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193), ptr noundef, ptr noundef, i32 noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Gowin10writeFLASHEjPKhib(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4) #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca [4 x i8], align 1
  %12 = alloca [4 x i8], align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca [39 x i8], align 16
  %20 = alloca [24 x i8], align 16
  %21 = alloca %class.ProgressBar, align 8
  %22 = alloca %"class.std::__cxx11::basic_string", align 8
  %23 = alloca %"class.std::allocator.0", align 1
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  %29 = alloca i32, align 4
  %30 = alloca i32, align 4
  %31 = alloca ptr, align 8
  %32 = alloca i32, align 4
  %33 = alloca i32, align 4
  %34 = alloca [751 x i8], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %35 = zext i1 %4 to i8
  store i8 %35, ptr %10, align 1, !tbaa !11
  %36 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %11, ptr align 1 @__const._ZN5Gowin10writeFLASHEjPKhib.tx, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = sdiv i32 %37, 8
  store i32 %38, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.start.p0(i64 39, ptr %19) #9
  %39 = getelementptr inbounds [39 x i8], ptr %19, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %39, i8 0, i64 39, i1 false)
  %40 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  call void @_ZN4Jtag19go_test_logic_resetEv(ptr noundef nonnull align 8 dereferenceable(193) %41)
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %72

44:                                               ; preds = %5
  %45 = load i32, ptr %15, align 4, !tbaa !9
  %46 = add nsw i32 %45, 24
  store i32 %46, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %20, ptr align 16 @__const._ZN5Gowin10writeFLASHEjPKhib.bufvalues, i64 24, i1 false)
  %47 = load i32, ptr %16, align 4, !tbaa !9
  %48 = sdiv i32 %47, 256
  store i32 %48, ptr %18, align 4, !tbaa !9
  %49 = load i32, ptr %18, align 4, !tbaa !9
  %50 = mul nsw i32 %49, 256
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = icmp ne i32 %50, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %44
  %54 = load i32, ptr %18, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %18, align 4, !tbaa !9
  %56 = load i32, ptr %18, align 4, !tbaa !9
  %57 = mul nsw i32 %56, 256
  store i32 %57, ptr %16, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %53, %44
  %59 = load i32, ptr %16, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = call noalias noundef nonnull ptr @_Znam(i64 noundef %60) #10
  store ptr %61, ptr %17, align 8, !tbaa !5
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %62, i8 -1, i64 %64, i1 false)
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = getelementptr inbounds [24 x i8], ptr %20, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %65, ptr align 16 %66, i64 24, i1 false)
  %67 = load ptr, ptr %17, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 24
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = load i32, ptr %15, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %68, ptr align 1 %69, i64 %71, i1 false)
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #9
  br label %96

72:                                               ; preds = %5
  %73 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %73, ptr %16, align 4, !tbaa !9
  %74 = load i32, ptr %16, align 4, !tbaa !9
  %75 = sdiv i32 %74, 256
  store i32 %75, ptr %18, align 4, !tbaa !9
  %76 = load i32, ptr %18, align 4, !tbaa !9
  %77 = mul nsw i32 %76, 256
  %78 = load i32, ptr %16, align 4, !tbaa !9
  %79 = icmp ne i32 %77, %78
  br i1 %79, label %80, label %85

80:                                               ; preds = %72
  %81 = load i32, ptr %18, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %18, align 4, !tbaa !9
  %83 = load i32, ptr %18, align 4, !tbaa !9
  %84 = mul nsw i32 %83, 256
  store i32 %84, ptr %16, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %80, %72
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = call noalias noundef nonnull ptr @_Znam(i64 noundef %87) #10
  store ptr %88, ptr %17, align 8, !tbaa !5
  %89 = load ptr, ptr %17, align 8, !tbaa !5
  %90 = load i32, ptr %16, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %89, i8 -1, i64 %91, i1 false)
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load ptr, ptr %8, align 8, !tbaa !5
  %94 = load i32, ptr %15, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %92, ptr align 1 %93, i64 %95, i1 false)
  br label %96

96:                                               ; preds = %85, %58
  call void @llvm.lifetime.start.p0(i64 56, ptr %21) #9
  call void @llvm.lifetime.start.p0(i64 32, ptr %22) #9
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #9
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %23) #9
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %22, ptr noundef @.str.647, ptr noundef nonnull align 1 dereferenceable(1) %23)
          to label %97 unwind label %108

97:                                               ; preds = %96
  %98 = load i32, ptr %16, align 4, !tbaa !9
  %99 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 7
  %100 = load i8, ptr %99, align 2, !tbaa !19, !range !20, !noundef !21
  %101 = trunc i8 %100 to i1
  invoke void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50) %21, ptr noundef nonnull align 8 dereferenceable(32) %22, i32 noundef %98, i32 noundef 50, i1 noundef zeroext %101)
          to label %102 unwind label %112

102:                                              ; preds = %97
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %22) #9
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %23) #9
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr %22) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #9
  store i32 0, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #9
  store i32 0, ptr %27, align 4, !tbaa !9
  br label %103

103:                                              ; preds = %280, %102
  %104 = load i32, ptr %27, align 4, !tbaa !9
  %105 = load i32, ptr %18, align 4, !tbaa !9
  %106 = icmp slt i32 %104, %105
  br i1 %106, label %117, label %107

107:                                              ; preds = %103
  store i32 2, ptr %28, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #9
  br label %293

108:                                              ; preds = %96
  %109 = landingpad { ptr, i32 }
          cleanup
  %110 = extractvalue { ptr, i32 } %109, 0
  store ptr %110, ptr %24, align 8
  %111 = extractvalue { ptr, i32 } %109, 1
  store i32 %111, ptr %25, align 4
  br label %116

112:                                              ; preds = %97
  %113 = landingpad { ptr, i32 }
          cleanup
  %114 = extractvalue { ptr, i32 } %113, 0
  store ptr %114, ptr %24, align 8
  %115 = extractvalue { ptr, i32 } %113, 1
  store i32 %115, ptr %25, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %22) #9
  br label %116

116:                                              ; preds = %112, %108
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %23) #9
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr %22) #9
  br label %307

117:                                              ; preds = %103
  %118 = invoke noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192) %36, i8 noundef zeroext 21)
          to label %119 unwind label %130

119:                                              ; preds = %117
  %120 = invoke noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192) %36, i8 noundef zeroext 113)
          to label %121 unwind label %130

121:                                              ; preds = %119
  %122 = load i32, ptr %7, align 4, !tbaa !9
  %123 = load i32, ptr %27, align 4, !tbaa !9
  %124 = add i32 %122, %123
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %134

126:                                              ; preds = %121
  %127 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %128 = load ptr, ptr %127, align 8, !tbaa !13
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %128, i32 noundef 312)
          to label %129 unwind label %130

129:                                              ; preds = %126
  br label %134

130:                                              ; preds = %162, %134, %126, %119, %117
  %131 = landingpad { ptr, i32 }
          cleanup
  %132 = extractvalue { ptr, i32 } %131, 0
  store ptr %132, ptr %24, align 8
  %133 = extractvalue { ptr, i32 } %131, 1
  store i32 %133, ptr %25, align 4
  br label %292

134:                                              ; preds = %129, %121
  %135 = load i32, ptr %7, align 4, !tbaa !9
  %136 = load i32, ptr %27, align 4, !tbaa !9
  %137 = add i32 %135, %136
  %138 = shl i32 %137, 6
  store i32 %138, ptr %13, align 4, !tbaa !9
  %139 = load i32, ptr %13, align 4, !tbaa !9
  %140 = lshr i32 %139, 24
  %141 = and i32 255, %140
  %142 = trunc i32 %141 to i8
  %143 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 3
  store i8 %142, ptr %143, align 1, !tbaa !22
  %144 = load i32, ptr %13, align 4, !tbaa !9
  %145 = lshr i32 %144, 16
  %146 = and i32 255, %145
  %147 = trunc i32 %146 to i8
  %148 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 2
  store i8 %147, ptr %148, align 1, !tbaa !22
  %149 = load i32, ptr %13, align 4, !tbaa !9
  %150 = lshr i32 %149, 8
  %151 = and i32 255, %150
  %152 = trunc i32 %151 to i8
  %153 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 1
  store i8 %152, ptr %153, align 1, !tbaa !22
  %154 = load i32, ptr %13, align 4, !tbaa !9
  %155 = and i32 %154, 255
  %156 = trunc i32 %155 to i8
  %157 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  store i8 %156, ptr %157, align 1, !tbaa !22
  %158 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %159 = load ptr, ptr %158, align 8, !tbaa !13
  %160 = getelementptr inbounds [4 x i8], ptr %12, i64 0, i64 0
  %161 = invoke noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193) %159, ptr noundef %160, ptr noundef null, i32 noundef 32, i32 noundef 1)
          to label %162 unwind label %130

162:                                              ; preds = %134
  %163 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %164 = load ptr, ptr %163, align 8, !tbaa !13
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %164, i32 noundef 312)
          to label %165 unwind label %130

165:                                              ; preds = %162
  call void @llvm.lifetime.start.p0(i64 4, ptr %29) #9
  %166 = load i32, ptr %27, align 4, !tbaa !9
  %167 = mul nsw i32 %166, 256
  store i32 %167, ptr %29, align 4, !tbaa !9
  %168 = load i32, ptr %29, align 4, !tbaa !9
  %169 = add nsw i32 %168, 256
  %170 = load i32, ptr %16, align 4, !tbaa !9
  %171 = icmp sgt i32 %169, %170
  br i1 %171, label %172, label %177

172:                                              ; preds = %165
  %173 = load i32, ptr %16, align 4, !tbaa !9
  %174 = load i32, ptr %29, align 4, !tbaa !9
  %175 = sub nsw i32 %173, %174
  %176 = sdiv i32 %175, 4
  store i32 %176, ptr %14, align 4, !tbaa !9
  br label %178

177:                                              ; preds = %165
  store i32 64, ptr %14, align 4, !tbaa !9
  br label %178

178:                                              ; preds = %177, %172
  call void @llvm.lifetime.start.p0(i64 4, ptr %30) #9
  store i32 0, ptr %30, align 4, !tbaa !9
  br label %179

179:                                              ; preds = %261, %178
  %180 = load i32, ptr %30, align 4, !tbaa !9
  %181 = load i32, ptr %14, align 4, !tbaa !9
  %182 = icmp slt i32 %180, %181
  br i1 %182, label %184, label %183

183:                                              ; preds = %179
  store i32 5, ptr %28, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #9
  br label %264

184:                                              ; preds = %179
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #9
  %185 = load ptr, ptr %17, align 8, !tbaa !5
  %186 = load i32, ptr %29, align 4, !tbaa !9
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds i8, ptr %185, i64 %187
  %189 = load i32, ptr %30, align 4, !tbaa !9
  %190 = mul nsw i32 4, %189
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds i8, ptr %188, i64 %191
  store ptr %192, ptr %31, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %32) #9
  store i32 0, ptr %32, align 4, !tbaa !9
  br label %193

193:                                              ; preds = %220, %184
  %194 = load i32, ptr %32, align 4, !tbaa !9
  %195 = icmp slt i32 %194, 4
  br i1 %195, label %197, label %196

196:                                              ; preds = %193
  store i32 8, ptr %28, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %32) #9
  br label %223

197:                                              ; preds = %193
  %198 = load i32, ptr %7, align 4, !tbaa !9
  %199 = icmp eq i32 %198, 0
  br i1 %199, label %200, label %210

200:                                              ; preds = %197
  %201 = load ptr, ptr %31, align 8, !tbaa !5
  %202 = load i32, ptr %32, align 4, !tbaa !9
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds i8, ptr %201, i64 %203
  %205 = load i8, ptr %204, align 1, !tbaa !22
  %206 = load i32, ptr %32, align 4, !tbaa !9
  %207 = sub nsw i32 3, %206
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds [4 x i8], ptr %11, i64 0, i64 %208
  store i8 %205, ptr %209, align 1, !tbaa !22
  br label %219

210:                                              ; preds = %197
  %211 = load ptr, ptr %31, align 8, !tbaa !5
  %212 = load i32, ptr %32, align 4, !tbaa !9
  %213 = sext i32 %212 to i64
  %214 = getelementptr inbounds i8, ptr %211, i64 %213
  %215 = load i8, ptr %214, align 1, !tbaa !22
  %216 = load i32, ptr %32, align 4, !tbaa !9
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [4 x i8], ptr %11, i64 0, i64 %217
  store i8 %215, ptr %218, align 1, !tbaa !22
  br label %219

219:                                              ; preds = %210, %200
  br label %220

220:                                              ; preds = %219
  %221 = load i32, ptr %32, align 4, !tbaa !9
  %222 = add nsw i32 %221, 1
  store i32 %222, ptr %32, align 4, !tbaa !9
  br label %193, !llvm.loop !23

223:                                              ; preds = %196
  %224 = load i8, ptr %10, align 1, !tbaa !11, !range !20, !noundef !21
  %225 = trunc i8 %224 to i1
  br i1 %225, label %226, label %243

226:                                              ; preds = %223
  call void @llvm.lifetime.start.p0(i64 4, ptr %33) #9
  store i32 0, ptr %33, align 4, !tbaa !9
  br label %227

227:                                              ; preds = %239, %226
  %228 = load i32, ptr %33, align 4, !tbaa !9
  %229 = icmp slt i32 %228, 4
  br i1 %229, label %231, label %230

230:                                              ; preds = %227
  store i32 11, ptr %28, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %33) #9
  br label %242

231:                                              ; preds = %227
  %232 = load i32, ptr %33, align 4, !tbaa !9
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [4 x i8], ptr %11, i64 0, i64 %233
  %235 = load i8, ptr %234, align 1, !tbaa !22
  %236 = zext i8 %235 to i32
  %237 = xor i32 %236, 255
  %238 = trunc i32 %237 to i8
  store i8 %238, ptr %234, align 1, !tbaa !22
  br label %239

239:                                              ; preds = %231
  %240 = load i32, ptr %33, align 4, !tbaa !9
  %241 = add nsw i32 %240, 1
  store i32 %241, ptr %33, align 4, !tbaa !9
  br label %227, !llvm.loop !25

242:                                              ; preds = %230
  br label %243

243:                                              ; preds = %242, %223
  %244 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %245 = load ptr, ptr %244, align 8, !tbaa !13
  %246 = getelementptr inbounds [4 x i8], ptr %11, i64 0, i64 0
  %247 = invoke noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193) %245, ptr noundef %246, ptr noundef null, i32 noundef 32, i32 noundef 1)
          to label %248 unwind label %256

248:                                              ; preds = %243
  %249 = getelementptr inbounds %class.Gowin, ptr %36, i32 0, i32 6
  %250 = load i8, ptr %249, align 4, !tbaa !26, !range !20, !noundef !21
  %251 = trunc i8 %250 to i1
  br i1 %251, label %260, label %252

252:                                              ; preds = %248
  %253 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %254 = load ptr, ptr %253, align 8, !tbaa !13
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %254, i32 noundef 40)
          to label %255 unwind label %256

255:                                              ; preds = %252
  br label %260

256:                                              ; preds = %252, %243
  %257 = landingpad { ptr, i32 }
          cleanup
  %258 = extractvalue { ptr, i32 } %257, 0
  store ptr %258, ptr %24, align 8
  %259 = extractvalue { ptr, i32 } %257, 1
  store i32 %259, ptr %25, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %30) #9
  br label %291

260:                                              ; preds = %255, %248
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #9
  br label %261

261:                                              ; preds = %260
  %262 = load i32, ptr %30, align 4, !tbaa !9
  %263 = add nsw i32 %262, 1
  store i32 %263, ptr %30, align 4, !tbaa !9
  br label %179, !llvm.loop !36

264:                                              ; preds = %183
  %265 = getelementptr inbounds %class.Gowin, ptr %36, i32 0, i32 6
  %266 = load i8, ptr %265, align 4, !tbaa !26, !range !20, !noundef !21
  %267 = trunc i8 %266 to i1
  br i1 %267, label %268, label %277

268:                                              ; preds = %264
  call void @llvm.lifetime.start.p0(i64 751, ptr %34) #9
  %269 = getelementptr inbounds [751 x i8], ptr %34, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %269, i8 0, i64 751, i1 false)
  %270 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %271 = load ptr, ptr %270, align 8, !tbaa !13
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %271, i32 noundef 6008)
          to label %272 unwind label %273

272:                                              ; preds = %268
  call void @llvm.lifetime.end.p0(i64 751, ptr %34) #9
  br label %277

273:                                              ; preds = %268
  %274 = landingpad { ptr, i32 }
          cleanup
  %275 = extractvalue { ptr, i32 } %274, 0
  store ptr %275, ptr %24, align 8
  %276 = extractvalue { ptr, i32 } %274, 1
  store i32 %276, ptr %25, align 4
  call void @llvm.lifetime.end.p0(i64 751, ptr %34) #9
  br label %291

277:                                              ; preds = %272, %264
  %278 = load i32, ptr %26, align 4, !tbaa !9
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %21, i32 noundef %278, i8 noundef signext 0)
          to label %279 unwind label %287

279:                                              ; preds = %277
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #9
  br label %280

280:                                              ; preds = %279
  %281 = load i32, ptr %14, align 4, !tbaa !9
  %282 = mul nsw i32 %281, 4
  %283 = load i32, ptr %26, align 4, !tbaa !9
  %284 = add nsw i32 %283, %282
  store i32 %284, ptr %26, align 4, !tbaa !9
  %285 = load i32, ptr %27, align 4, !tbaa !9
  %286 = add nsw i32 %285, 1
  store i32 %286, ptr %27, align 4, !tbaa !9
  br label %103, !llvm.loop !37

287:                                              ; preds = %277
  %288 = landingpad { ptr, i32 }
          cleanup
  %289 = extractvalue { ptr, i32 } %288, 0
  store ptr %289, ptr %24, align 8
  %290 = extractvalue { ptr, i32 } %288, 1
  store i32 %290, ptr %25, align 4
  br label %291

291:                                              ; preds = %287, %273, %256
  call void @llvm.lifetime.end.p0(i64 4, ptr %29) #9
  br label %292

292:                                              ; preds = %291, %130
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #9
  br label %306

293:                                              ; preds = %107
  %294 = getelementptr inbounds %class.Device, ptr %36, i32 0, i32 1
  %295 = load ptr, ptr %294, align 8, !tbaa !13
  invoke void @_ZN4Jtag9set_stateENS_10tapState_tEh(ptr noundef nonnull align 8 dereferenceable(193) %295, i32 noundef 1, i8 noundef zeroext 1)
          to label %296 unwind label %302

296:                                              ; preds = %293
  invoke void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50) %21)
          to label %297 unwind label %302

297:                                              ; preds = %296
  %298 = load ptr, ptr %17, align 8, !tbaa !5
  %299 = icmp eq ptr %298, null
  br i1 %299, label %301, label %300

300:                                              ; preds = %297
  call void @_ZdaPv(ptr noundef %298) #11
  br label %301

301:                                              ; preds = %300, %297
  store i32 1, ptr %28, align 4
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %21) #9
  call void @llvm.lifetime.end.p0(i64 56, ptr %21) #9
  call void @llvm.lifetime.end.p0(i64 39, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  ret i1 true

302:                                              ; preds = %296, %293
  %303 = landingpad { ptr, i32 }
          cleanup
  %304 = extractvalue { ptr, i32 } %303, 0
  store ptr %304, ptr %24, align 8
  %305 = extractvalue { ptr, i32 } %303, 1
  store i32 %305, ptr %25, align 4
  br label %306

306:                                              ; preds = %302, %292
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %21) #9
  br label %307

307:                                              ; preds = %306, %116
  call void @llvm.lifetime.end.p0(i64 56, ptr %21) #9
  call void @llvm.lifetime.end.p0(i64 39, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #9
  br label %308

308:                                              ; preds = %307
  %309 = load ptr, ptr %24, align 8
  %310 = load i32, ptr %25, align 4
  %311 = insertvalue { ptr, i32 } poison, ptr %309, 0
  %312 = insertvalue { ptr, i32 } %311, i32 %310, 1
  resume { ptr, i32 } %312
}

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

declare void @_ZN4Jtag19go_test_logic_resetEv(ptr noundef nonnull align 8 dereferenceable(193)) #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #6

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 #4

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #7

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50)) unnamed_addr #8 align 2

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS6Device", !6, i64 8, !15, i64 16, !15, i64 48, !18, i64 80, !12, i64 84, !12, i64 85, !12, i64 86}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !17, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN6Device9prog_modeE", !7, i64 0}
!19 = !{!14, !12, i64 86}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}
!26 = !{!27, !12, i64 172}
!27 = !{!"_ZTS5Gowin", !14, i64 0, !28, i64 88, !29, i64 144, !29, i64 152, !29, i64 160, !10, i64 168, !12, i64 172, !12, i64 173, !12, i64 174, !12, i64 175, !12, i64 176, !12, i64 177, !12, i64 178, !7, i64 179, !7, i64 180, !7, i64 181, !7, i64 182, !7, i64 183, !35, i64 184, !35, i64 188}
!28 = !{!"_ZTS12SPIInterface", !7, i64 8, !10, i64 12, !12, i64 16, !12, i64 17, !12, i64 18, !15, i64 24}
!29 = !{!"_ZTSSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EE", !30, i64 0}
!30 = !{!"_ZTSSt15__uniq_ptr_dataI21ConfigBitstreamParserSt14default_deleteIS0_ELb1ELb1EE", !31, i64 0}
!31 = !{!"_ZTSSt15__uniq_ptr_implI21ConfigBitstreamParserSt14default_deleteIS0_EE", !32, i64 0}
!32 = !{!"_ZTSSt5tupleIJP21ConfigBitstreamParserSt14default_deleteIS0_EEE", !33, i64 0}
!33 = !{!"_ZTSSt11_Tuple_implILm0EJP21ConfigBitstreamParserSt14default_deleteIS0_EEE", !34, i64 0}
!34 = !{!"_ZTSSt10_Head_baseILm0EP21ConfigBitstreamParserLb0EE", !6, i64 0}
!35 = !{!"_ZTSN13JtagInterface10tck_edge_tE", !7, i64 0}
!36 = distinct !{!36, !24}
!37 = distinct !{!37, !24}


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

@__const._ZN5Gowin10writeFLASHEjPKhib.tx = external hidden unnamed_addr constant [4 x i8], align 1
@__const._ZN5Gowin10writeFLASHEjPKhib.bufvalues = external hidden unnamed_addr constant [24 x i8], align 16
@.str.647 = external hidden unnamed_addr constant [12 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; 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 @_ZN4Jtag9set_stateENS_10tapState_tEh(ptr noundef nonnull align 8 dereferenceable(193), i32 noundef, i8 noundef zeroext) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192), i8 noundef zeroext) local_unnamed_addr #2 align 2

declare void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193), i32 noundef) local_unnamed_addr #4

declare noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193), ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN5Gowin10writeFLASHEjPKhib(ptr noundef nonnull align 8 dereferenceable(192) %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca [4 x i8], align 4
  %7 = alloca [4 x i8], align 1
  %8 = alloca %class.ProgressBar, align 8
  %9 = alloca %"class.std::__cxx11::basic_string", align 8
  %10 = alloca %"class.std::allocator.0", align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #9
  %11 = load i32, ptr @__const._ZN5Gowin10writeFLASHEjPKhib.tx, align 1
  store i32 %11, ptr %6, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #9
  %12 = sdiv i32 %3, 8
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  tail call void @_ZN4Jtag19go_test_logic_resetEv(ptr noundef nonnull align 8 dereferenceable(193) %14)
  %15 = icmp eq i32 %1, 0
  br i1 %15, label %16, label %29

16:                                               ; preds = %5
  %17 = add nsw i32 %12, 24
  %18 = sdiv i32 %17, 256
  %19 = shl nsw i32 %18, 8
  %.not89 = icmp eq i32 %19, %17
  %20 = add nsw i32 %18, 1
  %21 = shl nsw i32 %20, 8
  %.083 = select i1 %.not89, i32 %18, i32 %20
  %.072 = select i1 %.not89, i32 %17, i32 %21
  %22 = sext i32 %.072 to i64
  %23 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %22) #10
  %24 = icmp ult i32 %.072, 25
  %25 = add nsw i64 %22, -24
  %26 = select i1 %24, i64 0, i64 %25
  %27 = getelementptr i8, ptr %23, i64 24
  tail call void @llvm.memset.p0.i64(ptr align 1 %27, i8 -1, i64 %26, i1 false)
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(24) %23, ptr noundef nonnull align 16 dereferenceable(24) @__const._ZN5Gowin10writeFLASHEjPKhib.bufvalues, i64 24, i1 false)
  %28 = getelementptr inbounds i8, ptr %23, i64 24
  br label %36

29:                                               ; preds = %5
  %30 = sdiv i32 %3, 2048
  %31 = shl nsw i32 %30, 8
  %.not = icmp eq i32 %31, %12
  %32 = add nsw i32 %30, 1
  %33 = shl nsw i32 %32, 8
  %.184 = select i1 %.not, i32 %30, i32 %32
  %.1 = select i1 %.not, i32 %12, i32 %33
  %34 = sext i32 %.1 to i64
  %35 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %34) #10
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %35, i8 -1, i64 %34, i1 false)
  br label %36

36:                                               ; preds = %29, %16
  %.sink = phi ptr [ %35, %29 ], [ %28, %16 ]
  %.086 = phi ptr [ %35, %29 ], [ %23, %16 ]
  %.285 = phi i32 [ %.184, %29 ], [ %.083, %16 ]
  %.2 = phi i32 [ %.1, %29 ], [ %.072, %16 ]
  %37 = sext i32 %12 to i64
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %.sink, ptr align 1 %2, i64 %37, i1 false)
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %8) #9
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %9) #9
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #9
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #9
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull @.str.647, ptr noundef nonnull align 1 dereferenceable(1) %10)
          to label %38 unwind label %53

38:                                               ; preds = %36
  %39 = getelementptr inbounds i8, ptr %0, i64 86
  %40 = load i8, ptr %39, align 2, !tbaa !15, !range !16, !noundef !17
  %41 = trunc nuw i8 %40 to i1
  invoke void @_ZN11ProgressBarC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiib(ptr noundef nonnull align 8 dereferenceable(50) %8, ptr noundef nonnull align 8 dereferenceable(32) %9, i32 noundef %.2, i32 noundef 50, i1 noundef zeroext %41)
          to label %42 unwind label %55

42:                                               ; preds = %38
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %9) #9
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #9
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  %43 = icmp sgt i32 %.285, 0
  br i1 %43, label %.lr.ph107, label %._crit_edge108

.lr.ph107:                                        ; preds = %42
  %44 = getelementptr inbounds i8, ptr %7, i64 3
  %45 = getelementptr inbounds i8, ptr %7, i64 2
  %46 = getelementptr inbounds i8, ptr %7, i64 1
  %47 = getelementptr inbounds i8, ptr %0, i64 172
  %48 = sext i32 %.2 to i64
  %wide.trip.count123 = zext nneg i32 %.285 to i64
  %invariant.op = add nsw i64 %48, -256
  %49 = getelementptr inbounds i8, ptr %6, i64 3
  %50 = getelementptr inbounds i8, ptr %6, i64 2
  %51 = getelementptr inbounds i8, ptr %6, i64 1
  br label %58

._crit_edge108:                                   ; preds = %134, %42
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9set_stateENS_10tapState_tEh(ptr noundef nonnull align 8 dereferenceable(193) %52, i32 noundef 1, i8 noundef zeroext 1)
          to label %139 unwind label %141

53:                                               ; preds = %36
  %54 = landingpad { ptr, i32 }
          cleanup
  br label %57

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

57:                                               ; preds = %55, %53
  %.pn = phi { ptr, i32 } [ %56, %55 ], [ %54, %53 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %10) #9
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %9) #9
  br label %144

58:                                               ; preds = %.lr.ph107, %134
  %indvar = phi i64 [ 0, %.lr.ph107 ], [ %indvar.next, %134 ]
  %.074104 = phi i32 [ 0, %.lr.ph107 ], [ %136, %134 ]
  %59 = shl nsw i64 %indvar, 8
  %60 = invoke noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192) %0, i8 noundef zeroext 21)
          to label %61 unwind label %68

61:                                               ; preds = %58
  %62 = invoke noundef zeroext i1 @_ZN5Gowin12send_commandEh(ptr noundef nonnull align 8 dereferenceable(192) %0, i8 noundef zeroext 113)
          to label %63 unwind label %68

63:                                               ; preds = %61
  %64 = trunc nuw nsw i64 %indvar to i32
  %65 = add i32 %64, %1
  %.not91 = icmp eq i32 %65, 0
  br i1 %.not91, label %70, label %66

66:                                               ; preds = %63
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %67, i32 noundef 312)
          to label %70 unwind label %68

68:                                               ; preds = %81, %70, %66, %61, %58
  %69 = landingpad { ptr, i32 }
          cleanup
  br label %143

70:                                               ; preds = %66, %63
  %71 = shl i32 %65, 6
  %72 = lshr i32 %71, 24
  %73 = trunc nuw i32 %72 to i8
  store i8 %73, ptr %44, align 1, !tbaa !18
  %74 = lshr i32 %71, 16
  %75 = trunc i32 %74 to i8
  store i8 %75, ptr %45, align 1, !tbaa !18
  %76 = lshr i32 %71, 8
  %77 = trunc i32 %76 to i8
  store i8 %77, ptr %46, align 1, !tbaa !18
  %78 = trunc i32 %71 to i8
  store i8 %78, ptr %7, align 1, !tbaa !18
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = invoke noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193) %79, ptr noundef nonnull %7, ptr noundef null, i32 noundef 32, i32 noundef 1)
          to label %81 unwind label %68

81:                                               ; preds = %70
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %82, i32 noundef 312)
          to label %83 unwind label %68

83:                                               ; preds = %81
  %84 = icmp sgt i64 %59, %invariant.op
  br i1 %84, label %85, label %.lr.ph

85:                                               ; preds = %83
  %86 = trunc i64 %59 to i32
  %87 = sub i32 %.2, %86
  %88 = sdiv i32 %87, 4
  %89 = icmp sgt i32 %87, 3
  br i1 %89, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %83, %85
  %.070127 = phi i32 [ %88, %85 ], [ 64, %83 ]
  %90 = getelementptr inbounds i8, ptr %.086, i64 %59
  %wide.trip.count120 = zext nneg i32 %.070127 to i64
  br i1 %15, label %.split.us.us, label %.split

.split.us.us:                                     ; preds = %.lr.ph, %107
  %indvars.iv = phi i64 [ %indvars.iv.next, %107 ], [ 0, %.lr.ph ]
  %91 = shl nsw i64 %indvars.iv, 2
  %92 = getelementptr inbounds i8, ptr %90, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !18
  store i8 %93, ptr %49, align 1, !tbaa !18
  %94 = getelementptr inbounds i8, ptr %92, i64 1
  %95 = load i8, ptr %94, align 1, !tbaa !18
  store i8 %95, ptr %50, align 2, !tbaa !18
  %96 = getelementptr inbounds i8, ptr %92, i64 2
  %97 = load i8, ptr %96, align 1, !tbaa !18
  store i8 %97, ptr %51, align 1, !tbaa !18
  %98 = getelementptr inbounds i8, ptr %92, i64 3
  %99 = load i8, ptr %98, align 1, !tbaa !18
  store i8 %99, ptr %6, align 4, !tbaa !18
  br i1 %4, label %.preheader.us.preheader, label %.loopexit.us

.loopexit.us:                                     ; preds = %.preheader.us.preheader, %.split.us.us
  %100 = load ptr, ptr %13, align 8, !tbaa !5
  %101 = invoke noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193) %100, ptr noundef nonnull %6, ptr noundef null, i32 noundef 32, i32 noundef 1)
          to label %102 unwind label %.split103.us

102:                                              ; preds = %.loopexit.us
  %103 = load i8, ptr %47, align 4, !tbaa !19, !range !16, !noundef !17
  %104 = trunc nuw i8 %103 to i1
  br i1 %104, label %107, label %105

105:                                              ; preds = %102
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %106, i32 noundef 40)
          to label %107 unwind label %.split103.us

107:                                              ; preds = %105, %102
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond121.not = icmp eq i64 %indvars.iv.next, %wide.trip.count120
  br i1 %exitcond121.not, label %._crit_edge, label %.split.us.us, !llvm.loop !30

.preheader.us.preheader:                          ; preds = %.split.us.us
  %108 = xor i8 %99, -1
  store i8 %108, ptr %6, align 4, !tbaa !18
  %109 = xor i8 %97, -1
  store i8 %109, ptr %51, align 1, !tbaa !18
  %110 = xor i8 %95, -1
  store i8 %110, ptr %50, align 2, !tbaa !18
  %111 = xor i8 %93, -1
  store i8 %111, ptr %49, align 1, !tbaa !18
  br label %.loopexit.us

.split103.us:                                     ; preds = %105, %.loopexit.us
  %112 = landingpad { ptr, i32 }
          cleanup
  br label %143

._crit_edge:                                      ; preds = %128, %107, %85
  %.070126 = phi i32 [ %88, %85 ], [ %.070127, %107 ], [ %.070127, %128 ]
  %113 = load i8, ptr %47, align 4, !tbaa !19, !range !16, !noundef !17
  %114 = trunc nuw i8 %113 to i1
  br i1 %114, label %129, label %133

.split:                                           ; preds = %.lr.ph, %128
  %indvar110 = phi i64 [ %indvar.next111, %128 ], [ 0, %.lr.ph ]
  %115 = shl nuw nsw i64 %indvar110, 2
  %116 = add nuw nsw i64 %59, %115
  %scevgep = getelementptr i8, ptr %.086, i64 %116
  %117 = load i32, ptr %scevgep, align 1, !tbaa !18
  store i32 %117, ptr %6, align 4, !tbaa !18
  br i1 %4, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %.split
  %118 = load <4 x i8>, ptr %6, align 4, !tbaa !18
  %119 = xor <4 x i8> %118, <i8 -1, i8 -1, i8 -1, i8 -1>
  store <4 x i8> %119, ptr %6, align 4, !tbaa !18
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.preheader, %.split
  %120 = load ptr, ptr %13, align 8, !tbaa !5
  %121 = invoke noundef i32 @_ZN4Jtag7shiftDREPKhPhiNS_10tapState_tE(ptr noundef nonnull align 8 dereferenceable(193) %120, ptr noundef nonnull %6, ptr noundef null, i32 noundef 32, i32 noundef 1)
          to label %122 unwind label %.split103

122:                                              ; preds = %.loopexit
  %123 = load i8, ptr %47, align 4, !tbaa !19, !range !16, !noundef !17
  %124 = trunc nuw i8 %123 to i1
  br i1 %124, label %128, label %125

125:                                              ; preds = %122
  %126 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %126, i32 noundef 40)
          to label %128 unwind label %.split103

.split103:                                        ; preds = %125, %.loopexit
  %127 = landingpad { ptr, i32 }
          cleanup
  br label %143

128:                                              ; preds = %125, %122
  %indvar.next111 = add nuw nsw i64 %indvar110, 1
  %exitcond.not = icmp eq i64 %indvar.next111, %wide.trip.count120
  br i1 %exitcond.not, label %._crit_edge, label %.split, !llvm.loop !30

129:                                              ; preds = %._crit_edge
  %130 = load ptr, ptr %13, align 8, !tbaa !5
  invoke void @_ZN4Jtag9toggleClkEi(ptr noundef nonnull align 8 dereferenceable(193) %130, i32 noundef 6008)
          to label %133 unwind label %131

131:                                              ; preds = %129
  %132 = landingpad { ptr, i32 }
          cleanup
  br label %143

133:                                              ; preds = %129, %._crit_edge
  invoke void @_ZN11ProgressBar7displayEic(ptr noundef nonnull align 8 dereferenceable(50) %8, i32 noundef %.074104, i8 noundef signext 0)
          to label %134 unwind label %137

134:                                              ; preds = %133
  %135 = shl nsw i32 %.070126, 2
  %136 = add nsw i32 %135, %.074104
  %indvar.next = add nuw nsw i64 %indvar, 1
  %exitcond124.not = icmp eq i64 %indvar.next, %wide.trip.count123
  br i1 %exitcond124.not, label %._crit_edge108, label %58, !llvm.loop !32

137:                                              ; preds = %133
  %138 = landingpad { ptr, i32 }
          cleanup
  br label %143

139:                                              ; preds = %._crit_edge108
  invoke void @_ZN11ProgressBar4doneEv(ptr noundef nonnull align 8 dereferenceable(50) %8)
          to label %140 unwind label %141

140:                                              ; preds = %139
  call void @_ZdaPv(ptr noundef nonnull %.086) #11
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %8) #9
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  ret i1 true

141:                                              ; preds = %139, %._crit_edge108
  %142 = landingpad { ptr, i32 }
          cleanup
  br label %143

143:                                              ; preds = %.split103, %.split103.us, %68, %137, %131, %141
  %.pn92.pn.pn = phi { ptr, i32 } [ %142, %141 ], [ %69, %68 ], [ %138, %137 ], [ %132, %131 ], [ %127, %.split103 ], [ %112, %.split103.us ]
  call void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50) %8) #9
  br label %144

144:                                              ; preds = %143, %57
  %.pn92.pn.pn.pn = phi { ptr, i32 } [ %.pn92.pn.pn, %143 ], [ %.pn, %57 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #9
  resume { ptr, i32 } %.pn92.pn.pn.pn
}

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

declare void @_ZN4Jtag19go_test_logic_resetEv(ptr noundef nonnull align 8 dereferenceable(193)) local_unnamed_addr #4

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #6

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 #4

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #7

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN11ProgressBarD2Ev(ptr noundef nonnull align 8 dereferenceable(50)) unnamed_addr #8 align 2

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nobuiltin nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin allocsize(0) }
attributes #11 = { builtin nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 8}
!6 = !{!"_ZTS6Device", !7, i64 8, !10, i64 16, !10, i64 48, !13, i64 80, !14, i64 84, !14, i64 85, !14, i64 86}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !12, i64 8, !8, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !7, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_ZTSN6Device9prog_modeE", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!6, !14, i64 86}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !14, i64 172}
!20 = !{!"_ZTS5Gowin", !6, i64 0, !21, i64 88, !23, i64 144, !23, i64 152, !23, i64 160, !22, i64 168, !14, i64 172, !14, i64 173, !14, i64 174, !14, i64 175, !14, i64 176, !14, i64 177, !14, i64 178, !8, i64 179, !8, i64 180, !8, i64 181, !8, i64 182, !8, i64 183, !29, i64 184, !29, i64 188}
!21 = !{!"_ZTS12SPIInterface", !8, i64 8, !22, i64 12, !14, i64 16, !14, i64 17, !14, i64 18, !10, i64 24}
!22 = !{!"int", !8, i64 0}
!23 = !{!"_ZTSSt10unique_ptrI21ConfigBitstreamParserSt14default_deleteIS0_EE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_dataI21ConfigBitstreamParserSt14default_deleteIS0_ELb1ELb1EE", !25, i64 0}
!25 = !{!"_ZTSSt15__uniq_ptr_implI21ConfigBitstreamParserSt14default_deleteIS0_EE", !26, i64 0}
!26 = !{!"_ZTSSt5tupleIJP21ConfigBitstreamParserSt14default_deleteIS0_EEE", !27, i64 0}
!27 = !{!"_ZTSSt11_Tuple_implILm0EJP21ConfigBitstreamParserSt14default_deleteIS0_EEE", !28, i64 0}
!28 = !{!"_ZTSSt10_Head_baseILm0EP21ConfigBitstreamParserLb0EE", !7, i64 0}
!29 = !{!"_ZTSN13JtagInterface10tck_edge_tE", !8, i64 0}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = distinct !{!32, !31}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass