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

; 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_client_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 %127

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 3363, 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 %127

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 %127

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
  %54 = icmp eq i32 %53, 12
  br i1 %54, label %55, label %65

55:                                               ; preds = %50
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %56, i32 0, i32 15
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %58, i32 0, i32 38
  %60 = load i32, ptr %59, align 4, !tbaa !29
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %55
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %63, i32 0, i32 1
  store i32 17, ptr %64, align 8, !tbaa !11
  br label %65

65:                                               ; preds = %62, %55, %50
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 8, !tbaa !11
  switch i32 %68, label %120 [
    i32 0, label %69
    i32 1, label %72
    i32 2, label %75
    i32 3, label %78
    i32 4, label %81
    i32 5, label %84
    i32 6, label %87
    i32 7, label %90
    i32 8, label %93
    i32 9, label %96
    i32 10, label %99
    i32 11, label %102
    i32 17, label %105
    i32 12, label %108
    i32 13, label %111
    i32 14, label %114
    i32 15, label %118
  ]

69:                                               ; preds = %65
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %70, i32 0, i32 1
  store i32 1, ptr %71, align 8, !tbaa !11
  br label %125

72:                                               ; preds = %65
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = call i32 @ssl_write_client_hello(ptr noundef %73)
  store i32 %74, ptr %4, align 4, !tbaa !9
  br label %125

75:                                               ; preds = %65
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = call i32 @ssl_parse_server_hello(ptr noundef %76)
  store i32 %77, ptr %4, align 4, !tbaa !9
  br label %125

78:                                               ; preds = %65
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = call i32 @mbedtls_ssl_parse_certificate(ptr noundef %79)
  store i32 %80, ptr %4, align 4, !tbaa !9
  br label %125

81:                                               ; preds = %65
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = call i32 @ssl_parse_server_key_exchange(ptr noundef %82)
  store i32 %83, ptr %4, align 4, !tbaa !9
  br label %125

84:                                               ; preds = %65
  %85 = load ptr, ptr %3, align 8, !tbaa !5
  %86 = call i32 @ssl_parse_certificate_request(ptr noundef %85)
  store i32 %86, ptr %4, align 4, !tbaa !9
  br label %125

87:                                               ; preds = %65
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = call i32 @ssl_parse_server_hello_done(ptr noundef %88)
  store i32 %89, ptr %4, align 4, !tbaa !9
  br label %125

90:                                               ; preds = %65
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = call i32 @mbedtls_ssl_write_certificate(ptr noundef %91)
  store i32 %92, ptr %4, align 4, !tbaa !9
  br label %125

93:                                               ; preds = %65
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = call i32 @ssl_write_client_key_exchange(ptr noundef %94)
  store i32 %95, ptr %4, align 4, !tbaa !9
  br label %125

96:                                               ; preds = %65
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = call i32 @ssl_write_certificate_verify(ptr noundef %97)
  store i32 %98, ptr %4, align 4, !tbaa !9
  br label %125

99:                                               ; preds = %65
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = call i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef %100)
  store i32 %101, ptr %4, align 4, !tbaa !9
  br label %125

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

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

108:                                              ; preds = %65
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = call i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef %109)
  store i32 %110, ptr %4, align 4, !tbaa !9
  br label %125

111:                                              ; preds = %65
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = call i32 @mbedtls_ssl_parse_finished(ptr noundef %112)
  store i32 %113, ptr %4, align 4, !tbaa !9
  br label %125

114:                                              ; preds = %65
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %115, i32 noundef 2, ptr noundef @.str, i32 noundef 3474, ptr noundef @.str.2)
  %116 = load ptr, ptr %3, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %116, i32 0, i32 1
  store i32 15, ptr %117, align 8, !tbaa !11
  br label %125

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

120:                                              ; preds = %65
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 8, !tbaa !11
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %121, i32 noundef 1, ptr noundef @.str, i32 noundef 3483, ptr noundef @.str.3, i32 noundef %124)
  store i32 -28928, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %127

125:                                              ; preds = %118, %114, %111, %108, %105, %102, %99, %96, %93, %90, %87, %84, %81, %78, %75, %72, %69
  %126 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %126, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %127

127:                                              ; preds = %125, %120, %47, %24, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %128 = load i32, ptr %2, align 4
  ret i32 %128
}

; 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_write_client_hello(ptr noundef) #0

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

declare i32 @mbedtls_ssl_parse_certificate(ptr noundef) #2

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

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

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

declare i32 @mbedtls_ssl_write_certificate(ptr noundef) #2

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

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

declare i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef) #2

declare i32 @mbedtls_ssl_write_finished(ptr noundef) #2

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

declare i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef) #2

declare i32 @mbedtls_ssl_parse_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_client_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 %60, 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 %60, 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 3363, 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 %60

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
  %.not41 = icmp eq i32 %15, 0
  br i1 %.not41, 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
  %.not42 = icmp eq i32 %22, 0
  br i1 %.not42, label %23, label %60

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

25:                                               ; preds = %23
  %26 = load ptr, ptr %6, align 8, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %26, i64 2700
  %28 = load i32, ptr %27, align 4, !tbaa !27
  %.not43 = icmp eq i32 %28, 0
  br i1 %.not43, label %thread-pre-split.thread, label %.thread

.thread:                                          ; preds = %25
  store i32 17, ptr %2, align 8, !tbaa !5
  br label %52

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

30:                                               ; preds = %23
  %31 = tail call i32 @ssl_write_client_hello(ptr noundef nonnull %0)
  br label %60

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

34:                                               ; preds = %23
  %35 = tail call i32 @mbedtls_ssl_parse_certificate(ptr noundef nonnull %0) #2
  br label %60

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

38:                                               ; preds = %23
  %39 = tail call i32 @ssl_parse_certificate_request(ptr noundef nonnull %0)
  br label %60

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

42:                                               ; preds = %23
  %43 = tail call i32 @mbedtls_ssl_write_certificate(ptr noundef nonnull %0) #2
  br label %60

44:                                               ; preds = %23
  %45 = tail call i32 @ssl_write_client_key_exchange(ptr noundef nonnull %0)
  br label %60

46:                                               ; preds = %23
  %47 = tail call i32 @ssl_write_certificate_verify(ptr noundef nonnull %0)
  br label %60

48:                                               ; preds = %23
  %49 = tail call i32 @mbedtls_ssl_write_change_cipher_spec(ptr noundef nonnull %0) #2
  br label %60

50:                                               ; preds = %23
  %51 = tail call i32 @mbedtls_ssl_write_finished(ptr noundef nonnull %0) #2
  br label %60

52:                                               ; preds = %23, %.thread
  %53 = tail call i32 @ssl_parse_new_session_ticket(ptr noundef nonnull %0)
  br label %60

thread-pre-split.thread:                          ; preds = %25
  %54 = tail call i32 @mbedtls_ssl_parse_change_cipher_spec(ptr noundef nonnull %0) #2
  br label %60

55:                                               ; preds = %23
  %56 = tail call i32 @mbedtls_ssl_parse_finished(ptr noundef nonnull %0) #2
  br label %60

57:                                               ; 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 3474, ptr noundef nonnull @.str.2) #2
  store i32 15, ptr %2, align 8, !tbaa !5
  br label %60

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

59:                                               ; 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 3483, ptr noundef nonnull @.str.3, i32 noundef %24) #2
  br label %60

60:                                               ; preds = %29, %30, %32, %34, %36, %38, %40, %42, %44, %46, %48, %50, %52, %thread-pre-split.thread, %55, %57, %58, %21, %9, %1, %5, %59
  %.035 = phi i32 [ -28928, %59 ], [ -28928, %5 ], [ -28928, %1 ], [ %10, %9 ], [ %22, %21 ], [ 0, %58 ], [ 0, %57 ], [ %56, %55 ], [ %54, %thread-pre-split.thread ], [ %53, %52 ], [ %51, %50 ], [ %49, %48 ], [ %47, %46 ], [ %45, %44 ], [ %43, %42 ], [ %41, %40 ], [ %39, %38 ], [ %37, %36 ], [ %35, %34 ], [ %33, %32 ], [ %31, %30 ], [ 0, %29 ]
  ret i32 %.035
}

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_write_client_hello(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_server_hello(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_server_key_exchange(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_server_hello_done(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_client_key_exchange(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_write_certificate_verify(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

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_parse_new_session_ticket(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

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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass