; LLVM IR from PacktPublishing/Demystifying-Cryptography-with-OpenSSL-3 :: Chapter10 (tls-server2)

; 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.4 = external hidden unnamed_addr constant [114 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.handle_accepted_connection = external hidden unnamed_addr constant [46 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [45 x i8], align 1
@stdout = external global ptr, align 8
@.str.24 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [36 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

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

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

declare void @ERR_clear_error() #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

declare i64 @ERR_peek_error() #2

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

declare void @ERR_print_errors_fp(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @handle_accepted_connection(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 16384, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %18 = call noalias ptr @malloc(i64 noundef 16384) #8
  store ptr %18, ptr %11, align 8, !tbaa !5
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %2
  br label %23

22:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.4, i32 noundef 180, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

23:                                               ; preds = %21
  call void @ERR_clear_error()
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call i64 @BIO_ctrl(ptr noundef %24, i32 noundef 101, i64 noundef 0, ptr noundef null)
  %26 = trunc i64 %25 to i32
  store i32 %26, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = icmp sle i32 %27, 0
  br i1 %28, label %29, label %36

29:                                               ; preds = %23
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.19) #7
  br label %35

35:                                               ; preds = %32, %29
  br label %139

36:                                               ; preds = %23
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call i64 @BIO_ctrl(ptr noundef %37, i32 noundef 110, i64 noundef 0, ptr noundef %8)
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %43

42:                                               ; preds = %36
  br label %44

43:                                               ; preds = %36
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.4, i32 noundef 192, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

44:                                               ; preds = %42
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  br label %49

48:                                               ; preds = %44
  call void @__assert_fail(ptr noundef @.str.21, ptr noundef @.str.4, i32 noundef 193, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

49:                                               ; preds = %47
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  br label %51

51:                                               ; preds = %95, %49
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = call i32 @SSL_get_shutdown(ptr noundef %52)
  %54 = and i32 %53, 2
  %55 = icmp ne i32 %54, 2
  br i1 %55, label %56, label %96

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = call i32 @BIO_get_line(ptr noundef %57, ptr noundef %58, i32 noundef 16384)
  store i32 %59, ptr %12, align 4, !tbaa !9
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = icmp sle i32 %60, 0
  br i1 %61, label %62, label %78

62:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i32, ptr %12, align 4, !tbaa !9
  %65 = call i32 @SSL_get_error(ptr noundef %63, i32 noundef %64)
  store i32 %65, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = icmp eq i32 %66, 6
  br i1 %67, label %68, label %69

68:                                               ; preds = %62
  store i32 4, ptr %14, align 4
  br label %77

69:                                               ; preds = %62
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %76

72:                                               ; preds = %69
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.23, i32 noundef %74) #7
  br label %76

76:                                               ; preds = %72, %69
  store i32 2, ptr %14, align 4
  br label %77

77:                                               ; preds = %76, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  br label %93

78:                                               ; preds = %56
  %79 = load ptr, ptr %11, align 8, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = load ptr, ptr @stdout, align 8, !tbaa !5
  %83 = call i64 @fwrite(ptr noundef %79, i64 noundef 1, i64 noundef %81, ptr noundef %82)
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  %85 = call i32 @strcmp(ptr noundef %84, ptr noundef @.str.24) #10
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %91

87:                                               ; preds = %78
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = call i32 @strcmp(ptr noundef %88, ptr noundef @.str.12) #10
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %92, label %91

91:                                               ; preds = %87, %78
  store i32 4, ptr %14, align 4
  br label %93

92:                                               ; preds = %87
  store i32 0, ptr %14, align 4
  br label %93

93:                                               ; preds = %92, %91, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %94 = load i32, ptr %14, align 4
  switch i32 %94, label %165 [
    i32 0, label %95
    i32 4, label %96
    i32 2, label %139
  ]

95:                                               ; preds = %93
  br label %51, !llvm.loop !13

96:                                               ; preds = %93, %51
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.25)
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = call ptr @construct_response(ptr noundef %98)
  store ptr %99, ptr %9, align 8, !tbaa !5
  %100 = load ptr, ptr %9, align 8, !tbaa !5
  %101 = icmp ne ptr %100, null
  br i1 %101, label %102, label %103

102:                                              ; preds = %96
  br label %104

103:                                              ; preds = %96
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.4, i32 noundef 215, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

104:                                              ; preds = %102
  store ptr null, ptr %15, align 8, !tbaa !5
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  %106 = call i64 @BIO_ctrl(ptr noundef %105, i32 noundef 3, i64 noundef 0, ptr noundef %15)
  store i64 %106, ptr %16, align 8, !tbaa !11
  %107 = load ptr, ptr %15, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %110

109:                                              ; preds = %104
  br label %111

110:                                              ; preds = %104
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.4, i32 noundef 219, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

111:                                              ; preds = %109
  %112 = load i64, ptr %16, align 8, !tbaa !11
  %113 = icmp sgt i64 %112, 0
  br i1 %113, label %114, label %115

114:                                              ; preds = %111
  br label %116

115:                                              ; preds = %111
  call void @__assert_fail(ptr noundef @.str.28, ptr noundef @.str.4, i32 noundef 220, ptr noundef @__PRETTY_FUNCTION__.handle_accepted_connection) #9
  unreachable

116:                                              ; preds = %114
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.29)
  %118 = load ptr, ptr %15, align 8, !tbaa !5
  %119 = call i32 (ptr, ...) @printf(ptr noundef @.str.30, ptr noundef %118)
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  %122 = load i64, ptr %16, align 8, !tbaa !11
  %123 = trunc i64 %122 to i32
  %124 = call i32 @BIO_write(ptr noundef %120, ptr noundef %121, i32 noundef %123)
  store i32 %124, ptr %17, align 4, !tbaa !9
  %125 = load i32, ptr %17, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = load i64, ptr %16, align 8, !tbaa !11
  %128 = icmp ne i64 %126, %127
  br i1 %128, label %129, label %136

129:                                              ; preds = %116
  %130 = load ptr, ptr %5, align 8, !tbaa !5
  %131 = icmp ne ptr %130, null
  br i1 %131, label %132, label %135

132:                                              ; preds = %129
  %133 = load ptr, ptr %5, align 8, !tbaa !5
  %134 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %133, ptr noundef @.str.31) #7
  br label %135

135:                                              ; preds = %132, %129
  br label %139

136:                                              ; preds = %116
  %137 = call i32 (ptr, ...) @printf(ptr noundef @.str.32)
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  call void @BIO_ssl_shutdown(ptr noundef %138)
  br label %140

139:                                              ; preds = %135, %93, %35
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %139, %136
  %141 = load ptr, ptr %9, align 8, !tbaa !5
  %142 = icmp ne ptr %141, null
  br i1 %142, label %143, label %146

143:                                              ; preds = %140
  %144 = load ptr, ptr %9, align 8, !tbaa !5
  %145 = call i32 @BIO_free(ptr noundef %144)
  br label %146

146:                                              ; preds = %143, %140
  %147 = load ptr, ptr %4, align 8, !tbaa !5
  %148 = icmp ne ptr %147, null
  br i1 %148, label %149, label %151

149:                                              ; preds = %146
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  call void @BIO_free_all(ptr noundef %150)
  br label %151

151:                                              ; preds = %149, %146
  %152 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %152) #7
  %153 = call i64 @ERR_peek_error()
  %154 = icmp ne i64 %153, 0
  br i1 %154, label %155, label %163

155:                                              ; preds = %151
  store i32 1, ptr %6, align 4, !tbaa !9
  %156 = load ptr, ptr %5, align 8, !tbaa !5
  %157 = icmp ne ptr %156, null
  br i1 %157, label %158, label %162

158:                                              ; preds = %155
  %159 = load ptr, ptr %5, align 8, !tbaa !5
  %160 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %159, ptr noundef @.str.15) #7
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ERR_print_errors_fp(ptr noundef %161)
  br label %162

162:                                              ; preds = %158, %155
  call void @ERR_clear_error()
  br label %163

163:                                              ; preds = %162, %151
  %164 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %164, ptr %3, align 4
  store i32 1, ptr %14, align 4
  br label %165

165:                                              ; preds = %163, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %166 = load i32, ptr %3, align 4
  ret i32 %166
}

declare void @BIO_free_all(ptr noundef) #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

declare i32 @SSL_get_shutdown(ptr noundef) #2

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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #6

; Function Attrs: nounwind uwtable
declare dso_local ptr @construct_response(ptr noundef) #4

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

declare void @BIO_ssl_shutdown(ptr noundef) #2

declare i32 @BIO_free(ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { noreturn 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 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 #5 = { nounwind allocsize(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 #6 = { nounwind willreturn memory(read) "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind willreturn memory(read) }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.4 = external hidden unnamed_addr constant [114 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.handle_accepted_connection = external hidden unnamed_addr constant [46 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [45 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.24 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [36 x i8], align 1

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

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

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

declare void @ERR_clear_error() local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

declare i64 @ERR_peek_error() local_unnamed_addr #2

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

declare void @ERR_print_errors_fp(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @handle_accepted_connection(ptr noundef %0, ptr noundef %1) local_unnamed_addr #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  store ptr null, ptr %3, align 8, !tbaa !5
  %5 = tail call noalias dereferenceable_or_null(16384) ptr @malloc(i64 noundef 16384) #9
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.4, i32 noundef 180, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

7:                                                ; preds = %2
  tail call void @ERR_clear_error() #8
  %8 = tail call i64 @BIO_ctrl(ptr noundef %0, i32 noundef 101, i64 noundef 0, ptr noundef null) #8
  %9 = trunc i64 %8 to i32
  %10 = icmp slt i32 %9, 1
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %.not62 = icmp eq ptr %1, null
  br i1 %.not62, label %.thread72, label %12

12:                                               ; preds = %11
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %1, ptr noundef nonnull @.str.19) #8
  br label %.thread72

14:                                               ; preds = %7
  %15 = call i64 @BIO_ctrl(ptr noundef %0, i32 noundef 110, i64 noundef 0, ptr noundef nonnull %3) #8
  %16 = and i64 %15, 4294967295
  %17 = icmp eq i64 %16, 1
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.4, i32 noundef 192, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

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

21:                                               ; preds = %19
  call void @__assert_fail(ptr noundef nonnull @.str.21, ptr noundef nonnull @.str.4, i32 noundef 193, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

22:                                               ; preds = %19
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  br label %24

24:                                               ; preds = %43, %22
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call i32 @SSL_get_shutdown(ptr noundef %25) #8
  %27 = and i32 %26, 2
  %.not54.not = icmp eq i32 %27, 0
  br i1 %.not54.not, label %28, label %.thread

28:                                               ; preds = %24
  %29 = call i32 @BIO_get_line(ptr noundef %0, ptr noundef nonnull %5, i32 noundef 16384) #8
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %31, label %38

31:                                               ; preds = %28
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = call i32 @SSL_get_error(ptr noundef %32, i32 noundef %29) #8
  %34 = icmp eq i32 %33, 6
  br i1 %34, label %.thread, label %35

35:                                               ; preds = %31
  %.not57 = icmp eq ptr %1, null
  br i1 %.not57, label %.thread72, label %36

36:                                               ; preds = %35
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %1, ptr noundef nonnull @.str.23, i32 noundef %33) #8
  br label %.thread72

38:                                               ; preds = %28
  %39 = zext nneg i32 %29 to i64
  %40 = load ptr, ptr @stdout, align 8, !tbaa !5
  %41 = call i64 @fwrite(ptr noundef nonnull %5, i64 noundef 1, i64 noundef %39, ptr noundef %40)
  %42 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str.24) #11
  %.not55 = icmp eq i32 %42, 0
  br i1 %.not55, label %.thread, label %43

43:                                               ; preds = %38
  %44 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) @.str.12) #11
  %.not56 = icmp eq i32 %44, 0
  br i1 %.not56, label %.thread, label %24

.thread:                                          ; preds = %43, %38, %24, %31
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = call ptr @construct_response(ptr noundef %46)
  %.not58 = icmp eq ptr %47, null
  br i1 %.not58, label %48, label %49

48:                                               ; preds = %.thread
  call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.4, i32 noundef 215, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

49:                                               ; preds = %.thread
  store ptr null, ptr %4, align 8, !tbaa !5
  %50 = call i64 @BIO_ctrl(ptr noundef nonnull %47, i32 noundef 3, i64 noundef 0, ptr noundef nonnull %4) #8
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %.not59 = icmp eq ptr %51, null
  br i1 %.not59, label %52, label %53

52:                                               ; preds = %49
  call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.4, i32 noundef 219, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

53:                                               ; preds = %49
  %54 = icmp sgt i64 %50, 0
  br i1 %54, label %56, label %55

55:                                               ; preds = %53
  call void @__assert_fail(ptr noundef nonnull @.str.28, ptr noundef nonnull @.str.4, i32 noundef 220, ptr noundef nonnull @__PRETTY_FUNCTION__.handle_accepted_connection) #10
  unreachable

56:                                               ; preds = %53
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.29)
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.30, ptr noundef %58)
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = trunc i64 %50 to i32
  %62 = call i32 @BIO_write(ptr noundef %0, ptr noundef %60, i32 noundef %61) #8
  %63 = sext i32 %62 to i64
  %.not60 = icmp eq i64 %50, %63
  br i1 %.not60, label %67, label %64

64:                                               ; preds = %56
  %.not61 = icmp eq ptr %1, null
  br i1 %.not61, label %69, label %65

65:                                               ; preds = %64
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %1, ptr noundef nonnull @.str.31) #8
  br label %69

67:                                               ; preds = %56
  %68 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32)
  call void @BIO_ssl_shutdown(ptr noundef %0) #8
  br label %69

69:                                               ; preds = %67, %64, %65
  %.039 = phi i32 [ 0, %67 ], [ 1, %64 ], [ 1, %65 ]
  %70 = call i32 @BIO_free(ptr noundef nonnull %47) #8
  br label %.thread72

.thread72:                                        ; preds = %35, %36, %11, %12, %69
  %.03976 = phi i32 [ %.039, %69 ], [ 1, %12 ], [ 1, %11 ], [ 1, %36 ], [ 1, %35 ]
  %.not64 = icmp eq ptr %0, null
  br i1 %.not64, label %72, label %71

71:                                               ; preds = %.thread72
  call void @BIO_free_all(ptr noundef nonnull %0) #8
  br label %72

72:                                               ; preds = %71, %.thread72
  call void @free(ptr noundef %5) #8
  %73 = call i64 @ERR_peek_error() #8
  %.not65 = icmp eq i64 %73, 0
  br i1 %.not65, label %78, label %74

74:                                               ; preds = %72
  %.not66 = icmp eq ptr %1, null
  br i1 %.not66, label %77, label %75

75:                                               ; preds = %74
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %1, ptr noundef nonnull @.str.15) #8
  call void @ERR_print_errors_fp(ptr noundef nonnull %1) #8
  br label %77

77:                                               ; preds = %75, %74
  call void @ERR_clear_error() #8
  br label %78

78:                                               ; preds = %72, %77
  %.0 = phi i32 [ 1, %77 ], [ %.03976, %72 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  ret i32 %.0
}

declare void @BIO_free_all(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

declare i32 @SSL_get_shutdown(ptr noundef) local_unnamed_addr #2

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

declare i32 @SSL_get_error(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 #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
declare dso_local ptr @construct_response(ptr noundef) local_unnamed_addr #4

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

declare void @BIO_ssl_shutdown(ptr noundef) local_unnamed_addr #2

declare i32 @BIO_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #7

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { noreturn 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 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 #7 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { noreturn nounwind }
attributes #11 = { nounwind willreturn memory(read) }

!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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass