; LLVM IR from openanolis/openssl :: apps/lib (app_libctx)

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

@app_libctx = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @app_create_libctx() #0 {
  %1 = alloca ptr, align 8
  %2 = load ptr, ptr @app_libctx, align 8, !tbaa !5
  %3 = icmp eq ptr %2, null
  br i1 %3, label %4, label %11

4:                                                ; preds = %0
  %5 = call i32 @app_provider_load(ptr noundef null, ptr noundef @.str)
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %9, label %7

7:                                                ; preds = %4
  %8 = call i32 (ptr, ...) @opt_printf_stderr(ptr noundef @.str.1)
  store ptr null, ptr %1, align 8
  br label %18

9:                                                ; preds = %4
  %10 = call ptr @OSSL_LIB_CTX_new()
  store ptr %10, ptr @app_libctx, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %9, %0
  %12 = load ptr, ptr @app_libctx, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = call i32 (ptr, ...) @opt_printf_stderr(ptr noundef @.str.2)
  br label %16

16:                                               ; preds = %14, %11
  %17 = load ptr, ptr @app_libctx, align 8, !tbaa !5
  store ptr %17, ptr %1, align 8
  br label %18

18:                                               ; preds = %16, %7
  %19 = load ptr, ptr %1, align 8
  ret ptr %19
}

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

declare i32 @opt_printf_stderr(ptr noundef, ...) #1

declare ptr @OSSL_LIB_CTX_new() #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" }

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


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

@app_libctx = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @app_create_libctx() local_unnamed_addr #0 {
  %1 = load ptr, ptr @app_libctx, align 8, !tbaa !5
  %2 = icmp eq ptr %1, null
  br i1 %2, label %3, label %.thread

3:                                                ; preds = %0
  %4 = tail call i32 @app_provider_load(ptr noundef null, ptr noundef nonnull @.str) #2
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %7

5:                                                ; preds = %3
  %6 = tail call i32 (ptr, ...) @opt_printf_stderr(ptr noundef nonnull @.str.1) #2
  br label %.thread

7:                                                ; preds = %3
  %8 = tail call ptr @OSSL_LIB_CTX_new() #2
  store ptr %8, ptr @app_libctx, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %.thread

10:                                               ; preds = %7
  %11 = tail call i32 (ptr, ...) @opt_printf_stderr(ptr noundef nonnull @.str.2) #2
  %.pre = load ptr, ptr @app_libctx, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %7, %10, %0, %5
  %.0 = phi ptr [ null, %5 ], [ %1, %0 ], [ %.pre, %10 ], [ %8, %7 ]
  ret ptr %.0
}

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

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

declare ptr @OSSL_LIB_CTX_new() 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: GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,SROAPass,TailCallElimPass