; LLVM IR from Try/Tempest :: Engine/libspirv/libspirv.ll (ZN8libspirv15MutableBytecode8Iterator8setToNopEv)

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

%"struct.libspirv::Bytecode::Iterator" = type <{ ptr, i32, [4 x i8] }>
%"struct.libspirv::MutableBytecode::Iterator" = type { %"struct.libspirv::Bytecode::Iterator.base", ptr }
%"struct.libspirv::Bytecode::Iterator.base" = type <{ ptr, i32 }>
%"class.libspirv::Bytecode" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libspirv::MutableBytecode" = type { %"class.libspirv::Bytecode.base", %"class.std::vector" }
%"class.libspirv::Bytecode.base" = type <{ ptr, i64, i32 }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<libspirv::Bytecode::OpCode, std::allocator<libspirv::Bytecode::OpCode>>::_Vector_impl" }
%"struct.std::_Vector_base<libspirv::Bytecode::OpCode, std::allocator<libspirv::Bytecode::OpCode>>::_Vector_impl" = type { %"struct.std::_Vector_base<libspirv::Bytecode::OpCode, std::allocator<libspirv::Bytecode::OpCode>>::_Vector_impl_data" }
%"struct.std::_Vector_base<libspirv::Bytecode::OpCode, std::allocator<libspirv::Bytecode::OpCode>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.libspirv::Bytecode::OpCode" = type { i16, i16 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._ZN8libspirv15MutableBytecode8Iterator8setToNopEv = external hidden unnamed_addr constant [53 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIPKN8libspirv8Bytecode6OpCodeEENSt15iterator_traitsIT_E15difference_typeES6_S6_(ptr noundef, ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8libspirv15MutableBytecode8Iterator8setToNopEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i16, align 2
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds %"struct.libspirv::Bytecode::Iterator", ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = getelementptr inbounds %"struct.libspirv::MutableBytecode::Iterator", ptr %7, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds %"class.libspirv::Bytecode", ptr %11, i32 0, i32 2
  %13 = load i32, ptr %12, align 8, !tbaa !14
  %14 = icmp eq i32 %9, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  br label %18

16:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 607, ptr noundef @__PRETTY_FUNCTION__._ZN8libspirv15MutableBytecode8Iterator8setToNopEv) #5
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %19 = getelementptr inbounds %"struct.libspirv::MutableBytecode::Iterator", ptr %7, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = getelementptr inbounds %"class.libspirv::MutableBytecode", ptr %20, i32 0, i32 1
  %22 = call noundef ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %21) #6
  %23 = getelementptr inbounds %"struct.libspirv::Bytecode::Iterator", ptr %7, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = call noundef i64 @_ZSt8distanceIPKN8libspirv8Bytecode6OpCodeEENSt15iterator_traitsIT_E15difference_typeES6_S6_(ptr noundef %22, ptr noundef %24)
  store i64 %25, ptr %3, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #6
  %26 = getelementptr inbounds %"struct.libspirv::Bytecode::Iterator", ptr %7, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %27, i32 0, i32 1
  %29 = load i16, ptr %28, align 2, !tbaa !19
  store i16 %29, ptr %4, align 2, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %30 = getelementptr inbounds %"struct.libspirv::MutableBytecode::Iterator", ptr %7, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  %32 = getelementptr inbounds %"class.libspirv::MutableBytecode", ptr %31, i32 0, i32 1
  %33 = load i64, ptr %3, align 8, !tbaa !18
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %33) #6
  store ptr %34, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #6
  store i16 0, ptr %6, align 2, !tbaa !22
  br label %35

35:                                               ; preds = %53, %18
  %36 = load i16, ptr %6, align 2, !tbaa !22
  %37 = zext i16 %36 to i32
  %38 = load i16, ptr %4, align 2, !tbaa !22
  %39 = zext i16 %38 to i32
  %40 = icmp slt i32 %37, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #6
  br label %56

42:                                               ; preds = %35
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i16, ptr %6, align 2, !tbaa !22
  %45 = zext i16 %44 to i64
  %46 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %43, i64 %45
  %47 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %46, i32 0, i32 0
  store i16 0, ptr %47, align 4, !tbaa !23
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load i16, ptr %6, align 2, !tbaa !22
  %50 = zext i16 %49 to i64
  %51 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %48, i64 %50
  %52 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %51, i32 0, i32 1
  store i16 1, ptr %52, align 2, !tbaa !19
  br label %53

53:                                               ; preds = %42
  %54 = load i16, ptr %6, align 2, !tbaa !22
  %55 = add i16 %54, 1
  store i16 %55, ptr %6, align 2, !tbaa !22
  br label %35, !llvm.loop !24

56:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { noreturn 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 #3 = { 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 #4 = { 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 #5 = { noreturn nounwind }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN8libspirv8Bytecode8IteratorE", !6, i64 0, !11, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"_ZTSN8libspirv15MutableBytecode8IteratorE", !10, i64 0, !6, i64 16}
!14 = !{!15, !11, i64 16}
!15 = !{!"_ZTSN8libspirv8BytecodeE", !6, i64 0, !16, i64 8, !11, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!10, !6, i64 0}
!18 = !{!16, !16, i64 0}
!19 = !{!20, !21, i64 2}
!20 = !{!"_ZTSN8libspirv8Bytecode6OpCodeE", !21, i64 0, !21, i64 2}
!21 = !{!"short", !7, i64 0}
!22 = !{!21, !21, i64 0}
!23 = !{!20, !21, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%"struct.libspirv::Bytecode::OpCode" = type { i16, i16 }

@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._ZN8libspirv15MutableBytecode8Iterator8setToNopEv = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIPKN8libspirv8Bytecode6OpCodeEENSt15iterator_traitsIT_E15difference_typeES6_S6_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8libspirv15MutableBytecode8Iterator8setToNopEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(24) %0) local_unnamed_addr #3 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load i32, ptr %6, align 8, !tbaa !13
  %8 = icmp eq i32 %3, %7
  br i1 %8, label %10, label %9

9:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 607, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8libspirv15MutableBytecode8Iterator8setToNopEv) #4
  unreachable

10:                                               ; preds = %1
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  %12 = tail call noundef ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #5
  %13 = load ptr, ptr %0, align 8, !tbaa !16
  %14 = tail call noundef i64 @_ZSt8distanceIPKN8libspirv8Bytecode6OpCodeEENSt15iterator_traitsIT_E15difference_typeES6_S6_(ptr noundef %12, ptr noundef %13)
  %15 = load ptr, ptr %0, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %15, i64 2
  %17 = load i16, ptr %16, align 2, !tbaa !17
  %18 = load ptr, ptr %4, align 8, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIN8libspirv8Bytecode6OpCodeESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %14) #5
  %.not = icmp eq i16 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %10
  %wide.trip.count = zext i16 %17 to i64
  %min.iters.check = icmp ult i16 %17, 8
  br i1 %min.iters.check, label %.lr.ph.preheader10, label %vector.ph

.lr.ph.preheader10:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 65528
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %21 = or disjoint i64 %index, 4
  %22 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %20, i64 %index
  %23 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %20, i64 %21
  store <8 x i16> <i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1>, ptr %22, align 4, !tbaa !20
  store <8 x i16> <i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1>, ptr %23, align 4, !tbaa !20
  %index.next = add nuw i64 %index, 8
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader10

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %10
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader10, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader10 ]
  %25 = getelementptr inbounds %"struct.libspirv::Bytecode::OpCode", ptr %20, i64 %indvars.iv
  store i16 0, ptr %25, align 4, !tbaa !25
  %26 = getelementptr inbounds i8, ptr %25, i64 2
  store i16 1, ptr %26, align 2, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !26
}

attributes #0 = { inlinehint 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 #1 = { noreturn 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 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 #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 = { noreturn nounwind }
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, !10, i64 8}
!6 = !{!"_ZTSN8libspirv8Bytecode8IteratorE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"_ZTSN8libspirv15MutableBytecode8IteratorE", !6, i64 0, !7, i64 16}
!13 = !{!14, !10, i64 16}
!14 = !{!"_ZTSN8libspirv8BytecodeE", !7, i64 0, !15, i64 8, !10, i64 16}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!18, !19, i64 2}
!18 = !{!"_ZTSN8libspirv8Bytecode6OpCodeE", !19, i64 0, !19, i64 2}
!19 = !{!"short", !8, i64 0}
!20 = !{!19, !19, i64 0}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = !{!18, !19, i64 0}
!26 = distinct !{!26, !22, !24, !23}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass