; LLVM IR from specinfo-ua/UAPKI :: library/cm-pkcs12/src/cm-pkcs12.ll (ZN8CmPkcs1211parseConfigEPhR16FileStorageParam)

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

%class.ParsonHelper = type { ptr, ptr }
%struct.FileStorageParam = type { ptr, ptr, ptr, i64 }

@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 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 i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8CmPkcs1211parseConfigEPhR16FileStorageParam(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %class.ParsonHelper, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %89

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  call void @_ZN12ParsonHelperC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6)
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = invoke noundef ptr @_ZN12ParsonHelper5parseEPKcb(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef %15, i1 noundef zeroext false)
          to label %17 unwind label %20

17:                                               ; preds = %14
  %18 = icmp ne ptr %16, null
  br i1 %18, label %24, label %19

19:                                               ; preds = %17
  store i32 1056, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %87

20:                                               ; preds = %14
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %7, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %8, align 4
  br label %88

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %25 = invoke noundef ptr @_ZN12ParsonHelper9getObjectEPKc(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef @.str.1)
          to label %26 unwind label %42

26:                                               ; preds = %24
  store ptr %25, ptr %10, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %85

29:                                               ; preds = %26
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = invoke ptr @json_object_get_string(ptr noundef %30, ptr noundef @.str.2)
          to label %32 unwind label %42

32:                                               ; preds = %29
  %33 = invoke noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef %31, ptr noundef null)
          to label %34 unwind label %42

34:                                               ; preds = %32
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.FileStorageParam, ptr %35, i32 0, i32 0
  store ptr %33, ptr %36, align 8, !tbaa !9
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.FileStorageParam, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = icmp ne ptr %39, null
  br i1 %40, label %46, label %41

41:                                               ; preds = %34
  store i32 1048, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

42:                                               ; preds = %72, %62, %59, %49, %46, %32, %29, %24
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %7, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %88

46:                                               ; preds = %34
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = invoke ptr @json_object_get_string(ptr noundef %47, ptr noundef @.str.3)
          to label %49 unwind label %42

49:                                               ; preds = %46
  %50 = invoke noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef %48, ptr noundef null)
          to label %51 unwind label %42

51:                                               ; preds = %49
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.FileStorageParam, ptr %52, i32 0, i32 1
  store ptr %50, ptr %53, align 8, !tbaa !12
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.FileStorageParam, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !12
  %57 = icmp ne ptr %56, null
  br i1 %57, label %59, label %58

58:                                               ; preds = %51
  store i32 1051, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

59:                                               ; preds = %51
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = invoke ptr @json_object_get_string(ptr noundef %60, ptr noundef @.str.4)
          to label %62 unwind label %42

62:                                               ; preds = %59
  %63 = invoke noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef %61, ptr noundef null)
          to label %64 unwind label %42

64:                                               ; preds = %62
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.FileStorageParam, ptr %65, i32 0, i32 2
  store ptr %63, ptr %66, align 8, !tbaa !13
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.FileStorageParam, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !13
  %70 = icmp ne ptr %69, null
  br i1 %70, label %72, label %71

71:                                               ; preds = %64
  store i32 1034, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

72:                                               ; preds = %64
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = invoke noundef i32 @_ZN12ParsonHelper19jsonObjectGetUint32EP13json_object_tPKcj(ptr noundef %73, ptr noundef @.str.5, i32 noundef 0)
          to label %75 unwind label %42

75:                                               ; preds = %72
  %76 = zext i32 %74 to i64
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.FileStorageParam, ptr %77, i32 0, i32 3
  store i64 %76, ptr %78, align 8, !tbaa !14
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.FileStorageParam, ptr %79, i32 0, i32 3
  %81 = load i64, ptr %80, align 8, !tbaa !14
  %82 = icmp eq i64 %81, 0
  br i1 %82, label %83, label %84

83:                                               ; preds = %75
  store i32 1026, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

84:                                               ; preds = %75
  br label %85

85:                                               ; preds = %84, %26
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %86

86:                                               ; preds = %85, %83, %71, %58, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %87

87:                                               ; preds = %86, %19
  call void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %89

88:                                               ; preds = %42, %20
  call void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  br label %91

89:                                               ; preds = %87, %13
  %90 = load i32, ptr %3, align 4
  ret i32 %90

91:                                               ; preds = %88
  %92 = load ptr, ptr %7, align 8
  %93 = load i32, ptr %8, align 4
  %94 = insertvalue { ptr, i32 } poison, ptr %92, 0
  %95 = insertvalue { ptr, i32 } %94, i32 %93, 1
  resume { ptr, i32 } %95
}

declare void @_ZN12ParsonHelperC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare noundef ptr @_ZN12ParsonHelper5parseEPKcb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i1 noundef zeroext) #2

; Function Attrs: nounwind
declare void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare noundef ptr @_ZN12ParsonHelper9getObjectEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #2

declare noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef, ptr noundef) #2

declare ptr @json_object_get_string(ptr noundef, ptr noundef) #2

declare noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef, ptr noundef) #2

declare noundef i32 @_ZN12ParsonHelper19jsonObjectGetUint32EP13json_object_tPKcj(ptr noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS16FileStorageParam", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 16}
!14 = !{!10, !11, i64 24}


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

%class.ParsonHelper = type { ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [11 x i8], align 1

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 1057) i32 @_ZN8CmPkcs1211parseConfigEPhR16FileStorageParam(ptr noundef %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(32) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %class.ParsonHelper, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %40, label %4

4:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  call void @_ZN12ParsonHelperC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %5 = invoke noundef ptr @_ZN12ParsonHelper5parseEPKcb(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull %0, i1 noundef zeroext false)
          to label %6 unwind label %7

6:                                                ; preds = %4
  %.not21 = icmp eq ptr %5, null
  br i1 %.not21, label %38, label %9

7:                                                ; preds = %4
  %8 = landingpad { ptr, i32 }
          cleanup
  br label %39

9:                                                ; preds = %6
  %10 = invoke noundef ptr @_ZN12ParsonHelper9getObjectEPKc(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull @.str.1)
          to label %11 unwind label %17

11:                                               ; preds = %9
  %.not22 = icmp eq ptr %10, null
  br i1 %.not22, label %37, label %12

12:                                               ; preds = %11
  %13 = invoke ptr @json_object_get_string(ptr noundef nonnull %10, ptr noundef nonnull @.str.2)
          to label %14 unwind label %17

14:                                               ; preds = %12
  %15 = invoke noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef %13, ptr noundef null)
          to label %16 unwind label %17

16:                                               ; preds = %14
  store ptr %15, ptr %1, align 8, !tbaa !5
  %.not23 = icmp eq ptr %15, null
  br i1 %.not23, label %38, label %19

17:                                               ; preds = %31, %27, %25, %21, %19, %14, %12, %9
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %39

19:                                               ; preds = %16
  %20 = invoke ptr @json_object_get_string(ptr noundef nonnull %10, ptr noundef nonnull @.str.3)
          to label %21 unwind label %17

21:                                               ; preds = %19
  %22 = invoke noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef %20, ptr noundef null)
          to label %23 unwind label %17

23:                                               ; preds = %21
  %24 = getelementptr inbounds i8, ptr %1, i64 8
  store ptr %22, ptr %24, align 8, !tbaa !11
  %.not24 = icmp eq ptr %22, null
  br i1 %.not24, label %38, label %25

25:                                               ; preds = %23
  %26 = invoke ptr @json_object_get_string(ptr noundef nonnull %10, ptr noundef nonnull @.str.4)
          to label %27 unwind label %17

27:                                               ; preds = %25
  %28 = invoke noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef %26, ptr noundef null)
          to label %29 unwind label %17

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %1, i64 16
  store ptr %28, ptr %30, align 8, !tbaa !12
  %.not25 = icmp eq ptr %28, null
  br i1 %.not25, label %38, label %31

31:                                               ; preds = %29
  %32 = invoke noundef i32 @_ZN12ParsonHelper19jsonObjectGetUint32EP13json_object_tPKcj(ptr noundef nonnull %10, ptr noundef nonnull @.str.5, i32 noundef 0)
          to label %33 unwind label %17

33:                                               ; preds = %31
  %34 = zext i32 %32 to i64
  %35 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 %34, ptr %35, align 8, !tbaa !13
  %36 = icmp eq i32 %32, 0
  br i1 %36, label %38, label %37

37:                                               ; preds = %33, %11
  br label %38

38:                                               ; preds = %37, %16, %23, %29, %33, %6
  %.1 = phi i32 [ 1056, %6 ], [ 0, %37 ], [ 1048, %16 ], [ 1051, %23 ], [ 1034, %29 ], [ 1026, %33 ]
  call void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  br label %40

39:                                               ; preds = %17, %7
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %8, %7 ]
  call void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  resume { ptr, i32 } %.pn

40:                                               ; preds = %2, %38
  %.2 = phi i32 [ %.1, %38 ], [ 0, %2 ]
  ret i32 %.2
}

declare void @_ZN12ParsonHelperC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

declare noundef ptr @_ZN12ParsonHelper5parseEPKcb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN12ParsonHelperD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare noundef ptr @_ZN12ParsonHelper9getObjectEPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN11FileStorage14checkCipherOidEPKcS1_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @json_object_get_string(ptr noundef, ptr noundef) local_unnamed_addr #2

declare noundef ptr @_ZN11FileStorage12checkHashOidEPKcS1_(ptr noundef, ptr noundef) local_unnamed_addr #2

declare noundef i32 @_ZN12ParsonHelper19jsonObjectGetUint32EP13json_object_tPKcj(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTS16FileStorageParam", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !10, i64 24}


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