; 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_uper(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca %struct.asn_dec_rval_s, align 8
  %7 = alloca ptr, 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 %struct.asn_dec_rval_s, align 8
  %14 = alloca ptr, align 8
  %15 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca %struct.asn_dec_rval_s, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  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 8, ptr %12) #6
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %19, i32 0, i32 19
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %23, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store ptr %15, ptr %16, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %14, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %39, label %27

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

32:                                               ; preds = %27
  br label %33

33:                                               ; preds = %32
  %34 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %6, i32 0, i32 0
  store i32 2, ptr %34, align 8, !tbaa !12
  %35 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %6, i32 0, i32 1
  store i64 0, ptr %35, align 8, !tbaa !15
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 294, i32 noundef 102, ptr noundef null)
  store i32 1, ptr %17, align 4
  br label %74

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37, %27
  br label %39

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

52:                                               ; preds = %39
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %64

55:                                               ; preds = %52
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.asn_INTEGER_specifics_s, ptr %56, i32 0, i32 6
  %58 = load i32, ptr %57, align 8, !tbaa !19
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %55
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = call i32 @asn_INTEGER2ulong(ptr noundef %15, ptr noundef %61)
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %68, label %70

64:                                               ; preds = %55, %52
  %65 = load ptr, ptr %14, align 8, !tbaa !5
  %66 = call i32 @asn_INTEGER2long(ptr noundef %15, ptr noundef %65)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %70

68:                                               ; preds = %64, %60
  %69 = getelementptr inbounds %struct.asn_dec_rval_s, ptr %13, i32 0, i32 0
  store i32 2, ptr %69, align 8, !tbaa !12
  br label %71

70:                                               ; preds = %64, %60
  br label %71

71:                                               ; preds = %70, %68
  br label %72

72:                                               ; preds = %71, %39
  %73 = load ptr, ptr getelementptr inbounds (%struct.asn_TYPE_descriptor_s, ptr @INTEGER_desc, i32 0, i32 2), align 8, !tbaa !21
  call void %73(ptr noundef @INTEGER_desc, ptr noundef %15, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %13, i64 16, i1 false), !tbaa.struct !16
  store i32 1, ptr %17, align 4
  br label %74

74:                                               ; preds = %72, %33
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  %75 = load { i32, i64 }, ptr %6, align 8
  ret { i32, i64 } %75
}

; 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_uper(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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, !6, i64 152}
!10 = !{!"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, !11, i64 104, !6, i64 112, !11, i64 120, !6, i64 128, !6, i64 136, !11, i64 144, !6, i64 152}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"asn_dec_rval_s", !11, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !14, i64 8}
!16 = !{i64 0, i64 4, !17, i64 8, i64 8, !18}
!17 = !{!11, !11, i64 0}
!18 = !{!14, !14, i64 0}
!19 = !{!20, !11, i64 32}
!20 = !{!"asn_INTEGER_specifics_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32}
!21 = !{!10, !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_uper(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr nocapture noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %7 = alloca ptr, align 8
  %8 = getelementptr inbounds i8, ptr %1, i64 152
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store ptr %6, ptr %7, align 8, !tbaa !11
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %14

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

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

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

19:                                               ; preds = %14
  %.not23 = icmp eq ptr %9, null
  br i1 %.not23, label %25, label %20

20:                                               ; preds = %19
  %21 = getelementptr inbounds i8, ptr %9, i64 32
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %.not24 = icmp eq i32 %22, 0
  br i1 %.not24, label %25, label %23

23:                                               ; preds = %20
  %24 = call i32 @asn_INTEGER2ulong(ptr noundef nonnull %6, ptr noundef nonnull %.0) #5
  %.not26 = icmp eq i32 %24, 0
  br i1 %.not26, label %28, label %27

25:                                               ; preds = %20, %19
  %26 = call i32 @asn_INTEGER2long(ptr noundef nonnull %6, ptr noundef nonnull %.0) #5
  %.not25 = icmp eq i32 %26, 0
  br i1 %.not25, label %28, label %27

27:                                               ; preds = %25, %23
  br label %28

28:                                               ; preds = %27, %25, %23, %14
  %.sroa.05.0 = phi i32 [ 2, %27 ], [ 0, %23 ], [ 0, %25 ], [ %16, %14 ]
  %29 = load ptr, ptr getelementptr inbounds (i8, ptr @INTEGER_desc, i64 16), align 8, !tbaa !14
  call void %29(ptr noundef nonnull @INTEGER_desc, ptr noundef nonnull %6, i32 noundef 1) #5
  br label %30

30:                                               ; preds = %28, %13
  %.sroa.016.0 = phi i32 [ %.sroa.05.0, %28 ], [ 2, %13 ]
  %.sroa.417.0 = phi i64 [ %17, %28 ], [ 0, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  %.fca.0.insert = insertvalue { i32, i64 } poison, i32 %.sroa.016.0, 0
  %.fca.1.insert = insertvalue { i32, i64 } %.fca.0.insert, i64 %.sroa.417.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_uper(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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 = !{!6, !7, i64 16}


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