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

; 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::MutableBytecode::Iterator" = type { %"struct.libspirv::Bytecode::Iterator.base", ptr }
%"struct.libspirv::Bytecode::Iterator.base" = type <{ ptr, i32 }>
%"class.std::basic_string_view" = type { i64, ptr }

; 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) #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN8libspirvneERKNS_8Bytecode8IteratorES3_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(12)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8libspirv8Bytecode6OpCode2opEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4), i16 noundef zeroext) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8libspirv8Bytecode8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(12)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8libspirv15MutableBytecode5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8libspirv15MutableBytecode16findOpEntryPointEN3spv14ExecutionModelESt17basic_string_viewIcSt11char_traitsIcEE(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1, i32 noundef %2, i64 %3, ptr %4) #3 align 2 {
  %6 = alloca %"class.std::basic_string_view", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.libspirv::MutableBytecode::Iterator", align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"class.std::basic_string_view", align 8
  %13 = alloca %"class.std::basic_string_view", align 8
  %14 = alloca %"class.std::basic_string_view", align 8
  %15 = getelementptr inbounds { i64, ptr }, ptr %6, i32 0, i32 0
  store i64 %3, ptr %15, align 8
  %16 = getelementptr inbounds { i64, ptr }, ptr %6, i32 0, i32 1
  store ptr %4, ptr %16, align 8
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  %17 = load ptr, ptr %7, align 8
  call void @_ZN8libspirv15MutableBytecode5beginEv(ptr dead_on_unwind writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %17)
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #4
  call void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(48) %17)
  br label %18

18:                                               ; preds = %50, %5
  %19 = call noundef zeroext i1 @_ZN8libspirvneERKNS_8Bytecode8IteratorES3_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(12) %9)
  br i1 %19, label %21, label %20

20:                                               ; preds = %18
  store i32 2, ptr %10, align 4
  br label %51

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  store ptr %22, ptr %11, align 8, !tbaa !5
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = call noundef i32 @_ZNK8libspirv8Bytecode6OpCode2opEv(ptr noundef nonnull align 4 dereferenceable(4) %23)
  %25 = icmp ne i32 %24, 15
  br i1 %25, label %32, label %26

26:                                               ; preds = %21
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4) %27, i16 noundef zeroext 1)
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = icmp ne i32 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %26, %21
  store i32 4, ptr %10, align 4
  br label %48

33:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4) %34, i16 noundef zeroext 3)
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef %35) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %12, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %14, ptr align 8 %6, i64 16, i1 false), !tbaa.struct !13
  %36 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 0
  %37 = load i64, ptr %36, align 8
  %38 = getelementptr inbounds { i64, ptr }, ptr %13, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8
  %40 = getelementptr inbounds { i64, ptr }, ptr %14, i32 0, i32 0
  %41 = load i64, ptr %40, align 8
  %42 = getelementptr inbounds { i64, ptr }, ptr %14, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8
  %44 = call noundef zeroext i1 @_ZStneIcSt11char_traitsIcEEbSt17basic_string_viewIT_T0_ES5_(i64 %37, ptr %39, i64 %41, ptr %43) #4
  br i1 %44, label %45, label %46

45:                                               ; preds = %33
  store i32 4, ptr %10, align 4
  br label %47

46:                                               ; preds = %33
  store i32 1, ptr %10, align 4
  br label %47

47:                                               ; preds = %46, %45
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #4
  br label %48

48:                                               ; preds = %47, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %49 = load i32, ptr %10, align 4
  switch i32 %49, label %51 [
    i32 4, label %50
  ]

50:                                               ; preds = %48
  call void @_ZN8libspirv8Bytecode8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  br label %18, !llvm.loop !16

51:                                               ; preds = %48, %20
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #4
  %52 = load i32, ptr %10, align 4
  switch i32 %52, label %55 [
    i32 2, label %53
    i32 1, label %54
  ]

53:                                               ; preds = %51
  call void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %17)
  br label %54

54:                                               ; preds = %53, %51
  ret void

55:                                               ; preds = %51
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIcSt11char_traitsIcEEbSt17basic_string_viewIT_T0_ES5_(i64, ptr, i64, ptr) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"_ZTSN3spv14ExecutionModelE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i64 0, i64 8, !14, i64 8, i64 8, !5}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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::MutableBytecode::Iterator" = type { %"struct.libspirv::Bytecode::Iterator.base", ptr }
%"struct.libspirv::Bytecode::Iterator.base" = type <{ ptr, i32 }>
%"class.std::basic_string_view" = type { i64, ptr }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN8libspirvneERKNS_8Bytecode8IteratorES3_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK8libspirv8Bytecode6OpCode2opEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4), i16 noundef zeroext) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8libspirv8Bytecode8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8libspirv15MutableBytecode5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8libspirv15MutableBytecode16findOpEntryPointEN3spv14ExecutionModelESt17basic_string_viewIcSt11char_traitsIcEE(ptr dead_on_unwind noalias writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1, i32 noundef %2, i64 %3, ptr %4) local_unnamed_addr #2 align 2 {
  %6 = alloca %"struct.libspirv::MutableBytecode::Iterator", align 8
  %7 = alloca %"class.std::basic_string_view", align 8
  tail call void @_ZN8libspirv15MutableBytecode5beginEv(ptr dead_on_unwind writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %6, ptr noundef nonnull align 8 dereferenceable(48) %1)
  %8 = call noundef zeroext i1 @_ZN8libspirvneERKNS_8Bytecode8IteratorES3_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(12) %6)
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %.sroa.22.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  br label %9

9:                                                ; preds = %.lr.ph, %select.unfold
  %10 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  %11 = call noundef i32 @_ZNK8libspirv8Bytecode6OpCode2opEv(ptr noundef nonnull align 4 dereferenceable(4) %10)
  %.not = icmp eq i32 %11, 15
  br i1 %.not, label %12, label %select.unfold

12:                                               ; preds = %9
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4) %10, i16 noundef zeroext 1)
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %.not10 = icmp eq i32 %14, %2
  br i1 %.not10, label %15, label %select.unfold

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #3
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK8libspirv8Bytecode6OpCodeixEt(ptr noundef nonnull align 4 dereferenceable(4) %10, i16 noundef zeroext 3)
  call void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef %16) #3
  %.sroa.01.0.copyload = load i64, ptr %7, align 8, !tbaa !9
  %.sroa.22.0.copyload = load ptr, ptr %.sroa.22.0..sroa_idx, align 8, !tbaa !11
  %17 = call noundef zeroext i1 @_ZStneIcSt11char_traitsIcEEbSt17basic_string_viewIT_T0_ES5_(i64 %.sroa.01.0.copyload, ptr %.sroa.22.0.copyload, i64 %3, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #3
  br i1 %17, label %select.unfold, label %19

select.unfold:                                    ; preds = %15, %12, %9
  call void @_ZN8libspirv8Bytecode8IteratorppEv(ptr noundef nonnull align 8 dereferenceable(12) %0)
  %18 = call noundef zeroext i1 @_ZN8libspirvneERKNS_8Bytecode8IteratorES3_(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef nonnull align 8 dereferenceable(12) %6)
  br i1 %18, label %9, label %._crit_edge, !llvm.loop !13

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  br label %20

._crit_edge:                                      ; preds = %select.unfold, %5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  call void @_ZN8libspirv15MutableBytecode3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.libspirv::MutableBytecode::Iterator") align 8 %0, ptr noundef nonnull align 8 dereferenceable(48) %1)
  br label %20

20:                                               ; preds = %19, %._crit_edge
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt17basic_string_viewIcSt11char_traitsIcEEC2EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneIcSt11char_traitsIcEEbSt17basic_string_viewIT_T0_ES5_(i64, ptr, i64, ptr) local_unnamed_addr #1

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass