; LLVM IR from trabucayre/openFPGALoader :: src/xvc_client.ll (ZN10XVC_client8writeTDIEPKhPhjb)

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

@_ZTISt13runtime_error = external constant ptr
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

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

declare void @__cxa_free_exception(ptr)

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

declare void @__cxa_throw(ptr, ptr, ptr)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10XVC_client8writeTDIEPKhPhjb(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i1 noundef zeroext %4) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i16, align 2
  %18 = alloca i16, align 2
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  %21 = zext i1 %4 to i8
  store i8 %21, ptr %11, align 1, !tbaa !11
  %22 = load ptr, ptr %7, align 8
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %5
  store i32 0, ptr %6, align 4
  br label %147

26:                                               ; preds = %5
  %27 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 5
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %26
  %31 = load ptr, ptr %22, align 8, !tbaa !19
  %32 = getelementptr inbounds ptr, ptr %31, i64 14
  %33 = load ptr, ptr %32, align 8
  %34 = call noundef i32 %33(ptr noundef nonnull align 8 dereferenceable(128) %22)
  br label %35

35:                                               ; preds = %30, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %36 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 8
  %37 = load i32, ptr %36, align 4, !tbaa !21
  %38 = mul i32 %37, 8
  store i32 %38, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #6
  %39 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 6
  %40 = load i32, ptr %39, align 4, !tbaa !22
  %41 = icmp ne i32 %40, 0
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 255, i32 0
  %44 = trunc i32 %43 to i8
  store i8 %44, ptr %13, align 1, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %45, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %46, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %141, %35
  %48 = load i32, ptr %16, align 4, !tbaa !9
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = icmp ult i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %145

52:                                               ; preds = %47
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = load i32, ptr %16, align 4, !tbaa !9
  %55 = add i32 %53, %54
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = icmp ugt i32 %55, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %52
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = load i32, ptr %16, align 4, !tbaa !9
  %61 = sub i32 %59, %60
  store i32 %61, ptr %12, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %58, %52
  call void @llvm.lifetime.start.p0(i64 2, ptr %17) #6
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = add i32 %63, 7
  %65 = lshr i32 %64, 3
  %66 = trunc i32 %65 to i16
  store i16 %66, ptr %17, align 2, !tbaa !24
  %67 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !26
  %69 = load i8, ptr %13, align 1, !tbaa !23
  %70 = zext i8 %69 to i32
  %71 = trunc i32 %70 to i8
  %72 = load i16, ptr %17, align 2, !tbaa !24
  %73 = zext i16 %72 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %68, i8 %71, i64 %73, i1 false)
  %74 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !27
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load i16, ptr %17, align 2, !tbaa !24
  %78 = zext i16 %77 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %75, ptr align 1 %76, i64 %78, i1 false)
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 5
  store i32 %79, ptr %80, align 8, !tbaa !13
  %81 = load i8, ptr %11, align 1, !tbaa !11, !range !28, !noundef !29
  %82 = trunc i8 %81 to i1
  br i1 %82, label %83, label %110

83:                                               ; preds = %62
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = load i32, ptr %16, align 4, !tbaa !9
  %86 = add i32 %84, %85
  %87 = load i32, ptr %10, align 4, !tbaa !9
  %88 = icmp eq i32 %86, %87
  br i1 %88, label %89, label %110

89:                                               ; preds = %83
  %90 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 6
  store i32 1, ptr %90, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 2, ptr %18) #6
  %91 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 5
  %92 = load i32, ptr %91, align 8, !tbaa !13
  %93 = sub i32 %92, 1
  %94 = trunc i32 %93 to i16
  store i16 %94, ptr %18, align 2, !tbaa !24
  %95 = load i16, ptr %18, align 2, !tbaa !24
  %96 = zext i16 %95 to i32
  %97 = and i32 %96, 7
  %98 = shl i32 1, %97
  %99 = getelementptr inbounds %class.XVC_client, ptr %22, i32 0, i32 3
  %100 = load ptr, ptr %99, align 8, !tbaa !26
  %101 = load i16, ptr %18, align 2, !tbaa !24
  %102 = zext i16 %101 to i32
  %103 = ashr i32 %102, 3
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds i8, ptr %100, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !23
  %107 = zext i8 %106 to i32
  %108 = or i32 %107, %98
  %109 = trunc i32 %108 to i8
  store i8 %109, ptr %105, align 1, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 2, ptr %18) #6
  br label %110

110:                                              ; preds = %89, %83, %62
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  %112 = icmp ne ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %110
  %114 = load ptr, ptr %15, align 8, !tbaa !5
  br label %116

115:                                              ; preds = %110
  br label %116

116:                                              ; preds = %115, %113
  %117 = phi ptr [ %114, %113 ], [ null, %115 ]
  %118 = call noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128) %22, ptr noundef %117)
  br i1 %118, label %126, label %119

119:                                              ; preds = %116
  %120 = call ptr @__cxa_allocate_exception(i64 16) #6
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %120, ptr noundef @.str.7)
          to label %121 unwind label %122

121:                                              ; preds = %119
  call void @__cxa_throw(ptr %120, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #7
  unreachable

122:                                              ; preds = %119
  %123 = landingpad { ptr, i32 }
          cleanup
  %124 = extractvalue { ptr, i32 } %123, 0
  store ptr %124, ptr %19, align 8
  %125 = extractvalue { ptr, i32 } %123, 1
  store i32 %125, ptr %20, align 4
  call void @__cxa_free_exception(ptr %120) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %149

126:                                              ; preds = %116
  %127 = load i16, ptr %17, align 2, !tbaa !24
  %128 = zext i16 %127 to i32
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = sext i32 %128 to i64
  %131 = getelementptr inbounds i8, ptr %129, i64 %130
  store ptr %131, ptr %14, align 8, !tbaa !5
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = icmp ne ptr %132, null
  br i1 %133, label %134, label %140

134:                                              ; preds = %126
  %135 = load i16, ptr %17, align 2, !tbaa !24
  %136 = zext i16 %135 to i32
  %137 = load ptr, ptr %15, align 8, !tbaa !5
  %138 = sext i32 %136 to i64
  %139 = getelementptr inbounds i8, ptr %137, i64 %138
  store ptr %139, ptr %15, align 8, !tbaa !5
  br label %140

140:                                              ; preds = %134, %126
  call void @llvm.lifetime.end.p0(i64 2, ptr %17) #6
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %12, align 4, !tbaa !9
  %143 = load i32, ptr %16, align 4, !tbaa !9
  %144 = add i32 %143, %142
  store i32 %144, ptr %16, align 4, !tbaa !9
  br label %47, !llvm.loop !30

145:                                              ; preds = %51
  %146 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %146, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %147

147:                                              ; preds = %145, %25
  %148 = load i32, ptr %6, align 4
  ret i32 %148

149:                                              ; preds = %122
  %150 = load ptr, ptr %19, align 8
  %151 = load i32, ptr %20, align 4
  %152 = insertvalue { ptr, i32 } poison, ptr %150, 0
  %153 = insertvalue { ptr, i32 } %152, i32 %151, 1
  resume { ptr, i32 } %153
}

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

; 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

attributes #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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"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, !10, i64 40}
!14 = !{!"_ZTS10XVC_client", !15, i64 0, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !16, i64 56, !16, i64 88, !10, i64 120, !10, i64 124}
!15 = !{!"_ZTS13JtagInterface", !10, i64 8}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"vtable pointer", !8, i64 0}
!21 = !{!14, !10, i64 52}
!22 = !{!14, !10, i64 44}
!23 = !{!7, !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"short", !7, i64 0}
!26 = !{!14, !6, i64 24}
!27 = !{!14, !6, i64 32}
!28 = !{i8 0, i8 2}
!29 = !{}
!30 = distinct !{!30, !31}
!31 = !{!"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"

@_ZTISt13runtime_error = external constant ptr
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10XVC_client8writeTDIEPKhPhjb(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr nocapture noundef readonly %1, ptr noundef %2, i32 noundef returned %3, i1 noundef zeroext %4) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = icmp eq i32 %3, 0
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %15, label %10

10:                                               ; preds = %7
  %11 = load ptr, ptr %0, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %11, i64 112
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef i32 %13(ptr noundef nonnull align 8 dereferenceable(128) %0)
  br label %15

15:                                               ; preds = %10, %7
  %16 = getelementptr inbounds i8, ptr %0, i64 52
  %17 = load i32, ptr %16, align 4, !tbaa !18
  %18 = shl i32 %17, 3
  %19 = getelementptr inbounds i8, ptr %0, i64 44
  %20 = load i32, ptr %19, align 4, !tbaa !19
  %.not41 = icmp ne i32 %20, 0
  %21 = sext i1 %.not41 to i8
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %.not42 = icmp eq ptr %2, null
  br i1 %4, label %.split, label %.split.us

.split.us:                                        ; preds = %15
  br i1 %.not42, label %.split.us.split.us, label %.split.us.split

.split.us.split.us:                               ; preds = %.split.us, %33
  %.03548.us.us = phi i32 [ %spec.select.us.us, %33 ], [ %18, %.split.us ]
  %.03647.us.us = phi ptr [ %35, %33 ], [ %1, %.split.us ]
  %.03945.us.us = phi i32 [ %34, %33 ], [ 0, %.split.us ]
  %24 = add i32 %.03548.us.us, %.03945.us.us
  %25 = icmp ugt i32 %24, %3
  %26 = sub i32 %3, %.03945.us.us
  %spec.select.us.us = select i1 %25, i32 %26, i32 %.03548.us.us
  %27 = add i32 %spec.select.us.us, 7
  %28 = lshr i32 %27, 3
  %29 = load ptr, ptr %22, align 8, !tbaa !20
  %.mask.us.us = and i32 %28, 65535
  %30 = zext nneg i32 %.mask.us.us to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %29, i8 %21, i64 %30, i1 false)
  %31 = load ptr, ptr %23, align 8, !tbaa !21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %.03647.us.us, i64 %30, i1 false)
  store i32 %spec.select.us.us, ptr %8, align 8, !tbaa !5
  %32 = tail call noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef null)
  br i1 %32, label %33, label %.split50.us

33:                                               ; preds = %.split.us.split.us
  %34 = add i32 %spec.select.us.us, %.03945.us.us
  %35 = getelementptr inbounds i8, ptr %.03647.us.us, i64 %30
  %36 = icmp ult i32 %34, %3
  br i1 %36, label %.split.us.split.us, label %.loopexit, !llvm.loop !22

.split.us.split:                                  ; preds = %.split.us, %46
  %.03548.us = phi i32 [ %spec.select.us, %46 ], [ %18, %.split.us ]
  %.03647.us = phi ptr [ %48, %46 ], [ %1, %.split.us ]
  %.03746.us = phi ptr [ %spec.select44.us, %46 ], [ %2, %.split.us ]
  %.03945.us = phi i32 [ %47, %46 ], [ 0, %.split.us ]
  %37 = add i32 %.03548.us, %.03945.us
  %38 = icmp ugt i32 %37, %3
  %39 = sub i32 %3, %.03945.us
  %spec.select.us = select i1 %38, i32 %39, i32 %.03548.us
  %40 = add i32 %spec.select.us, 7
  %41 = lshr i32 %40, 3
  %42 = load ptr, ptr %22, align 8, !tbaa !20
  %.mask.us = and i32 %41, 65535
  %43 = zext nneg i32 %.mask.us to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %42, i8 %21, i64 %43, i1 false)
  %44 = load ptr, ptr %23, align 8, !tbaa !21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %44, ptr align 1 %.03647.us, i64 %43, i1 false)
  store i32 %spec.select.us, ptr %8, align 8, !tbaa !5
  %45 = tail call noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %.03746.us)
  br i1 %45, label %46, label %.split50.us

46:                                               ; preds = %.split.us.split
  %47 = add i32 %spec.select.us, %.03945.us
  %48 = getelementptr inbounds i8, ptr %.03647.us, i64 %43
  %spec.select44.us = getelementptr inbounds i8, ptr %.03746.us, i64 %43
  %49 = icmp ult i32 %47, %3
  br i1 %49, label %.split.us.split, label %.loopexit, !llvm.loop !22

.split:                                           ; preds = %15
  br i1 %.not42, label %.split.split.us, label %.split.split

.split.split.us:                                  ; preds = %.split, %74
  %.03548.us51 = phi i32 [ %spec.select.us55, %74 ], [ %18, %.split ]
  %.03647.us52 = phi ptr [ %75, %74 ], [ %1, %.split ]
  %.03945.us54 = phi i32 [ %58, %74 ], [ 0, %.split ]
  %50 = add i32 %.03548.us51, %.03945.us54
  %51 = icmp ugt i32 %50, %3
  %52 = sub i32 %3, %.03945.us54
  %spec.select.us55 = select i1 %51, i32 %52, i32 %.03548.us51
  %53 = add i32 %spec.select.us55, 7
  %54 = lshr i32 %53, 3
  %55 = load ptr, ptr %22, align 8, !tbaa !20
  %.mask.us56 = and i32 %54, 65535
  %56 = zext nneg i32 %.mask.us56 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %55, i8 %21, i64 %56, i1 false)
  %57 = load ptr, ptr %23, align 8, !tbaa !21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %57, ptr align 1 %.03647.us52, i64 %56, i1 false)
  store i32 %spec.select.us55, ptr %8, align 8, !tbaa !5
  %58 = add i32 %spec.select.us55, %.03945.us54
  %59 = icmp eq i32 %58, %3
  br i1 %59, label %60, label %72

60:                                               ; preds = %.split.split.us
  store i32 1, ptr %19, align 4, !tbaa !19
  %61 = add i32 %spec.select.us55, 65535
  %62 = and i32 %61, 7
  %63 = shl nuw nsw i32 1, %62
  %64 = load ptr, ptr %22, align 8, !tbaa !20
  %65 = lshr i32 %61, 3
  %66 = and i32 %65, 8191
  %67 = zext nneg i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %64, i64 %67
  %69 = load i8, ptr %68, align 1, !tbaa !24
  %70 = trunc nuw i32 %63 to i8
  %71 = or i8 %69, %70
  store i8 %71, ptr %68, align 1, !tbaa !24
  br label %72

72:                                               ; preds = %60, %.split.split.us
  %73 = tail call noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef null)
  br i1 %73, label %74, label %.split50.us

74:                                               ; preds = %72
  %75 = getelementptr inbounds i8, ptr %.03647.us52, i64 %56
  %76 = icmp ult i32 %58, %3
  br i1 %76, label %.split.split.us, label %.loopexit, !llvm.loop !22

.split.split:                                     ; preds = %.split, %105
  %.03548 = phi i32 [ %spec.select, %105 ], [ %18, %.split ]
  %.03647 = phi ptr [ %106, %105 ], [ %1, %.split ]
  %.03746 = phi ptr [ %spec.select44, %105 ], [ %2, %.split ]
  %.03945 = phi i32 [ %85, %105 ], [ 0, %.split ]
  %77 = add i32 %.03548, %.03945
  %78 = icmp ugt i32 %77, %3
  %79 = sub i32 %3, %.03945
  %spec.select = select i1 %78, i32 %79, i32 %.03548
  %80 = add i32 %spec.select, 7
  %81 = lshr i32 %80, 3
  %82 = load ptr, ptr %22, align 8, !tbaa !20
  %.mask = and i32 %81, 65535
  %83 = zext nneg i32 %.mask to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %82, i8 %21, i64 %83, i1 false)
  %84 = load ptr, ptr %23, align 8, !tbaa !21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %84, ptr align 1 %.03647, i64 %83, i1 false)
  store i32 %spec.select, ptr %8, align 8, !tbaa !5
  %85 = add i32 %spec.select, %.03945
  %86 = icmp eq i32 %85, %3
  br i1 %86, label %87, label %99

87:                                               ; preds = %.split.split
  store i32 1, ptr %19, align 4, !tbaa !19
  %88 = add i32 %spec.select, 65535
  %89 = and i32 %88, 7
  %90 = shl nuw nsw i32 1, %89
  %91 = load ptr, ptr %22, align 8, !tbaa !20
  %92 = lshr i32 %88, 3
  %93 = and i32 %92, 8191
  %94 = zext nneg i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %91, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !24
  %97 = trunc nuw i32 %90 to i8
  %98 = or i8 %96, %97
  store i8 %98, ptr %95, align 1, !tbaa !24
  br label %99

99:                                               ; preds = %87, %.split.split
  %100 = tail call noundef zeroext i1 @_ZN10XVC_client8ll_writeEPh(ptr noundef nonnull align 8 dereferenceable(128) %0, ptr noundef %.03746)
  br i1 %100, label %105, label %.split50.us

.split50.us:                                      ; preds = %.split.us.split, %.split.us.split.us, %99, %72
  %101 = tail call ptr @__cxa_allocate_exception(i64 16) #5
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %101, ptr noundef nonnull @.str.7)
          to label %102 unwind label %103

102:                                              ; preds = %.split50.us
  tail call void @__cxa_throw(ptr nonnull %101, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #6
  unreachable

103:                                              ; preds = %.split50.us
  %104 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %101) #5
  resume { ptr, i32 } %104

105:                                              ; preds = %99
  %106 = getelementptr inbounds i8, ptr %.03647, i64 %83
  %spec.select44 = getelementptr inbounds i8, ptr %.03746, i64 %83
  %107 = icmp ult i32 %85, %3
  br i1 %107, label %.split.split, label %.loopexit, !llvm.loop !22

.loopexit:                                        ; preds = %46, %33, %105, %74, %5
  ret i32 %3
}

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #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 #1 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !8, i64 40}
!6 = !{!"_ZTS10XVC_client", !7, i64 0, !11, i64 12, !12, i64 16, !12, i64 24, !12, i64 32, !8, i64 40, !8, i64 44, !8, i64 48, !8, i64 52, !13, i64 56, !13, i64 88, !8, i64 120, !8, i64 124}
!7 = !{!"_ZTS13JtagInterface", !8, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !15, i64 8, !9, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!15 = !{!"long", !9, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !10, i64 0}
!18 = !{!6, !8, i64 52}
!19 = !{!6, !8, i64 44}
!20 = !{!6, !12, i64 24}
!21 = !{!6, !12, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!9, !9, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass