; LLVM IR from open-quantum-safe/oqs-provider :: test (tlstest_helpers)

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

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

19:                                               ; preds = %6
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19, %6
  br label %93

23:                                               ; preds = %19
  %24 = load i32, ptr %13, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call ptr @DTLS_server_method()
  %29 = call ptr @SSL_CTX_new_ex(ptr noundef %27, ptr noundef null, ptr noundef %28)
  store ptr %29, ptr %14, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call ptr @DTLS_client_method()
  %32 = call ptr @SSL_CTX_new_ex(ptr noundef %30, ptr noundef null, ptr noundef %31)
  store ptr %32, ptr %15, align 8, !tbaa !5
  br label %40

33:                                               ; preds = %23
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = call ptr @TLS_server_method()
  %36 = call ptr @SSL_CTX_new_ex(ptr noundef %34, ptr noundef null, ptr noundef %35)
  store ptr %36, ptr %14, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call ptr @TLS_client_method()
  %39 = call ptr @SSL_CTX_new_ex(ptr noundef %37, ptr noundef null, ptr noundef %38)
  store ptr %39, ptr %15, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %33, %26
  %41 = load ptr, ptr %14, align 8, !tbaa !5
  %42 = icmp eq ptr %41, null
  br i1 %42, label %46, label %43

43:                                               ; preds = %40
  %44 = load ptr, ptr %15, align 8, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %43, %40
  br label %93

47:                                               ; preds = %43
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = call i64 @SSL_CTX_set_options(ptr noundef %48, i64 noundef 256)
  %50 = load i32, ptr %13, align 4, !tbaa !9
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %47
  br label %93

53:                                               ; preds = %47
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = call i64 @SSL_CTX_ctrl(ptr noundef %54, i32 noundef 123, i64 noundef 772, ptr noundef null)
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %57, label %69

57:                                               ; preds = %53
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = call i64 @SSL_CTX_ctrl(ptr noundef %58, i32 noundef 124, i64 noundef 772, ptr noundef null)
  %60 = icmp ne i64 %59, 0
  br i1 %60, label %61, label %69

61:                                               ; preds = %57
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  %63 = call i64 @SSL_CTX_ctrl(ptr noundef %62, i32 noundef 123, i64 noundef 772, ptr noundef null)
  %64 = icmp ne i64 %63, 0
  br i1 %64, label %65, label %69

65:                                               ; preds = %61
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = call i64 @SSL_CTX_ctrl(ptr noundef %66, i32 noundef 124, i64 noundef 772, ptr noundef null)
  %68 = icmp ne i64 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %65, %61, %57, %53
  br label %93

70:                                               ; preds = %65
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %14, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = call i32 @SSL_CTX_use_certificate_file(ptr noundef %72, ptr noundef %73, i32 noundef 1)
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %77, label %76

76:                                               ; preds = %71
  br label %93

77:                                               ; preds = %71
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = call i32 @SSL_CTX_use_PrivateKey_file(ptr noundef %78, ptr noundef %79, i32 noundef 1)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %83, label %82

82:                                               ; preds = %77
  br label %93

83:                                               ; preds = %77
  %84 = load ptr, ptr %14, align 8, !tbaa !5
  %85 = call i32 @SSL_CTX_check_private_key(ptr noundef %84)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %83
  br label %93

88:                                               ; preds = %83
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %89, ptr %90, align 8, !tbaa !5
  %91 = load ptr, ptr %15, align 8, !tbaa !5
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %91, ptr %92, align 8, !tbaa !5
  store i32 1, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %96

93:                                               ; preds = %87, %82, %76, %69, %52, %46, %22
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  call void @SSL_CTX_free(ptr noundef %94)
  %95 = load ptr, ptr %15, align 8, !tbaa !5
  call void @SSL_CTX_free(ptr noundef %95)
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %96

96:                                               ; preds = %93, %88
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %97 = load i32, ptr %7, align 4
  ret i32 %97
}

declare ptr @SSL_CTX_new_ex(ptr noundef, ptr noundef, ptr noundef) #2

declare ptr @DTLS_server_method() #2

declare ptr @DTLS_client_method() #2

declare ptr @TLS_server_method() #2

declare ptr @TLS_client_method() #2

declare i64 @SSL_CTX_set_options(ptr noundef, i64 noundef) #2

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

declare i32 @SSL_CTX_use_certificate_file(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @SSL_CTX_use_PrivateKey_file(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @SSL_CTX_check_private_key(ptr noundef) #2

declare void @SSL_CTX_free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @create_tls1_3_ctx_pair(ptr noundef %0, ptr noundef writeonly %1, ptr noundef writeonly %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = icmp eq ptr %1, null
  %8 = icmp eq ptr %2, null
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %39, label %9

9:                                                ; preds = %6
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %14, label %10

10:                                               ; preds = %9
  %11 = tail call ptr @DTLS_server_method() #2
  %12 = tail call ptr @SSL_CTX_new_ex(ptr noundef %0, ptr noundef null, ptr noundef %11) #2
  %13 = tail call ptr @DTLS_client_method() #2
  br label %18

14:                                               ; preds = %9
  %15 = tail call ptr @TLS_server_method() #2
  %16 = tail call ptr @SSL_CTX_new_ex(ptr noundef %0, ptr noundef null, ptr noundef %15) #2
  %17 = tail call ptr @TLS_client_method() #2
  br label %18

18:                                               ; preds = %14, %10
  %.sink = phi ptr [ %17, %14 ], [ %13, %10 ]
  %.029 = phi ptr [ %16, %14 ], [ %12, %10 ]
  %19 = tail call ptr @SSL_CTX_new_ex(ptr noundef %0, ptr noundef null, ptr noundef %.sink) #2
  %20 = icmp eq ptr %.029, null
  %21 = icmp eq ptr %19, null
  %or.cond3 = select i1 %20, i1 true, i1 %21
  br i1 %or.cond3, label %39, label %22

22:                                               ; preds = %18
  %23 = tail call i64 @SSL_CTX_set_options(ptr noundef nonnull %.029, i64 noundef 256) #2
  br i1 %.not, label %24, label %39

24:                                               ; preds = %22
  %25 = tail call i64 @SSL_CTX_ctrl(ptr noundef nonnull %.029, i32 noundef 123, i64 noundef 772, ptr noundef null) #2
  %.not34 = icmp eq i64 %25, 0
  br i1 %.not34, label %39, label %26

26:                                               ; preds = %24
  %27 = tail call i64 @SSL_CTX_ctrl(ptr noundef nonnull %.029, i32 noundef 124, i64 noundef 772, ptr noundef null) #2
  %.not35 = icmp eq i64 %27, 0
  br i1 %.not35, label %39, label %28

28:                                               ; preds = %26
  %29 = tail call i64 @SSL_CTX_ctrl(ptr noundef nonnull %19, i32 noundef 123, i64 noundef 772, ptr noundef null) #2
  %.not36 = icmp eq i64 %29, 0
  br i1 %.not36, label %39, label %30

30:                                               ; preds = %28
  %31 = tail call i64 @SSL_CTX_ctrl(ptr noundef nonnull %19, i32 noundef 124, i64 noundef 772, ptr noundef null) #2
  %.not37 = icmp eq i64 %31, 0
  br i1 %.not37, label %39, label %32

32:                                               ; preds = %30
  %33 = tail call i32 @SSL_CTX_use_certificate_file(ptr noundef nonnull %.029, ptr noundef %3, i32 noundef 1) #2
  %.not38 = icmp eq i32 %33, 0
  br i1 %.not38, label %39, label %34

34:                                               ; preds = %32
  %35 = tail call i32 @SSL_CTX_use_PrivateKey_file(ptr noundef nonnull %.029, ptr noundef %4, i32 noundef 1) #2
  %.not39 = icmp eq i32 %35, 0
  br i1 %.not39, label %39, label %36

36:                                               ; preds = %34
  %37 = tail call i32 @SSL_CTX_check_private_key(ptr noundef nonnull %.029) #2
  %.not40 = icmp eq i32 %37, 0
  br i1 %.not40, label %39, label %38

38:                                               ; preds = %36
  store ptr %.029, ptr %1, align 8, !tbaa !5
  store ptr %19, ptr %2, align 8, !tbaa !5
  br label %40

39:                                               ; preds = %36, %34, %32, %24, %26, %28, %30, %22, %18, %6
  %.130 = phi ptr [ null, %6 ], [ %.029, %18 ], [ %.029, %22 ], [ %.029, %36 ], [ %.029, %34 ], [ %.029, %32 ], [ %.029, %30 ], [ %.029, %28 ], [ %.029, %26 ], [ %.029, %24 ]
  %.1 = phi ptr [ null, %6 ], [ %19, %18 ], [ %19, %22 ], [ %19, %36 ], [ %19, %34 ], [ %19, %32 ], [ %19, %30 ], [ %19, %28 ], [ %19, %26 ], [ %19, %24 ]
  tail call void @SSL_CTX_free(ptr noundef %.130) #2
  tail call void @SSL_CTX_free(ptr noundef %.1) #2
  br label %40

40:                                               ; preds = %39, %38
  %.031 = phi i32 [ 0, %39 ], [ 1, %38 ]
  ret i32 %.031
}

declare ptr @SSL_CTX_new_ex(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @DTLS_server_method() local_unnamed_addr #1

declare ptr @DTLS_client_method() local_unnamed_addr #1

declare ptr @TLS_server_method() local_unnamed_addr #1

declare ptr @TLS_client_method() local_unnamed_addr #1

declare i64 @SSL_CTX_set_options(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

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

declare i32 @SSL_CTX_check_private_key(ptr noundef) local_unnamed_addr #1

declare void @SSL_CTX_free(ptr noundef) local_unnamed_addr #1

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

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


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