; 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_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_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_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 }

@.str = external hidden unnamed_addr constant [97 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.62 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [42 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: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_resend(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_prepare_handshake_record(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %7, i32 0, i32 31
  %9 = load i64, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef %10)
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %1
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %15, i32 0, i32 31
  %17 = load i64, ptr %16, align 8, !tbaa !9
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %14, i32 noundef 1, ptr noundef @.str, i32 noundef 3078, ptr noundef @.str.56, i64 noundef %17)
  store i32 -29184, ptr %2, align 4
  br label %201

18:                                               ; preds = %1
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef %19)
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %21, i32 0, i32 28
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %23, i64 1
  %25 = load i8, ptr %24, align 1, !tbaa !15
  %26 = zext i8 %25 to i32
  %27 = shl i32 %26, 16
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %28, i32 0, i32 28
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %30, i64 2
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = zext i8 %32 to i32
  %34 = shl i32 %33, 8
  %35 = or i32 %27, %34
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %36, i32 0, i32 28
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = getelementptr inbounds i8, ptr %38, i64 3
  %40 = load i8, ptr %39, align 1, !tbaa !15
  %41 = zext i8 %40 to i32
  %42 = or i32 %35, %41
  %43 = sext i32 %42 to i64
  %44 = add i64 %20, %43
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %45, i32 0, i32 37
  store i64 %44, ptr %46, align 8, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %48, i32 0, i32 31
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %51, i32 0, i32 28
  %53 = load ptr, ptr %52, align 8, !tbaa !14
  %54 = getelementptr inbounds i8, ptr %53, i64 0
  %55 = load i8, ptr %54, align 1, !tbaa !15
  %56 = zext i8 %55 to i32
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %57, i32 0, i32 37
  %59 = load i64, ptr %58, align 8, !tbaa !16
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %47, i32 noundef 3, ptr noundef @.str, i32 noundef 3089, ptr noundef @.str.57, i64 noundef %50, i32 noundef %56, i64 noundef %59)
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  %63 = getelementptr inbounds %struct.mbedtls_ssl_config, ptr %62, i32 0, i32 46
  %64 = load i32, ptr %63, align 4
  %65 = lshr i32 %64, 1
  %66 = and i32 %65, 1
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %189

68:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %69, i32 0, i32 28
  %71 = load ptr, ptr %70, align 8, !tbaa !14
  %72 = getelementptr inbounds i8, ptr %71, i64 4
  %73 = load i8, ptr %72, align 1, !tbaa !15
  %74 = zext i8 %73 to i32
  %75 = shl i32 %74, 8
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %76, i32 0, i32 28
  %78 = load ptr, ptr %77, align 8, !tbaa !14
  %79 = getelementptr inbounds i8, ptr %78, i64 5
  %80 = load i8, ptr %79, align 1, !tbaa !15
  %81 = zext i8 %80 to i32
  %82 = or i32 %75, %81
  store i32 %82, ptr %5, align 4, !tbaa !18
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %83, i32 0, i32 15
  %85 = load ptr, ptr %84, align 8, !tbaa !19
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %137

87:                                               ; preds = %68
  %88 = load i32, ptr %5, align 4, !tbaa !18
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %89, i32 0, i32 15
  %91 = load ptr, ptr %90, align 8, !tbaa !19
  %92 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %91, i32 0, i32 12
  %93 = load i32, ptr %92, align 4, !tbaa !20
  %94 = icmp ne i32 %88, %93
  br i1 %94, label %95, label %137

95:                                               ; preds = %87
  %96 = load i32, ptr %5, align 4, !tbaa !18
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %97, i32 0, i32 15
  %99 = load ptr, ptr %98, align 8, !tbaa !19
  %100 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %99, i32 0, i32 20
  %101 = load i32, ptr %100, align 8, !tbaa !32
  %102 = sub i32 %101, 1
  %103 = icmp eq i32 %96, %102
  br i1 %103, label %104, label %128

104:                                              ; preds = %95
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %105, i32 0, i32 28
  %107 = load ptr, ptr %106, align 8, !tbaa !14
  %108 = getelementptr inbounds i8, ptr %107, i64 0
  %109 = load i8, ptr %108, align 1, !tbaa !15
  %110 = zext i8 %109 to i32
  %111 = icmp ne i32 %110, 3
  br i1 %111, label %112, label %128

112:                                              ; preds = %104
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = load i32, ptr %5, align 4, !tbaa !18
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %115, i32 0, i32 15
  %117 = load ptr, ptr %116, align 8, !tbaa !19
  %118 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %117, i32 0, i32 20
  %119 = load i32, ptr %118, align 8, !tbaa !32
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %113, i32 noundef 2, ptr noundef @.str, i32 noundef 3110, ptr noundef @.str.58, i32 noundef %114, i32 noundef %119)
  %120 = load ptr, ptr %3, align 8, !tbaa !5
  %121 = call i32 @mbedtls_ssl_resend(ptr noundef %120)
  store i32 %121, ptr %4, align 4, !tbaa !18
  %122 = icmp ne i32 %121, 0
  br i1 %122, label %123, label %127

123:                                              ; preds = %112
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = load i32, ptr %4, align 4, !tbaa !18
  call void @mbedtls_debug_print_ret(ptr noundef %124, i32 noundef 1, ptr noundef @.str, i32 noundef 3114, ptr noundef @.str.37, i32 noundef %125)
  %126 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %126, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %186

127:                                              ; preds = %112
  br label %136

128:                                              ; preds = %104, %95
  %129 = load ptr, ptr %3, align 8, !tbaa !5
  %130 = load i32, ptr %5, align 4, !tbaa !18
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %131, i32 0, i32 15
  %133 = load ptr, ptr %132, align 8, !tbaa !19
  %134 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %133, i32 0, i32 12
  %135 = load i32, ptr %134, align 4, !tbaa !20
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %129, i32 noundef 2, ptr noundef @.str, i32 noundef 3123, ptr noundef @.str.59, i32 noundef %130, i32 noundef %135)
  br label %136

136:                                              ; preds = %128, %127
  store i32 -26880, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %186

137:                                              ; preds = %87, %68
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %138, i32 0, i32 31
  %140 = load i64, ptr %139, align 8, !tbaa !9
  %141 = load ptr, ptr %3, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %141, i32 0, i32 37
  %143 = load i64, ptr %142, align 8, !tbaa !16
  %144 = icmp ult i64 %140, %143
  br i1 %144, label %175, label %145

145:                                              ; preds = %137
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %146, i32 0, i32 28
  %148 = load ptr, ptr %147, align 8, !tbaa !14
  %149 = getelementptr inbounds i8, ptr %148, i64 6
  %150 = call i32 @memcmp(ptr noundef %149, ptr noundef @.str.60, i64 noundef 3) #6
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %175, label %152

152:                                              ; preds = %145
  %153 = load ptr, ptr %3, align 8, !tbaa !5
  %154 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %153, i32 0, i32 28
  %155 = load ptr, ptr %154, align 8, !tbaa !14
  %156 = getelementptr inbounds i8, ptr %155, i64 9
  %157 = load ptr, ptr %3, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %157, i32 0, i32 28
  %159 = load ptr, ptr %158, align 8, !tbaa !14
  %160 = getelementptr inbounds i8, ptr %159, i64 1
  %161 = call i32 @memcmp(ptr noundef %156, ptr noundef %160, i64 noundef 3) #6
  %162 = icmp ne i32 %161, 0
  br i1 %162, label %175, label %163

163:                                              ; preds = %152
  %164 = load ptr, ptr %3, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %164, i32 0, i32 15
  %166 = load ptr, ptr %165, align 8, !tbaa !19
  %167 = icmp ne ptr %166, null
  br i1 %167, label %168, label %185

168:                                              ; preds = %163
  %169 = load ptr, ptr %3, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %169, i32 0, i32 15
  %171 = load ptr, ptr %170, align 8, !tbaa !19
  %172 = getelementptr inbounds %struct.mbedtls_ssl_handshake_params, ptr %171, i32 0, i32 15
  %173 = load ptr, ptr %172, align 8, !tbaa !33
  %174 = icmp ne ptr %173, null
  br i1 %174, label %175, label %185

175:                                              ; preds = %168, %152, %145, %137
  %176 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %176, i32 noundef 2, ptr noundef @.str, i32 noundef 3137, ptr noundef @.str.61)
  %177 = load ptr, ptr %3, align 8, !tbaa !5
  %178 = call i32 @ssl_reassemble_dtls_handshake(ptr noundef %177)
  store i32 %178, ptr %4, align 4, !tbaa !18
  %179 = icmp ne i32 %178, 0
  br i1 %179, label %180, label %184

180:                                              ; preds = %175
  %181 = load ptr, ptr %3, align 8, !tbaa !5
  %182 = load i32, ptr %4, align 4, !tbaa !18
  call void @mbedtls_debug_print_ret(ptr noundef %181, i32 noundef 1, ptr noundef @.str, i32 noundef 3141, ptr noundef @.str.62, i32 noundef %182)
  %183 = load i32, ptr %4, align 4, !tbaa !18
  store i32 %183, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %186

184:                                              ; preds = %175
  br label %185

185:                                              ; preds = %184, %168, %163
  store i32 0, ptr %6, align 4
  br label %186

186:                                              ; preds = %185, %180, %136, %123
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %187 = load i32, ptr %6, align 4
  switch i32 %187, label %203 [
    i32 0, label %188
    i32 1, label %201
  ]

188:                                              ; preds = %186
  br label %200

189:                                              ; preds = %18
  %190 = load ptr, ptr %3, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %190, i32 0, i32 31
  %192 = load i64, ptr %191, align 8, !tbaa !9
  %193 = load ptr, ptr %3, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.mbedtls_ssl_context, ptr %193, i32 0, i32 37
  %195 = load i64, ptr %194, align 8, !tbaa !16
  %196 = icmp ult i64 %192, %195
  br i1 %196, label %197, label %199

197:                                              ; preds = %189
  %198 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ptr, i32, ptr, ...) @mbedtls_debug_print_msg(ptr noundef %198, i32 noundef 1, ptr noundef @.str, i32 noundef 3151, ptr noundef @.str.63)
  store i32 -28800, ptr %2, align 4
  br label %201

199:                                              ; preds = %189
  br label %200

200:                                              ; preds = %199, %188
  store i32 0, ptr %2, align 4
  br label %201

201:                                              ; preds = %200, %197, %186, %13
  %202 = load i32, ptr %2, align 4
  ret i32 %202

203:                                              ; preds = %186
  unreachable
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @ssl_reassemble_dtls_handshake(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 = { 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 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 #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

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


; 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.37 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.61 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.62 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [42 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: nounwind uwtable
declare dso_local i32 @mbedtls_ssl_resend(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ssl_prepare_handshake_record(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 224
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = tail call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef %0)
  %5 = icmp ult i64 %3, %4
  br i1 %5, label %6, label %8

6:                                                ; preds = %1
  %7 = load i64, ptr %2, align 8, !tbaa !5
  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 3078, ptr noundef nonnull @.str.56, i64 noundef %7) #4
  br label %.thread

8:                                                ; preds = %1
  %9 = tail call i64 @mbedtls_ssl_hs_hdr_len(ptr noundef nonnull %0)
  %10 = getelementptr inbounds i8, ptr %0, i64 200
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %11, i64 1
  %13 = load i8, ptr %12, align 1, !tbaa !14
  %14 = zext i8 %13 to i64
  %15 = shl nuw nsw i64 %14, 16
  %16 = getelementptr inbounds i8, ptr %11, i64 2
  %17 = load i8, ptr %16, align 1, !tbaa !14
  %18 = zext i8 %17 to i64
  %19 = shl nuw nsw i64 %18, 8
  %20 = or disjoint i64 %19, %15
  %21 = getelementptr inbounds i8, ptr %11, i64 3
  %22 = load i8, ptr %21, align 1, !tbaa !14
  %23 = zext i8 %22 to i64
  %24 = or disjoint i64 %20, %23
  %25 = add i64 %24, %9
  %26 = getelementptr inbounds i8, ptr %0, i64 272
  store i64 %25, ptr %26, align 8, !tbaa !15
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = load i8, ptr %11, align 1, !tbaa !14
  %29 = zext i8 %28 to i32
  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 3089, ptr noundef nonnull @.str.57, i64 noundef %27, i32 noundef %29, i64 noundef %25) #4
  %30 = load ptr, ptr %0, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %30, i64 372
  %32 = load i32, ptr %31, align 4
  %33 = and i32 %32, 2
  %.not = icmp eq i32 %33, 0
  br i1 %.not, label %76, label %34

34:                                               ; preds = %8
  %35 = load ptr, ptr %10, align 8, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %35, i64 4
  %37 = load i8, ptr %36, align 1, !tbaa !14
  %38 = zext i8 %37 to i32
  %39 = shl nuw nsw i32 %38, 8
  %40 = getelementptr inbounds i8, ptr %35, i64 5
  %41 = load i8, ptr %40, align 1, !tbaa !14
  %42 = zext i8 %41 to i32
  %43 = or disjoint i32 %39, %42
  %44 = getelementptr inbounds i8, ptr %0, i64 96
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %.not54 = icmp eq ptr %45, null
  br i1 %.not54, label %60, label %46

46:                                               ; preds = %34
  %47 = getelementptr inbounds i8, ptr %45, i64 940
  %48 = load i32, ptr %47, align 4, !tbaa !18
  %.not55 = icmp eq i32 %43, %48
  br i1 %.not55, label %60, label %49

49:                                               ; preds = %46
  %50 = getelementptr inbounds i8, ptr %45, i64 992
  %51 = load i32, ptr %50, align 8, !tbaa !30
  %52 = add i32 %51, -1
  %53 = icmp eq i32 %43, %52
  br i1 %53, label %54, label %59

54:                                               ; preds = %49
  %55 = load i8, ptr %35, align 1, !tbaa !14
  %.not62 = icmp eq i8 %55, 3
  br i1 %.not62, label %59, label %56

56:                                               ; preds = %54
  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 3110, ptr noundef nonnull @.str.58, i32 noundef %43, i32 noundef %51) #4
  %57 = tail call i32 @mbedtls_ssl_resend(ptr noundef nonnull %0)
  %.not63 = icmp eq i32 %57, 0
  br i1 %.not63, label %.thread, label %58

58:                                               ; preds = %56
  tail call void @mbedtls_debug_print_ret(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 3114, ptr noundef nonnull @.str.37, i32 noundef %57) #4
  br label %.thread

59:                                               ; preds = %54, %49
  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 3123, ptr noundef nonnull @.str.59, i32 noundef %43, i32 noundef %48) #4
  br label %.thread

60:                                               ; preds = %46, %34
  %61 = load i64, ptr %2, align 8, !tbaa !5
  %62 = load i64, ptr %26, align 8, !tbaa !15
  %63 = icmp ult i64 %61, %62
  br i1 %63, label %73, label %64

64:                                               ; preds = %60
  %65 = getelementptr inbounds i8, ptr %35, i64 6
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %65, ptr noundef nonnull dereferenceable(3) @.str.60, i64 3)
  %.not56 = icmp eq i32 %bcmp, 0
  br i1 %.not56, label %66, label %73

66:                                               ; preds = %64
  %67 = getelementptr inbounds i8, ptr %35, i64 9
  %68 = getelementptr inbounds i8, ptr %35, i64 1
  %bcmp57 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(3) %67, ptr noundef nonnull dereferenceable(3) %68, i64 3)
  %.not58 = icmp eq i32 %bcmp57, 0
  br i1 %.not58, label %69, label %73

69:                                               ; preds = %66
  br i1 %.not54, label %.thread, label %70

70:                                               ; preds = %69
  %71 = getelementptr inbounds i8, ptr %45, i64 960
  %72 = load ptr, ptr %71, align 8, !tbaa !31
  %.not60 = icmp eq ptr %72, null
  br i1 %.not60, label %.thread, label %73

73:                                               ; preds = %70, %66, %64, %60
  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 3137, ptr noundef nonnull @.str.61) #4
  %74 = tail call i32 @ssl_reassemble_dtls_handshake(ptr noundef nonnull %0)
  %.not61 = icmp eq i32 %74, 0
  br i1 %.not61, label %.thread, label %75

75:                                               ; preds = %73
  tail call void @mbedtls_debug_print_ret(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 3141, ptr noundef nonnull @.str.62, i32 noundef %74) #4
  br label %.thread

76:                                               ; preds = %8
  %77 = load i64, ptr %2, align 8, !tbaa !5
  %78 = load i64, ptr %26, align 8, !tbaa !15
  %79 = icmp ult i64 %77, %78
  br i1 %79, label %80, label %.thread

80:                                               ; preds = %76
  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 3151, ptr noundef nonnull @.str.63) #4
  br label %.thread

.thread:                                          ; preds = %59, %56, %75, %58, %76, %69, %70, %73, %80, %6
  %.1 = phi i32 [ -29184, %6 ], [ -28800, %80 ], [ 0, %73 ], [ 0, %70 ], [ 0, %69 ], [ 0, %76 ], [ -26880, %59 ], [ -26880, %56 ], [ %74, %75 ], [ %57, %58 ]
  ret i32 %.1
}

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

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

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

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 = { 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 #3 = { nofree nounwind willreturn memory(argmem: read) }
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, !11, i64 224}
!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 = !{!6, !7, i64 200}
!14 = !{!8, !8, i64 0}
!15 = !{!6, !11, i64 272}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 96}
!18 = !{!19, !10, i64 940}
!19 = !{!"mbedtls_ssl_handshake_params", !20, i64 0, !21, i64 8, !23, 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, !26, i64 1016, !27, i64 1104, !28, i64 1196, !29, 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}
!20 = !{!"mbedtls_ssl_sig_hash_set_t", !10, i64 0, !10, i64 4}
!21 = !{!"", !11, i64 0, !22, i64 8, !22, i64 32, !22, i64 56, !22, i64 80, !22, i64 104, !22, i64 128, !22, i64 152, !22, i64 176, !22, i64 200, !22, i64 224}
!22 = !{!"", !10, i64 0, !11, i64 8, !7, i64 16}
!23 = !{!"", !24, i64 0, !22, i64 248, !25, i64 272, !25, i64 344, !22, i64 416, !10, i64 440, !25, i64 448, !25, i64 520, !22, i64 592}
!24 = !{!"", !10, i64 0, !22, i64 8, !22, i64 32, !22, i64 56, !25, i64 80, !22, 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}
!25 = !{!"", !22, i64 0, !22, i64 24, !22, i64 48}
!26 = !{!"", !8, i64 0, !8, i64 8, !8, i64 24}
!27 = !{!"", !8, i64 0, !8, i64 8, !8, i64 28}
!28 = !{!"", !8, i64 0, !8, i64 8, !8, i64 40, !10, i64 104}
!29 = !{!"", !8, i64 0, !8, i64 16, !8, i64 80, !10, i64 208}
!30 = !{!19, !10, i64 992}
!31 = !{!19, !7, i64 960}


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