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

; 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_enc_rval_s = type { i64, ptr, ptr }
%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_INTEGER_enum_map_s = type { i64, i64, ptr }

@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

29:                                               ; preds = %7
  br label %30

30:                                               ; preds = %29
  %31 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %32, ptr %33, align 8, !tbaa !16
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %34, ptr %35, align 8, !tbaa !17
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 89, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %18, align 4
  br label %95

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37, %7
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %16, align 8, !tbaa !5
  %41 = load i64, ptr %40, align 8, !tbaa !18
  %42 = call ptr @INTEGER_map_value2enum(ptr noundef %39, i64 noundef %41)
  store ptr %42, ptr %17, align 8, !tbaa !5
  %43 = load ptr, ptr %17, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %85

45:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %46 = load ptr, ptr %17, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.asn_INTEGER_enum_map_s, ptr %46, i32 0, i32 1
  %48 = load i64, ptr %47, align 8, !tbaa !19
  %49 = add i64 %48, 5
  store i64 %49, ptr %19, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %50 = load i64, ptr %19, align 8, !tbaa !18
  %51 = alloca i8, i64 %50, align 16
  store ptr %51, ptr %20, align 8, !tbaa !5
  %52 = load ptr, ptr %20, align 8, !tbaa !5
  %53 = load i64, ptr %19, align 8, !tbaa !18
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.asn_INTEGER_enum_map_s, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !21
  %57 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %52, i64 noundef %53, ptr noundef @.str.2, ptr noundef %56) #5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %15, i32 0, i32 0
  store i64 %58, ptr %59, align 8, !tbaa !13
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = load ptr, ptr %20, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %15, i32 0, i32 0
  %63 = load i64, ptr %62, align 8, !tbaa !13
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = call i32 %60(ptr noundef %61, i64 noundef %63, ptr noundef %64)
  %66 = icmp slt i32 %65, 0
  br i1 %66, label %67, label %76

67:                                               ; preds = %45
  br label %68

68:                                               ; preds = %67
  %69 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %69, align 8, !tbaa !13
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %70, ptr %71, align 8, !tbaa !16
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %72, ptr %73, align 8, !tbaa !17
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 100, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %18, align 4
  br label %82

74:                                               ; No predecessors!
  br label %75

75:                                               ; preds = %74
  br label %76

76:                                               ; preds = %75, %45
  br label %77

77:                                               ; preds = %76
  %78 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %15, i32 0, i32 2
  store ptr null, ptr %78, align 8, !tbaa !17
  %79 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %15, i32 0, i32 1
  store ptr null, ptr %79, align 8, !tbaa !16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %15, i64 24, i1 false), !tbaa.struct !22
  store i32 1, ptr %18, align 4
  br label %82

80:                                               ; No predecessors!
  br label %81

81:                                               ; preds = %80
  store i32 0, ptr %18, align 4
  br label %82

82:                                               ; preds = %81, %77, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  %83 = load i32, ptr %18, align 4
  switch i32 %83, label %95 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %94

85:                                               ; preds = %38
  br label %86

86:                                               ; preds = %85
  %87 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 0
  store i64 -1, ptr %87, align 8, !tbaa !13
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 1
  store ptr %88, ptr %89, align 8, !tbaa !16
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.asn_enc_rval_s, ptr %0, i32 0, i32 2
  store ptr %90, ptr %91, align 8, !tbaa !17
  call void @stacktrace_create(ptr noundef @.str.1, i64 noundef 106, i32 noundef 101, ptr noundef null)
  store i32 1, ptr %18, align 4
  br label %95

92:                                               ; No predecessors!
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93, %84
  store i32 0, ptr %18, align 4
  br label %95

95:                                               ; preds = %94, %86, %82, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  %96 = load i32, ptr %18, align 4
  switch i32 %96, label %98 [
    i32 0, label %97
    i32 1, label %97
  ]

97:                                               ; preds = %95, %95
  ret void

98:                                               ; preds = %95
  unreachable
}

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

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

declare ptr @INTEGER_map_value2enum(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #3

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

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

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !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, !10, i64 104, !6, i64 112, !10, i64 120, !6, i64 128, !6, i64 136, !10, i64 144, !6, i64 152}
!13 = !{!14, !15, i64 0}
!14 = !{!"asn_enc_rval_s", !15, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !6, i64 16}
!18 = !{!15, !15, i64 0}
!19 = !{!20, !15, i64 8}
!20 = !{!"asn_INTEGER_enum_map_s", !15, i64 0, !15, i64 8, !6, i64 16}
!21 = !{!20, !6, i64 16}
!22 = !{i64 0, i64 8, !18, i64 8, i64 8, !5, i64 16, i64 8, !5}


; 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_enc_rval_s = type { i64, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @NativeEnumerated_encode_xer(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.asn_enc_rval_s) align 8 %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef readonly %5, ptr noundef %6) local_unnamed_addr #0 {
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %8, label %11

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

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %1, i64 152
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = load i64, ptr %2, align 8, !tbaa !16
  %15 = tail call ptr @INTEGER_map_value2enum(ptr noundef %13, i64 noundef %14) #4
  %.not23 = icmp eq ptr %15, null
  br i1 %.not23, label %31, label %16

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %15, i64 8
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = add i64 %18, 5
  %20 = alloca i8, i64 %19, align 16
  %21 = getelementptr inbounds i8, ptr %15, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull %20, i64 noundef %19, ptr noundef nonnull @.str.2, ptr noundef %22) #4
  %24 = sext i32 %23 to i64
  %25 = call i32 %5(ptr noundef nonnull %20, i64 noundef %24, ptr noundef %6) #4
  %26 = icmp slt i32 %25, 0
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %26, label %28, label %30

28:                                               ; preds = %16
  store i64 -1, ptr %0, align 8, !tbaa !5
  store ptr %1, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %2, ptr %29, align 8, !tbaa !12
  call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 100, i32 noundef 101, ptr noundef null) #4
  br label %34

30:                                               ; preds = %16
  store i64 %24, ptr %0, align 8, !tbaa !16
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %27, i8 0, i64 16, i1 false)
  br label %34

31:                                               ; preds = %11
  store i64 -1, ptr %0, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %32, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %2, ptr %33, align 8, !tbaa !12
  tail call void @stacktrace_create(ptr noundef nonnull @.str.1, i64 noundef 106, i32 noundef 101, ptr noundef null) #4
  br label %34

34:                                               ; preds = %28, %30, %31, %8
  ret void
}

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

declare ptr @INTEGER_map_value2enum(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { "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 = { nofree 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"asn_enc_rval_s", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !10, i64 152}
!14 = !{!"asn_TYPE_descriptor_s", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !15, i64 104, !10, i64 112, !15, i64 120, !10, i64 128, !10, i64 136, !15, i64 144, !10, i64 152}
!15 = !{!"int", !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !7, i64 8}
!18 = !{!"asn_INTEGER_enum_map_s", !7, i64 0, !7, i64 8, !10, i64 16}
!19 = !{!18, !10, i64 16}


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