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

@stderr = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [52 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

declare i32 @BIO_free(ptr noundef) #1

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

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

22:                                               ; preds = %19, %5
  br label %72

23:                                               ; preds = %19
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = call ptr @SSL_new(ptr noundef %24)
  store ptr %25, ptr %12, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = call ptr @SSL_new(ptr noundef %26)
  store ptr %27, ptr %13, align 8, !tbaa !5
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %33, label %30

30:                                               ; preds = %23
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %34

33:                                               ; preds = %30, %23
  br label %72

34:                                               ; preds = %30
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %34
  %38 = load ptr, ptr @stderr, align 8, !tbaa !5
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.8) #4
  %40 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %40)
  br label %72

41:                                               ; preds = %34
  %42 = call ptr @BIO_s_mem()
  %43 = call ptr @BIO_new(ptr noundef %42)
  store ptr %43, ptr %14, align 8, !tbaa !5
  %44 = call ptr @BIO_s_mem()
  %45 = call ptr @BIO_new(ptr noundef %44)
  store ptr %45, ptr %15, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %41
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = icmp eq ptr %47, null
  br i1 %48, label %52, label %49

49:                                               ; preds = %46
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %53

52:                                               ; preds = %49, %46
  br label %72

53:                                               ; preds = %49
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = call i64 @BIO_ctrl(ptr noundef %54, i32 noundef 130, i64 noundef -1, ptr noundef null)
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  %57 = call i64 @BIO_ctrl(ptr noundef %56, i32 noundef 130, i64 noundef -1, ptr noundef null)
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = load ptr, ptr %14, align 8, !tbaa !5
  call void @SSL_set_bio(ptr noundef %58, ptr noundef %59, ptr noundef %60)
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = call i32 @BIO_up_ref(ptr noundef %61)
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  %64 = call i32 @BIO_up_ref(ptr noundef %63)
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  call void @SSL_set_bio(ptr noundef %65, ptr noundef %66, ptr noundef %67)
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %68, ptr %69, align 8, !tbaa !5
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %70, ptr %71, align 8, !tbaa !5
  store i32 1, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %79

72:                                               ; preds = %52, %37, %33, %22
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  call void @SSL_free(ptr noundef %73)
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  call void @SSL_free(ptr noundef %74)
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = call i32 @BIO_free(ptr noundef %75)
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = call i32 @BIO_free(ptr noundef %77)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %16, align 4
  br label %79

79:                                               ; preds = %72, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %80 = load i32, ptr %6, align 4
  ret i32 %80
}

declare ptr @SSL_new(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare void @ERR_print_errors_fp(ptr noundef) #1

declare ptr @BIO_new(ptr noundef) #1

declare ptr @BIO_s_mem() #1

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

declare void @SSL_set_bio(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @BIO_up_ref(ptr noundef) #1

declare void @SSL_free(ptr 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 "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 }

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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [52 x i8], align 1

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #0

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

8:                                                ; preds = %5
  %9 = tail call ptr @SSL_new(ptr noundef nonnull %0) #3
  %10 = tail call ptr @SSL_new(ptr noundef nonnull %1) #3
  %11 = icmp eq ptr %9, null
  %12 = icmp eq ptr %10, null
  %or.cond3 = select i1 %11, i1 true, i1 %12
  br i1 %or.cond3, label %30, label %13

13:                                               ; preds = %8
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %18, label %14

14:                                               ; preds = %13
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.8) #4
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  tail call void @ERR_print_errors_fp(ptr noundef %17) #3
  br label %30

18:                                               ; preds = %13
  %19 = tail call ptr @BIO_s_mem() #3
  %20 = tail call ptr @BIO_new(ptr noundef %19) #3
  %21 = tail call ptr @BIO_s_mem() #3
  %22 = tail call ptr @BIO_new(ptr noundef %21) #3
  %23 = icmp eq ptr %20, null
  %24 = icmp eq ptr %22, null
  %or.cond5 = select i1 %23, i1 true, i1 %24
  br i1 %or.cond5, label %30, label %25

25:                                               ; preds = %18
  %26 = tail call i64 @BIO_ctrl(ptr noundef nonnull %20, i32 noundef 130, i64 noundef -1, ptr noundef null) #3
  %27 = tail call i64 @BIO_ctrl(ptr noundef nonnull %22, i32 noundef 130, i64 noundef -1, ptr noundef null) #3
  tail call void @SSL_set_bio(ptr noundef nonnull %9, ptr noundef nonnull %22, ptr noundef nonnull %20) #3
  %28 = tail call i32 @BIO_up_ref(ptr noundef nonnull %20) #3
  %29 = tail call i32 @BIO_up_ref(ptr noundef nonnull %22) #3
  tail call void @SSL_set_bio(ptr noundef nonnull %10, ptr noundef nonnull %20, ptr noundef nonnull %22) #3
  store ptr %9, ptr %2, align 8, !tbaa !5
  store ptr %10, ptr %3, align 8, !tbaa !5
  br label %33

30:                                               ; preds = %18, %8, %5, %14
  %.034 = phi ptr [ null, %5 ], [ %9, %8 ], [ %9, %14 ], [ %9, %18 ]
  %.033 = phi ptr [ null, %5 ], [ %10, %8 ], [ %10, %14 ], [ %10, %18 ]
  %.032 = phi ptr [ null, %5 ], [ null, %8 ], [ null, %14 ], [ %20, %18 ]
  %.0 = phi ptr [ null, %5 ], [ null, %8 ], [ null, %14 ], [ %22, %18 ]
  tail call void @SSL_free(ptr noundef %.034) #3
  tail call void @SSL_free(ptr noundef %.033) #3
  %31 = tail call i32 @BIO_free(ptr noundef %.032) #3
  %32 = tail call i32 @BIO_free(ptr noundef %.0) #3
  br label %33

33:                                               ; preds = %30, %25
  %.035 = phi i32 [ 0, %30 ], [ 1, %25 ]
  ret i32 %.035
}

declare ptr @SSL_new(ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #0

declare ptr @BIO_new(ptr noundef) local_unnamed_addr #0

declare ptr @BIO_s_mem() local_unnamed_addr #0

declare i64 @BIO_ctrl(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare void @SSL_set_bio(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @BIO_up_ref(ptr noundef) local_unnamed_addr #0

declare void @SSL_free(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 = { nofree 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 = { nounwind }
attributes #4 = { cold 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass