; LLVM IR from openssl/openssl :: crypto/hpke (hpke_util)

; 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.wpacket_st = type { ptr, ptr, i64, i64, i64, ptr, i8 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@LABEL_HPKEV1 = external hidden constant [8 x i8], align 1
@__func__.ossl_hpke_labeled_extract = external hidden unnamed_addr constant [26 x i8], align 1

; 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

declare void @ERR_new() #1

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) #1

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_hpke_kdf_extract(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_hpke_labeled_extract(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9, i64 noundef %10) #2 {
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i64, align 8
  %26 = alloca i64, align 8
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  %29 = alloca ptr, align 8
  %30 = alloca %struct.wpacket_st, align 8
  %31 = alloca i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store ptr %1, ptr %14, align 8, !tbaa !5
  store i64 %2, ptr %15, align 8, !tbaa !9
  store ptr %3, ptr %16, align 8, !tbaa !5
  store i64 %4, ptr %17, align 8, !tbaa !9
  store ptr %5, ptr %18, align 8, !tbaa !5
  store ptr %6, ptr %19, align 8, !tbaa !5
  store i64 %7, ptr %20, align 8, !tbaa !9
  store ptr %8, ptr %21, align 8, !tbaa !5
  store ptr %9, ptr %22, align 8, !tbaa !5
  store i64 %10, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 0, ptr %24, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  store i64 0, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  store i64 0, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  store i64 0, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  store i64 0, ptr %28, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  store ptr null, ptr %29, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 56, ptr %30) #4
  store i64 7, ptr %25, align 8, !tbaa !9
  %32 = load ptr, ptr %18, align 8, !tbaa !5
  %33 = call i64 @strlen(ptr noundef %32) #5
  store i64 %33, ptr %26, align 8, !tbaa !9
  %34 = load ptr, ptr %21, align 8, !tbaa !5
  %35 = call i64 @strlen(ptr noundef %34) #5
  store i64 %35, ptr %27, align 8, !tbaa !9
  %36 = load i64, ptr %25, align 8, !tbaa !9
  %37 = load i64, ptr %26, align 8, !tbaa !9
  %38 = add i64 %36, %37
  %39 = load i64, ptr %20, align 8, !tbaa !9
  %40 = add i64 %38, %39
  %41 = load i64, ptr %27, align 8, !tbaa !9
  %42 = add i64 %40, %41
  %43 = load i64, ptr %23, align 8, !tbaa !9
  %44 = add i64 %42, %43
  store i64 %44, ptr %28, align 8, !tbaa !9
  %45 = load i64, ptr %28, align 8, !tbaa !9
  %46 = call ptr @CRYPTO_malloc(i64 noundef %45, ptr noundef @.str, i32 noundef 316)
  store ptr %46, ptr %29, align 8, !tbaa !5
  %47 = load ptr, ptr %29, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %49, label %50

49:                                               ; preds = %11
  store i32 0, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %100

50:                                               ; preds = %11
  %51 = load ptr, ptr %29, align 8, !tbaa !5
  %52 = load i64, ptr %28, align 8, !tbaa !9
  %53 = call i32 @WPACKET_init_static_len(ptr noundef %30, ptr noundef %51, i64 noundef %52, i64 noundef 0)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %85

55:                                               ; preds = %50
  %56 = load i64, ptr %25, align 8, !tbaa !9
  %57 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef @LABEL_HPKEV1, i64 noundef %56)
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %85

59:                                               ; preds = %55
  %60 = load ptr, ptr %18, align 8, !tbaa !5
  %61 = load i64, ptr %26, align 8, !tbaa !9
  %62 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %60, i64 noundef %61)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %85

64:                                               ; preds = %59
  %65 = load ptr, ptr %19, align 8, !tbaa !5
  %66 = load i64, ptr %20, align 8, !tbaa !9
  %67 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %65, i64 noundef %66)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %85

69:                                               ; preds = %64
  %70 = load ptr, ptr %21, align 8, !tbaa !5
  %71 = load i64, ptr %27, align 8, !tbaa !9
  %72 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %70, i64 noundef %71)
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %85

74:                                               ; preds = %69
  %75 = load ptr, ptr %22, align 8, !tbaa !5
  %76 = load i64, ptr %23, align 8, !tbaa !9
  %77 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %75, i64 noundef %76)
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %85

79:                                               ; preds = %74
  %80 = call i32 @WPACKET_get_total_written(ptr noundef %30, ptr noundef %28)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %85

82:                                               ; preds = %79
  %83 = call i32 @WPACKET_finish(ptr noundef %30)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %86, label %85

85:                                               ; preds = %82, %79, %74, %69, %64, %59, %55, %50
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 329, ptr noundef @__func__.ossl_hpke_labeled_extract)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 106, ptr noundef null)
  br label %95

86:                                               ; preds = %82
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  %89 = load i64, ptr %15, align 8, !tbaa !9
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  %91 = load i64, ptr %17, align 8, !tbaa !9
  %92 = load ptr, ptr %29, align 8, !tbaa !5
  %93 = load i64, ptr %28, align 8, !tbaa !9
  %94 = call i32 @ossl_hpke_kdf_extract(ptr noundef %87, ptr noundef %88, i64 noundef %89, ptr noundef %90, i64 noundef %91, ptr noundef %92, i64 noundef %93)
  store i32 %94, ptr %24, align 4, !tbaa !11
  br label %95

95:                                               ; preds = %86, %85
  call void @WPACKET_cleanup(ptr noundef %30)
  %96 = load ptr, ptr %29, align 8, !tbaa !5
  %97 = load i64, ptr %28, align 8, !tbaa !9
  call void @OPENSSL_cleanse(ptr noundef %96, i64 noundef %97)
  %98 = load ptr, ptr %29, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %98, ptr noundef @.str, i32 noundef 338)
  %99 = load i32, ptr %24, align 4, !tbaa !11
  store i32 %99, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %100

100:                                              ; preds = %95, %49
  call void @llvm.lifetime.end.p0(i64 56, ptr %30) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  %101 = load i32, ptr %12, align 4
  ret i32 %101
}

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #1

declare i32 @WPACKET_init_static_len(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #1

declare i32 @WPACKET_memcpy(ptr noundef, ptr noundef, i64 noundef) #1

declare i32 @WPACKET_get_total_written(ptr noundef, ptr noundef) #1

declare i32 @WPACKET_finish(ptr noundef) #1

declare void @WPACKET_cleanup(ptr noundef) #1

declare void @OPENSSL_cleanse(ptr noundef, i64 noundef) #1

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { nounwind willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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, !12, i64 0}
!12 = !{!"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"

%struct.wpacket_st = type { ptr, ptr, i64, i64, i64, ptr, i8 }

@.str = external hidden unnamed_addr constant [73 x i8], align 1
@LABEL_HPKEV1 = external hidden constant [8 x i8], align 1
@__func__.ossl_hpke_labeled_extract = external hidden unnamed_addr constant [26 x i8], align 1

; 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

declare void @ERR_new() local_unnamed_addr #1

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ossl_hpke_kdf_extract(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_hpke_labeled_extract(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, ptr noundef %9, i64 noundef %10) local_unnamed_addr #2 {
  %12 = alloca i64, align 8
  %13 = alloca %struct.wpacket_st, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #4
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %13) #4
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %5) #5
  %15 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %8) #5
  %16 = add i64 %7, 7
  %17 = add i64 %16, %10
  %18 = add i64 %17, %14
  %19 = add i64 %18, %15
  store i64 %19, ptr %12, align 8, !tbaa !5
  %20 = tail call ptr @CRYPTO_malloc(i64 noundef %19, ptr noundef nonnull @.str, i32 noundef 316) #4
  %21 = icmp eq ptr %20, null
  br i1 %21, label %44, label %22

22:                                               ; preds = %11
  %23 = call i32 @WPACKET_init_static_len(ptr noundef nonnull %13, ptr noundef nonnull %20, i64 noundef %19, i64 noundef 0) #4
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %38, label %24

24:                                               ; preds = %22
  %25 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef nonnull @LABEL_HPKEV1, i64 noundef 7) #4
  %.not29 = icmp eq i32 %25, 0
  br i1 %.not29, label %38, label %26

26:                                               ; preds = %24
  %27 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %5, i64 noundef %14) #4
  %.not30 = icmp eq i32 %27, 0
  br i1 %.not30, label %38, label %28

28:                                               ; preds = %26
  %29 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %6, i64 noundef %7) #4
  %.not31 = icmp eq i32 %29, 0
  br i1 %.not31, label %38, label %30

30:                                               ; preds = %28
  %31 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %8, i64 noundef %15) #4
  %.not32 = icmp eq i32 %31, 0
  br i1 %.not32, label %38, label %32

32:                                               ; preds = %30
  %33 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %9, i64 noundef %10) #4
  %.not33 = icmp eq i32 %33, 0
  br i1 %.not33, label %38, label %34

34:                                               ; preds = %32
  %35 = call i32 @WPACKET_get_total_written(ptr noundef nonnull %13, ptr noundef nonnull %12) #4
  %.not34 = icmp eq i32 %35, 0
  br i1 %.not34, label %38, label %36

36:                                               ; preds = %34
  %37 = call i32 @WPACKET_finish(ptr noundef nonnull %13) #4
  %.not35 = icmp eq i32 %37, 0
  br i1 %.not35, label %38, label %39

38:                                               ; preds = %36, %34, %32, %30, %28, %26, %24, %22
  call void @ERR_new() #4
  call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 329, ptr noundef nonnull @__func__.ossl_hpke_labeled_extract) #4
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 106, ptr noundef null) #4
  br label %42

39:                                               ; preds = %36
  %40 = load i64, ptr %12, align 8, !tbaa !5
  %41 = call i32 @ossl_hpke_kdf_extract(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef nonnull %20, i64 noundef %40)
  br label %42

42:                                               ; preds = %39, %38
  %.0 = phi i32 [ %41, %39 ], [ 0, %38 ]
  call void @WPACKET_cleanup(ptr noundef nonnull %13) #4
  %43 = load i64, ptr %12, align 8, !tbaa !5
  call void @OPENSSL_cleanse(ptr noundef nonnull %20, i64 noundef %43) #4
  call void @CRYPTO_free(ptr noundef nonnull %20, ptr noundef nonnull @.str, i32 noundef 338) #4
  br label %44

44:                                               ; preds = %11, %42
  %.027 = phi i32 [ %.0, %42 ], [ 0, %11 ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #4
  ret i32 %.027
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @WPACKET_init_static_len(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare i32 @WPACKET_memcpy(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @WPACKET_get_total_written(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @WPACKET_finish(ptr noundef) local_unnamed_addr #1

declare void @WPACKET_cleanup(ptr noundef) local_unnamed_addr #1

declare void @OPENSSL_cleanse(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass