; 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_flight_item = type { ptr, i64, i8, ptr }

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [22 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_buf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 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 hidden void @ssl_set_timer(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_resend(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %7, i32 noundef 2, ptr noundef @.str, i32 noundef 2591, ptr noundef @.str.44)
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %8, i32 0, i32 15
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %10, i32 0, i32 17
  %12 = load i8, ptr %11, align 4, !tbaa !14
  %13 = zext i8 %12 to i32
  %14 = icmp ne i32 %13, 1
  br i1 %14, label %15, label %31

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %16, i32 noundef 2, ptr noundef @.str, i32 noundef 2595, ptr noundef @.str.45)
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %17, i32 0, i32 15
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %19, i32 0, i32 18
  %21 = load ptr, ptr %20, align 8, !tbaa !26
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %22, i32 0, i32 15
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %24, i32 0, i32 19
  store ptr %21, ptr %25, align 8, !tbaa !27
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ssl_swap_epochs(ptr noundef %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %27, i32 0, i32 15
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %29, i32 0, i32 17
  store i8 1, ptr %30, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %15, %1
  br label %32

32:                                               ; preds = %102, %31
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %33, i32 0, i32 15
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %35, i32 0, i32 19
  %37 = load ptr, ptr %36, align 8, !tbaa !27
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %103

39:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %40, i32 0, i32 15
  %42 = load ptr, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %42, i32 0, i32 19
  %44 = load ptr, ptr %43, align 8, !tbaa !27
  store ptr %44, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %45, i32 0, i32 2
  %47 = load i8, ptr %46, align 8, !tbaa !28
  %48 = zext i8 %47 to i32
  %49 = icmp eq i32 %48, 22
  br i1 %49, label %50, label %60

50:                                               ; preds = %39
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !30
  %54 = getelementptr inbounds i8, ptr %53, i64 0
  %55 = load i8, ptr %54, align 1, !tbaa !31
  %56 = zext i8 %55 to i32
  %57 = icmp eq i32 %56, 20
  br i1 %57, label %58, label %60

58:                                               ; preds = %50
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  call void @ssl_swap_epochs(ptr noundef %59)
  br label %60

60:                                               ; preds = %58, %50, %39
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %61, i32 0, i32 45
  %63 = load ptr, ptr %62, align 8, !tbaa !32
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %64, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !30
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %67, i32 0, i32 1
  %69 = load i64, ptr %68, align 8, !tbaa !33
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %63, ptr align 1 %66, i64 %69, i1 false)
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %70, i32 0, i32 1
  %72 = load i64, ptr %71, align 8, !tbaa !33
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %73, i32 0, i32 47
  store i64 %72, ptr %74, align 8, !tbaa !34
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %75, i32 0, i32 2
  %77 = load i8, ptr %76, align 8, !tbaa !28
  %78 = zext i8 %77 to i32
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %79, i32 0, i32 46
  store i32 %78, ptr %80, align 8, !tbaa !35
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.mbedtls_ssl_flight_item, ptr %81, i32 0, i32 3
  %83 = load ptr, ptr %82, align 8, !tbaa !36
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %84, i32 0, i32 15
  %86 = load ptr, ptr %85, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %86, i32 0, i32 19
  store ptr %83, ptr %87, align 8, !tbaa !27
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %89, i32 0, i32 45
  %91 = load ptr, ptr %90, align 8, !tbaa !32
  call void @mbedtls_debug_print_buf(ptr noundef %88, i32 noundef 3, ptr noundef @.str, i32 noundef 2623, ptr noundef @.str.46, ptr noundef %91, i64 noundef 12)
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = call i32 @mbedtls_ssl_write_record(ptr noundef %92)
  store i32 %93, ptr %4, align 4, !tbaa !37
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %99

95:                                               ; preds = %60
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = load i32, ptr %4, align 4, !tbaa !37
  call void @mbedtls_debug_print_ret(ptr noundef %96, i32 noundef 1, ptr noundef @.str, i32 noundef 2627, ptr noundef @.str.47, i32 noundef %97)
  %98 = load i32, ptr %4, align 4, !tbaa !37
  store i32 %98, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %100

99:                                               ; preds = %60
  store i32 0, ptr %6, align 4
  br label %100

100:                                              ; preds = %99, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %101 = load i32, ptr %6, align 4
  switch i32 %101, label %128 [
    i32 0, label %102
    i32 1, label %126
  ]

102:                                              ; preds = %100
  br label %32, !llvm.loop !38

103:                                              ; preds = %32
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %104, i32 0, i32 1
  %106 = load i32, ptr %105, align 8, !tbaa !40
  %107 = icmp eq i32 %106, 16
  br i1 %107, label %108, label %113

108:                                              ; preds = %103
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %109, i32 0, i32 15
  %111 = load ptr, ptr %110, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %111, i32 0, i32 17
  store i8 3, ptr %112, align 4, !tbaa !14
  br label %124

113:                                              ; preds = %103
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %114, i32 0, i32 15
  %116 = load ptr, ptr %115, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %116, i32 0, i32 17
  store i8 2, ptr %117, align 4, !tbaa !14
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %119, i32 0, i32 15
  %121 = load ptr, ptr %120, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %121, i32 0, i32 16
  %123 = load i32, ptr %122, align 8, !tbaa !41
  call void @ssl_set_timer(ptr noundef %118, i32 noundef %123)
  br label %124

124:                                              ; preds = %113, %108
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %125, i32 noundef 2, ptr noundef @.str, i32 noundef 2640, ptr noundef @.str.48)
  store i32 0, ptr %2, align 4
  br label %126

126:                                              ; preds = %124, %100
  %127 = load i32, ptr %2, align 4
  ret i32 %127

128:                                              ; preds = %100
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden void @ssl_swap_epochs(ptr noundef) #3

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

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 = { 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, !7, i64 972}
!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 = !{!15, !6, i64 976}
!27 = !{!15, !6, i64 984}
!28 = !{!29, !7, i64 16}
!29 = !{!"mbedtls_ssl_flight_item", !6, i64 0, !12, i64 8, !7, i64 16, !6, i64 24}
!30 = !{!29, !6, i64 0}
!31 = !{!7, !7, i64 0}
!32 = !{!10, !6, i64 328}
!33 = !{!29, !12, i64 8}
!34 = !{!10, !12, i64 344}
!35 = !{!10, !11, i64 336}
!36 = !{!29, !6, i64 24}
!37 = !{!11, !11, i64 0}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!10, !11, i64 8}
!41 = !{!15, !11, i64 968}


; 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.44 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [22 x i8], align 1

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

declare void @mbedtls_debug_print_buf(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare hidden void @ssl_set_timer(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_resend(ptr noundef %0) local_unnamed_addr #2 {
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 2591, ptr noundef nonnull @.str.44) #3
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 972
  %5 = load i8, ptr %4, align 4, !tbaa !13
  %.not = icmp eq i8 %5, 1
  br i1 %.not, label %13, label %6

6:                                                ; preds = %1
  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 2595, ptr noundef nonnull @.str.45) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 976
  %9 = load ptr, ptr %8, align 8, !tbaa !25
  %10 = getelementptr inbounds i8, ptr %7, i64 984
  store ptr %9, ptr %10, align 8, !tbaa !26
  tail call void @ssl_swap_epochs(ptr noundef nonnull %0)
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 972
  store i8 1, ptr %12, align 4, !tbaa !13
  br label %13

13:                                               ; preds = %6, %1
  %14 = getelementptr inbounds i8, ptr %0, i64 328
  %15 = getelementptr inbounds i8, ptr %0, i64 344
  %16 = getelementptr inbounds i8, ptr %0, i64 336
  br label %17

17:                                               ; preds = %29, %13
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 984
  %20 = load ptr, ptr %19, align 8, !tbaa !26
  %.not37 = icmp eq ptr %20, null
  br i1 %.not37, label %43, label %21

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %20, i64 16
  %23 = load i8, ptr %22, align 8, !tbaa !27
  %24 = icmp eq i8 %23, 22
  %.pre45 = load ptr, ptr %20, align 8, !tbaa !29
  br i1 %24, label %25, label %29

25:                                               ; preds = %21
  %26 = load i8, ptr %.pre45, align 1, !tbaa !30
  %27 = icmp eq i8 %26, 20
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  tail call void @ssl_swap_epochs(ptr noundef nonnull %0)
  %.pre = load ptr, ptr %20, align 8, !tbaa !29
  br label %29

29:                                               ; preds = %28, %25, %21
  %30 = phi ptr [ %.pre, %28 ], [ %.pre45, %25 ], [ %.pre45, %21 ]
  %31 = load ptr, ptr %14, align 8, !tbaa !31
  %32 = getelementptr inbounds i8, ptr %20, i64 8
  %33 = load i64, ptr %32, align 8, !tbaa !32
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %30, i64 %33, i1 false)
  %34 = load i64, ptr %32, align 8, !tbaa !32
  store i64 %34, ptr %15, align 8, !tbaa !33
  %35 = load i8, ptr %22, align 8, !tbaa !27
  %36 = zext i8 %35 to i32
  store i32 %36, ptr %16, align 8, !tbaa !34
  %37 = getelementptr inbounds i8, ptr %20, i64 24
  %38 = load ptr, ptr %37, align 8, !tbaa !35
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 984
  store ptr %38, ptr %40, align 8, !tbaa !26
  %41 = load ptr, ptr %14, align 8, !tbaa !31
  tail call void @mbedtls_debug_print_buf(ptr noundef %0, i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 2623, ptr noundef nonnull @.str.46, ptr noundef %41, i64 noundef 12) #3
  %42 = tail call i32 @mbedtls_ssl_write_record(ptr noundef %0)
  %.not38.not = icmp eq i32 %42, 0
  br i1 %.not38.not, label %17, label %.thread

.thread:                                          ; preds = %29
  tail call void @mbedtls_debug_print_ret(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 2627, ptr noundef nonnull @.str.47, i32 noundef %42) #3
  br label %53

43:                                               ; preds = %17
  %44 = getelementptr inbounds i8, ptr %0, i64 8
  %45 = load i32, ptr %44, align 8, !tbaa !36
  %46 = icmp eq i32 %45, 16
  %47 = getelementptr inbounds i8, ptr %18, i64 972
  br i1 %46, label %48, label %49

48:                                               ; preds = %43
  store i8 3, ptr %47, align 4, !tbaa !13
  br label %52

49:                                               ; preds = %43
  store i8 2, ptr %47, align 4, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %18, i64 968
  %51 = load i32, ptr %50, align 8, !tbaa !37
  tail call void @ssl_set_timer(ptr noundef nonnull %0, i32 noundef %51)
  br label %52

52:                                               ; preds = %49, %48
  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 2640, ptr noundef nonnull @.str.48) #3
  br label %53

53:                                               ; preds = %.thread, %52
  %.2 = phi i32 [ 0, %52 ], [ %42, %.thread ]
  ret i32 %.2
}

; Function Attrs: nounwind uwtable
declare hidden void @ssl_swap_epochs(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !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, !8, i64 972}
!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 = !{!14, !7, i64 976}
!26 = !{!14, !7, i64 984}
!27 = !{!28, !8, i64 16}
!28 = !{!"mbedtls_ssl_flight_item", !7, i64 0, !11, i64 8, !8, i64 16, !7, i64 24}
!29 = !{!28, !7, i64 0}
!30 = !{!8, !8, i64 0}
!31 = !{!6, !7, i64 328}
!32 = !{!28, !11, i64 8}
!33 = !{!6, !11, i64 344}
!34 = !{!6, !10, i64 336}
!35 = !{!28, !7, i64 24}
!36 = !{!6, !10, i64 8}
!37 = !{!14, !10, i64 968}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass