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

%struct.Hacl_Hash_Blake2s_state_t_s = type { %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr, i64 }
%struct.Hacl_Hash_Blake2s_block_state_t_s = type { ptr, ptr }

; 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: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_update_multi(i32 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_update_last(i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_finish(i32 noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @Hacl_Hash_Blake2s_digest(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.Hacl_Hash_Blake2s_state_t_s, align 8
  %6 = alloca %struct.Hacl_Hash_Blake2s_block_state_t_s, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca [16 x i32], align 16
  %12 = alloca [16 x i32], align 16
  %13 = alloca %struct.Hacl_Hash_Blake2s_block_state_t_s, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i64, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %26, i64 32, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  %27 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_state_t_s, ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %27, i64 16, i1 false), !tbaa.struct !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %28 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_state_t_s, ptr %5, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  store ptr %29, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %30 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_state_t_s, ptr %5, i32 0, i32 2
  %31 = load i64, ptr %30, align 8, !tbaa !16
  store i64 %31, ptr %8, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %32 = load i64, ptr %8, align 8, !tbaa !10
  %33 = urem i64 %32, 64
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %39

35:                                               ; preds = %2
  %36 = load i64, ptr %8, align 8, !tbaa !10
  %37 = icmp ugt i64 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store i32 64, ptr %9, align 4, !tbaa !17
  br label %43

39:                                               ; preds = %35, %2
  %40 = load i64, ptr %8, align 8, !tbaa !10
  %41 = urem i64 %40, 64
  %42 = trunc i64 %41 to i32
  store i32 %42, ptr %9, align 4, !tbaa !17
  br label %43

43:                                               ; preds = %39, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %44, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %11) #4
  call void @llvm.memset.p0.i64(ptr align 16 %11, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 64, ptr %12) #4
  call void @llvm.memset.p0.i64(ptr align 16 %12, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %45 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 0
  %46 = getelementptr inbounds [16 x i32], ptr %11, i64 0, i64 0
  store ptr %46, ptr %45, align 8, !tbaa !19
  %47 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 1
  %48 = getelementptr inbounds [16 x i32], ptr %12, i64 0, i64 0
  store ptr %48, ptr %47, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %49 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %6, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  store ptr %50, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %51 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  store ptr %52, ptr %15, align 8, !tbaa !5
  %53 = load ptr, ptr %15, align 8, !tbaa !5
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %54, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %55 = load i64, ptr %8, align 8, !tbaa !10
  %56 = load i32, ptr %9, align 4, !tbaa !17
  %57 = zext i32 %56 to i64
  %58 = sub i64 %55, %57
  store i64 %58, ptr %16, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %59 = load i32, ptr %9, align 4, !tbaa !17
  %60 = urem i32 %59, 64
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %66

62:                                               ; preds = %43
  %63 = load i32, ptr %9, align 4, !tbaa !17
  %64 = icmp ugt i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  store i32 64, ptr %17, align 4, !tbaa !17
  br label %69

66:                                               ; preds = %62, %43
  %67 = load i32, ptr %9, align 4, !tbaa !17
  %68 = urem i32 %67, 64
  store i32 %68, ptr %17, align 4, !tbaa !17
  br label %69

69:                                               ; preds = %66, %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !17
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds i8, ptr %70, i64 %72
  %74 = load i32, ptr %17, align 4, !tbaa !17
  %75 = zext i32 %74 to i64
  %76 = sub i64 0, %75
  %77 = getelementptr inbounds i8, ptr %73, i64 %76
  store ptr %77, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %78, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %79 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 0
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  store ptr %80, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %81 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  store ptr %82, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  store i32 0, ptr %22, align 4, !tbaa !17
  %83 = load ptr, ptr %20, align 8, !tbaa !5
  %84 = load ptr, ptr %21, align 8, !tbaa !5
  %85 = load i64, ptr %16, align 8, !tbaa !10
  %86 = load ptr, ptr %19, align 8, !tbaa !5
  %87 = load i32, ptr %22, align 4, !tbaa !17
  call void @Hacl_Hash_Blake2s_update_multi(i32 noundef 0, ptr noundef %83, ptr noundef %84, i64 noundef %85, ptr noundef %86, i32 noundef %87)
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %88 = load i64, ptr %8, align 8, !tbaa !10
  %89 = load i32, ptr %9, align 4, !tbaa !17
  %90 = zext i32 %89 to i64
  %91 = sub i64 %88, %90
  store i64 %91, ptr %23, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %92 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !19
  store ptr %93, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %94 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 1
  %95 = load ptr, ptr %94, align 8, !tbaa !20
  store ptr %95, ptr %25, align 8, !tbaa !5
  %96 = load i32, ptr %9, align 4, !tbaa !17
  %97 = load ptr, ptr %24, align 8, !tbaa !5
  %98 = load ptr, ptr %25, align 8, !tbaa !5
  %99 = load i64, ptr %23, align 8, !tbaa !10
  %100 = load i32, ptr %9, align 4, !tbaa !17
  %101 = load ptr, ptr %18, align 8, !tbaa !5
  call void @Hacl_Hash_Blake2s_update_last(i32 noundef %96, ptr noundef %97, ptr noundef %98, i64 noundef %99, i32 noundef %100, ptr noundef %101)
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.Hacl_Hash_Blake2s_block_state_t_s, ptr %13, i32 0, i32 1
  %104 = load ptr, ptr %103, align 8, !tbaa !20
  call void @Hacl_Hash_Blake2s_finish(i32 noundef 32, ptr noundef %102, ptr noundef %104)
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{i64 0, i64 8, !5, i64 8, i64 8, !5}
!13 = !{!14, !6, i64 16}
!14 = !{!"Hacl_Hash_Blake2s_state_t_s", !15, i64 0, !6, i64 16, !11, i64 24}
!15 = !{!"Hacl_Hash_Blake2s_block_state_t_s", !6, i64 0, !6, i64 8}
!16 = !{!14, !11, i64 24}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!15, !6, i64 0}
!20 = !{!15, !6, i64 8}


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

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_update_multi(i32 noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_update_last(i32 noundef, ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Hash_Blake2s_finish(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @Hacl_Hash_Blake2s_digest(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [16 x i32], align 16
  %4 = alloca [16 x i32], align 16
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.4.0.copyload = load ptr, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !5
  %.sroa.536.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 16
  %.sroa.536.0.copyload = load ptr, ptr %.sroa.536.0..sroa_idx, align 8, !tbaa !5
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  %.sroa.6.0.copyload = load i64, ptr %.sroa.6.0..sroa_idx, align 8, !tbaa !9
  %5 = and i64 %.sroa.6.0.copyload, 63
  %6 = icmp eq i64 %5, 0
  %7 = icmp ne i64 %.sroa.6.0.copyload, 0
  %or.cond = and i1 %7, %6
  %8 = trunc nuw nsw i64 %5 to i32
  %.0 = select i1 %or.cond, i32 64, i32 %8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %3, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %4, ptr noundef nonnull align 4 dereferenceable(64) %.sroa.4.0.copyload, i64 64, i1 false)
  %9 = and i32 %.0, 63
  %10 = icmp eq i32 %9, 0
  %11 = icmp ne i32 %.0, 0
  %or.cond3 = and i1 %11, %10
  %12 = zext nneg i32 %9 to i64
  %.039 = select i1 %or.cond3, i64 64, i64 %12
  %13 = zext nneg i32 %.0 to i64
  %14 = sub i64 %.sroa.6.0.copyload, %13
  %15 = getelementptr inbounds i8, ptr %.sroa.536.0.copyload, i64 %13
  %16 = sub nsw i64 0, %.039
  %17 = getelementptr inbounds i8, ptr %15, i64 %16
  call void @Hacl_Hash_Blake2s_update_multi(i32 noundef 0, ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef %14, ptr noundef %.sroa.536.0.copyload, i32 noundef 0)
  call void @Hacl_Hash_Blake2s_update_last(i32 noundef %.0, ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef %14, i32 noundef %.0, ptr noundef %17)
  call void @Hacl_Hash_Blake2s_finish(i32 noundef 32, ptr noundef %1, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #4
  ret void
}

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass