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

; 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_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_mpi = type { i32, i64, ptr }
%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 }
%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 }

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [18 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

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

declare void @mbedtls_debug_print_ret(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_ssl_recv_flight_completed(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mbedtls_ssl_hs_hdr_len(ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_read_record(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_send_alert_message(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_parse_finished(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [12 x i8], align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %8, i32 noundef 2, ptr noundef @.str, i32 noundef 5359, ptr noundef @.str.119)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %9, i32 0, i32 15
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %11, i32 0, i32 29
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds [12 x i8], ptr %6, i64 0, i64 0
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !26
  %19 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %18, i32 0, i32 46
  %20 = load i32, ptr %19, align 4
  %21 = and i32 %20, 1
  %22 = xor i32 %21, 1
  call void %13(ptr noundef %14, ptr noundef %15, i32 noundef %22)
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = call i32 @mbedtls_ssl_read_record(ptr noundef %23)
  store i32 %24, ptr %4, align 4, !tbaa !27
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %1
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = load i32, ptr %4, align 4, !tbaa !27
  call void @mbedtls_debug_print_ret(ptr noundef %27, i32 noundef 1, ptr noundef @.str, i32 noundef 5365, ptr noundef @.str.90, i32 noundef %28)
  %29 = load i32, ptr %4, align 4, !tbaa !27
  store i32 %29, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

30:                                               ; preds = %1
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %31, i32 0, i32 30
  %33 = load i32, ptr %32, align 8, !tbaa !28
  %34 = icmp ne i32 %33, 22
  br i1 %34, label %35, label %39

35:                                               ; preds = %30
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %36, i32 noundef 1, ptr noundef @.str, i32 noundef 5371, ptr noundef @.str.120)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef %37, i8 noundef zeroext 2, i8 noundef zeroext 10)
  store i32 -30464, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

39:                                               ; preds = %30
  store i32 12, ptr %5, align 4, !tbaa !27
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %40, i32 0, i32 28
  %42 = load ptr, ptr %41, align 8, !tbaa !29
  %43 = getelementptr inbounds i8, ptr %42, i64 0
  %44 = load i8, ptr %43, align 1, !tbaa !30
  %45 = zext i8 %44 to i32
  %46 = icmp ne i32 %45, 20
  br i1 %46, label %57, label %47

47:                                               ; preds = %39
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %48, i32 0, i32 37
  %50 = load i64, ptr %49, align 8, !tbaa !31
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef %51)
  %53 = load i32, ptr %5, align 4, !tbaa !27
  %54 = zext i32 %53 to i64
  %55 = add i64 %52, %54
  %56 = icmp ne i64 %50, %55
  br i1 %56, label %57, label %61

57:                                               ; preds = %47, %39
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %58, i32 noundef 1, ptr noundef @.str, i32 noundef 5388, ptr noundef @.str.120)
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef %59, i8 noundef zeroext 2, i8 noundef zeroext 50)
  store i32 -32384, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

61:                                               ; preds = %47
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %62, i32 0, i32 28
  %64 = load ptr, ptr %63, align 8, !tbaa !29
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef %65)
  %67 = getelementptr inbounds i8, ptr %64, i64 %66
  %68 = getelementptr inbounds [12 x i8], ptr %6, i64 0, i64 0
  %69 = load i32, ptr %5, align 4, !tbaa !27
  %70 = zext i32 %69 to i64
  %71 = call i32 @mbedtls_ssl_safer_memcmp(ptr noundef %67, ptr noundef %68, i64 noundef %70)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %77

73:                                               ; preds = %61
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %74, i32 noundef 1, ptr noundef @.str, i32 noundef 5397, ptr noundef @.str.120)
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef %75, i8 noundef zeroext 2, i8 noundef zeroext 50)
  store i32 -32384, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

77:                                               ; preds = %61
  %78 = load i32, ptr %5, align 4, !tbaa !27
  %79 = zext i32 %78 to i64
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %80, i32 0, i32 56
  store i64 %79, ptr %81, align 8, !tbaa !32
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %82, i32 0, i32 58
  %84 = getelementptr inbounds [12 x i8], ptr %83, i64 0, i64 0
  %85 = getelementptr inbounds [12 x i8], ptr %6, i64 0, i64 0
  %86 = load i32, ptr %5, align 4, !tbaa !27
  %87 = zext i32 %86 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %84, ptr align 1 %85, i64 %87, i1 false)
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %88, i32 0, i32 15
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %90, i32 0, i32 34
  %92 = load i32, ptr %91, align 4, !tbaa !33
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %117

94:                                               ; preds = %77
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %95, i32 0, i32 0
  %97 = load ptr, ptr %96, align 8, !tbaa !26
  %98 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %97, i32 0, i32 46
  %99 = load i32, ptr %98, align 4
  %100 = and i32 %99, 1
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %94
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %103, i32 0, i32 1
  store i32 10, ptr %104, align 8, !tbaa !34
  br label %105

105:                                              ; preds = %102, %94
  %106 = load ptr, ptr %3, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %106, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8, !tbaa !26
  %109 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %108, i32 0, i32 46
  %110 = load i32, ptr %109, align 4
  %111 = and i32 %110, 1
  %112 = icmp eq i32 %111, 1
  br i1 %112, label %113, label %116

113:                                              ; preds = %105
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %114, i32 0, i32 1
  store i32 15, ptr %115, align 8, !tbaa !34
  br label %116

116:                                              ; preds = %113, %105
  br label %122

117:                                              ; preds = %77
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %118, i32 0, i32 1
  %120 = load i32, ptr %119, align 8, !tbaa !34
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %119, align 8, !tbaa !34
  br label %122

122:                                              ; preds = %117, %116
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %123, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !26
  %126 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %125, i32 0, i32 46
  %127 = load i32, ptr %126, align 4
  %128 = lshr i32 %127, 1
  %129 = and i32 %128, 1
  %130 = icmp eq i32 %129, 1
  br i1 %130, label %131, label %133

131:                                              ; preds = %122
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  call void @mbedtls_ssl_recv_flight_completed(ptr noundef %132)
  br label %133

133:                                              ; preds = %131, %122
  %134 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %134, i32 noundef 2, ptr noundef @.str, i32 noundef 5427, ptr noundef @.str.121)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %7, align 4
  br label %135

135:                                              ; preds = %133, %73, %57, %35, %26
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %136 = load i32, ptr %2, align 4
  ret i32 %136
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mbedtls_ssl_safer_memcmp(ptr noundef, ptr noundef, i64 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { inlinehint 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 }

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


; 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.90 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [18 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

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

declare void @mbedtls_debug_print_ret(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) 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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_ssl_recv_flight_completed(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @mbedtls_ssl_hs_hdr_len(ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_read_record(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_send_alert_message(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_parse_finished(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca [12 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #5
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 5359, ptr noundef nonnull @.str.119) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 1536
  %6 = load ptr, ptr %5, align 8, !tbaa !13
  %7 = load ptr, ptr %0, align 8, !tbaa !25
  %8 = getelementptr inbounds i8, ptr %7, i64 372
  %9 = load i32, ptr %8, align 4
  %10 = and i32 %9, 1
  %11 = xor i32 %10, 1
  call void %6(ptr noundef nonnull %0, ptr noundef nonnull %2, i32 noundef %11) #5
  %12 = call i32 @mbedtls_ssl_read_record(ptr noundef nonnull %0)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %14, label %13

13:                                               ; preds = %1
  call void @mbedtls_debug_print_ret(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 5365, ptr noundef nonnull @.str.90, i32 noundef %12) #5
  br label %64

14:                                               ; preds = %1
  %15 = getelementptr inbounds i8, ptr %0, i64 216
  %16 = load i32, ptr %15, align 8, !tbaa !26
  %.not36 = icmp eq i32 %16, 22
  br i1 %.not36, label %19, label %17

17:                                               ; preds = %14
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 5371, ptr noundef nonnull @.str.120) #5
  %18 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef nonnull %0, i8 noundef zeroext 2, i8 noundef zeroext 10)
  br label %64

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %0, i64 200
  %21 = load ptr, ptr %20, align 8, !tbaa !27
  %22 = load i8, ptr %21, align 1, !tbaa !28
  %.not37 = icmp eq i8 %22, 20
  br i1 %.not37, label %23, label %28

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %0, i64 272
  %25 = load i64, ptr %24, align 8, !tbaa !29
  %26 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef nonnull %0)
  %27 = add i64 %26, 12
  %.not38 = icmp eq i64 %25, %27
  br i1 %.not38, label %30, label %28

28:                                               ; preds = %23, %19
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 5388, ptr noundef nonnull @.str.120) #5
  %29 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef nonnull %0, i8 noundef zeroext 2, i8 noundef zeroext 50)
  br label %64

30:                                               ; preds = %23
  %31 = load ptr, ptr %20, align 8, !tbaa !27
  %32 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef nonnull %0)
  %33 = getelementptr inbounds i8, ptr %31, i64 %32
  %34 = call i32 @mbedtls_ssl_safer_memcmp(ptr noundef %33, ptr noundef nonnull %2, i64 noundef 12)
  %.not39 = icmp eq i32 %34, 0
  br i1 %.not39, label %37, label %35

35:                                               ; preds = %30
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 5397, ptr noundef nonnull @.str.120) #5
  %36 = call i32 @mbedtls_ssl_send_alert_message(ptr noundef nonnull %0, i8 noundef zeroext 2, i8 noundef zeroext 50)
  br label %64

37:                                               ; preds = %30
  %38 = getelementptr inbounds i8, ptr %0, i64 408
  store i64 12, ptr %38, align 8, !tbaa !30
  %39 = getelementptr inbounds i8, ptr %0, i64 428
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %39, ptr noundef nonnull align 1 dereferenceable(12) %2, i64 12, i1 false)
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 2684
  %42 = load i32, ptr %41, align 4, !tbaa !31
  %.not40 = icmp eq i32 %42, 0
  br i1 %.not40, label %53, label %43

43:                                               ; preds = %37
  %44 = load ptr, ptr %0, align 8, !tbaa !25
  %45 = getelementptr inbounds i8, ptr %44, i64 372
  %46 = load i32, ptr %45, align 4
  %47 = and i32 %46, 1
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %.thread

49:                                               ; preds = %43
  %50 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 10, ptr %50, align 8, !tbaa !32
  %.pre = load i32, ptr %45, align 4
  %.pre44 = and i32 %.pre, 1
  %51 = icmp eq i32 %.pre44, 0
  br i1 %51, label %57, label %.thread

.thread:                                          ; preds = %43, %49
  %52 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 15, ptr %52, align 8, !tbaa !32
  br label %57

53:                                               ; preds = %37
  %54 = getelementptr inbounds i8, ptr %0, i64 8
  %55 = load i32, ptr %54, align 8, !tbaa !32
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %54, align 8, !tbaa !32
  %.pre43 = load ptr, ptr %0, align 8, !tbaa !25
  br label %57

57:                                               ; preds = %49, %.thread, %53
  %58 = phi ptr [ %44, %49 ], [ %44, %.thread ], [ %.pre43, %53 ]
  %59 = getelementptr inbounds i8, ptr %58, i64 372
  %60 = load i32, ptr %59, align 4
  %61 = and i32 %60, 2
  %.not42 = icmp eq i32 %61, 0
  br i1 %.not42, label %63, label %62

62:                                               ; preds = %57
  call void @mbedtls_ssl_recv_flight_completed(ptr noundef nonnull %0)
  br label %63

63:                                               ; preds = %62, %57
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 5427, ptr noundef nonnull @.str.121) #5
  br label %64

64:                                               ; preds = %63, %35, %28, %17, %13
  %.0 = phi i32 [ %12, %13 ], [ -30464, %17 ], [ -32384, %28 ], [ -32384, %35 ], [ 0, %63 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #5
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @mbedtls_ssl_safer_memcmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { inlinehint 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 }

!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, !7, i64 96}
!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 = !{!14, !7, i64 1536}
!14 = !{!"mbedtls_ssl_handshake_params", !15, i64 0, !16, i64 8, !18, 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, !21, i64 1016, !22, i64 1104, !23, i64 1196, !24, 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}
!15 = !{!"mbedtls_ssl_sig_hash_set_t", !10, i64 0, !10, i64 4}
!16 = !{!"", !11, i64 0, !17, i64 8, !17, i64 32, !17, i64 56, !17, i64 80, !17, i64 104, !17, i64 128, !17, i64 152, !17, i64 176, !17, i64 200, !17, i64 224}
!17 = !{!"", !10, i64 0, !11, i64 8, !7, i64 16}
!18 = !{!"", !19, i64 0, !17, i64 248, !20, i64 272, !20, i64 344, !17, i64 416, !10, i64 440, !20, i64 448, !20, i64 520, !17, i64 592}
!19 = !{!"", !10, i64 0, !17, i64 8, !17, i64 32, !17, i64 56, !20, i64 80, !17, 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}
!20 = !{!"", !17, i64 0, !17, i64 24, !17, i64 48}
!21 = !{!"", !8, i64 0, !8, i64 8, !8, i64 24}
!22 = !{!"", !8, i64 0, !8, i64 8, !8, i64 28}
!23 = !{!"", !8, i64 0, !8, i64 8, !8, i64 40, !10, i64 104}
!24 = !{!"", !8, i64 0, !8, i64 16, !8, i64 80, !10, i64 208}
!25 = !{!6, !7, i64 0}
!26 = !{!6, !10, i64 216}
!27 = !{!6, !7, i64 200}
!28 = !{!8, !8, i64 0}
!29 = !{!6, !11, i64 272}
!30 = !{!6, !11, i64 408}
!31 = !{!14, !10, i64 2684}
!32 = !{!6, !10, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass