; LLVM IR from openssl/openssl :: providers/implementations/digests (blake2b_prov)

; 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.blake2b_ctx_st = type { [8 x i64], [2 x i64], [2 x i64], [128 x i8], i64, i64 }

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@__PRETTY_FUNCTION__.ossl_blake2b_update = external hidden unnamed_addr constant [61 x i8], align 1

; 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: nounwind uwtable
define dso_local i32 @ossl_blake2b_update(ptr noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %11, i32 0, i32 4
  %13 = load i64, ptr %12, align 8, !tbaa !11
  %14 = sub i64 128, %13
  store i64 %14, ptr %8, align 8, !tbaa !9
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = load i64, ptr %8, align 8, !tbaa !9
  %17 = icmp ugt i64 %15, %16
  br i1 %17, label %18, label %69

18:                                               ; preds = %3
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %19, i32 0, i32 4
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = icmp ne i64 %21, 0
  br i1 %22, label %23, label %45

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %24, i32 0, i32 3
  %26 = getelementptr inbounds [128 x i8], ptr %25, i64 0, i64 0
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %27, i32 0, i32 4
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %26, i64 %29
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %30, ptr align 1 %31, i64 %32, i1 false)
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %34, i32 0, i32 3
  %36 = getelementptr inbounds [128 x i8], ptr %35, i64 0, i64 0
  call void @blake2b_compress(ptr noundef %33, ptr noundef %36, i64 noundef 128)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %37, i32 0, i32 4
  store i64 0, ptr %38, align 8, !tbaa !11
  %39 = load i64, ptr %8, align 8, !tbaa !9
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 %39
  store ptr %41, ptr %7, align 8, !tbaa !5
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = load i64, ptr %6, align 8, !tbaa !9
  %44 = sub i64 %43, %42
  store i64 %44, ptr %6, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %23, %18
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = icmp ugt i64 %46, 128
  br i1 %47, label %48, label %68

48:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %49 = load i64, ptr %6, align 8, !tbaa !9
  %50 = urem i64 %49, 128
  store i64 %50, ptr %9, align 8, !tbaa !9
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %55

53:                                               ; preds = %48
  %54 = load i64, ptr %9, align 8, !tbaa !9
  br label %56

55:                                               ; preds = %48
  br label %56

56:                                               ; preds = %55, %53
  %57 = phi i64 [ %54, %53 ], [ 128, %55 ]
  store i64 %57, ptr %9, align 8, !tbaa !9
  %58 = load i64, ptr %9, align 8, !tbaa !9
  %59 = load i64, ptr %6, align 8, !tbaa !9
  %60 = sub i64 %59, %58
  store i64 %60, ptr %6, align 8, !tbaa !9
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i64, ptr %6, align 8, !tbaa !9
  call void @blake2b_compress(ptr noundef %61, ptr noundef %62, i64 noundef %63)
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 %64
  store ptr %66, ptr %7, align 8, !tbaa !5
  %67 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %67, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %68

68:                                               ; preds = %56, %45
  br label %69

69:                                               ; preds = %68, %3
  %70 = load i64, ptr %6, align 8, !tbaa !9
  %71 = icmp ule i64 %70, 128
  br i1 %71, label %72, label %73

72:                                               ; preds = %69
  br label %74

73:                                               ; preds = %69
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 295, ptr noundef @__PRETTY_FUNCTION__.ossl_blake2b_update) #5
  unreachable

74:                                               ; preds = %72
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %75, i32 0, i32 3
  %77 = getelementptr inbounds [128 x i8], ptr %76, i64 0, i64 0
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %78, i32 0, i32 4
  %80 = load i64, ptr %79, align 8, !tbaa !11
  %81 = getelementptr inbounds i8, ptr %77, i64 %80
  %82 = load ptr, ptr %7, align 8, !tbaa !5
  %83 = load i64, ptr %6, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %81, ptr align 1 %82, i64 %83, i1 false)
  %84 = load i64, ptr %6, align 8, !tbaa !9
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.blake2b_ctx_st, ptr %85, i32 0, i32 4
  %87 = load i64, ptr %86, align 8, !tbaa !11
  %88 = add i64 %87, %84
  store i64 %88, ptr %86, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 1
}

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

; Function Attrs: nounwind uwtable
declare hidden void @blake2b_compress(ptr noundef, ptr noundef, i64 noundef) #2

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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}
!11 = !{!12, !10, i64 224}
!12 = !{!"blake2b_ctx_st", !7, i64 0, !7, i64 64, !7, i64 80, !7, i64 96, !10, i64 224, !10, i64 232}


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

@.str = external hidden unnamed_addr constant [30 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [98 x i8], align 1
@__PRETTY_FUNCTION__.ossl_blake2b_update = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @ossl_blake2b_update(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 224
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = sub i64 128, %5
  %7 = icmp ult i64 %6, %2
  br i1 %7, label %8, label %21

8:                                                ; preds = %3
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %14, label %9

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = getelementptr inbounds i8, ptr %10, i64 %5
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %11, ptr align 1 %1, i64 %6, i1 false)
  tail call void @blake2b_compress(ptr noundef nonnull %0, ptr noundef nonnull %10, i64 noundef 128)
  store i64 0, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 %6
  %13 = sub i64 %2, %6
  br label %14

14:                                               ; preds = %9, %8
  %.034 = phi ptr [ %12, %9 ], [ %1, %8 ]
  %.0 = phi i64 [ %13, %9 ], [ %2, %8 ]
  %15 = icmp ugt i64 %.0, 128
  br i1 %15, label %16, label %.thread

16:                                               ; preds = %14
  %17 = and i64 %.0, 127
  %.not40 = icmp eq i64 %17, 0
  %18 = select i1 %.not40, i64 128, i64 %17
  %19 = sub nuw i64 %.0, %18
  tail call void @blake2b_compress(ptr noundef nonnull %0, ptr noundef %.034, i64 noundef %19)
  %20 = getelementptr inbounds i8, ptr %.034, i64 %19
  %.pre = load i64, ptr %4, align 8, !tbaa !5
  br label %.thread

21:                                               ; preds = %3
  %22 = icmp ult i64 %2, 129
  br i1 %22, label %.thread, label %23

23:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 295, ptr noundef nonnull @__PRETTY_FUNCTION__.ossl_blake2b_update) #3
  unreachable

.thread:                                          ; preds = %14, %16, %21
  %24 = phi i64 [ %5, %21 ], [ 0, %14 ], [ %.pre, %16 ]
  %.144 = phi i64 [ %2, %21 ], [ %.0, %14 ], [ %18, %16 ]
  %.13543 = phi ptr [ %1, %21 ], [ %.034, %14 ], [ %20, %16 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 96
  %26 = getelementptr inbounds i8, ptr %25, i64 %24
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %26, ptr align 1 %.13543, i64 %.144, i1 false)
  %27 = load i64, ptr %4, align 8, !tbaa !5
  %28 = add i64 %27, %.144
  store i64 %28, ptr %4, align 8, !tbaa !5
  ret i32 1
}

; Function Attrs: nounwind uwtable
declare hidden void @blake2b_compress(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree 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 = { 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 = { noreturn 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, !9, i64 224}
!6 = !{!"blake2b_ctx_st", !7, i64 0, !7, i64 64, !7, i64 80, !7, i64 96, !9, i64 224, !9, i64 232}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"long", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass