; 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_session = type { i64, i32, i32, i64, [32 x i8], [48 x i8], ptr, i32, ptr, i64, i32, i8, i32, 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.112 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [20 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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mbedtls_ssl_handshake_wrapup(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %4, i32 0, i32 15
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %6, i32 0, i32 34
  %8 = load i32, ptr %7, align 4, !tbaa !14
  store i32 %8, ptr %3, align 4, !tbaa !26
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %9, i32 noundef 3, ptr noundef @.str, i32 noundef 5171, ptr noundef @.str.112)
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %10, i32 0, i32 2
  %12 = load i32, ptr %11, align 4, !tbaa !27
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %19

14:                                               ; preds = %1
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %15, i32 0, i32 2
  store i32 2, ptr %16, align 4, !tbaa !27
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %17, i32 0, i32 3
  store i32 0, ptr %18, align 8, !tbaa !28
  br label %19

19:                                               ; preds = %14, %1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %20, i32 0, i32 13
  %22 = load ptr, ptr %21, align 8, !tbaa !29
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %40

24:                                               ; preds = %19
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %25, i32 0, i32 13
  %27 = load ptr, ptr %26, align 8, !tbaa !29
  %28 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %27, i32 0, i32 13
  %29 = load i32, ptr %28, align 4, !tbaa !30
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %30, i32 0, i32 14
  %32 = load ptr, ptr %31, align 8, !tbaa !32
  %33 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %32, i32 0, i32 13
  store i32 %29, ptr %33, align 4, !tbaa !30
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %34, i32 0, i32 13
  %36 = load ptr, ptr %35, align 8, !tbaa !29
  call void @mbedtls_ssl_session_free(ptr noundef %36)
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %37, i32 0, i32 13
  %39 = load ptr, ptr %38, align 8, !tbaa !29
  call void @free(ptr noundef %39) #4
  br label %40

40:                                               ; preds = %24, %19
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %41, i32 0, i32 14
  %43 = load ptr, ptr %42, align 8, !tbaa !32
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %44, i32 0, i32 13
  store ptr %43, ptr %45, align 8, !tbaa !29
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %46, i32 0, i32 14
  store ptr null, ptr %47, align 8, !tbaa !32
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !33
  %51 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %50, i32 0, i32 6
  %52 = load ptr, ptr %51, align 8, !tbaa !34
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %83

54:                                               ; preds = %40
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %55, i32 0, i32 13
  %57 = load ptr, ptr %56, align 8, !tbaa !29
  %58 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %57, i32 0, i32 3
  %59 = load i64, ptr %58, align 8, !tbaa !36
  %60 = icmp ne i64 %59, 0
  br i1 %60, label %61, label %83

61:                                               ; preds = %54
  %62 = load i32, ptr %3, align 4, !tbaa !26
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %83

64:                                               ; preds = %61
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !33
  %68 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %67, i32 0, i32 6
  %69 = load ptr, ptr %68, align 8, !tbaa !34
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !33
  %73 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %72, i32 0, i32 7
  %74 = load ptr, ptr %73, align 8, !tbaa !37
  %75 = load ptr, ptr %2, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %75, i32 0, i32 13
  %77 = load ptr, ptr %76, align 8, !tbaa !29
  %78 = call i32 %69(ptr noundef %74, ptr noundef %77)
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %82

80:                                               ; preds = %64
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %81, i32 noundef 1, ptr noundef @.str, i32 noundef 5206, ptr noundef @.str.113)
  br label %82

82:                                               ; preds = %80, %64
  br label %83

83:                                               ; preds = %82, %61, %54, %40
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %84, i32 0, i32 0
  %86 = load ptr, ptr %85, align 8, !tbaa !33
  %87 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %86, i32 0, i32 46
  %88 = load i32, ptr %87, align 4
  %89 = lshr i32 %88, 1
  %90 = and i32 %89, 1
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %92, label %102

92:                                               ; preds = %83
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %93, i32 0, i32 15
  %95 = load ptr, ptr %94, align 8, !tbaa !9
  %96 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %95, i32 0, i32 18
  %97 = load ptr, ptr %96, align 8, !tbaa !38
  %98 = icmp ne ptr %97, null
  br i1 %98, label %99, label %102

99:                                               ; preds = %92
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ssl_set_timer(ptr noundef %100, i32 noundef 0)
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %101, i32 noundef 3, ptr noundef @.str, i32 noundef 5218, ptr noundef @.str.114)
  br label %104

102:                                              ; preds = %92, %83
  %103 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ssl_handshake_wrapup_free_hs_transform(ptr noundef %103)
  br label %104

104:                                              ; preds = %102, %99
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %105, i32 0, i32 1
  %107 = load i32, ptr %106, align 8, !tbaa !39
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %106, align 8, !tbaa !39
  %109 = load ptr, ptr %2, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %109, i32 noundef 3, ptr noundef @.str, i32 noundef 5226, ptr noundef @.str.115)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_ssl_session_free(ptr noundef) #2

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 = { 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 "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, !11, i64 2684}
!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 = !{!11, !11, i64 0}
!27 = !{!10, !11, i64 12}
!28 = !{!10, !11, i64 16}
!29 = !{!10, !6, i64 80}
!30 = !{!31, !11, i64 148}
!31 = !{!"mbedtls_ssl_session", !12, i64 0, !11, i64 8, !11, i64 12, !12, i64 16, !7, i64 24, !7, i64 56, !6, i64 104, !11, i64 112, !6, i64 120, !12, i64 128, !11, i64 136, !7, i64 140, !11, i64 144, !11, i64 148}
!32 = !{!10, !6, i64 88}
!33 = !{!10, !6, i64 0}
!34 = !{!35, !6, i64 72}
!35 = !{!"mbedtls_ssl_config", !7, i64 0, !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, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !18, i64 248, !18, i64 272, !6, i64 296, !12, i64 304, !6, i64 312, !12, i64 320, !6, i64 328, !11, i64 336, !11, i64 340, !11, i64 344, !11, i64 348, !7, i64 352, !11, i64 360, !11, i64 364, !7, i64 368, !7, i64 369, !7, i64 370, !7, i64 371, !11, i64 372, !11, i64 372, !11, i64 372, !11, i64 372, !11, i64 372, !11, i64 372, !11, i64 373, !11, i64 373, !11, i64 373, !11, i64 373, !11, i64 373, !11, i64 373, !11, i64 374, !11, i64 374, !11, i64 374}
!36 = !{!31, !12, i64 16}
!37 = !{!35, !6, i64 80}
!38 = !{!15, !6, i64 976}
!39 = !{!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.112 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.113 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.114 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [20 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mbedtls_ssl_handshake_wrapup(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 2684
  %5 = load i32, ptr %4, align 4, !tbaa !13
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %0, i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 5171, ptr noundef nonnull @.str.112) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = load i32, ptr %6, align 4, !tbaa !25
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %9, label %11

9:                                                ; preds = %1
  store i32 2, ptr %6, align 4, !tbaa !25
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 0, ptr %10, align 8, !tbaa !26
  br label %11

11:                                               ; preds = %9, %1
  %12 = getelementptr inbounds i8, ptr %0, i64 80
  %13 = load ptr, ptr %12, align 8, !tbaa !27
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %21, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %13, i64 148
  %16 = load i32, ptr %15, align 4, !tbaa !28
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %18 = load ptr, ptr %17, align 8, !tbaa !30
  %19 = getelementptr inbounds i8, ptr %18, i64 148
  store i32 %16, ptr %19, align 4, !tbaa !28
  tail call void @mbedtls_ssl_session_free(ptr noundef nonnull %13)
  %20 = load ptr, ptr %12, align 8, !tbaa !27
  tail call void @free(ptr noundef %20) #3
  br label %21

21:                                               ; preds = %14, %11
  %22 = getelementptr inbounds i8, ptr %0, i64 88
  %23 = load ptr, ptr %22, align 8, !tbaa !30
  store ptr %23, ptr %12, align 8, !tbaa !27
  store ptr null, ptr %22, align 8, !tbaa !30
  %24 = load ptr, ptr %0, align 8, !tbaa !31
  %25 = getelementptr inbounds i8, ptr %24, i64 72
  %26 = load ptr, ptr %25, align 8, !tbaa !32
  %.not28 = icmp eq ptr %26, null
  br i1 %.not28, label %37, label %27

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %23, i64 16
  %29 = load i64, ptr %28, align 8, !tbaa !34
  %30 = icmp ne i64 %29, 0
  %31 = icmp eq i32 %5, 0
  %or.cond = select i1 %30, i1 %31, i1 false
  br i1 %or.cond, label %32, label %37

32:                                               ; preds = %27
  %33 = getelementptr inbounds i8, ptr %24, i64 80
  %34 = load ptr, ptr %33, align 8, !tbaa !35
  %35 = tail call i32 %26(ptr noundef %34, ptr noundef nonnull %23) #3
  %.not29 = icmp eq i32 %35, 0
  br i1 %.not29, label %37, label %36

36:                                               ; preds = %32
  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 5206, ptr noundef nonnull @.str.113) #3
  br label %37

37:                                               ; preds = %32, %36, %27, %21
  %38 = load ptr, ptr %0, align 8, !tbaa !31
  %39 = getelementptr inbounds i8, ptr %38, i64 372
  %40 = load i32, ptr %39, align 4
  %41 = and i32 %40, 2
  %.not30 = icmp eq i32 %41, 0
  br i1 %.not30, label %47, label %42

42:                                               ; preds = %37
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 976
  %45 = load ptr, ptr %44, align 8, !tbaa !36
  %.not31 = icmp eq ptr %45, null
  br i1 %.not31, label %47, label %46

46:                                               ; preds = %42
  tail call void @ssl_set_timer(ptr noundef nonnull %0, i32 noundef 0)
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 5218, ptr noundef nonnull @.str.114) #3
  br label %48

47:                                               ; preds = %42, %37
  tail call void @ssl_handshake_wrapup_free_hs_transform(ptr noundef nonnull %0)
  br label %48

48:                                               ; preds = %47, %46
  %49 = getelementptr inbounds i8, ptr %0, i64 8
  %50 = load i32, ptr %49, align 8, !tbaa !37
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %49, align 8, !tbaa !37
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef nonnull %0, i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 5226, ptr noundef nonnull @.str.115) #3
  ret void
}

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

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 = { 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 #2 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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, !10, i64 2684}
!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, !10, i64 12}
!26 = !{!6, !10, i64 16}
!27 = !{!6, !7, i64 80}
!28 = !{!29, !10, i64 148}
!29 = !{!"mbedtls_ssl_session", !11, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !8, i64 24, !8, i64 56, !7, i64 104, !10, i64 112, !7, i64 120, !11, i64 128, !10, i64 136, !8, i64 140, !10, i64 144, !10, i64 148}
!30 = !{!6, !7, i64 88}
!31 = !{!6, !7, i64 0}
!32 = !{!33, !7, i64 72}
!33 = !{!"mbedtls_ssl_config", !8, i64 0, !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, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !17, i64 248, !17, i64 272, !7, i64 296, !11, i64 304, !7, i64 312, !11, i64 320, !7, i64 328, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !8, i64 352, !10, i64 360, !10, i64 364, !8, i64 368, !8, i64 369, !8, i64 370, !8, i64 371, !10, i64 372, !10, i64 372, !10, i64 372, !10, i64 372, !10, i64 372, !10, i64 372, !10, i64 373, !10, i64 373, !10, i64 373, !10, i64 373, !10, i64 373, !10, i64 373, !10, i64 374, !10, i64 374, !10, i64 374}
!34 = !{!29, !11, i64 16}
!35 = !{!33, !7, i64 80}
!36 = !{!14, !7, i64 976}
!37 = !{!6, !10, i64 8}


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