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

; 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_asn1_buf = type { i32, i64, ptr }
%struct.mbedtls_x509_csr = type { %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, i32, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_named_data, %struct.mbedtls_pk_context, %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, i32, i32, ptr }
%struct.mbedtls_asn1_named_data = type { %struct.mbedtls_asn1_buf, %struct.mbedtls_asn1_buf, ptr, i8 }
%struct.mbedtls_pk_context = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_x509_csr_parse_der(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca %struct.mbedtls_asn1_buf, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #6
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 24, i1 false)
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %22, label %16

16:                                               ; preds = %3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %22, label %19

19:                                               ; preds = %16
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = icmp eq i64 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %19, %16, %3
  store i32 -10240, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

23:                                               ; preds = %19
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_init(ptr noundef %24)
  %25 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %25, ptr %9, align 8, !tbaa !9
  %26 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %25) #7
  store ptr %26, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %23
  store i32 -10368, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

30:                                               ; preds = %23
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %32, i64 %33, i1 false)
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %36, i32 0, i32 2
  store ptr %34, ptr %37, align 8, !tbaa !11
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %40, i32 0, i32 1
  store i64 %38, ptr %41, align 8, !tbaa !17
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  store ptr %44, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = call i32 @mbedtls_asn1_get_tag(ptr noundef %10, ptr noundef %45, ptr noundef %9, i32 noundef 48)
  store i32 %46, ptr %8, align 4, !tbaa !18
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %30
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %49)
  store i32 -8576, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

50:                                               ; preds = %30
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = ptrtoint ptr %52 to i64
  %55 = ptrtoint ptr %53 to i64
  %56 = sub i64 %54, %55
  %57 = icmp ne i64 %51, %56
  br i1 %57, label %58, label %60

58:                                               ; preds = %50
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %59)
  store i32 -8678, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

60:                                               ; preds = %50
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %62, i32 0, i32 1
  %64 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %63, i32 0, i32 2
  store ptr %61, ptr %64, align 8, !tbaa !19
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = call i32 @mbedtls_asn1_get_tag(ptr noundef %10, ptr noundef %65, ptr noundef %9, i32 noundef 48)
  store i32 %66, ptr %8, align 4, !tbaa !18
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %60
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %69)
  %70 = load i32, ptr %8, align 4, !tbaa !18
  %71 = add nsw i32 -8576, %70
  store i32 %71, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

72:                                               ; preds = %60
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load i64, ptr %9, align 8, !tbaa !9
  %75 = getelementptr inbounds i8, ptr %73, i64 %74
  store ptr %75, ptr %11, align 8, !tbaa !5
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %77, i32 0, i32 1
  %79 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !19
  %81 = ptrtoint ptr %76 to i64
  %82 = ptrtoint ptr %80 to i64
  %83 = sub i64 %81, %82
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %84, i32 0, i32 1
  %86 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %85, i32 0, i32 1
  store i64 %83, ptr %86, align 8, !tbaa !20
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %88, i32 0, i32 2
  %90 = call i32 @x509_csr_get_version(ptr noundef %10, ptr noundef %87, ptr noundef %89)
  store i32 %90, ptr %8, align 4, !tbaa !18
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %95

92:                                               ; preds = %72
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %93)
  %94 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %94, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

95:                                               ; preds = %72
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %96, i32 0, i32 2
  %98 = load i32, ptr %97, align 8, !tbaa !21
  %99 = icmp ne i32 %98, 0
  br i1 %99, label %100, label %102

100:                                              ; preds = %95
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %101)
  store i32 -9600, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

102:                                              ; preds = %95
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %103, i32 0, i32 2
  %105 = load i32, ptr %104, align 8, !tbaa !21
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %104, align 8, !tbaa !21
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %108, i32 0, i32 3
  %110 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %109, i32 0, i32 2
  store ptr %107, ptr %110, align 8, !tbaa !22
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = call i32 @mbedtls_asn1_get_tag(ptr noundef %10, ptr noundef %111, ptr noundef %9, i32 noundef 48)
  store i32 %112, ptr %8, align 4, !tbaa !18
  %113 = icmp ne i32 %112, 0
  br i1 %113, label %114, label %118

114:                                              ; preds = %102
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %115)
  %116 = load i32, ptr %8, align 4, !tbaa !18
  %117 = add nsw i32 -8576, %116
  store i32 %117, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

118:                                              ; preds = %102
  %119 = load ptr, ptr %10, align 8, !tbaa !5
  %120 = load i64, ptr %9, align 8, !tbaa !9
  %121 = getelementptr inbounds i8, ptr %119, i64 %120
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %122, i32 0, i32 4
  %124 = call i32 @mbedtls_x509_get_name(ptr noundef %10, ptr noundef %121, ptr noundef %123)
  store i32 %124, ptr %8, align 4, !tbaa !18
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %129

126:                                              ; preds = %118
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %127)
  %128 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %128, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

129:                                              ; preds = %118
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %131, i32 0, i32 3
  %133 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %132, i32 0, i32 2
  %134 = load ptr, ptr %133, align 8, !tbaa !22
  %135 = ptrtoint ptr %130 to i64
  %136 = ptrtoint ptr %134 to i64
  %137 = sub i64 %135, %136
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %138, i32 0, i32 3
  %140 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %139, i32 0, i32 1
  store i64 %137, ptr %140, align 8, !tbaa !23
  %141 = load ptr, ptr %11, align 8, !tbaa !5
  %142 = load ptr, ptr %5, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %142, i32 0, i32 5
  %144 = call i32 @mbedtls_pk_parse_subpubkey(ptr noundef %10, ptr noundef %141, ptr noundef %143)
  store i32 %144, ptr %8, align 4, !tbaa !18
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %146, label %149

146:                                              ; preds = %129
  %147 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %147)
  %148 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %148, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

149:                                              ; preds = %129
  %150 = load ptr, ptr %11, align 8, !tbaa !5
  %151 = call i32 @mbedtls_asn1_get_tag(ptr noundef %10, ptr noundef %150, ptr noundef %9, i32 noundef 160)
  store i32 %151, ptr %8, align 4, !tbaa !18
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %157

153:                                              ; preds = %149
  %154 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %154)
  %155 = load i32, ptr %8, align 4, !tbaa !18
  %156 = add nsw i32 -8576, %155
  store i32 %156, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

157:                                              ; preds = %149
  %158 = load i64, ptr %9, align 8, !tbaa !9
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = getelementptr inbounds i8, ptr %159, i64 %158
  store ptr %160, ptr %10, align 8, !tbaa !5
  %161 = load ptr, ptr %5, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %161, i32 0, i32 0
  %163 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %162, i32 0, i32 2
  %164 = load ptr, ptr %163, align 8, !tbaa !11
  %165 = load ptr, ptr %5, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %165, i32 0, i32 0
  %167 = getelementptr inbounds %struct.mbedtls_asn1_buf, ptr %166, i32 0, i32 1
  %168 = load i64, ptr %167, align 8, !tbaa !17
  %169 = getelementptr inbounds i8, ptr %164, i64 %168
  store ptr %169, ptr %11, align 8, !tbaa !5
  %170 = load ptr, ptr %11, align 8, !tbaa !5
  %171 = load ptr, ptr %5, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %171, i32 0, i32 6
  %173 = call i32 @mbedtls_x509_get_alg(ptr noundef %10, ptr noundef %170, ptr noundef %172, ptr noundef %12)
  store i32 %173, ptr %8, align 4, !tbaa !18
  %174 = icmp ne i32 %173, 0
  br i1 %174, label %175, label %178

175:                                              ; preds = %157
  %176 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %176)
  %177 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %177, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

178:                                              ; preds = %157
  %179 = load ptr, ptr %5, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %179, i32 0, i32 6
  %181 = load ptr, ptr %5, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %181, i32 0, i32 8
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %183, i32 0, i32 9
  %185 = load ptr, ptr %5, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %185, i32 0, i32 10
  %187 = call i32 @mbedtls_x509_get_sig_alg(ptr noundef %180, ptr noundef %12, ptr noundef %182, ptr noundef %184, ptr noundef %186)
  store i32 %187, ptr %8, align 4, !tbaa !18
  %188 = icmp ne i32 %187, 0
  br i1 %188, label %189, label %191

189:                                              ; preds = %178
  %190 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %190)
  store i32 -9728, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

191:                                              ; preds = %178
  %192 = load ptr, ptr %11, align 8, !tbaa !5
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.mbedtls_x509_csr, ptr %193, i32 0, i32 7
  %195 = call i32 @mbedtls_x509_get_sig(ptr noundef %10, ptr noundef %192, ptr noundef %194)
  store i32 %195, ptr %8, align 4, !tbaa !18
  %196 = icmp ne i32 %195, 0
  br i1 %196, label %197, label %200

197:                                              ; preds = %191
  %198 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %198)
  %199 = load i32, ptr %8, align 4, !tbaa !18
  store i32 %199, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

200:                                              ; preds = %191
  %201 = load ptr, ptr %10, align 8, !tbaa !5
  %202 = load ptr, ptr %11, align 8, !tbaa !5
  %203 = icmp ne ptr %201, %202
  br i1 %203, label %204, label %206

204:                                              ; preds = %200
  %205 = load ptr, ptr %5, align 8, !tbaa !5
  call void @mbedtls_x509_csr_free(ptr noundef %205)
  store i32 -8678, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

206:                                              ; preds = %200
  store i32 0, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %207

207:                                              ; preds = %206, %204, %197, %189, %175, %153, %146, %126, %114, %100, %92, %68, %58, %48, %29, %22
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %208 = load i32, ptr %4, align 4
  ret i32 %208
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_x509_csr_init(ptr noundef) #0

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 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

declare i32 @mbedtls_asn1_get_tag(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_x509_csr_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @x509_csr_get_version(ptr noundef, ptr noundef, ptr noundef) #0

declare i32 @mbedtls_x509_get_name(ptr noundef, ptr noundef, ptr noundef) #5

declare i32 @mbedtls_pk_parse_subpubkey(ptr noundef, ptr noundef, ptr noundef) #5

declare i32 @mbedtls_x509_get_alg(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

declare i32 @mbedtls_x509_get_sig_alg(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #5

declare i32 @mbedtls_x509_get_sig(ptr noundef, ptr noundef, ptr noundef) #5

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 = { nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"mbedtls_x509_csr", !13, i64 0, !13, i64 24, !14, i64 48, !13, i64 56, !15, i64 80, !16, i64 144, !13, i64 160, !13, i64 184, !14, i64 208, !14, i64 212, !6, i64 216}
!13 = !{!"mbedtls_asn1_buf", !14, i64 0, !10, i64 8, !6, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!"mbedtls_asn1_named_data", !13, i64 0, !13, i64 24, !6, i64 48, !7, i64 56}
!16 = !{!"", !6, i64 0, !6, i64 8}
!17 = !{!12, !10, i64 8}
!18 = !{!14, !14, i64 0}
!19 = !{!12, !6, i64 40}
!20 = !{!12, !10, i64 32}
!21 = !{!12, !14, i64 48}
!22 = !{!12, !6, i64 72}
!23 = !{!12, !10, i64 64}


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

%struct.mbedtls_asn1_buf = type { i32, i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_x509_csr_parse_der(ptr noundef %0, ptr noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.mbedtls_asn1_buf, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %6, i8 0, i64 24, i1 false)
  %7 = icmp eq ptr %0, null
  %8 = icmp eq ptr %1, null
  %or.cond = or i1 %7, %8
  %9 = icmp eq i64 %2, 0
  %or.cond3 = or i1 %or.cond, %9
  br i1 %or.cond3, label %96, label %10

10:                                               ; preds = %3
  tail call void @mbedtls_x509_csr_init(ptr noundef nonnull %0)
  store i64 %2, ptr %4, align 8, !tbaa !5
  %11 = tail call noalias ptr @calloc(i64 noundef 1, i64 noundef %2) #7
  store ptr %11, ptr %5, align 8, !tbaa !9
  %12 = icmp eq ptr %11, null
  br i1 %12, label %96, label %13

13:                                               ; preds = %10
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %11, ptr nonnull align 1 %1, i64 %2, i1 false)
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %11, ptr %14, align 8, !tbaa !11
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %2, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %11, i64 %2
  %17 = call i32 @mbedtls_asn1_get_tag(ptr noundef nonnull %5, ptr noundef nonnull %16, ptr noundef nonnull %4, i32 noundef 48) #6
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %19, label %18

18:                                               ; preds = %13
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

19:                                               ; preds = %13
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = ptrtoint ptr %16 to i64
  %23 = ptrtoint ptr %21 to i64
  %24 = sub i64 %22, %23
  %.not76 = icmp eq i64 %20, %24
  br i1 %.not76, label %26, label %25

25:                                               ; preds = %19
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %21, ptr %27, align 8, !tbaa !18
  %28 = call i32 @mbedtls_asn1_get_tag(ptr noundef nonnull %5, ptr noundef nonnull %16, ptr noundef nonnull %4, i32 noundef 48) #6
  %.not77 = icmp eq i32 %28, 0
  br i1 %.not77, label %31, label %29

29:                                               ; preds = %26
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  %30 = add nsw i32 %28, -8576
  br label %96

31:                                               ; preds = %26
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  %35 = load ptr, ptr %27, align 8, !tbaa !18
  %36 = ptrtoint ptr %34 to i64
  %37 = ptrtoint ptr %35 to i64
  %38 = sub i64 %36, %37
  %39 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %38, ptr %39, align 8, !tbaa !19
  %40 = getelementptr inbounds i8, ptr %0, i64 48
  %41 = call i32 @x509_csr_get_version(ptr noundef nonnull %5, ptr noundef %34, ptr noundef nonnull %40)
  %.not78 = icmp eq i32 %41, 0
  br i1 %.not78, label %43, label %42

42:                                               ; preds = %31
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

43:                                               ; preds = %31
  %44 = load i32, ptr %40, align 8, !tbaa !20
  %.not79 = icmp eq i32 %44, 0
  br i1 %.not79, label %46, label %45

45:                                               ; preds = %43
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

46:                                               ; preds = %43
  store i32 1, ptr %40, align 8, !tbaa !20
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %47, ptr %48, align 8, !tbaa !21
  %49 = call i32 @mbedtls_asn1_get_tag(ptr noundef nonnull %5, ptr noundef %34, ptr noundef nonnull %4, i32 noundef 48) #6
  %.not80 = icmp eq i32 %49, 0
  br i1 %.not80, label %52, label %50

50:                                               ; preds = %46
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  %51 = add nsw i32 %49, -8576
  br label %96

52:                                               ; preds = %46
  %53 = load ptr, ptr %5, align 8, !tbaa !9
  %54 = load i64, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  %56 = getelementptr inbounds i8, ptr %0, i64 80
  %57 = call i32 @mbedtls_x509_get_name(ptr noundef nonnull %5, ptr noundef %55, ptr noundef nonnull %56) #6
  %.not81 = icmp eq i32 %57, 0
  br i1 %.not81, label %59, label %58

58:                                               ; preds = %52
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

59:                                               ; preds = %52
  %60 = load ptr, ptr %5, align 8, !tbaa !9
  %61 = load ptr, ptr %48, align 8, !tbaa !21
  %62 = ptrtoint ptr %60 to i64
  %63 = ptrtoint ptr %61 to i64
  %64 = sub i64 %62, %63
  %65 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %64, ptr %65, align 8, !tbaa !22
  %66 = getelementptr inbounds i8, ptr %0, i64 144
  %67 = call i32 @mbedtls_pk_parse_subpubkey(ptr noundef nonnull %5, ptr noundef %34, ptr noundef nonnull %66) #6
  %.not82 = icmp eq i32 %67, 0
  br i1 %.not82, label %69, label %68

68:                                               ; preds = %59
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

69:                                               ; preds = %59
  %70 = call i32 @mbedtls_asn1_get_tag(ptr noundef nonnull %5, ptr noundef %34, ptr noundef nonnull %4, i32 noundef 160) #6
  %.not83 = icmp eq i32 %70, 0
  br i1 %.not83, label %73, label %71

71:                                               ; preds = %69
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  %72 = add nsw i32 %70, -8576
  br label %96

73:                                               ; preds = %69
  %74 = load i64, ptr %4, align 8, !tbaa !5
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = getelementptr inbounds i8, ptr %75, i64 %74
  store ptr %76, ptr %5, align 8, !tbaa !9
  %77 = load ptr, ptr %14, align 8, !tbaa !11
  %78 = load i64, ptr %15, align 8, !tbaa !17
  %79 = getelementptr inbounds i8, ptr %77, i64 %78
  %80 = getelementptr inbounds i8, ptr %0, i64 160
  %81 = call i32 @mbedtls_x509_get_alg(ptr noundef nonnull %5, ptr noundef %79, ptr noundef nonnull %80, ptr noundef nonnull %6) #6
  %.not84 = icmp eq i32 %81, 0
  br i1 %.not84, label %83, label %82

82:                                               ; preds = %73
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

83:                                               ; preds = %73
  %84 = getelementptr inbounds i8, ptr %0, i64 208
  %85 = getelementptr inbounds i8, ptr %0, i64 212
  %86 = getelementptr inbounds i8, ptr %0, i64 216
  %87 = call i32 @mbedtls_x509_get_sig_alg(ptr noundef nonnull %80, ptr noundef nonnull %6, ptr noundef nonnull %84, ptr noundef nonnull %85, ptr noundef nonnull %86) #6
  %.not85 = icmp eq i32 %87, 0
  br i1 %.not85, label %89, label %88

88:                                               ; preds = %83
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

89:                                               ; preds = %83
  %90 = getelementptr inbounds i8, ptr %0, i64 184
  %91 = call i32 @mbedtls_x509_get_sig(ptr noundef nonnull %5, ptr noundef %79, ptr noundef nonnull %90) #6
  %.not86 = icmp eq i32 %91, 0
  br i1 %.not86, label %93, label %92

92:                                               ; preds = %89
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

93:                                               ; preds = %89
  %94 = load ptr, ptr %5, align 8, !tbaa !9
  %.not87 = icmp eq ptr %94, %79
  br i1 %.not87, label %96, label %95

95:                                               ; preds = %93
  call void @mbedtls_x509_csr_free(ptr noundef nonnull %0)
  br label %96

96:                                               ; preds = %93, %10, %3, %95, %92, %88, %82, %71, %68, %58, %50, %45, %42, %29, %25, %18
  %.0 = phi i32 [ -8576, %18 ], [ -8678, %25 ], [ %30, %29 ], [ %41, %42 ], [ -9600, %45 ], [ %51, %50 ], [ %57, %58 ], [ %67, %68 ], [ %72, %71 ], [ %81, %82 ], [ -9728, %88 ], [ %91, %92 ], [ -8678, %95 ], [ -10240, %3 ], [ -10368, %10 ], [ 0, %93 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret i32 %.0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

; 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

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

declare i32 @mbedtls_asn1_get_tag(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

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

; Function Attrs: nounwind uwtable
declare hidden i32 @x509_csr_get_version(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @mbedtls_x509_get_name(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare i32 @mbedtls_pk_parse_subpubkey(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare i32 @mbedtls_x509_get_alg(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare i32 @mbedtls_x509_get_sig_alg(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare i32 @mbedtls_x509_get_sig(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { "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 = { nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"mbedtls_x509_csr", !13, i64 0, !13, i64 24, !14, i64 48, !13, i64 56, !15, i64 80, !16, i64 144, !13, i64 160, !13, i64 184, !14, i64 208, !14, i64 212, !10, i64 216}
!13 = !{!"mbedtls_asn1_buf", !14, i64 0, !6, i64 8, !10, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!"mbedtls_asn1_named_data", !13, i64 0, !13, i64 24, !10, i64 48, !7, i64 56}
!16 = !{!"", !10, i64 0, !10, i64 8}
!17 = !{!12, !6, i64 8}
!18 = !{!12, !10, i64 40}
!19 = !{!12, !6, i64 32}
!20 = !{!12, !14, i64 48}
!21 = !{!12, !10, i64 72}
!22 = !{!12, !6, i64 64}


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