; LLVM IR from openssl/openssl :: crypto (params)

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

@.str = external hidden unnamed_addr constant [65 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @OSSL_PARAM_locate_const(ptr noundef, ptr noundef) #0

; 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

declare void @CRYPTO_clear_free(ptr noundef, i64 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_param_get1_concat_octet_string(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4) #0 {
  %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 i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i64 %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = call ptr @OSSL_PARAM_locate_const(ptr noundef %16, ptr noundef %17)
  store ptr %18, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !9
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

22:                                               ; preds = %5
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call i32 @setbuf_fromparams(ptr noundef %23, ptr noundef %24, ptr noundef null, ptr noundef %14)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

28:                                               ; preds = %22
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %30 = icmp ugt i64 %29, 0
  br i1 %30, label %31, label %36

31:                                               ; preds = %28
  %32 = load i64, ptr %14, align 8, !tbaa !9
  %33 = load i64, ptr %11, align 8, !tbaa !9
  %34 = icmp ugt i64 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

36:                                               ; preds = %31, %28
  %37 = load i64, ptr %14, align 8, !tbaa !9
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = call ptr @CRYPTO_zalloc(i64 noundef 1, ptr noundef @.str, i32 noundef 1637)
  store ptr %40, ptr %13, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %39
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

43:                                               ; preds = %39
  br label %60

44:                                               ; preds = %36
  %45 = load i64, ptr %14, align 8, !tbaa !9
  %46 = call ptr @CRYPTO_malloc(i64 noundef %45, ptr noundef @.str, i32 noundef 1643)
  store ptr %46, ptr %13, align 8, !tbaa !5
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %49, label %50

49:                                               ; preds = %44
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

50:                                               ; preds = %44
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = call i32 @setbuf_fromparams(ptr noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %14)
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %59, label %56

56:                                               ; preds = %50
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load i64, ptr %14, align 8, !tbaa !9
  call void @CRYPTO_clear_free(ptr noundef %57, i64 noundef %58, ptr noundef @.str, i32 noundef 1649)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

59:                                               ; preds = %50
  br label %60

60:                                               ; preds = %59, %43
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load i64, ptr %63, align 8, !tbaa !9
  call void @CRYPTO_clear_free(ptr noundef %62, i64 noundef %64, ptr noundef @.str, i32 noundef 1654)
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %65, ptr %66, align 8, !tbaa !5
  %67 = load i64, ptr %14, align 8, !tbaa !9
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %67, ptr %68, align 8, !tbaa !9
  store i32 1, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %69

69:                                               ; preds = %60, %56, %49, %42, %35, %27, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %70 = load i32, ptr %6, align 4
  ret i32 %70
}

; Function Attrs: nounwind uwtable
declare hidden i32 @setbuf_fromparams(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #0

declare ptr @CRYPTO_zalloc(i64 noundef, ptr noundef, i32 noundef) #2

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

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 = { "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 }

!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}


; 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 [65 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @OSSL_PARAM_locate_const(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

declare void @CRYPTO_clear_free(ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @ossl_param_get1_concat_octet_string(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3, i64 noundef %4) local_unnamed_addr #0 {
  %6 = alloca i64, align 8
  %7 = tail call ptr @OSSL_PARAM_locate_const(ptr noundef %0, ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store i64 0, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %30, label %9

9:                                                ; preds = %5
  %10 = call i32 @setbuf_fromparams(ptr noundef nonnull %7, ptr noundef %1, ptr noundef null, ptr noundef nonnull %6)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %30, label %11

11:                                               ; preds = %9
  %.not23 = icmp ne i64 %4, 0
  %12 = load i64, ptr %6, align 8
  %13 = icmp ugt i64 %12, %4
  %or.cond = select i1 %.not23, i1 %13, i1 false
  br i1 %or.cond, label %30, label %14

14:                                               ; preds = %11
  %15 = icmp eq i64 %12, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %14
  %17 = call ptr @CRYPTO_zalloc(i64 noundef 1, ptr noundef nonnull @.str, i32 noundef 1637) #3
  %18 = icmp eq ptr %17, null
  br i1 %18, label %30, label %26

19:                                               ; preds = %14
  %20 = call ptr @CRYPTO_malloc(i64 noundef %12, ptr noundef nonnull @.str, i32 noundef 1643) #3
  %21 = icmp eq ptr %20, null
  br i1 %21, label %30, label %22

22:                                               ; preds = %19
  %23 = call i32 @setbuf_fromparams(ptr noundef nonnull %7, ptr noundef %1, ptr noundef nonnull %20, ptr noundef nonnull %6)
  %.not24 = icmp eq i32 %23, 0
  br i1 %.not24, label %24, label %26

24:                                               ; preds = %22
  %25 = load i64, ptr %6, align 8, !tbaa !5
  call void @CRYPTO_clear_free(ptr noundef nonnull %20, i64 noundef %25, ptr noundef nonnull @.str, i32 noundef 1649) #3
  br label %30

26:                                               ; preds = %22, %16
  %.0 = phi ptr [ %17, %16 ], [ %20, %22 ]
  %27 = load ptr, ptr %2, align 8, !tbaa !9
  %28 = load i64, ptr %3, align 8, !tbaa !5
  call void @CRYPTO_clear_free(ptr noundef %27, i64 noundef %28, ptr noundef nonnull @.str, i32 noundef 1654) #3
  store ptr %.0, ptr %2, align 8, !tbaa !9
  %29 = load i64, ptr %6, align 8, !tbaa !5
  store i64 %29, ptr %3, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %19, %16, %11, %9, %5, %26, %24
  %.017 = phi i32 [ 1, %26 ], [ 0, %24 ], [ -1, %5 ], [ 0, %9 ], [ 0, %11 ], [ 0, %16 ], [ 0, %19 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret i32 %.017
}

; Function Attrs: nounwind uwtable
declare hidden i32 @setbuf_fromparams(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @CRYPTO_zalloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

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

!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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


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