; LLVM IR from openanolis/openssl :: demos/bio (server-cmod)

; 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 [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [512 x i8], align 16
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 512, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store ptr @.str, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 1, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %14 = call ptr @TLS_server_method()
  %15 = call ptr @SSL_CTX_new(ptr noundef %14)
  store ptr %15, ptr %11, align 8, !tbaa !9
  %16 = call i32 @CONF_modules_load_file(ptr noundef @.str.1, ptr noundef @.str.2, i64 noundef 0)
  %17 = icmp sle i32 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %2
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.3) #4
  br label %73

21:                                               ; preds = %2
  %22 = load ptr, ptr %11, align 8, !tbaa !9
  %23 = call i32 @SSL_CTX_config(ptr noundef %22, ptr noundef @.str.4)
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.5) #4
  br label %73

28:                                               ; preds = %21
  %29 = load ptr, ptr %11, align 8, !tbaa !9
  %30 = call ptr @BIO_new_ssl(ptr noundef %29, i32 noundef 0)
  store ptr %30, ptr %9, align 8, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = call ptr @BIO_new_accept(ptr noundef %31)
  store ptr %32, ptr %8, align 8, !tbaa !9
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %28
  br label %73

35:                                               ; preds = %28
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  %37 = load ptr, ptr %9, align 8, !tbaa !9
  %38 = call i64 @BIO_ctrl(ptr noundef %36, i32 noundef 118, i64 noundef 3, ptr noundef %37)
  br label %39

39:                                               ; preds = %51, %35
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = call i64 @BIO_ctrl(ptr noundef %40, i32 noundef 101, i64 noundef 0, ptr noundef null)
  %42 = icmp sle i64 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %73

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %65, %63, %44
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  %47 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %48 = call i32 @BIO_read(ptr noundef %46, ptr noundef %47, i32 noundef 512)
  store i32 %48, ptr %13, align 4, !tbaa !5
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %56

51:                                               ; preds = %45
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %53 = load ptr, ptr %8, align 8, !tbaa !9
  %54 = call ptr @BIO_pop(ptr noundef %53)
  store ptr %54, ptr %10, align 8, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !9
  call void @BIO_free_all(ptr noundef %55)
  br label %39

56:                                               ; preds = %45
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = icmp slt i32 %57, 0
  br i1 %58, label %59, label %65

59:                                               ; preds = %56
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = call i32 @BIO_test_flags(ptr noundef %60, i32 noundef 8)
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %59
  br label %45

64:                                               ; preds = %59
  br label %73

65:                                               ; preds = %56
  %66 = getelementptr inbounds [512 x i8], ptr %6, i64 0, i64 0
  %67 = load i32, ptr %13, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = load ptr, ptr @stdout, align 8, !tbaa !9
  %70 = call i64 @fwrite(ptr noundef %66, i64 noundef 1, i64 noundef %68, ptr noundef %69)
  %71 = load ptr, ptr @stdout, align 8, !tbaa !9
  %72 = call i32 @fflush(ptr noundef %71)
  br label %45

73:                                               ; preds = %64, %43, %34, %25, %18
  %74 = load i32, ptr %12, align 4, !tbaa !5
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %73
  %77 = load ptr, ptr @stderr, align 8, !tbaa !9
  call void @ERR_print_errors_fp(ptr noundef %77)
  br label %78

78:                                               ; preds = %76, %73
  %79 = load ptr, ptr %8, align 8, !tbaa !9
  %80 = call i32 @BIO_free(ptr noundef %79)
  %81 = load i32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %6) #4
  ret i32 %81
}

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

declare ptr @SSL_CTX_new(ptr noundef) #2

declare ptr @TLS_server_method() #2

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

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

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

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

declare ptr @BIO_new_accept(ptr noundef) #2

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

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

declare i32 @printf(ptr noundef, ...) #2

declare ptr @BIO_pop(ptr noundef) #2

declare void @BIO_free_all(ptr noundef) #2

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

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

declare i32 @fflush(ptr noundef) #2

declare void @ERR_print_errors_fp(ptr noundef) #2

declare i32 @BIO_free(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 "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 = !{!"int", !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}


; 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 [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca [512 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %3) #4
  %4 = tail call ptr @TLS_server_method() #4
  %5 = tail call ptr @SSL_CTX_new(ptr noundef %4) #4
  %6 = tail call i32 @CONF_modules_load_file(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i64 noundef 0) #4
  %7 = icmp slt i32 %6, 1
  br i1 %7, label %.loopexit.sink.split, label %8

8:                                                ; preds = %2
  %9 = tail call i32 @SSL_CTX_config(ptr noundef %5, ptr noundef nonnull @.str.4) #4
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.loopexit.sink.split, label %11

11:                                               ; preds = %8
  %12 = tail call ptr @BIO_new_ssl(ptr noundef %5, i32 noundef 0) #4
  %13 = tail call ptr @BIO_new_accept(ptr noundef nonnull @.str) #4
  %14 = icmp eq ptr %13, null
  br i1 %14, label %.loopexit, label %15

15:                                               ; preds = %11
  %16 = tail call i64 @BIO_ctrl(ptr noundef nonnull %13, i32 noundef 118, i64 noundef 3, ptr noundef %12) #4
  %17 = tail call i64 @BIO_ctrl(ptr noundef nonnull %13, i32 noundef 101, i64 noundef 0, ptr noundef null) #4
  %18 = icmp slt i64 %17, 1
  br i1 %18, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %15, %._crit_edge
  %19 = call i32 @BIO_read(ptr noundef nonnull %13, ptr noundef nonnull %3, i32 noundef 512) #4
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.backedge, %.preheader
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %22 = call ptr @BIO_pop(ptr noundef nonnull %13) #4
  call void @BIO_free_all(ptr noundef %22) #4
  %23 = call i64 @BIO_ctrl(ptr noundef nonnull %13, i32 noundef 101, i64 noundef 0, ptr noundef null) #4
  %24 = icmp slt i64 %23, 1
  br i1 %24, label %.loopexit, label %.preheader

.lr.ph:                                           ; preds = %.preheader, %.backedge
  %25 = phi i32 [ %35, %.backedge ], [ %19, %.preheader ]
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %.lr.ph
  %28 = call i32 @BIO_test_flags(ptr noundef nonnull %13, i32 noundef 8) #4
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %.loopexit, label %.backedge

29:                                               ; preds = %.lr.ph
  %30 = zext nneg i32 %25 to i64
  %31 = load ptr, ptr @stdout, align 8, !tbaa !5
  %32 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 1, i64 noundef %30, ptr noundef %31)
  %33 = load ptr, ptr @stdout, align 8, !tbaa !5
  %34 = call i32 @fflush(ptr noundef %33)
  br label %.backedge

.backedge:                                        ; preds = %29, %27
  %35 = call i32 @BIO_read(ptr noundef nonnull %13, ptr noundef nonnull %3, i32 noundef 512) #4
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %._crit_edge, label %.lr.ph

.loopexit.sink.split:                             ; preds = %8, %2
  %.str.3.sink = phi ptr [ @.str.3, %2 ], [ @.str.5, %8 ]
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull %.str.3.sink) #5
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge, %27, %.loopexit.sink.split, %15, %11
  %.0 = phi ptr [ null, %11 ], [ %13, %15 ], [ null, %.loopexit.sink.split ], [ %13, %27 ], [ %13, %._crit_edge ]
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %39) #4
  %40 = call i32 @BIO_free(ptr noundef %.0) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #4
  ret i32 1
}

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

declare ptr @SSL_CTX_new(ptr noundef) local_unnamed_addr #2

declare ptr @TLS_server_method() local_unnamed_addr #2

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

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

declare i32 @SSL_CTX_config(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @BIO_new_ssl(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @BIO_new_accept(ptr noundef) local_unnamed_addr #2

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

declare i32 @BIO_read(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare ptr @BIO_pop(ptr noundef) local_unnamed_addr #2

declare void @BIO_free_all(ptr noundef) local_unnamed_addr #2

declare i32 @BIO_test_flags(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #3

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #2

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass