; 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_transform = type { ptr, i32, i64, i64, i64, i64, [16 x i8], [16 x i8], %struct.mbedtls_md_context_t, %struct.mbedtls_md_context_t, %struct.mbedtls_cipher_context_t, %struct.mbedtls_cipher_context_t }
%struct.mbedtls_md_context_t = type { ptr, ptr, ptr }
%struct.mbedtls_cipher_context_t = type { ptr, i32, i32, ptr, ptr, [16 x i8], i64, [16 x i8], i64, ptr }
%struct.mbedtls_ssl_ciphersuite_t = type { i32, ptr, i32, i32, i32, i32, i32, i32, i32, i8 }
%struct.mbedtls_ssl_config = type { [4 x ptr], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.mbedtls_mpi, %struct.mbedtls_mpi, ptr, i64, ptr, i64, ptr, i32, i32, i32, i32, [8 x i8], i32, i32, i8, i8, i8, i8, i32 }
%struct.mbedtls_mpi = type { i32, i64, ptr }
%struct.mbedtls_x509_crt = type { %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, i32, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_named_data, %struct.mbedtls_asn1_named_data, %struct.mbedtls_x509_time, %struct.mbedtls_x509_time, %struct.mbedtls_pk_context, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_sequence, i32, i32, i32, i32, %struct.mbedtls_asn1_sequence, i8, %struct.mbedtls_asn1_buf, i32, i32, ptr, ptr }
%struct.mbedtls_asn1_named_data = type { %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, ptr, i8 }
%struct.mbedtls_x509_time = type { i32, i32, i32, i32, i32, i32 }
%struct.mbedtls_pk_context = type { ptr, ptr }
%struct.mbedtls_asn1_sequence = type { %struct.mbedtls_asn1_buf, ptr }
%struct.mbedtls_asn1_buf = type { i32, i64, ptr }

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [21 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 i32 @mbedtls_ssl_write_record(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_write_certificate(ptr noundef %0) #3 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 -28800, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %10, i32 0, i32 19
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %struct.mbedtls_ssl_transform, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  store ptr %14, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %15, i32 noundef 2, ptr noundef @.str, i32 noundef 4203, ptr noundef @.str.82)
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mbedtls_ssl_ciphersuite_t, ptr %16, i32 0, i32 4
  %18 = load i32, ptr %17, align 8, !tbaa !19
  %19 = icmp eq i32 %18, 5
  br i1 %19, label %35, label %20

20:                                               ; preds = %1
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mbedtls_ssl_ciphersuite_t, ptr %21, i32 0, i32 4
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = icmp eq i32 %23, 6
  br i1 %24, label %35, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mbedtls_ssl_ciphersuite_t, ptr %26, i32 0, i32 4
  %28 = load i32, ptr %27, align 8, !tbaa !19
  %29 = icmp eq i32 %28, 8
  br i1 %29, label %35, label %30

30:                                               ; preds = %25
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mbedtls_ssl_ciphersuite_t, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !19
  %34 = icmp eq i32 %33, 11
  br i1 %34, label %35, label %41

35:                                               ; preds = %30, %25, %20, %1
  %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 2, ptr noundef @.str, i32 noundef 4210, ptr noundef @.str.83)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !21
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %38, align 8, !tbaa !21
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

41:                                               ; preds = %30
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !22
  %45 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %44, i32 0, i32 46
  %46 = load i32, ptr %45, align 4
  %47 = and i32 %46, 1
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %61

49:                                               ; preds = %41
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %50, i32 0, i32 50
  %52 = load i32, ptr %51, align 4, !tbaa !23
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %49
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %55, i32 noundef 2, ptr noundef @.str, i32 noundef 4220, ptr noundef @.str.83)
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 8, !tbaa !21
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %57, align 8, !tbaa !21
  store i32 0, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

60:                                               ; preds = %49
  br label %61

61:                                               ; preds = %60, %41
  %62 = load ptr, ptr %3, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !22
  %65 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %64, i32 0, i32 46
  %66 = load i32, ptr %65, align 4
  %67 = and i32 %66, 1
  %68 = icmp eq i32 %67, 1
  br i1 %68, label %69, label %76

69:                                               ; preds = %61
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = call ptr @mbedtls_ssl_own_cert(ptr noundef %70)
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %75

73:                                               ; preds = %69
  %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 4249, ptr noundef @.str.84)
  store i32 -30080, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

75:                                               ; preds = %69
  br label %76

76:                                               ; preds = %75, %61
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call ptr @mbedtls_ssl_own_cert(ptr noundef %78)
  call void @mbedtls_debug_print_crt(ptr noundef %77, i32 noundef 3, ptr noundef @.str, i32 noundef 4255, ptr noundef @.str.85, ptr noundef %79)
  store i64 7, ptr %5, align 8, !tbaa !24
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call ptr @mbedtls_ssl_own_cert(ptr noundef %80)
  store ptr %81, ptr %7, align 8, !tbaa !5
  br label %82

82:                                               ; preds = %100, %76
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %144

85:                                               ; preds = %82
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.mbedtls_x509_crt, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %87, i32 0, i32 1
  %89 = load i64, ptr %88, align 8, !tbaa !25
  store i64 %89, ptr %6, align 8, !tbaa !24
  %90 = load i64, ptr %6, align 8, !tbaa !24
  %91 = load i64, ptr %5, align 8, !tbaa !24
  %92 = sub i64 16381, %91
  %93 = icmp ugt i64 %90, %92
  br i1 %93, label %94, label %100

94:                                               ; preds = %85
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = load i64, ptr %5, align 8, !tbaa !24
  %97 = add i64 %96, 3
  %98 = load i64, ptr %6, align 8, !tbaa !24
  %99 = add i64 %97, %98
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %95, i32 noundef 1, ptr noundef @.str, i32 noundef 4275, ptr noundef @.str.86, i64 noundef %99, i32 noundef 16384)
  store i32 -29952, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

100:                                              ; preds = %85
  %101 = load i64, ptr %6, align 8, !tbaa !24
  %102 = lshr i64 %101, 16
  %103 = trunc i64 %102 to i8
  %104 = load ptr, ptr %3, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %104, i32 0, i32 45
  %106 = load ptr, ptr %105, align 8, !tbaa !32
  %107 = load i64, ptr %5, align 8, !tbaa !24
  %108 = getelementptr inbounds i8, ptr %106, i64 %107
  store i8 %103, ptr %108, align 1, !tbaa !33
  %109 = load i64, ptr %6, align 8, !tbaa !24
  %110 = lshr i64 %109, 8
  %111 = trunc i64 %110 to i8
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %112, i32 0, i32 45
  %114 = load ptr, ptr %113, align 8, !tbaa !32
  %115 = load i64, ptr %5, align 8, !tbaa !24
  %116 = add i64 %115, 1
  %117 = getelementptr inbounds i8, ptr %114, i64 %116
  store i8 %111, ptr %117, align 1, !tbaa !33
  %118 = load i64, ptr %6, align 8, !tbaa !24
  %119 = trunc i64 %118 to i8
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %120, i32 0, i32 45
  %122 = load ptr, ptr %121, align 8, !tbaa !32
  %123 = load i64, ptr %5, align 8, !tbaa !24
  %124 = add i64 %123, 2
  %125 = getelementptr inbounds i8, ptr %122, i64 %124
  store i8 %119, ptr %125, align 1, !tbaa !33
  %126 = load i64, ptr %5, align 8, !tbaa !24
  %127 = add i64 %126, 3
  store i64 %127, ptr %5, align 8, !tbaa !24
  %128 = load ptr, ptr %3, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %128, i32 0, i32 45
  %130 = load ptr, ptr %129, align 8, !tbaa !32
  %131 = load i64, ptr %5, align 8, !tbaa !24
  %132 = getelementptr inbounds i8, ptr %130, i64 %131
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.mbedtls_x509_crt, ptr %133, i32 0, i32 0
  %135 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %134, i32 0, i32 2
  %136 = load ptr, ptr %135, align 8, !tbaa !34
  %137 = load i64, ptr %6, align 8, !tbaa !24
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %132, ptr align 1 %136, i64 %137, i1 false)
  %138 = load i64, ptr %6, align 8, !tbaa !24
  %139 = load i64, ptr %5, align 8, !tbaa !24
  %140 = add i64 %139, %138
  store i64 %140, ptr %5, align 8, !tbaa !24
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.mbedtls_x509_crt, ptr %141, i32 0, i32 26
  %143 = load ptr, ptr %142, align 8, !tbaa !35
  store ptr %143, ptr %7, align 8, !tbaa !5
  br label %82, !llvm.loop !36

144:                                              ; preds = %82
  %145 = load i64, ptr %5, align 8, !tbaa !24
  %146 = sub i64 %145, 7
  %147 = lshr i64 %146, 16
  %148 = trunc i64 %147 to i8
  %149 = load ptr, ptr %3, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %149, i32 0, i32 45
  %151 = load ptr, ptr %150, align 8, !tbaa !32
  %152 = getelementptr inbounds i8, ptr %151, i64 4
  store i8 %148, ptr %152, align 1, !tbaa !33
  %153 = load i64, ptr %5, align 8, !tbaa !24
  %154 = sub i64 %153, 7
  %155 = lshr i64 %154, 8
  %156 = trunc i64 %155 to i8
  %157 = load ptr, ptr %3, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %157, i32 0, i32 45
  %159 = load ptr, ptr %158, align 8, !tbaa !32
  %160 = getelementptr inbounds i8, ptr %159, i64 5
  store i8 %156, ptr %160, align 1, !tbaa !33
  %161 = load i64, ptr %5, align 8, !tbaa !24
  %162 = sub i64 %161, 7
  %163 = trunc i64 %162 to i8
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %164, i32 0, i32 45
  %166 = load ptr, ptr %165, align 8, !tbaa !32
  %167 = getelementptr inbounds i8, ptr %166, i64 6
  store i8 %163, ptr %167, align 1, !tbaa !33
  %168 = load i64, ptr %5, align 8, !tbaa !24
  %169 = load ptr, ptr %3, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %169, i32 0, i32 47
  store i64 %168, ptr %170, align 8, !tbaa !38
  %171 = load ptr, ptr %3, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %171, i32 0, i32 46
  store i32 22, ptr %172, align 8, !tbaa !39
  %173 = load ptr, ptr %3, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %173, i32 0, i32 45
  %175 = load ptr, ptr %174, align 8, !tbaa !32
  %176 = getelementptr inbounds i8, ptr %175, i64 0
  store i8 11, ptr %176, align 1, !tbaa !33
  %177 = load ptr, ptr %3, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %177, i32 0, i32 1
  %179 = load i32, ptr %178, align 8, !tbaa !21
  %180 = add nsw i32 %179, 1
  store i32 %180, ptr %178, align 8, !tbaa !21
  %181 = load ptr, ptr %3, align 8, !tbaa !5
  %182 = call i32 @mbedtls_ssl_write_record(ptr noundef %181)
  store i32 %182, ptr %4, align 4, !tbaa !9
  %183 = icmp ne i32 %182, 0
  br i1 %183, label %184, label %188

184:                                              ; preds = %144
  %185 = load ptr, ptr %3, align 8, !tbaa !5
  %186 = load i32, ptr %4, align 4, !tbaa !9
  call void @mbedtls_debug_print_ret(ptr noundef %185, i32 noundef 1, ptr noundef @.str, i32 noundef 4303, ptr noundef @.str.47, i32 noundef %186)
  %187 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %187, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

188:                                              ; preds = %144
  %189 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %189, i32 noundef 2, ptr noundef @.str, i32 noundef 4307, ptr noundef @.str.87)
  %190 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %190, ptr %2, align 4
  store i32 1, ptr %9, align 4
  br label %191

191:                                              ; preds = %188, %184, %94, %73, %54, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %192 = load i32, ptr %2, align 4
  ret i32 %192
}

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

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

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 128}
!12 = !{!"mbedtls_ssl_context", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !10, i64 216, !13, i64 224, !13, i64 232, !14, i64 240, !13, i64 248, !13, i64 256, !13, i64 264, !13, i64 272, !10, i64 280, !10, i64 284, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !10, i64 336, !13, i64 344, !13, i64 352, !7, i64 360, !10, i64 364, !6, i64 368, !6, i64 376, !6, i64 384, !13, i64 392, !10, i64 400, !13, i64 408, !7, i64 416, !7, i64 428}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"mbedtls_ssl_transform", !6, i64 0, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !7, i64 48, !7, i64 64, !17, i64 80, !17, i64 104, !18, i64 128, !18, i64 216}
!17 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !7, i64 32, !13, i64 48, !7, i64 56, !13, i64 72, !6, i64 80}
!19 = !{!20, !10, i64 24}
!20 = !{!"mbedtls_ssl_ciphersuite_t", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44}
!21 = !{!12, !10, i64 8}
!22 = !{!12, !6, i64 0}
!23 = !{!12, !10, i64 364}
!24 = !{!13, !13, i64 0}
!25 = !{!26, !13, i64 8}
!26 = !{!"mbedtls_x509_crt", !27, i64 0, !27, i64 24, !10, i64 48, !27, i64 56, !27, i64 80, !27, i64 104, !27, i64 128, !28, i64 152, !28, i64 216, !29, i64 280, !29, i64 304, !30, i64 328, !27, i64 344, !27, i64 368, !27, i64 392, !31, i64 416, !10, i64 448, !10, i64 452, !10, i64 456, !10, i64 460, !31, i64 464, !7, i64 496, !27, i64 504, !10, i64 528, !10, i64 532, !6, i64 536, !6, i64 544}
!27 = !{!"mbedtls_asn1_buf", !10, i64 0, !13, i64 8, !6, i64 16}
!28 = !{!"mbedtls_asn1_named_data", !27, i64 0, !27, i64 24, !6, i64 48, !7, i64 56}
!29 = !{!"mbedtls_x509_time", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!30 = !{!"", !6, i64 0, !6, i64 8}
!31 = !{!"mbedtls_asn1_sequence", !27, i64 0, !6, i64 24}
!32 = !{!12, !6, i64 328}
!33 = !{!7, !7, i64 0}
!34 = !{!26, !6, i64 16}
!35 = !{!26, !6, i64 544}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!12, !13, i64 344}
!39 = !{!12, !10, i64 336}


; 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.47 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [21 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_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 dso_local i32 @mbedtls_ssl_write_record(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_write_certificate(ptr noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 128
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !13
  tail call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %0, i32 noundef 2, ptr noundef nonnull @.str, i32 noundef 4203, ptr noundef nonnull @.str.82) #4
  %5 = getelementptr inbounds i8, ptr %4, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !17
  switch i32 %6, label %11 [
    i32 5, label %7
    i32 6, label %7
    i32 8, label %7
    i32 11, label %7
  ]

7:                                                ; preds = %1, %1, %1, %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 4210, ptr noundef nonnull @.str.83) #4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !19
  %10 = add nsw i32 %9, 1
  store i32 %10, ptr %8, align 8, !tbaa !19
  br label %84

11:                                               ; preds = %1
  %12 = load ptr, ptr %0, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %12, i64 372
  %14 = load i32, ptr %13, align 4
  %15 = and i32 %14, 1
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %25

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 364
  %19 = load i32, ptr %18, align 4, !tbaa !21
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %.thread

21:                                               ; preds = %17
  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 4220, ptr noundef nonnull @.str.83) #4
  %22 = getelementptr inbounds i8, ptr %0, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !19
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %22, align 8, !tbaa !19
  br label %84

25:                                               ; preds = %11
  %26 = tail call ptr @mbedtls_ssl_own_cert(ptr noundef nonnull %0)
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %.thread

28:                                               ; preds = %25
  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 4249, ptr noundef nonnull @.str.84) #4
  br label %84

.thread:                                          ; preds = %17, %25
  %29 = tail call ptr @mbedtls_ssl_own_cert(ptr noundef nonnull %0)
  tail call void @mbedtls_debug_print_crt(ptr noundef nonnull %0, i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 4255, ptr noundef nonnull @.str.85, ptr noundef %29) #4
  %30 = tail call ptr @mbedtls_ssl_own_cert(ptr noundef nonnull %0)
  %.not6568 = icmp eq ptr %30, null
  br i1 %.not6568, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.thread
  %31 = getelementptr inbounds i8, ptr %0, i64 328
  br label %32

32:                                               ; preds = %.lr.ph, %40
  %.05970 = phi ptr [ %30, %.lr.ph ], [ %61, %40 ]
  %.06069 = phi i64 [ 7, %.lr.ph ], [ %59, %40 ]
  %33 = getelementptr inbounds i8, ptr %.05970, i64 8
  %34 = load i64, ptr %33, align 8, !tbaa !22
  %35 = sub i64 16381, %.06069
  %36 = icmp ugt i64 %34, %35
  br i1 %36, label %37, label %40

37:                                               ; preds = %32
  %38 = add i64 %.06069, 3
  %39 = add i64 %38, %34
  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 4275, ptr noundef nonnull @.str.86, i64 noundef %39, i32 noundef 16384) #4
  br label %84

40:                                               ; preds = %32
  %41 = lshr i64 %34, 16
  %42 = trunc i64 %41 to i8
  %43 = load ptr, ptr %31, align 8, !tbaa !29
  %44 = getelementptr inbounds i8, ptr %43, i64 %.06069
  store i8 %42, ptr %44, align 1, !tbaa !30
  %45 = lshr i64 %34, 8
  %46 = trunc i64 %45 to i8
  %47 = load ptr, ptr %31, align 8, !tbaa !29
  %48 = getelementptr i8, ptr %47, i64 %.06069
  %49 = getelementptr i8, ptr %48, i64 1
  store i8 %46, ptr %49, align 1, !tbaa !30
  %50 = trunc i64 %34 to i8
  %51 = load ptr, ptr %31, align 8, !tbaa !29
  %52 = getelementptr i8, ptr %51, i64 %.06069
  %53 = getelementptr i8, ptr %52, i64 2
  store i8 %50, ptr %53, align 1, !tbaa !30
  %54 = add i64 %.06069, 3
  %55 = load ptr, ptr %31, align 8, !tbaa !29
  %56 = getelementptr inbounds i8, ptr %55, i64 %54
  %57 = getelementptr inbounds i8, ptr %.05970, i64 16
  %58 = load ptr, ptr %57, align 8, !tbaa !31
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %56, ptr align 1 %58, i64 %34, i1 false)
  %59 = add i64 %34, %54
  %60 = getelementptr inbounds i8, ptr %.05970, i64 544
  %61 = load ptr, ptr %60, align 8, !tbaa !32
  %.not65 = icmp eq ptr %61, null
  br i1 %.not65, label %._crit_edge, label %32, !llvm.loop !33

._crit_edge:                                      ; preds = %40, %.thread
  %.060.lcssa = phi i64 [ 7, %.thread ], [ %59, %40 ]
  %62 = add i64 %.060.lcssa, -7
  %63 = lshr i64 %62, 16
  %64 = trunc i64 %63 to i8
  %65 = getelementptr inbounds i8, ptr %0, i64 328
  %66 = load ptr, ptr %65, align 8, !tbaa !29
  %67 = getelementptr inbounds i8, ptr %66, i64 4
  store i8 %64, ptr %67, align 1, !tbaa !30
  %68 = lshr i64 %62, 8
  %69 = trunc i64 %68 to i8
  %70 = load ptr, ptr %65, align 8, !tbaa !29
  %71 = getelementptr inbounds i8, ptr %70, i64 5
  store i8 %69, ptr %71, align 1, !tbaa !30
  %72 = trunc i64 %62 to i8
  %73 = load ptr, ptr %65, align 8, !tbaa !29
  %74 = getelementptr inbounds i8, ptr %73, i64 6
  store i8 %72, ptr %74, align 1, !tbaa !30
  %75 = getelementptr inbounds i8, ptr %0, i64 344
  store i64 %.060.lcssa, ptr %75, align 8, !tbaa !35
  %76 = getelementptr inbounds i8, ptr %0, i64 336
  store i32 22, ptr %76, align 8, !tbaa !36
  %77 = load ptr, ptr %65, align 8, !tbaa !29
  store i8 11, ptr %77, align 1, !tbaa !30
  %78 = getelementptr inbounds i8, ptr %0, i64 8
  %79 = load i32, ptr %78, align 8, !tbaa !19
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %78, align 8, !tbaa !19
  %81 = tail call i32 @mbedtls_ssl_write_record(ptr noundef nonnull %0)
  %.not66 = icmp eq i32 %81, 0
  br i1 %.not66, label %83, label %82

82:                                               ; preds = %._crit_edge
  tail call void @mbedtls_debug_print_ret(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 4303, ptr noundef nonnull @.str.47, i32 noundef %81) #4
  br label %84

83:                                               ; preds = %._crit_edge
  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 4307, ptr noundef nonnull @.str.87) #4
  br label %84

84:                                               ; preds = %83, %82, %37, %28, %21, %7
  %.0 = phi i32 [ 0, %7 ], [ 0, %21 ], [ -30080, %28 ], [ -29952, %37 ], [ %81, %82 ], [ 0, %83 ]
  ret i32 %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mbedtls_ssl_own_cert(ptr noundef) local_unnamed_addr #3

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

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 = { 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 #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, !7, i64 128}
!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 0}
!14 = !{!"mbedtls_ssl_transform", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !8, i64 48, !8, i64 64, !15, i64 80, !15, i64 104, !16, i64 128, !16, i64 216}
!15 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16}
!16 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 24, !8, i64 32, !11, i64 48, !8, i64 56, !11, i64 72, !7, i64 80}
!17 = !{!18, !10, i64 24}
!18 = !{!"mbedtls_ssl_ciphersuite_t", !10, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !8, i64 44}
!19 = !{!6, !10, i64 8}
!20 = !{!6, !7, i64 0}
!21 = !{!6, !10, i64 364}
!22 = !{!23, !11, i64 8}
!23 = !{!"mbedtls_x509_crt", !24, i64 0, !24, i64 24, !10, i64 48, !24, i64 56, !24, i64 80, !24, i64 104, !24, i64 128, !25, i64 152, !25, i64 216, !26, i64 280, !26, i64 304, !27, i64 328, !24, i64 344, !24, i64 368, !24, i64 392, !28, i64 416, !10, i64 448, !10, i64 452, !10, i64 456, !10, i64 460, !28, i64 464, !8, i64 496, !24, i64 504, !10, i64 528, !10, i64 532, !7, i64 536, !7, i64 544}
!24 = !{!"mbedtls_asn1_buf", !10, i64 0, !11, i64 8, !7, i64 16}
!25 = !{!"mbedtls_asn1_named_data", !24, i64 0, !24, i64 24, !7, i64 48, !8, i64 56}
!26 = !{!"mbedtls_x509_time", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!27 = !{!"", !7, i64 0, !7, i64 8}
!28 = !{!"mbedtls_asn1_sequence", !24, i64 0, !7, i64 24}
!29 = !{!6, !7, i64 328}
!30 = !{!8, !8, i64 0}
!31 = !{!23, !7, i64 16}
!32 = !{!23, !7, i64 544}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!6, !11, i64 344}
!36 = !{!6, !10, i64 336}


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