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

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

@.str.9 = external hidden unnamed_addr constant [9 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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @_fetch_present_idx(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @CHOICE_print(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  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) #2
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %17, i32 0, i32 19
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %29, label %22

22:                                               ; preds = %5
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = call i32 %23(ptr noundef @.str.9, i64 noundef 8, ptr noundef %24)
  %26 = icmp slt i32 %25, 0
  %27 = zext i1 %26 to i64
  %28 = select i1 %26, i32 -1, i32 0
  store i32 %28, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %106

29:                                               ; preds = %5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.asn_CHOICE_specifics_s, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.asn_CHOICE_specifics_s, ptr %34, i32 0, i32 3
  %36 = load i32, ptr %35, align 4, !tbaa !15
  %37 = call i32 @_fetch_present_idx(ptr noundef %30, i32 noundef %33, i32 noundef %36)
  store i32 %37, ptr %13, align 4, !tbaa !9
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = icmp sgt i32 %38, 0
  br i1 %39, label %40, label %99

40:                                               ; preds = %29
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %42, i32 0, i32 18
  %44 = load i32, ptr %43, align 8, !tbaa !16
  %45 = icmp sle i32 %41, %44
  br i1 %45, label %46, label %99

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %47, i32 0, i32 17
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = load i32, ptr %13, align 4, !tbaa !9
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %49, i64 %52
  store ptr %53, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %54 = load ptr, ptr %15, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !18
  %57 = and i32 %56, 1
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %77

59:                                               ; preds = %46
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 8, !tbaa !20
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds i8, ptr %60, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  store ptr %66, ptr %16, align 8, !tbaa !5
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %76, label %69

69:                                               ; preds = %59
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = call i32 %70(ptr noundef @.str.9, i64 noundef 8, ptr noundef %71)
  %73 = icmp slt i32 %72, 0
  %74 = zext i1 %73 to i64
  %75 = select i1 %73, i32 -1, i32 0
  store i32 %75, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %98

76:                                               ; preds = %59
  br label %84

77:                                               ; preds = %46
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %79, i32 0, i32 2
  %81 = load i32, ptr %80, align 8, !tbaa !20
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds i8, ptr %78, i64 %82
  store ptr %83, ptr %16, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %77, %76
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %85, i32 0, i32 5
  %87 = load ptr, ptr %86, align 8, !tbaa !21
  %88 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %87, i32 0, i32 3
  %89 = load ptr, ptr %88, align 8, !tbaa !22
  %90 = load ptr, ptr %15, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %90, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !21
  %93 = load ptr, ptr %16, align 8, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !9
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = call i32 %89(ptr noundef %92, ptr noundef %93, i32 noundef %94, ptr noundef %95, ptr noundef %96)
  store i32 %97, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %98

98:                                               ; preds = %84, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  br label %106

99:                                               ; preds = %40, %29
  %100 = load ptr, ptr %10, align 8, !tbaa !5
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = call i32 %100(ptr noundef @.str.9, i64 noundef 8, ptr noundef %101)
  %103 = icmp slt i32 %102, 0
  %104 = zext i1 %103 to i64
  %105 = select i1 %103, i32 -1, i32 0
  store i32 %105, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %106

106:                                              ; preds = %99, %98, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %107 = load i32, ptr %6, align 4
  ret i32 %107
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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, !10, i64 8}
!14 = !{!"asn_CHOICE_specifics_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !10, i64 24, !6, i64 32, !10, i64 40}
!15 = !{!14, !10, i64 12}
!16 = !{!12, !10, i64 144}
!17 = !{!12, !6, i64 136}
!18 = !{!19, !10, i64 0}
!19 = !{!"asn_TYPE_member_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!20 = !{!19, !10, i64 8}
!21 = !{!19, !6, i64 24}
!22 = !{!12, !6, 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"

%struct.asn_TYPE_member_s = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr }

@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare hidden i32 @_fetch_present_idx(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @CHOICE_print(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %8

6:                                                ; preds = %5
  %7 = tail call i32 %3(ptr noundef nonnull @.str.9, i64 noundef 8, ptr noundef %4) #1
  %.lobit = ashr i32 %7, 31
  br label %44

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %10, i64 12
  %14 = load i32, ptr %13, align 4, !tbaa !13
  %15 = tail call i32 @_fetch_present_idx(ptr noundef nonnull %1, i32 noundef %12, i32 noundef %14)
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %17, label %42

17:                                               ; preds = %8
  %18 = getelementptr inbounds i8, ptr %0, i64 144
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %.not32 = icmp sgt i32 %15, %19
  br i1 %.not32, label %42, label %20

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %0, i64 136
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = zext nneg i32 %15 to i64
  %24 = getelementptr %struct.asn_TYPE_member_s, ptr %22, i64 %23
  %25 = getelementptr i8, ptr %24, i64 -64
  %26 = load i32, ptr %25, align 8, !tbaa !16
  %27 = and i32 %26, 1
  %.not34 = icmp eq i32 %27, 0
  %28 = getelementptr i8, ptr %24, i64 -56
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i8, ptr %1, i64 %30
  br i1 %.not34, label %36, label %32

32:                                               ; preds = %20
  %33 = load ptr, ptr %31, align 8, !tbaa !19
  %.not35 = icmp eq ptr %33, null
  br i1 %.not35, label %34, label %36

34:                                               ; preds = %32
  %35 = tail call i32 %3(ptr noundef nonnull @.str.9, i64 noundef 8, ptr noundef %4) #1
  %.lobit36 = ashr i32 %35, 31
  br label %44

36:                                               ; preds = %20, %32
  %.0 = phi ptr [ %33, %32 ], [ %31, %20 ]
  %37 = getelementptr i8, ptr %24, i64 -40
  %38 = load ptr, ptr %37, align 8, !tbaa !20
  %39 = getelementptr inbounds i8, ptr %38, i64 24
  %40 = load ptr, ptr %39, align 8, !tbaa !21
  %41 = tail call i32 %40(ptr noundef %38, ptr noundef %.0, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1
  br label %44

42:                                               ; preds = %17, %8
  %43 = tail call i32 %3(ptr noundef nonnull @.str.9, i64 noundef 8, ptr noundef %4) #1
  %.lobit33 = ashr i32 %43, 31
  br label %44

44:                                               ; preds = %34, %36, %42, %6
  %.1 = phi i32 [ %.lobit33, %42 ], [ %.lobit, %6 ], [ %41, %36 ], [ %.lobit36, %34 ]
  ret i32 %.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 = { 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, !10, i64 8}
!12 = !{!"asn_CHOICE_specifics_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40}
!13 = !{!12, !10, i64 12}
!14 = !{!6, !10, i64 144}
!15 = !{!6, !7, i64 136}
!16 = !{!17, !10, i64 0}
!17 = !{!"asn_TYPE_member_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!18 = !{!17, !10, i64 8}
!19 = !{!7, !7, i64 0}
!20 = !{!17, !7, i64 24}
!21 = !{!6, !7, i64 24}


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