; 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_expand = external hidden unnamed_addr constant [25 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_expand(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #2

; 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 @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_hpke_labeled_expand(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 %15, align 8, !tbaa !9
  %37 = add i64 2, %36
  %38 = load i64, ptr %17, align 8, !tbaa !9
  %39 = add i64 %37, %38
  %40 = load i64, ptr %25, align 8, !tbaa !9
  %41 = add i64 %39, %40
  %42 = load i64, ptr %26, align 8, !tbaa !9
  %43 = add i64 %41, %42
  %44 = load i64, ptr %20, align 8, !tbaa !9
  %45 = add i64 %43, %44
  %46 = load i64, ptr %27, align 8, !tbaa !9
  %47 = add i64 %45, %46
  %48 = load i64, ptr %23, align 8, !tbaa !9
  %49 = add i64 %47, %48
  store i64 %49, ptr %28, align 8, !tbaa !9
  %50 = load i64, ptr %28, align 8, !tbaa !9
  %51 = call ptr @CRYPTO_malloc(i64 noundef %50, ptr noundef @.str, i32 noundef 366)
  store ptr %51, ptr %29, align 8, !tbaa !5
  %52 = load ptr, ptr %29, align 8, !tbaa !5
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

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

55:                                               ; preds = %11
  %56 = load ptr, ptr %29, align 8, !tbaa !5
  %57 = load i64, ptr %28, align 8, !tbaa !9
  %58 = call i32 @WPACKET_init_static_len(ptr noundef %30, ptr noundef %56, i64 noundef %57, i64 noundef 0)
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %94

60:                                               ; preds = %55
  %61 = load i64, ptr %15, align 8, !tbaa !9
  %62 = call i32 @WPACKET_put_bytes__(ptr noundef %30, i64 noundef %61, i64 noundef 2)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %94

64:                                               ; preds = %60
  %65 = load i64, ptr %25, align 8, !tbaa !9
  %66 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef @LABEL_HPKEV1, i64 noundef %65)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %94

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

73:                                               ; preds = %68
  %74 = load ptr, ptr %19, align 8, !tbaa !5
  %75 = load i64, ptr %20, align 8, !tbaa !9
  %76 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %74, i64 noundef %75)
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %94

78:                                               ; preds = %73
  %79 = load ptr, ptr %21, align 8, !tbaa !5
  %80 = load i64, ptr %27, align 8, !tbaa !9
  %81 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %79, i64 noundef %80)
  %82 = icmp ne i32 %81, 0
  br i1 %82, label %83, label %94

83:                                               ; preds = %78
  %84 = load ptr, ptr %22, align 8, !tbaa !5
  %85 = load i64, ptr %23, align 8, !tbaa !9
  %86 = call i32 @WPACKET_memcpy(ptr noundef %30, ptr noundef %84, i64 noundef %85)
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %94

88:                                               ; preds = %83
  %89 = call i32 @WPACKET_get_total_written(ptr noundef %30, ptr noundef %28)
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %88
  %92 = call i32 @WPACKET_finish(ptr noundef %30)
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %95, label %94

94:                                               ; preds = %91, %88, %83, %78, %73, %68, %64, %60, %55
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 380, ptr noundef @__func__.ossl_hpke_labeled_expand)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 106, ptr noundef null)
  br label %104

95:                                               ; preds = %91
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = load i64, ptr %15, align 8, !tbaa !9
  %99 = load ptr, ptr %16, align 8, !tbaa !5
  %100 = load i64, ptr %17, align 8, !tbaa !9
  %101 = load ptr, ptr %29, align 8, !tbaa !5
  %102 = load i64, ptr %28, align 8, !tbaa !9
  %103 = call i32 @ossl_hpke_kdf_expand(ptr noundef %96, ptr noundef %97, i64 noundef %98, ptr noundef %99, i64 noundef %100, ptr noundef %101, i64 noundef %102)
  store i32 %103, ptr %24, align 4, !tbaa !11
  br label %104

104:                                              ; preds = %95, %94
  call void @WPACKET_cleanup(ptr noundef %30)
  %105 = load ptr, ptr %29, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %105, ptr noundef @.str, i32 noundef 388)
  %106 = load i32, ptr %24, align 4, !tbaa !11
  store i32 %106, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %107

107:                                              ; preds = %104, %54
  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
  %108 = load i32, ptr %12, align 4
  ret i32 %108
}

declare i32 @WPACKET_put_bytes__(ptr noundef, i64 noundef, i64 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_expand = external hidden unnamed_addr constant [25 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_expand(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; 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 @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_hpke_labeled_expand(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 %2, 9
  %17 = add i64 %16, %4
  %18 = add i64 %17, %7
  %19 = add i64 %18, %10
  %20 = add i64 %19, %14
  %21 = add i64 %20, %15
  store i64 %21, ptr %12, align 8, !tbaa !5
  %22 = tail call ptr @CRYPTO_malloc(i64 noundef %21, ptr noundef nonnull @.str, i32 noundef 366) #4
  %23 = icmp eq ptr %22, null
  br i1 %23, label %47, label %24

24:                                               ; preds = %11
  %25 = call i32 @WPACKET_init_static_len(ptr noundef nonnull %13, ptr noundef nonnull %22, i64 noundef %21, i64 noundef 0) #4
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %42, label %26

26:                                               ; preds = %24
  %27 = call i32 @WPACKET_put_bytes__(ptr noundef nonnull %13, i64 noundef %2, i64 noundef 2) #4
  %.not31 = icmp eq i32 %27, 0
  br i1 %.not31, label %42, label %28

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

30:                                               ; preds = %28
  %31 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %5, i64 noundef %14) #4
  %.not33 = icmp eq i32 %31, 0
  br i1 %.not33, label %42, label %32

32:                                               ; preds = %30
  %33 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %6, i64 noundef %7) #4
  %.not34 = icmp eq i32 %33, 0
  br i1 %.not34, label %42, label %34

34:                                               ; preds = %32
  %35 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %8, i64 noundef %15) #4
  %.not35 = icmp eq i32 %35, 0
  br i1 %.not35, label %42, label %36

36:                                               ; preds = %34
  %37 = call i32 @WPACKET_memcpy(ptr noundef nonnull %13, ptr noundef %9, i64 noundef %10) #4
  %.not36 = icmp eq i32 %37, 0
  br i1 %.not36, label %42, label %38

38:                                               ; preds = %36
  %39 = call i32 @WPACKET_get_total_written(ptr noundef nonnull %13, ptr noundef nonnull %12) #4
  %.not37 = icmp eq i32 %39, 0
  br i1 %.not37, label %42, label %40

40:                                               ; preds = %38
  %41 = call i32 @WPACKET_finish(ptr noundef nonnull %13) #4
  %.not38 = icmp eq i32 %41, 0
  br i1 %.not38, label %42, label %43

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

43:                                               ; preds = %40
  %44 = load i64, ptr %12, align 8, !tbaa !5
  %45 = call i32 @ossl_hpke_kdf_expand(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef nonnull %22, i64 noundef %44)
  br label %46

46:                                               ; preds = %43, %42
  %.0 = phi i32 [ %45, %43 ], [ 0, %42 ]
  call void @WPACKET_cleanup(ptr noundef nonnull %13) #4
  call void @CRYPTO_free(ptr noundef nonnull %22, ptr noundef nonnull @.str, i32 noundef 388) #4
  br label %47

47:                                               ; preds = %11, %46
  %.029 = phi i32 [ %.0, %46 ], [ 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 %.029
}

declare i32 @WPACKET_put_bytes__(ptr noundef, i64 noundef, i64 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