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

; 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_cache_context = type { ptr, i32, i32 }
%struct.mbedtls_ssl_cache_entry = type { i64, %struct.mbedtls_ssl_session, %struct.mbedtls_asn1_buf, ptr }
%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_asn1_buf = type { i32, i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_cache_get(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %10 = call i64 @time(ptr noundef null) #7
  store i64 %10, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %11, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mbedtls_ssl_cache_context, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  store ptr %14, ptr %8, align 8, !tbaa !5
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %81, %66, %38, %2
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %132

18:                                               ; preds = %15
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %19, ptr %9, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  store ptr %22, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mbedtls_ssl_cache_context, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 8, !tbaa !19
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %39

27:                                               ; preds = %18
  %28 = load i64, ptr %6, align 8, !tbaa !11
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !20
  %32 = sub nsw i64 %28, %31
  %33 = trunc i64 %32 to i32
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mbedtls_ssl_cache_context, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !19
  %37 = icmp sgt i32 %33, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %27
  br label %15, !llvm.loop !21

39:                                               ; preds = %27, %18
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !23
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %43, i32 0, i32 1
  %45 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %44, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !24
  %47 = icmp ne i32 %42, %46
  br i1 %47, label %66, label %48

48:                                               ; preds = %39
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %49, i32 0, i32 2
  %51 = load i32, ptr %50, align 4, !tbaa !25
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 4, !tbaa !26
  %56 = icmp ne i32 %51, %55
  br i1 %56, label %66, label %57

57:                                               ; preds = %48
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %58, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !27
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %62, i32 0, i32 3
  %64 = load i64, ptr %63, align 8, !tbaa !28
  %65 = icmp ne i64 %60, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %57, %48, %39
  br label %15, !llvm.loop !21

67:                                               ; preds = %57
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %68, i32 0, i32 4
  %70 = getelementptr inbounds [32 x i8], ptr %69, i64 0, i64 0
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %71, i32 0, i32 1
  %73 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %72, i32 0, i32 4
  %74 = getelementptr inbounds [32 x i8], ptr %73, i64 0, i64 0
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %75, i32 0, i32 1
  %77 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %76, i32 0, i32 3
  %78 = load i64, ptr %77, align 8, !tbaa !28
  %79 = call i32 @memcmp(ptr noundef %70, ptr noundef %74, i64 noundef %78) #8
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %67
  br label %15, !llvm.loop !21

82:                                               ; preds = %67
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %83, i32 0, i32 5
  %85 = getelementptr inbounds [48 x i8], ptr %84, i64 0, i64 0
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %86, i32 0, i32 1
  %88 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %87, i32 0, i32 5
  %89 = getelementptr inbounds [48 x i8], ptr %88, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %85, ptr align 8 %89, i64 48, i1 false)
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %90, i32 0, i32 1
  %92 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %91, i32 0, i32 7
  %93 = load i32, ptr %92, align 8, !tbaa !29
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %94, i32 0, i32 7
  store i32 %93, ptr %95, align 8, !tbaa !30
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %97, i32 0, i32 2
  %99 = load ptr, ptr %98, align 8, !tbaa !31
  %100 = icmp ne ptr %99, null
  br i1 %100, label %101, label %131

101:                                              ; preds = %82
  %102 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 552) #9
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %103, i32 0, i32 6
  store ptr %102, ptr %104, align 8, !tbaa !32
  %105 = icmp eq ptr %102, null
  br i1 %105, label %106, label %107

106:                                              ; preds = %101
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %133

107:                                              ; preds = %101
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %108, i32 0, i32 6
  %110 = load ptr, ptr %109, align 8, !tbaa !32
  call void @mbedtls_x509_crt_init(ptr noundef %110)
  %111 = load ptr, ptr %4, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %111, i32 0, i32 6
  %113 = load ptr, ptr %112, align 8, !tbaa !32
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %114, i32 0, i32 2
  %116 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !31
  %118 = load ptr, ptr %9, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.mbedtls_ssl_cache_entry, ptr %118, i32 0, i32 2
  %120 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %119, i32 0, i32 1
  %121 = load i64, ptr %120, align 8, !tbaa !33
  %122 = call i32 @mbedtls_x509_crt_parse(ptr noundef %113, ptr noundef %117, i64 noundef %121)
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %130

124:                                              ; preds = %107
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %125, i32 0, i32 6
  %127 = load ptr, ptr %126, align 8, !tbaa !32
  call void @free(ptr noundef %127) #7
  %128 = load ptr, ptr %4, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.mbedtls_ssl_session, ptr %128, i32 0, i32 6
  store ptr null, ptr %129, align 8, !tbaa !32
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %133

130:                                              ; preds = %107
  br label %131

131:                                              ; preds = %130, %82
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %133

132:                                              ; preds = %15
  br label %133

133:                                              ; preds = %132, %131, %124, %106
  %134 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  ret i32 %134
}

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

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

; 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) #4

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #5

declare void @mbedtls_x509_crt_init(ptr noundef) #6

declare i32 @mbedtls_x509_crt_parse(ptr noundef, ptr noundef, i64 noundef) #6

; Function Attrs: nounwind
declare void @free(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 = { 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 #3 = { nounwind willreturn memory(read) "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind allocsize(0,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 #6 = { "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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0,1) }

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"mbedtls_ssl_cache_context", !6, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!16, !6, i64 184}
!16 = !{!"mbedtls_ssl_cache_entry", !12, i64 0, !17, i64 8, !18, i64 160, !6, i64 184}
!17 = !{!"mbedtls_ssl_session", !12, i64 0, !10, i64 8, !10, i64 12, !12, i64 16, !7, i64 24, !7, i64 56, !6, i64 104, !10, i64 112, !6, i64 120, !12, i64 128, !10, i64 136, !7, i64 140, !10, i64 144, !10, i64 148}
!18 = !{!"mbedtls_asn1_buf", !10, i64 0, !12, i64 8, !6, i64 16}
!19 = !{!14, !10, i64 8}
!20 = !{!16, !12, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!17, !10, i64 8}
!24 = !{!16, !10, i64 16}
!25 = !{!17, !10, i64 12}
!26 = !{!16, !10, i64 20}
!27 = !{!17, !12, i64 16}
!28 = !{!16, !12, i64 24}
!29 = !{!16, !10, i64 120}
!30 = !{!17, !10, i64 112}
!31 = !{!16, !6, i64 176}
!32 = !{!17, !6, i64 104}
!33 = !{!16, !12, i64 168}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @mbedtls_ssl_cache_get(ptr nocapture noundef readonly %0, ptr nocapture noundef %1) local_unnamed_addr #0 {
  %3 = tail call i64 @time(ptr noundef null) #7
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %.not42 = icmp eq ptr %4, null
  br i1 %.not42, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %.not34 = icmp eq i32 %6, 0
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = getelementptr inbounds i8, ptr %1, i64 12
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  br i1 %.not34, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  %11 = load i32, ptr %7, align 8, !tbaa !12
  br label %12

12:                                               ; preds = %.backedge.us, %.lr.ph.split.us
  %.043.us = phi ptr [ %4, %.lr.ph.split.us ], [ %14, %.backedge.us ]
  %13 = getelementptr inbounds i8, ptr %.043.us, i64 184
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %.043.us, i64 16
  %16 = load i32, ptr %15, align 8, !tbaa !18
  %.not35.us = icmp eq i32 %11, %16
  br i1 %.not35.us, label %17, label %.backedge.us

17:                                               ; preds = %12
  %18 = load i32, ptr %8, align 4, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %.043.us, i64 20
  %20 = load i32, ptr %19, align 4, !tbaa !20
  %.not36.us = icmp eq i32 %18, %20
  br i1 %.not36.us, label %21, label %.backedge.us

21:                                               ; preds = %17
  %22 = load i64, ptr %9, align 8, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %.043.us, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !22
  %.not37.us = icmp eq i64 %22, %24
  br i1 %.not37.us, label %25, label %.backedge.us

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %.043.us, i64 32
  %bcmp.us = tail call i32 @bcmp(ptr nonnull %10, ptr nonnull %26, i64 %22)
  %.not38.us = icmp eq i32 %bcmp.us, 0
  br i1 %.not38.us, label %.split.us, label %.backedge.us

.backedge.us:                                     ; preds = %12, %17, %21, %25
  %.not.us = icmp eq ptr %14, null
  br i1 %.not.us, label %.loopexit, label %12, !llvm.loop !23

.lr.ph.split:                                     ; preds = %.lr.ph, %.backedge
  %.043 = phi ptr [ %28, %.backedge ], [ %4, %.lr.ph ]
  %27 = getelementptr inbounds i8, ptr %.043, i64 184
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load i64, ptr %.043, align 8, !tbaa !25
  %30 = sub nsw i64 %3, %29
  %31 = trunc i64 %30 to i32
  %32 = icmp slt i32 %6, %31
  br i1 %32, label %.backedge, label %33

33:                                               ; preds = %.lr.ph.split
  %34 = load i32, ptr %7, align 8, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %.043, i64 16
  %36 = load i32, ptr %35, align 8, !tbaa !18
  %.not35 = icmp eq i32 %34, %36
  br i1 %.not35, label %37, label %.backedge

37:                                               ; preds = %33
  %38 = load i32, ptr %8, align 4, !tbaa !19
  %39 = getelementptr inbounds i8, ptr %.043, i64 20
  %40 = load i32, ptr %39, align 4, !tbaa !20
  %.not36 = icmp eq i32 %38, %40
  br i1 %.not36, label %41, label %.backedge

41:                                               ; preds = %37
  %42 = load i64, ptr %9, align 8, !tbaa !21
  %43 = getelementptr inbounds i8, ptr %.043, i64 24
  %44 = load i64, ptr %43, align 8, !tbaa !22
  %.not37 = icmp eq i64 %42, %44
  br i1 %.not37, label %45, label %.backedge

.backedge:                                        ; preds = %33, %37, %41, %.lr.ph.split, %45
  %.not = icmp eq ptr %28, null
  br i1 %.not, label %.loopexit, label %.lr.ph.split, !llvm.loop !23

45:                                               ; preds = %41
  %46 = getelementptr inbounds i8, ptr %.043, i64 32
  %bcmp = tail call i32 @bcmp(ptr nonnull %10, ptr nonnull %46, i64 %42)
  %.not38 = icmp eq i32 %bcmp, 0
  br i1 %.not38, label %.split.us, label %.backedge

.split.us:                                        ; preds = %45, %25
  %.us-phi = phi ptr [ %.043.us, %25 ], [ %.043, %45 ]
  %47 = getelementptr inbounds i8, ptr %1, i64 56
  %48 = getelementptr inbounds i8, ptr %.us-phi, i64 64
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %47, ptr noundef nonnull align 8 dereferenceable(48) %48, i64 48, i1 false)
  %49 = getelementptr inbounds i8, ptr %.us-phi, i64 120
  %50 = load i32, ptr %49, align 8, !tbaa !26
  %51 = getelementptr inbounds i8, ptr %1, i64 112
  store i32 %50, ptr %51, align 8, !tbaa !27
  %52 = getelementptr inbounds i8, ptr %.us-phi, i64 176
  %53 = load ptr, ptr %52, align 8, !tbaa !28
  %.not39 = icmp eq ptr %53, null
  br i1 %.not39, label %.loopexit, label %54

54:                                               ; preds = %.split.us
  %55 = tail call noalias dereferenceable_or_null(552) ptr @calloc(i64 noundef 1, i64 noundef 552) #8
  %56 = getelementptr inbounds i8, ptr %1, i64 104
  store ptr %55, ptr %56, align 8, !tbaa !29
  %57 = icmp eq ptr %55, null
  br i1 %57, label %.loopexit, label %58

58:                                               ; preds = %54
  tail call void @mbedtls_x509_crt_init(ptr noundef nonnull %55) #7
  %59 = load ptr, ptr %56, align 8, !tbaa !29
  %60 = load ptr, ptr %52, align 8, !tbaa !28
  %61 = getelementptr inbounds i8, ptr %.us-phi, i64 168
  %62 = load i64, ptr %61, align 8, !tbaa !30
  %63 = tail call i32 @mbedtls_x509_crt_parse(ptr noundef %59, ptr noundef %60, i64 noundef %62) #7
  %.not40 = icmp eq i32 %63, 0
  br i1 %.not40, label %.loopexit, label %64

64:                                               ; preds = %58
  %65 = load ptr, ptr %56, align 8, !tbaa !29
  tail call void @free(ptr noundef %65) #7
  store ptr null, ptr %56, align 8, !tbaa !29
  br label %.loopexit

.loopexit:                                        ; preds = %.backedge, %.backedge.us, %2, %.split.us, %58, %54, %64
  %.030 = phi i32 [ 1, %64 ], [ 1, %54 ], [ 0, %58 ], [ 0, %.split.us ], [ 1, %2 ], [ 1, %.backedge.us ], [ 1, %.backedge ]
  ret i32 %.030
}

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #1

; 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: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

declare void @mbedtls_x509_crt_init(ptr noundef) local_unnamed_addr #4

declare i32 @mbedtls_x509_crt_parse(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6

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 = { 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 #4 = { "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 = { 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 #6 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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 0}
!6 = !{!"mbedtls_ssl_cache_context", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !10, i64 8}
!13 = !{!"mbedtls_ssl_session", !14, i64 0, !10, i64 8, !10, i64 12, !14, i64 16, !8, i64 24, !8, i64 56, !7, i64 104, !10, i64 112, !7, i64 120, !14, i64 128, !10, i64 136, !8, i64 140, !10, i64 144, !10, i64 148}
!14 = !{!"long", !8, i64 0}
!15 = !{!16, !7, i64 184}
!16 = !{!"mbedtls_ssl_cache_entry", !14, i64 0, !13, i64 8, !17, i64 160, !7, i64 184}
!17 = !{!"mbedtls_asn1_buf", !10, i64 0, !14, i64 8, !7, i64 16}
!18 = !{!16, !10, i64 16}
!19 = !{!13, !10, i64 12}
!20 = !{!16, !10, i64 20}
!21 = !{!13, !14, i64 16}
!22 = !{!16, !14, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!16, !14, i64 0}
!26 = !{!16, !10, i64 120}
!27 = !{!13, !10, i64 112}
!28 = !{!16, !7, i64 176}
!29 = !{!13, !7, i64 104}
!30 = !{!16, !14, i64 168}


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