; LLVM IR from specinfo-ua/UAPKI :: library/uapkif/src/asn1 (NativeInteger)

; 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.asn_TYPE_descriptor_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, ptr }
%struct.asn_dec_rval_s = type { i32, i64 }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }
%struct.asn_INTEGER_specifics_s = type { ptr, ptr, i32, i32, i32, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@INTEGER_desc = external global %struct.asn_TYPE_descriptor_s, align 8

; Function Attrs: nounwind uwtable
define dso_local { i32, i64 } @NativeInteger_decode_xer(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5) #0 {
  %7 = alloca %struct.asn_dec_rval_s, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %struct.asn_dec_rval_s, align 8
  %16 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %struct.asn_dec_rval_s, align 8
  %21 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %22, i32 0, i32 19
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  store ptr %24, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store ptr %16, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr %18, align 8, !tbaa !5
  %27 = load ptr, ptr %18, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %41, label %29

29:                                               ; preds = %6
  %30 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 8) #7
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %30, ptr %31, align 8, !tbaa !5
  store ptr %30, ptr %18, align 8, !tbaa !5
  %32 = load ptr, ptr %18, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %40, label %34

34:                                               ; preds = %29
  br label %35

35:                                               ; preds = %34
  %36 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %7, i32 0, i32 0
  store i32 2, ptr %36, align 8, !tbaa !14
  %37 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %7, i32 0, i32 1
  store i64 0, ptr %37, align 8, !tbaa !16
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 219, i32 noundef 102, ptr noundef null)
  store i32 1, ptr %19, align 4
  br label %80

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39, %29
  br label %41

41:                                               ; preds = %40, %6
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #6
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = load i64, ptr %13, align 8, !tbaa !9
  %47 = call { i32, i64 } @INTEGER_decode_xer(ptr noundef %42, ptr noundef %43, ptr noundef %17, ptr noundef %44, ptr noundef %45, i64 noundef %46)
  %48 = getelementptr inbounds { i32, i64 }, ptr %20, i32 0, i32 0
  %49 = extractvalue { i32, i64 } %47, 0
  store i32 %49, ptr %48, align 8
  %50 = getelementptr inbounds { i32, i64 }, ptr %20, i32 0, i32 1
  %51 = extractvalue { i32, i64 } %47, 1
  store i64 %51, ptr %50, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %20, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #6
  %52 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %15, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !14
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %76

55:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  %56 = load ptr, ptr %14, align 8, !tbaa !5
  %57 = icmp ne ptr %56, null
  br i1 %57, label %58, label %66

58:                                               ; preds = %55
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.asn_INTEGER_specifics_s, ptr %59, i32 0, i32 6
  %61 = load i32, ptr %60, align 8, !tbaa !19
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %66

63:                                               ; preds = %58
  %64 = call i32 @asn_INTEGER2ulong(ptr noundef %16, ptr noundef %21)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %69, label %72

66:                                               ; preds = %58, %55
  %67 = call i32 @asn_INTEGER2long(ptr noundef %16, ptr noundef %21)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %72

69:                                               ; preds = %66, %63
  %70 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %15, i32 0, i32 0
  store i32 2, ptr %70, align 8, !tbaa !14
  %71 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %15, i32 0, i32 1
  store i64 0, ptr %71, align 8, !tbaa !16
  br label %75

72:                                               ; preds = %66, %63
  %73 = load i64, ptr %21, align 8, !tbaa !9
  %74 = load ptr, ptr %18, align 8, !tbaa !5
  store i64 %73, ptr %74, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %72, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  br label %78

76:                                               ; preds = %41
  %77 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %15, i32 0, i32 1
  store i64 0, ptr %77, align 8, !tbaa !16
  br label %78

78:                                               ; preds = %76, %75
  %79 = load ptr, ptr getelementptr inbounds (%struct.asn_TYPE_descriptor_s, ptr @INTEGER_desc, i32 0, i32 2), align 8, !tbaa !21
  call void %79(ptr noundef @INTEGER_desc, ptr noundef %16, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %15, i64 16, i1 false), !tbaa.struct !17
  store i32 1, ptr %19, align 4
  br label %80

80:                                               ; preds = %78, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  %81 = load { i32, i64 }, ptr %7, align 8
  ret { i32, i64 } %81
}

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

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

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

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

declare i32 @asn_INTEGER2ulong(ptr noundef, ptr noundef) #4

declare i32 @asn_INTEGER2long(ptr noundef, ptr noundef) #4

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #4

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

declare { i32, i64 } @INTEGER_decode_xer(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #4

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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 152}
!12 = !{!"asn_TYPE_descriptor_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !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, !13, i64 104, !6, i64 112, !13, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !6, i64 152}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 0}
!15 = !{!"asn_dec_rval_s", !13, i64 0, !10, i64 8}
!16 = !{!15, !10, i64 8}
!17 = !{i64 0, i64 4, !18, i64 8, i64 8, !9}
!18 = !{!13, !13, i64 0}
!19 = !{!20, !13, i64 32}
!20 = !{!"asn_INTEGER_specifics_s", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32}
!21 = !{!12, !6, i64 16}


; 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.asn_TYPE_descriptor_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, ptr, ptr, i32, ptr }
%struct.ASN__PRIMITIVE_TYPE_s = type { ptr, i32 }

@.str.1 = external hidden unnamed_addr constant [28 x i8], align 1
@INTEGER_desc = external global %struct.asn_TYPE_descriptor_s, align 8

; Function Attrs: nounwind uwtable
define dso_local { i32, i64 } @NativeInteger_decode_xer(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = getelementptr inbounds i8, ptr %1, i64 152
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store ptr %7, ptr %8, align 8, !tbaa !11
  %12 = load ptr, ptr %2, align 8, !tbaa !11
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %16

13:                                               ; preds = %6
  %14 = call noalias dereferenceable_or_null(8) ptr @calloc(i64 noundef 1, i64 noundef 8) #6
  store ptr %14, ptr %2, align 8, !tbaa !11
  %.not20 = icmp eq ptr %14, null
  br i1 %.not20, label %15, label %16

15:                                               ; preds = %13
  call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 219, i32 noundef 102, ptr noundef null) #5
  br label %34

16:                                               ; preds = %13, %6
  %.0 = phi ptr [ %12, %6 ], [ %14, %13 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  %17 = call { i32, i64 } @INTEGER_decode_xer(ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %8, ptr noundef %3, ptr noundef %4, i64 noundef %5) #5
  %18 = extractvalue { i32, i64 } %17, 0
  %19 = extractvalue { i32, i64 } %17, 1
  %20 = icmp eq i32 %18, 0
  br i1 %20, label %21, label %32

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %.not21 = icmp eq ptr %11, null
  br i1 %.not21, label %27, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %11, i64 32
  %24 = load i32, ptr %23, align 8, !tbaa !12
  %.not22 = icmp eq i32 %24, 0
  br i1 %.not22, label %27, label %25

25:                                               ; preds = %22
  %26 = call i32 @asn_INTEGER2ulong(ptr noundef nonnull %7, ptr noundef nonnull %9) #5
  %.not24 = icmp eq i32 %26, 0
  br i1 %.not24, label %29, label %31

27:                                               ; preds = %22, %21
  %28 = call i32 @asn_INTEGER2long(ptr noundef nonnull %7, ptr noundef nonnull %9) #5
  %.not23 = icmp eq i32 %28, 0
  br i1 %.not23, label %29, label %31

29:                                               ; preds = %27, %25
  %30 = load i64, ptr %9, align 8, !tbaa !14
  store i64 %30, ptr %.0, align 8, !tbaa !14
  br label %31

31:                                               ; preds = %25, %27, %29
  %.sroa.04.0 = phi i32 [ 0, %29 ], [ 2, %27 ], [ 2, %25 ]
  %.sroa.7.0 = phi i64 [ %19, %29 ], [ 0, %27 ], [ 0, %25 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  br label %32

32:                                               ; preds = %16, %31
  %.sroa.04.1 = phi i32 [ %.sroa.04.0, %31 ], [ %18, %16 ]
  %.sroa.7.1 = phi i64 [ %.sroa.7.0, %31 ], [ 0, %16 ]
  %33 = load ptr, ptr getelementptr inbounds (i8, ptr @INTEGER_desc, i64 16), align 8, !tbaa !16
  call void %33(ptr noundef nonnull @INTEGER_desc, ptr noundef nonnull %7, i32 noundef 1) #5
  br label %34

34:                                               ; preds = %32, %15
  %.sroa.014.0 = phi i32 [ %.sroa.04.1, %32 ], [ 2, %15 ]
  %.sroa.415.0 = phi i64 [ %.sroa.7.1, %32 ], [ 0, %15 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  %.fca.0.insert = insertvalue { i32, i64 } poison, i32 %.sroa.014.0, 0
  %.fca.1.insert = insertvalue { i32, i64 } %.fca.0.insert, i64 %.sroa.415.0, 1
  ret { i32, i64 } %.fca.1.insert
}

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

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

declare i32 @asn_INTEGER2ulong(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @asn_INTEGER2long(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

declare { i32, i64 } @INTEGER_decode_xer(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

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 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 = { "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: write) }
attributes #5 = { nounwind }
attributes #6 = { 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, !7, i64 152}
!6 = !{!"asn_TYPE_descriptor_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !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, !10, i64 104, !7, i64 112, !10, i64 120, !7, i64 128, !7, i64 136, !10, i64 144, !7, i64 152}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 32}
!13 = !{!"asn_INTEGER_specifics_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!6, !7, i64 16}


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