; 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_enc_rval_s = type { i64, ptr, ptr }
%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 void @NativeInteger_encode_uper(ptr dead_on_unwind noalias writable sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.asn_enc_rval_s, align 8
  %12 = alloca i64, align 8
  %13 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %14 = alloca i32, align 4
  %15 = alloca %struct.asn_enc_rval_s, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %16, i32 0, i32 19
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %30, label %21

21:                                               ; preds = %5
  br label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %23, align 8, !tbaa !12
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %24, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %26, ptr %27, align 8, !tbaa !16
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 326, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %14, align 4
  br label %62

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29, %5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load i64, ptr %31, align 8, !tbaa !17
  store i64 %32, ptr %12, align 8, !tbaa !17
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 16, i1 false)
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %44

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.asn_INTEGER_specifics_s, ptr %36, i32 0, i32 6
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %44

40:                                               ; preds = %35
  %41 = load i64, ptr %12, align 8, !tbaa !17
  %42 = call i32 @asn_ulong2INTEGER(ptr noundef %13, i64 noundef %41)
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %48, label %57

44:                                               ; preds = %35, %30
  %45 = load i64, ptr %12, align 8, !tbaa !17
  %46 = call i32 @asn_long2INTEGER(ptr noundef %13, i64 noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %48, label %57

48:                                               ; preds = %44, %40
  br label %49

49:                                               ; preds = %48
  %50 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %50, align 8, !tbaa !12
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %51, ptr %52, align 8, !tbaa !15
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %53, ptr %54, align 8, !tbaa !16
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 337, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %14, align 4
  br label %62

55:                                               ; No predecessors!
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56, %44, %40
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #5
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  call void @INTEGER_encode_uper(ptr dead_on_unwind writable sret(%struct.asn_enc_rval_s) align 8 %15, ptr noundef %58, ptr noundef %59, ptr noundef %13, ptr noundef %60)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %15, i64 24, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #5
  %61 = load ptr, ptr getelementptr inbounds (%struct.asn_TYPE_descriptor_s, ptr @INTEGER_desc, i32 0, i32 2), align 8, !tbaa !21
  call void %61(ptr noundef @INTEGER_desc, ptr noundef %13, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 16, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %11, i64 24, i1 false), !tbaa.struct !20
  store i32 1, ptr %14, align 4
  br label %62

62:                                               ; preds = %57, %49, %22
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  ret void
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

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

declare i32 @asn_ulong2INTEGER(ptr noundef, i64 noundef) #3

declare i32 @asn_long2INTEGER(ptr noundef, i64 noundef) #3

declare void @INTEGER_encode_uper(ptr dead_on_unwind writable sret(%struct.asn_enc_rval_s) align 8, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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/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, !14, i64 0}
!13 = !{!"asn_enc_rval_s", !14, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!13, !6, i64 16}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !11, i64 32}
!19 = !{!"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}
!20 = !{i64 0, i64 8, !17, i64 8, i64 8, !5, i64 16, i64 8, !5}
!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_enc_rval_s = type { i64, ptr, 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 void @NativeInteger_encode_uper(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca %struct.asn_enc_rval_s, align 8
  %7 = alloca %struct.ASN__PRIMITIVE_TYPE_s, align 8
  %8 = getelementptr inbounds i8, ptr %1, i64 152
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %10, label %13

10:                                               ; preds = %5
  store i64 -1, ptr %0, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr null, ptr %12, align 8, !tbaa !15
  tail call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 326, i32 noundef 101, ptr noundef null) #5
  br label %27

13:                                               ; preds = %5
  %14 = load i64, ptr %3, align 8, !tbaa !16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 0, i64 16, i1 false)
  %.not14 = icmp eq ptr %9, null
  br i1 %.not14, label %20, label %15

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %9, i64 32
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %.not15 = icmp eq i32 %17, 0
  br i1 %.not15, label %20, label %18

18:                                               ; preds = %15
  %19 = call i32 @asn_ulong2INTEGER(ptr noundef nonnull %7, i64 noundef %14) #5
  %.not17 = icmp eq i32 %19, 0
  br i1 %.not17, label %25, label %22

20:                                               ; preds = %15, %13
  %21 = call i32 @asn_long2INTEGER(ptr noundef nonnull %7, i64 noundef %14) #5
  %.not16 = icmp eq i32 %21, 0
  br i1 %.not16, label %25, label %22

22:                                               ; preds = %18, %20
  store i64 -1, ptr %0, align 8, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %23, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %3, ptr %24, align 8, !tbaa !15
  call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 337, i32 noundef 101, ptr noundef null) #5
  br label %27

25:                                               ; preds = %20, %18
  call void @INTEGER_encode_uper(ptr dead_on_unwind nonnull writable sret(%struct.asn_enc_rval_s) align 8 %6, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %7, ptr noundef %4) #5
  %26 = load ptr, ptr getelementptr inbounds (i8, ptr @INTEGER_desc, i64 16), align 8, !tbaa !19
  call void %26(ptr noundef nonnull @INTEGER_desc, ptr noundef nonnull %7, i32 noundef 1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %6, i64 24, i1 false), !tbaa.struct !20
  br label %27

27:                                               ; preds = %25, %22, %10
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6)
  ret void
}

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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 @asn_ulong2INTEGER(ptr noundef, i64 noundef) local_unnamed_addr #3

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

declare void @INTEGER_encode_uper(ptr dead_on_unwind writable sret(%struct.asn_enc_rval_s) align 8, 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!12, !13, i64 0}
!12 = !{!"asn_enc_rval_s", !13, i64 0, !7, i64 8, !7, i64 16}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !7, i64 8}
!15 = !{!12, !7, i64 16}
!16 = !{!13, !13, i64 0}
!17 = !{!18, !10, i64 32}
!18 = !{!"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}
!19 = !{!6, !7, i64 16}
!20 = !{i64 0, i64 8, !16, i64 8, i64 8, !21, i64 16, i64 8, !21}
!21 = !{!7, !7, i64 0}


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