; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (ssl_srv)

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

%struct.mbedtls_ssl_context = type { ptr, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i16, i64, i64, i64, i64, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i8, i32, ptr, ptr, ptr, i64, i32, i64, [12 x i8], [12 x i8] }
%struct.mbedtls_ssl_config = type { [4 x ptr], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.mbedtls_mpi, %struct.mbedtls_mpi, ptr, i64, ptr, i64, ptr, i32, i32, i32, i32, [8 x i8], i32, i32, i8, i8, i8, i8, i32 }
%struct.mbedtls_mpi = type { i32, i64, ptr }
%struct.mbedtls_ssl_handshake_params = type { %struct.mbedtls_ssl_sig_hash_set_t, %struct.mbedtls_dhm_context, %struct.mbedtls_ecdh_context, ptr, ptr, i64, ptr, i32, ptr, ptr, ptr, i32, i32, ptr, i8, ptr, i32, i8, ptr, ptr, i32, ptr, [8 x i8], %struct.mbedtls_md5_context, %struct.mbedtls_sha1_context, %struct.mbedtls_sha256_context, %struct.mbedtls_sha512_context, ptr, ptr, ptr, ptr, i64, [64 x i8], [1060 x i8], i32, i32, i32, i32, i32, i32 }
%struct.mbedtls_ssl_sig_hash_set_t = type { i32, i32 }
%struct.mbedtls_dhm_context = type { i64, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi }
%struct.mbedtls_ecdh_context = type { %struct.mbedtls_ecp_group, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i32, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi }
%struct.mbedtls_ecp_group = type { i32, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, i64 }
%struct.mbedtls_ecp_point = type { %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi }
%struct.mbedtls_md5_context = type { [2 x i32], [4 x i32], [64 x i8] }
%struct.mbedtls_sha1_context = type { [2 x i32], [5 x i32], [64 x i8] }
%struct.mbedtls_sha256_context = type { [2 x i32], [8 x i32], [64 x i8], i32 }
%struct.mbedtls_sha512_context = type { [2 x i64], [8 x i64], [128 x i8], i32 }

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_handshake_server_step(ptr noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %6, i32 0, i32 1
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = icmp eq i32 %8, 16
  br i1 %9, label %15, label %10

10:                                               ; preds = %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %11, i32 0, i32 15
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %10, %1
  store i32 -28928, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

16:                                               ; preds = %10
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !11
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %17, i32 noundef 2, ptr noundef @.str, i32 noundef 4016, ptr noundef @.str.1, i32 noundef %20)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call i32 @mbedtls_ssl_flush_output(ptr noundef %21)
  store i32 %22, ptr %4, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %16
  %25 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %25, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

26:                                               ; preds = %16
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %27, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %29, i32 0, i32 46
  %31 = load i32, ptr %30, align 4
  %32 = lshr i32 %31, 1
  %33 = and i32 %32, 1
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %35, label %50

35:                                               ; preds = %26
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %36, i32 0, i32 15
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %38, i32 0, i32 17
  %40 = load i8, ptr %39, align 4, !tbaa !17
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %50

43:                                               ; preds = %35
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = call i32 @mbedtls_ssl_resend(ptr noundef %44)
  store i32 %45, ptr %4, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %48, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

49:                                               ; preds = %43
  br label %50

50:                                               ; preds = %49, %35, %26
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !11
  switch i32 %53, label %114 [
    i32 0, label %54
    i32 1, label %57
    i32 18, label %60
    i32 2, label %61
    i32 3, label %64
    i32 4, label %67
    i32 5, label %70
    i32 6, label %73
    i32 7, label %76
    i32 8, label %79
    i32 9, label %82
    i32 10, label %85
    i32 11, label %88
    i32 12, label %91
    i32 13, label %105
    i32 14, label %108
    i32 15, label %112
  ]

54:                                               ; preds = %50
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %55, i32 0, i32 1
  store i32 1, ptr %56, align 8, !tbaa !11
  br label %119

57:                                               ; preds = %50
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = call i32 @ssl_parse_client_hello(ptr noundef %58)
  store i32 %59, ptr %4, align 4, !tbaa !9
  br label %119

60:                                               ; preds = %50
  store i32 -27264, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

61:                                               ; preds = %50
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = call i32 @ssl_write_server_hello(ptr noundef %62)
  store i32 %63, ptr %4, align 4, !tbaa !9
  br label %119

64:                                               ; preds = %50
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = call i32 @mbedtls_ssl_write_certificate(ptr noundef %65)
  store i32 %66, ptr %4, align 4, !tbaa !9
  br label %119

67:                                               ; preds = %50
  %68 = load ptr, ptr %3, align 8, !tbaa !5
  %69 = call i32 @ssl_write_server_key_exchange(ptr noundef %68)
  store i32 %69, ptr %4, align 4, !tbaa !9
  br label %119

70:                                               ; preds = %50
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = call i32 @ssl_write_certificate_request(ptr noundef %71)
  store i32 %72, ptr %4, align 4, !tbaa !9
  br label %119

73:                                               ; preds = %50
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = call i32 @ssl_write_server_hello_done(ptr noundef %74)
  store i32 %75, ptr %4, align 4, !tbaa !9
  br label %119

76:                                               ; preds = %50
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = call i32 @mbedtls_ssl_parse_certificate(ptr noundef %77)
  store i32 %78, ptr %4, align 4, !tbaa !9
  br label %119

79:                                               ; preds = %50
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call i32 @ssl_parse_client_key_exchange(ptr noundef %80)
  store i32 %81, ptr %4, align 4, !tbaa !9
  br label %119

82:                                               ; preds = %50
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = call i32 @ssl_parse_certificate_verify(ptr noundef %83)
  store i32 %84, ptr %4, align 4, !tbaa !9
  br label %119

85:                                               ; preds = %50
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = call i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef %86)
  store i32 %87, ptr %4, align 4, !tbaa !9
  br label %119

88:                                               ; preds = %50
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = call i32 @mbedtls_ssl_parse_finished(ptr noundef %89)
  store i32 %90, ptr %4, align 4, !tbaa !9
  br label %119

91:                                               ; preds = %50
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %92, i32 0, i32 15
  %94 = load ptr, ptr %93, align 8, !tbaa !15
  %95 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %94, i32 0, i32 38
  %96 = load i32, ptr %95, align 4, !tbaa !29
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %101

98:                                               ; preds = %91
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = call i32 @ssl_write_new_session_ticket(ptr noundef %99)
  store i32 %100, ptr %4, align 4, !tbaa !9
  br label %104

101:                                              ; preds = %91
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = call i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef %102)
  store i32 %103, ptr %4, align 4, !tbaa !9
  br label %104

104:                                              ; preds = %101, %98
  br label %119

105:                                              ; preds = %50
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = call i32 @mbedtls_ssl_write_finished(ptr noundef %106)
  store i32 %107, ptr %4, align 4, !tbaa !9
  br label %119

108:                                              ; preds = %50
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %109, i32 noundef 2, ptr noundef @.str, i32 noundef 4121, ptr noundef @.str.2)
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %110, i32 0, i32 1
  store i32 15, ptr %111, align 8, !tbaa !11
  br label %119

112:                                              ; preds = %50
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mbedtls_ssl_handshake_wrapup(ptr noundef %113)
  br label %119

114:                                              ; preds = %50
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %116, i32 0, i32 1
  %118 = load i32, ptr %117, align 8, !tbaa !11
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %115, i32 noundef 1, ptr noundef @.str, i32 noundef 4130, ptr noundef @.str.3, i32 noundef %118)
  store i32 -28928, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

119:                                              ; preds = %112, %108, %105, %104, %88, %85, %82, %79, %76, %73, %70, %67, %64, %61, %57, %54
  %120 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %120, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %121

121:                                              ; preds = %119, %114, %60, %47, %24, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %122 = load i32, ptr %2, align 4
  ret i32 %122
}

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

declare void @mbedtls_debug_print_msg(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

declare i32 @mbedtls_ssl_flush_output(ptr noundef) #2

declare i32 @mbedtls_ssl_resend(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_client_hello(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_hello(ptr noundef) #0

declare i32 @mbedtls_ssl_write_certificate(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_key_exchange(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_certificate_request(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_hello_done(ptr noundef) #0

declare i32 @mbedtls_ssl_parse_certificate(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_client_key_exchange(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_certificate_verify(ptr noundef) #0

declare i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef) #2

declare i32 @mbedtls_ssl_parse_finished(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_new_session_ticket(ptr noundef) #0

declare i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef) #2

declare i32 @mbedtls_ssl_write_finished(ptr noundef) #2

declare void @mbedtls_ssl_handshake_wrapup(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 }

!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, !10, i64 8}
!12 = !{!"mbedtls_ssl_context", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !10, i64 216, !13, i64 224, !13, i64 232, !14, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272, !10, i64 280, !10, i64 284, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !10, i64 336, !13, i64 344, !13, i64 352, !7, i64 360, !10, i64 364, !6, i64 368, !6, i64 376, !6, i64 384, !13, i64 392, !10, i64 400, !13, i64 408, !7, i64 416, !7, i64 428}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 96}
!16 = !{!12, !6, i64 0}
!17 = !{!18, !7, i64 972}
!18 = !{!"mbedtls_ssl_handshake_params", !19, i64 0, !20, i64 8, !22, i64 256, !6, i64 872, !6, i64 880, !13, i64 888, !6, i64 896, !10, i64 904, !6, i64 912, !6, i64 920, !6, i64 928, !10, i64 936, !10, i64 940, !6, i64 944, !7, i64 952, !6, i64 960, !10, i64 968, !7, i64 972, !6, i64 976, !6, i64 984, !10, i64 992, !6, i64 1000, !7, i64 1008, !25, i64 1016, !26, i64 1104, !27, i64 1196, !28, i64 1304, !6, i64 1520, !6, i64 1528, !6, i64 1536, !6, i64 1544, !13, i64 1552, !7, i64 1560, !7, i64 1624, !10, i64 2684, !10, i64 2688, !10, i64 2692, !10, i64 2696, !10, i64 2700, !10, i64 2704}
!19 = !{!"mbedtls_ssl_sig_hash_set_t", !10, i64 0, !10, i64 4}
!20 = !{!"", !13, i64 0, !21, i64 8, !21, i64 32, !21, i64 56, !21, i64 80, !21, i64 104, !21, i64 128, !21, i64 152, !21, i64 176, !21, i64 200, !21, i64 224}
!21 = !{!"", !10, i64 0, !13, i64 8, !6, i64 16}
!22 = !{!"", !23, i64 0, !21, i64 248, !24, i64 272, !24, i64 344, !21, i64 416, !10, i64 440, !24, i64 448, !24, i64 520, !21, i64 592}
!23 = !{!"", !10, i64 0, !21, i64 8, !21, i64 32, !21, i64 56, !24, i64 80, !21, i64 152, !13, i64 176, !13, i64 184, !10, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !13, i64 240}
!24 = !{!"", !21, i64 0, !21, i64 24, !21, i64 48}
!25 = !{!"", !7, i64 0, !7, i64 8, !7, i64 24}
!26 = !{!"", !7, i64 0, !7, i64 8, !7, i64 28}
!27 = !{!"", !7, i64 0, !7, i64 8, !7, i64 40, !10, i64 104}
!28 = !{!"", !7, i64 0, !7, i64 16, !7, i64 80, !10, i64 208}
!29 = !{!18, !10, i64 2700}


; 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 [97 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_handshake_server_step(ptr noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i32 %3, 16
  br i1 %4, label %61, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  %7 = load ptr, ptr %6, align 8, !tbaa !13
  %8 = icmp eq ptr %7, null
  br i1 %8, label %61, label %9

9:                                                ; preds = %5
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 4016, ptr noundef nonnull @.str.1, i32 noundef %3) #2
  %10 = tail call i32 @mbedtls_ssl_flush_output(ptr noundef nonnull %0) #2
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %61

11:                                               ; preds = %9
  %12 = load ptr, ptr %0, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %12, i64 372
  %14 = load i32, ptr %13, align 4
  %15 = and i32 %14, 2
  %.not39 = icmp eq i32 %15, 0
  br i1 %.not39, label %23, label %16

16:                                               ; preds = %11
  %17 = load ptr, ptr %6, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %17, i64 972
  %19 = load i8, ptr %18, align 4, !tbaa !15
  %20 = icmp eq i8 %19, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  %22 = tail call i32 @mbedtls_ssl_resend(ptr noundef nonnull %0) #2
  %.not40 = icmp eq i32 %22, 0
  br i1 %.not40, label %23, label %61

23:                                               ; preds = %21, %16, %11
  %24 = load i32, ptr %2, align 8, !tbaa !5
  switch i32 %24, label %60 [
    i32 0, label %25
    i32 1, label %26
    i32 18, label %61
    i32 2, label %28
    i32 3, label %30
    i32 4, label %32
    i32 5, label %34
    i32 6, label %36
    i32 7, label %38
    i32 8, label %40
    i32 9, label %42
    i32 10, label %44
    i32 11, label %46
    i32 12, label %48
    i32 13, label %56
    i32 14, label %58
    i32 15, label %59
  ]

25:                                               ; preds = %23
  store i32 1, ptr %2, align 8, !tbaa !5
  br label %61

26:                                               ; preds = %23
  %27 = tail call i32 @ssl_parse_client_hello(ptr noundef nonnull %0)
  br label %61

28:                                               ; preds = %23
  %29 = tail call i32 @ssl_write_server_hello(ptr noundef nonnull %0)
  br label %61

30:                                               ; preds = %23
  %31 = tail call i32 @mbedtls_ssl_write_certificate(ptr noundef nonnull %0) #2
  br label %61

32:                                               ; preds = %23
  %33 = tail call i32 @ssl_write_server_key_exchange(ptr noundef nonnull %0)
  br label %61

34:                                               ; preds = %23
  %35 = tail call i32 @ssl_write_certificate_request(ptr noundef nonnull %0)
  br label %61

36:                                               ; preds = %23
  %37 = tail call i32 @ssl_write_server_hello_done(ptr noundef nonnull %0)
  br label %61

38:                                               ; preds = %23
  %39 = tail call i32 @mbedtls_ssl_parse_certificate(ptr noundef nonnull %0) #2
  br label %61

40:                                               ; preds = %23
  %41 = tail call i32 @ssl_parse_client_key_exchange(ptr noundef nonnull %0)
  br label %61

42:                                               ; preds = %23
  %43 = tail call i32 @ssl_parse_certificate_verify(ptr noundef nonnull %0)
  br label %61

44:                                               ; preds = %23
  %45 = tail call i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef nonnull %0) #2
  br label %61

46:                                               ; preds = %23
  %47 = tail call i32 @mbedtls_ssl_parse_finished(ptr noundef nonnull %0) #2
  br label %61

48:                                               ; preds = %23
  %49 = load ptr, ptr %6, align 8, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %49, i64 2700
  %51 = load i32, ptr %50, align 4, !tbaa !27
  %.not41 = icmp eq i32 %51, 0
  br i1 %.not41, label %54, label %52

52:                                               ; preds = %48
  %53 = tail call i32 @ssl_write_new_session_ticket(ptr noundef nonnull %0)
  br label %61

54:                                               ; preds = %48
  %55 = tail call i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef nonnull %0) #2
  br label %61

56:                                               ; preds = %23
  %57 = tail call i32 @mbedtls_ssl_write_finished(ptr noundef nonnull %0) #2
  br label %61

58:                                               ; preds = %23
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 4121, ptr noundef nonnull @.str.2) #2
  store i32 15, ptr %2, align 8, !tbaa !5
  br label %61

59:                                               ; preds = %23
  tail call void @mbedtls_ssl_handshake_wrapup(ptr noundef nonnull %0) #2
  br label %61

60:                                               ; preds = %23
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 4130, ptr noundef nonnull @.str.3, i32 noundef %24) #2
  br label %61

61:                                               ; preds = %25, %26, %28, %30, %32, %34, %36, %38, %40, %42, %44, %46, %56, %58, %59, %54, %52, %23, %21, %9, %1, %5, %60
  %.033 = phi i32 [ -28928, %60 ], [ -28928, %5 ], [ -28928, %1 ], [ %10, %9 ], [ %22, %21 ], [ -27264, %23 ], [ 0, %59 ], [ 0, %58 ], [ %57, %56 ], [ %53, %52 ], [ %55, %54 ], [ %47, %46 ], [ %45, %44 ], [ %43, %42 ], [ %41, %40 ], [ %39, %38 ], [ %37, %36 ], [ %35, %34 ], [ %33, %32 ], [ %31, %30 ], [ %29, %28 ], [ %27, %26 ], [ 0, %25 ]
  ret i32 %.033
}

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

declare i32 @mbedtls_ssl_flush_output(ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_ssl_resend(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_client_hello(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_hello(ptr noundef) local_unnamed_addr #0

declare i32 @mbedtls_ssl_write_certificate(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_key_exchange(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_certificate_request(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_server_hello_done(ptr noundef) local_unnamed_addr #0

declare i32 @mbedtls_ssl_parse_certificate(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_client_key_exchange(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_certificate_verify(ptr noundef) local_unnamed_addr #0

declare i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_ssl_parse_finished(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_new_session_ticket(ptr noundef) local_unnamed_addr #0

declare i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_ssl_write_finished(ptr noundef) local_unnamed_addr #1

declare void @mbedtls_ssl_handshake_wrapup(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, !10, i64 8}
!6 = !{!"mbedtls_ssl_context", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !10, i64 216, !11, i64 224, !11, i64 232, !12, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !10, i64 280, !10, i64 284, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !10, i64 336, !11, i64 344, !11, i64 352, !8, i64 360, !10, i64 364, !7, i64 368, !7, i64 376, !7, i64 384, !11, i64 392, !10, i64 400, !11, i64 408, !8, i64 416, !8, i64 428}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !7, i64 96}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !8, i64 972}
!16 = !{!"mbedtls_ssl_handshake_params", !17, i64 0, !18, i64 8, !20, i64 256, !7, i64 872, !7, i64 880, !11, i64 888, !7, i64 896, !10, i64 904, !7, i64 912, !7, i64 920, !7, i64 928, !10, i64 936, !10, i64 940, !7, i64 944, !8, i64 952, !7, i64 960, !10, i64 968, !8, i64 972, !7, i64 976, !7, i64 984, !10, i64 992, !7, i64 1000, !8, i64 1008, !23, i64 1016, !24, i64 1104, !25, i64 1196, !26, i64 1304, !7, i64 1520, !7, i64 1528, !7, i64 1536, !7, i64 1544, !11, i64 1552, !8, i64 1560, !8, i64 1624, !10, i64 2684, !10, i64 2688, !10, i64 2692, !10, i64 2696, !10, i64 2700, !10, i64 2704}
!17 = !{!"mbedtls_ssl_sig_hash_set_t", !10, i64 0, !10, i64 4}
!18 = !{!"", !11, i64 0, !19, i64 8, !19, i64 32, !19, i64 56, !19, i64 80, !19, i64 104, !19, i64 128, !19, i64 152, !19, i64 176, !19, i64 200, !19, i64 224}
!19 = !{!"", !10, i64 0, !11, i64 8, !7, i64 16}
!20 = !{!"", !21, i64 0, !19, i64 248, !22, i64 272, !22, i64 344, !19, i64 416, !10, i64 440, !22, i64 448, !22, i64 520, !19, i64 592}
!21 = !{!"", !10, i64 0, !19, i64 8, !19, i64 32, !19, i64 56, !22, i64 80, !19, i64 152, !11, i64 176, !11, i64 184, !10, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !11, i64 240}
!22 = !{!"", !19, i64 0, !19, i64 24, !19, i64 48}
!23 = !{!"", !8, i64 0, !8, i64 8, !8, i64 24}
!24 = !{!"", !8, i64 0, !8, i64 8, !8, i64 28}
!25 = !{!"", !8, i64 0, !8, i64 8, !8, i64 40, !10, i64 104}
!26 = !{!"", !8, i64 0, !8, i64 16, !8, i64 80, !10, i64 208}
!27 = !{!16, !10, i64 2700}


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