; LLVM IR from machinefi/psa-crypto-esp32 :: psa_layer (psa_crypto_storage)

; 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.psa_persistent_key_storage_format = type { [8 x i8], [4 x i8], [4 x i8], [2 x i8], [2 x i8], [12 x i8], [4 x i8], [0 x i8] }
%struct.psa_core_key_attributes_t = type { i16, i16, i32, i32, %struct.psa_key_policy_s, i16 }
%struct.psa_key_policy_s = type { i32, i32, i32 }

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @psa_parse_key_data_from_storage(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %16, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = icmp ult i64 %17, 36
  br i1 %18, label %19, label %20

19:                                               ; preds = %5
  store i32 -153, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

20:                                               ; preds = %5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = call i32 @check_magic_header(ptr noundef %21)
  store i32 %22, ptr %12, align 4, !tbaa !11
  %23 = load i32, ptr %12, align 4, !tbaa !11
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %26, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

27:                                               ; preds = %20
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %28, i32 0, i32 1
  %30 = getelementptr inbounds [4 x i8], ptr %29, i64 0, i64 0
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = zext i8 %31 to i32
  %33 = load ptr, ptr %13, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds [4 x i8], ptr %34, i64 0, i64 1
  %36 = load i8, ptr %35, align 1, !tbaa !13
  %37 = zext i8 %36 to i32
  %38 = shl i32 %37, 8
  %39 = or i32 %32, %38
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds [4 x i8], ptr %41, i64 0, i64 2
  %43 = load i8, ptr %42, align 1, !tbaa !13
  %44 = zext i8 %43 to i32
  %45 = shl i32 %44, 16
  %46 = or i32 %39, %45
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds [4 x i8], ptr %48, i64 0, i64 3
  %50 = load i8, ptr %49, align 1, !tbaa !13
  %51 = zext i8 %50 to i32
  %52 = shl i32 %51, 24
  %53 = or i32 %46, %52
  store i32 %53, ptr %14, align 4, !tbaa !11
  %54 = load i32, ptr %14, align 4, !tbaa !11
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %27
  store i32 -153, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

57:                                               ; preds = %27
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %58, i32 0, i32 6
  %60 = getelementptr inbounds [4 x i8], ptr %59, i64 0, i64 0
  %61 = load i8, ptr %60, align 1, !tbaa !13
  %62 = zext i8 %61 to i32
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %63, i32 0, i32 6
  %65 = getelementptr inbounds [4 x i8], ptr %64, i64 0, i64 1
  %66 = load i8, ptr %65, align 1, !tbaa !13
  %67 = zext i8 %66 to i32
  %68 = shl i32 %67, 8
  %69 = or i32 %62, %68
  %70 = load ptr, ptr %13, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %70, i32 0, i32 6
  %72 = getelementptr inbounds [4 x i8], ptr %71, i64 0, i64 2
  %73 = load i8, ptr %72, align 1, !tbaa !13
  %74 = zext i8 %73 to i32
  %75 = shl i32 %74, 16
  %76 = or i32 %69, %75
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %77, i32 0, i32 6
  %79 = getelementptr inbounds [4 x i8], ptr %78, i64 0, i64 3
  %80 = load i8, ptr %79, align 1, !tbaa !13
  %81 = zext i8 %80 to i32
  %82 = shl i32 %81, 24
  %83 = or i32 %76, %82
  %84 = zext i32 %83 to i64
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %84, ptr %85, align 8, !tbaa !9
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = load i64, ptr %8, align 8, !tbaa !9
  %89 = sub i64 %88, 36
  %90 = icmp ugt i64 %87, %89
  br i1 %90, label %95, label %91

91:                                               ; preds = %57
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  %93 = load i64, ptr %92, align 8, !tbaa !9
  %94 = icmp ugt i64 %93, 8191
  br i1 %94, label %95, label %96

95:                                               ; preds = %91, %57
  store i32 -153, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

96:                                               ; preds = %91
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load i64, ptr %97, align 8, !tbaa !9
  %99 = icmp eq i64 %98, 0
  br i1 %99, label %100, label %102

100:                                              ; preds = %96
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %101, align 8, !tbaa !5
  br label %119

102:                                              ; preds = %96
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = call noalias ptr @calloc(i64 noundef 1, i64 noundef %104) #5
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %105, ptr %106, align 8, !tbaa !5
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = load ptr, ptr %107, align 8, !tbaa !5
  %109 = icmp eq ptr %108, null
  br i1 %109, label %110, label %111

110:                                              ; preds = %102
  store i32 -141, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

111:                                              ; preds = %102
  %112 = load ptr, ptr %9, align 8, !tbaa !5
  %113 = load ptr, ptr %112, align 8, !tbaa !5
  %114 = load ptr, ptr %13, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %114, i32 0, i32 7
  %116 = getelementptr inbounds [0 x i8], ptr %115, i64 0, i64 0
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = load i64, ptr %117, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %113, ptr align 1 %116, i64 %118, i1 false)
  br label %119

119:                                              ; preds = %111, %100
  %120 = load ptr, ptr %13, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %120, i32 0, i32 2
  %122 = getelementptr inbounds [4 x i8], ptr %121, i64 0, i64 0
  %123 = load i8, ptr %122, align 1, !tbaa !13
  %124 = zext i8 %123 to i32
  %125 = load ptr, ptr %13, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %125, i32 0, i32 2
  %127 = getelementptr inbounds [4 x i8], ptr %126, i64 0, i64 1
  %128 = load i8, ptr %127, align 1, !tbaa !13
  %129 = zext i8 %128 to i32
  %130 = shl i32 %129, 8
  %131 = or i32 %124, %130
  %132 = load ptr, ptr %13, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %132, i32 0, i32 2
  %134 = getelementptr inbounds [4 x i8], ptr %133, i64 0, i64 2
  %135 = load i8, ptr %134, align 1, !tbaa !13
  %136 = zext i8 %135 to i32
  %137 = shl i32 %136, 16
  %138 = or i32 %131, %137
  %139 = load ptr, ptr %13, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %139, i32 0, i32 2
  %141 = getelementptr inbounds [4 x i8], ptr %140, i64 0, i64 3
  %142 = load i8, ptr %141, align 1, !tbaa !13
  %143 = zext i8 %142 to i32
  %144 = shl i32 %143, 24
  %145 = or i32 %138, %144
  %146 = load ptr, ptr %11, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %146, i32 0, i32 2
  store i32 %145, ptr %147, align 4, !tbaa !14
  %148 = load ptr, ptr %13, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %148, i32 0, i32 3
  %150 = getelementptr inbounds [2 x i8], ptr %149, i64 0, i64 0
  %151 = load i8, ptr %150, align 1, !tbaa !13
  %152 = zext i8 %151 to i16
  %153 = zext i16 %152 to i32
  %154 = load ptr, ptr %13, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %154, i32 0, i32 3
  %156 = getelementptr inbounds [2 x i8], ptr %155, i64 0, i64 1
  %157 = load i8, ptr %156, align 1, !tbaa !13
  %158 = zext i8 %157 to i16
  %159 = zext i16 %158 to i32
  %160 = shl i32 %159, 8
  %161 = or i32 %153, %160
  %162 = trunc i32 %161 to i16
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %163, i32 0, i32 0
  store i16 %162, ptr %164, align 4, !tbaa !18
  %165 = load ptr, ptr %13, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %165, i32 0, i32 4
  %167 = getelementptr inbounds [2 x i8], ptr %166, i64 0, i64 0
  %168 = load i8, ptr %167, align 1, !tbaa !13
  %169 = zext i8 %168 to i16
  %170 = zext i16 %169 to i32
  %171 = load ptr, ptr %13, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %171, i32 0, i32 4
  %173 = getelementptr inbounds [2 x i8], ptr %172, i64 0, i64 1
  %174 = load i8, ptr %173, align 1, !tbaa !13
  %175 = zext i8 %174 to i16
  %176 = zext i16 %175 to i32
  %177 = shl i32 %176, 8
  %178 = or i32 %170, %177
  %179 = trunc i32 %178 to i16
  %180 = load ptr, ptr %11, align 8, !tbaa !5
  %181 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %180, i32 0, i32 1
  store i16 %179, ptr %181, align 2, !tbaa !19
  %182 = load ptr, ptr %13, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %182, i32 0, i32 5
  %184 = getelementptr inbounds [12 x i8], ptr %183, i64 0, i64 0
  %185 = load i8, ptr %184, align 1, !tbaa !13
  %186 = zext i8 %185 to i32
  %187 = load ptr, ptr %13, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %187, i32 0, i32 5
  %189 = getelementptr inbounds [12 x i8], ptr %188, i64 0, i64 1
  %190 = load i8, ptr %189, align 1, !tbaa !13
  %191 = zext i8 %190 to i32
  %192 = shl i32 %191, 8
  %193 = or i32 %186, %192
  %194 = load ptr, ptr %13, align 8, !tbaa !5
  %195 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %194, i32 0, i32 5
  %196 = getelementptr inbounds [12 x i8], ptr %195, i64 0, i64 2
  %197 = load i8, ptr %196, align 1, !tbaa !13
  %198 = zext i8 %197 to i32
  %199 = shl i32 %198, 16
  %200 = or i32 %193, %199
  %201 = load ptr, ptr %13, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %201, i32 0, i32 5
  %203 = getelementptr inbounds [12 x i8], ptr %202, i64 0, i64 3
  %204 = load i8, ptr %203, align 1, !tbaa !13
  %205 = zext i8 %204 to i32
  %206 = shl i32 %205, 24
  %207 = or i32 %200, %206
  %208 = load ptr, ptr %11, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %208, i32 0, i32 4
  %210 = getelementptr inbounds %struct.psa_key_policy_s, ptr %209, i32 0, i32 0
  store i32 %207, ptr %210, align 4, !tbaa !20
  %211 = load ptr, ptr %13, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %211, i32 0, i32 5
  %213 = getelementptr inbounds [12 x i8], ptr %212, i64 0, i64 4
  %214 = load i8, ptr %213, align 1, !tbaa !13
  %215 = zext i8 %214 to i32
  %216 = load ptr, ptr %13, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %216, i32 0, i32 5
  %218 = getelementptr inbounds [12 x i8], ptr %217, i64 0, i64 5
  %219 = load i8, ptr %218, align 1, !tbaa !13
  %220 = zext i8 %219 to i32
  %221 = shl i32 %220, 8
  %222 = or i32 %215, %221
  %223 = load ptr, ptr %13, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %223, i32 0, i32 5
  %225 = getelementptr inbounds [12 x i8], ptr %224, i64 0, i64 6
  %226 = load i8, ptr %225, align 1, !tbaa !13
  %227 = zext i8 %226 to i32
  %228 = shl i32 %227, 16
  %229 = or i32 %222, %228
  %230 = load ptr, ptr %13, align 8, !tbaa !5
  %231 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %230, i32 0, i32 5
  %232 = getelementptr inbounds [12 x i8], ptr %231, i64 0, i64 7
  %233 = load i8, ptr %232, align 1, !tbaa !13
  %234 = zext i8 %233 to i32
  %235 = shl i32 %234, 24
  %236 = or i32 %229, %235
  %237 = load ptr, ptr %11, align 8, !tbaa !5
  %238 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %237, i32 0, i32 4
  %239 = getelementptr inbounds %struct.psa_key_policy_s, ptr %238, i32 0, i32 1
  store i32 %236, ptr %239, align 4, !tbaa !21
  %240 = load ptr, ptr %13, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %240, i32 0, i32 5
  %242 = getelementptr inbounds [12 x i8], ptr %241, i64 0, i64 8
  %243 = load i8, ptr %242, align 1, !tbaa !13
  %244 = zext i8 %243 to i32
  %245 = load ptr, ptr %13, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %245, i32 0, i32 5
  %247 = getelementptr inbounds [12 x i8], ptr %246, i64 0, i64 9
  %248 = load i8, ptr %247, align 1, !tbaa !13
  %249 = zext i8 %248 to i32
  %250 = shl i32 %249, 8
  %251 = or i32 %244, %250
  %252 = load ptr, ptr %13, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %252, i32 0, i32 5
  %254 = getelementptr inbounds [12 x i8], ptr %253, i64 0, i64 10
  %255 = load i8, ptr %254, align 1, !tbaa !13
  %256 = zext i8 %255 to i32
  %257 = shl i32 %256, 16
  %258 = or i32 %251, %257
  %259 = load ptr, ptr %13, align 8, !tbaa !5
  %260 = getelementptr inbounds %struct.psa_persistent_key_storage_format, ptr %259, i32 0, i32 5
  %261 = getelementptr inbounds [12 x i8], ptr %260, i64 0, i64 11
  %262 = load i8, ptr %261, align 1, !tbaa !13
  %263 = zext i8 %262 to i32
  %264 = shl i32 %263, 24
  %265 = or i32 %258, %264
  %266 = load ptr, ptr %11, align 8, !tbaa !5
  %267 = getelementptr inbounds %struct.psa_core_key_attributes_t, ptr %266, i32 0, i32 4
  %268 = getelementptr inbounds %struct.psa_key_policy_s, ptr %267, i32 0, i32 2
  store i32 %265, ptr %268, align 4, !tbaa !22
  store i32 0, ptr %6, align 4
  store i32 1, ptr %15, align 4
  br label %269

269:                                              ; preds = %119, %110, %95, %56, %25, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %270 = load i32, ptr %6, align 4
  ret i32 %270
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 = { nounwind }
attributes #5 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !12, i64 4}
!15 = !{!"", !16, i64 0, !16, i64 2, !12, i64 4, !12, i64 8, !17, i64 12, !16, i64 24}
!16 = !{!"short", !7, i64 0}
!17 = !{!"psa_key_policy_s", !12, i64 0, !12, i64 4, !12, i64 8}
!18 = !{!15, !16, i64 0}
!19 = !{!15, !16, i64 2}
!20 = !{!15, !12, i64 12}
!21 = !{!15, !12, i64 16}
!22 = !{!15, !12, i64 20}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: 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) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @psa_parse_key_data_from_storage(ptr noundef %0, i64 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = icmp ult i64 %1, 36
  br i1 %6, label %55, label %7

7:                                                ; preds = %5
  %8 = tail call i32 @check_magic_header(ptr noundef %0)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %55

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 1
  %.not56 = icmp eq i32 %11, 0
  br i1 %.not56, label %12, label %55

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load i16, ptr %13, align 1
  %15 = zext i16 %14 to i64
  %16 = getelementptr inbounds i8, ptr %0, i64 34
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = zext i8 %17 to i64
  %19 = shl nuw nsw i64 %18, 16
  %20 = or disjoint i64 %19, %15
  %21 = getelementptr inbounds i8, ptr %0, i64 35
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = zext i8 %22 to i64
  %24 = shl nuw nsw i64 %23, 24
  %25 = or disjoint i64 %20, %24
  store i64 %25, ptr %3, align 8, !tbaa !8
  %26 = add i64 %1, -36
  %27 = icmp ugt i64 %25, %26
  %28 = icmp ugt i64 %25, 8191
  %or.cond = or i1 %27, %28
  br i1 %or.cond, label %55, label %29

29:                                               ; preds = %12
  %30 = icmp eq i64 %25, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  store ptr null, ptr %2, align 8, !tbaa !10
  br label %37

32:                                               ; preds = %29
  %33 = tail call noalias ptr @calloc(i64 noundef 1, i64 noundef %25) #3
  store ptr %33, ptr %2, align 8, !tbaa !10
  %34 = icmp eq ptr %33, null
  br i1 %34, label %55, label %35

35:                                               ; preds = %32
  %36 = getelementptr inbounds i8, ptr %0, i64 36
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %33, ptr nonnull align 1 %36, i64 %25, i1 false)
  br label %37

37:                                               ; preds = %35, %31
  %38 = getelementptr inbounds i8, ptr %0, i64 12
  %39 = load i32, ptr %38, align 1
  %40 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %39, ptr %40, align 4, !tbaa !12
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  %42 = load i16, ptr %41, align 1
  store i16 %42, ptr %4, align 4, !tbaa !17
  %43 = getelementptr inbounds i8, ptr %0, i64 18
  %44 = load i16, ptr %43, align 1
  %45 = getelementptr inbounds i8, ptr %4, i64 2
  store i16 %44, ptr %45, align 2, !tbaa !18
  %46 = getelementptr inbounds i8, ptr %0, i64 20
  %47 = load i32, ptr %46, align 1
  %48 = getelementptr inbounds i8, ptr %4, i64 12
  store i32 %47, ptr %48, align 4, !tbaa !19
  %49 = getelementptr inbounds i8, ptr %0, i64 24
  %50 = load i32, ptr %49, align 1
  %51 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 %50, ptr %51, align 4, !tbaa !20
  %52 = getelementptr inbounds i8, ptr %0, i64 28
  %53 = load i32, ptr %52, align 1
  %54 = getelementptr inbounds i8, ptr %4, i64 20
  store i32 %53, ptr %54, align 4, !tbaa !21
  br label %55

55:                                               ; preds = %32, %12, %9, %7, %5, %37
  %.0 = phi i32 [ 0, %37 ], [ -153, %5 ], [ %8, %7 ], [ -153, %9 ], [ -153, %12 ], [ -141, %32 ]
  ret i32 %.0
}

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

; 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 #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress 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 #3 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !15, i64 4}
!13 = !{!"", !14, i64 0, !14, i64 2, !15, i64 4, !15, i64 8, !16, i64 12, !14, i64 24}
!14 = !{!"short", !6, i64 0}
!15 = !{!"int", !6, i64 0}
!16 = !{!"psa_key_policy_s", !15, i64 0, !15, i64 4, !15, i64 8}
!17 = !{!13, !14, i64 0}
!18 = !{!13, !14, i64 2}
!19 = !{!13, !15, i64 12}
!20 = !{!13, !15, i64 16}
!21 = !{!13, !15, i64 20}


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