; LLVM IR from cryspen/libcrux :: sys/hacl/c/src (Hacl_Hash_Blake2s)

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

@Hacl_Hash_Blake2s_ivTable_S = external hidden constant [8 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @Hacl_Hash_Blake2s_init(ptr noundef %0, i32 noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %21, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds i32, ptr %22, i64 4
  store ptr %23, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds i32, ptr %24, i64 8
  store ptr %25, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds i32, ptr %26, i64 12
  store ptr %27, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %28 = load i32, ptr @Hacl_Hash_Blake2s_ivTable_S, align 16, !tbaa !9
  store i32 %28, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %29 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 1), align 4, !tbaa !9
  store i32 %29, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %30 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 2), align 8, !tbaa !9
  store i32 %30, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %31 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 3), align 4, !tbaa !9
  store i32 %31, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  %32 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 4), align 16, !tbaa !9
  store i32 %32, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #2
  %33 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 5), align 4, !tbaa !9
  store i32 %33, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #2
  %34 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 6), align 8, !tbaa !9
  store i32 %34, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %35 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @Hacl_Hash_Blake2s_ivTable_S, i64 0, i64 7), align 4, !tbaa !9
  store i32 %35, ptr %18, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds i32, ptr %37, i64 0
  store i32 %36, ptr %38, align 4, !tbaa !9
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds i32, ptr %40, i64 1
  store i32 %39, ptr %41, align 4, !tbaa !9
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds i32, ptr %43, i64 2
  store i32 %42, ptr %44, align 4, !tbaa !9
  %45 = load i32, ptr %14, align 4, !tbaa !9
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 3
  store i32 %45, ptr %47, align 4, !tbaa !9
  %48 = load i32, ptr %15, align 4, !tbaa !9
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds i32, ptr %49, i64 0
  store i32 %48, ptr %50, align 4, !tbaa !9
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  %53 = getelementptr inbounds i32, ptr %52, i64 1
  store i32 %51, ptr %53, align 4, !tbaa !9
  %54 = load i32, ptr %17, align 4, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = getelementptr inbounds i32, ptr %55, i64 2
  store i32 %54, ptr %56, align 4, !tbaa !9
  %57 = load i32, ptr %18, align 4, !tbaa !9
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds i32, ptr %58, i64 3
  store i32 %57, ptr %59, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #2
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = shl i32 %60, 8
  store i32 %61, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #2
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = load i32, ptr %19, align 4, !tbaa !9
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = xor i32 %63, %64
  %66 = xor i32 16842752, %65
  %67 = xor i32 %62, %66
  store i32 %67, ptr %20, align 4, !tbaa !9
  %68 = load i32, ptr %20, align 4, !tbaa !9
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds i32, ptr %69, i64 0
  store i32 %68, ptr %70, align 4, !tbaa !9
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds i32, ptr %72, i64 1
  store i32 %71, ptr %73, align 4, !tbaa !9
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds i32, ptr %75, i64 2
  store i32 %74, ptr %76, align 4, !tbaa !9
  %77 = load i32, ptr %14, align 4, !tbaa !9
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = getelementptr inbounds i32, ptr %78, i64 3
  store i32 %77, ptr %79, align 4, !tbaa !9
  %80 = load i32, ptr %15, align 4, !tbaa !9
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds i32, ptr %81, i64 0
  store i32 %80, ptr %82, align 4, !tbaa !9
  %83 = load i32, ptr %16, align 4, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds i32, ptr %84, i64 1
  store i32 %83, ptr %85, align 4, !tbaa !9
  %86 = load i32, ptr %17, align 4, !tbaa !9
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds i32, ptr %87, i64 2
  store i32 %86, ptr %88, align 4, !tbaa !9
  %89 = load i32, ptr %18, align 4, !tbaa !9
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = getelementptr inbounds i32, ptr %90, i64 3
  store i32 %89, ptr %91, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@Hacl_Hash_Blake2s_ivTable_S = external hidden local_unnamed_addr constant [8 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @Hacl_Hash_Blake2s_init(ptr nocapture noundef writeonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr @Hacl_Hash_Blake2s_ivTable_S, align 16, !tbaa !5
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @Hacl_Hash_Blake2s_ivTable_S, i64 28), align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = getelementptr inbounds i8, ptr %0, i64 44
  %8 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @Hacl_Hash_Blake2s_ivTable_S, i64 12), align 4, !tbaa !5
  store <4 x i32> %8, ptr %7, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %5, ptr %9, align 4, !tbaa !5
  %10 = shl i32 %1, 8
  %11 = xor i32 %10, %2
  %12 = xor i32 %11, %4
  %13 = xor i32 %12, 16842752
  store i32 %13, ptr %0, align 4, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load <2 x i32>, ptr getelementptr inbounds (i8, ptr @Hacl_Hash_Blake2s_ivTable_S, i64 4), align 4, !tbaa !5
  %16 = extractelement <2 x i32> %15, i64 1
  store i32 %16, ptr %6, align 4, !tbaa !5
  store <2 x i32> %15, ptr %14, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 12
  %18 = shufflevector <4 x i32> %8, <4 x i32> poison, <2 x i32> <i32 0, i32 1>
  store <2 x i32> %18, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 20
  %20 = extractelement <4 x i32> %8, i64 2
  store i32 %20, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  %22 = shufflevector <4 x i32> %8, <4 x i32> poison, <4 x i32> <i32 3, i32 poison, i32 poison, i32 poison>
  %23 = insertelement <4 x i32> %22, i32 %5, i64 1
  %24 = insertelement <4 x i32> %23, i32 %4, i64 2
  %25 = shufflevector <2 x i32> %15, <2 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>
  %26 = shufflevector <4 x i32> %24, <4 x i32> %25, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
  store <4 x i32> %26, ptr %21, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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" }

!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/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass