; LLVM IR from rweather/lightweight-crypto :: src/genavr/code.ll (ZNK3Reg7shuffleEhhhhhhhh)

; 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.Reg = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTIPSt16invalid_argument = external dso_local constant { ptr, ptr, i32, ptr }, align 8
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1

declare ptr @__cxa_allocate_exception(i64)

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

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

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

; 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 void @_ZNK3Reg7shuffleEPKh(ptr dead_on_unwind noalias writable sret(%class.Reg) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #3 align 2

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Reg7shuffleEhhhhhhhh(ptr dead_on_unwind noalias writable sret(%class.Reg) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i8 noundef zeroext %6, i8 noundef zeroext %7, i8 noundef zeroext %8, i8 noundef zeroext %9) #3 align 2 personality ptr @__gxx_personality_v0 {
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  %18 = alloca i8, align 1
  %19 = alloca i8, align 1
  %20 = alloca i8, align 1
  %21 = alloca [8 x i8], align 1
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  store ptr %0, ptr %11, align 8
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i8 %2, ptr %13, align 1, !tbaa !9
  store i8 %3, ptr %14, align 1, !tbaa !9
  store i8 %4, ptr %15, align 1, !tbaa !9
  store i8 %5, ptr %16, align 1, !tbaa !9
  store i8 %6, ptr %17, align 1, !tbaa !9
  store i8 %7, ptr %18, align 1, !tbaa !9
  store i8 %8, ptr %19, align 1, !tbaa !9
  store i8 %9, ptr %20, align 1, !tbaa !9
  %24 = load ptr, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %25 = load i8, ptr %13, align 1, !tbaa !9
  store i8 %25, ptr %21, align 1, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %21, i64 1
  %27 = load i8, ptr %14, align 1, !tbaa !9
  store i8 %27, ptr %26, align 1, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %21, i64 2
  %29 = load i8, ptr %15, align 1, !tbaa !9
  store i8 %29, ptr %28, align 1, !tbaa !9
  %30 = getelementptr inbounds i8, ptr %21, i64 3
  %31 = load i8, ptr %16, align 1, !tbaa !9
  store i8 %31, ptr %30, align 1, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %21, i64 4
  %33 = load i8, ptr %17, align 1, !tbaa !9
  store i8 %33, ptr %32, align 1, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %21, i64 5
  %35 = load i8, ptr %18, align 1, !tbaa !9
  store i8 %35, ptr %34, align 1, !tbaa !9
  %36 = getelementptr inbounds i8, ptr %21, i64 6
  %37 = load i8, ptr %19, align 1, !tbaa !9
  store i8 %37, ptr %36, align 1, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %21, i64 7
  %39 = load i8, ptr %20, align 1, !tbaa !9
  store i8 %39, ptr %38, align 1, !tbaa !9
  %40 = call noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24)
  %41 = icmp ne i32 %40, 8
  br i1 %41, label %42, label %56

42:                                               ; preds = %10
  %43 = call ptr @__cxa_allocate_exception(i64 8) #6
  %44 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 16) #7
          to label %45 unwind label %47

45:                                               ; preds = %42
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef @.str.8)
          to label %46 unwind label %51

46:                                               ; preds = %45
  store ptr %44, ptr %43, align 16, !tbaa !5
  call void @__cxa_throw(ptr %43, ptr @_ZTIPSt16invalid_argument, ptr null) #8
  unreachable

47:                                               ; preds = %42
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %22, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %23, align 4
  br label %55

51:                                               ; preds = %45
  %52 = landingpad { ptr, i32 }
          cleanup
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %22, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %23, align 4
  call void @_ZdlPvm(ptr noundef %44, i64 noundef 16) #9
  br label %55

55:                                               ; preds = %51, %47
  call void @__cxa_free_exception(ptr %43) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  br label %58

56:                                               ; preds = %10
  %57 = getelementptr inbounds [8 x i8], ptr %21, i64 0, i64 0
  call void @_ZNK3Reg7shuffleEPKh(ptr dead_on_unwind writable sret(%class.Reg) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef %57)
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  ret void

58:                                               ; preds = %55
  %59 = load ptr, ptr %22, align 8
  %60 = load i32, ptr %23, align 4
  %61 = insertvalue { ptr, i32 } poison, ptr %59, 0
  %62 = insertvalue { ptr, i32 } %61, i32 %60, 1
  resume { ptr, i32 } %62
}

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 = { 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 = { 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { noreturn }
attributes #9 = { 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 = !{!7, !7, i64 0}


; 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.Reg = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTIPSt16invalid_argument = external dso_local constant { ptr, ptr, i32, ptr }, align 8
@.str.8 = external hidden unnamed_addr constant [22 x i8], align 1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

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

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

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

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

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

; Function Attrs: mustprogress 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 void @_ZNK3Reg7shuffleEPKh(ptr dead_on_unwind noalias writable sret(%class.Reg) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Reg7shuffleEhhhhhhhh(ptr dead_on_unwind noalias writable sret(%class.Reg) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i8 noundef zeroext %6, i8 noundef zeroext %7, i8 noundef zeroext %8, i8 noundef zeroext %9) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %11 = alloca [8 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #6
  store i8 %2, ptr %11, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 1
  store i8 %3, ptr %12, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %11, i64 2
  store i8 %4, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %11, i64 3
  store i8 %5, ptr %14, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %11, i64 4
  store i8 %6, ptr %15, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %11, i64 5
  store i8 %7, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %11, i64 6
  store i8 %8, ptr %17, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %11, i64 7
  store i8 %9, ptr %18, align 1, !tbaa !5
  %19 = tail call noundef i32 @_ZNK3Reg4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1)
  %.not = icmp eq i32 %19, 8
  br i1 %.not, label %30, label %20

20:                                               ; preds = %10
  %21 = tail call ptr @__cxa_allocate_exception(i64 8) #6
  %22 = invoke noalias noundef nonnull dereferenceable(16) ptr @_Znwm(i64 noundef 16) #7
          to label %23 unwind label %25

23:                                               ; preds = %20
  invoke void @_ZNSt16invalid_argumentC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull @.str.8)
          to label %24 unwind label %27

24:                                               ; preds = %23
  store ptr %22, ptr %21, align 16, !tbaa !8
  tail call void @__cxa_throw(ptr nonnull %21, ptr nonnull @_ZTIPSt16invalid_argument, ptr null) #8
  unreachable

25:                                               ; preds = %20
  %26 = landingpad { ptr, i32 }
          cleanup
  br label %29

27:                                               ; preds = %23
  %28 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %22, i64 noundef 16) #9
  br label %29

29:                                               ; preds = %27, %25
  %.pn = phi { ptr, i32 } [ %28, %27 ], [ %26, %25 ]
  tail call void @__cxa_free_exception(ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #6
  resume { ptr, i32 } %.pn

30:                                               ; preds = %10
  call void @_ZNK3Reg7shuffleEPKh(ptr dead_on_unwind writable sret(%class.Reg) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #6
  ret void
}

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 = { 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 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { noreturn }
attributes #9 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass