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

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

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %21, label %20

20:                                               ; preds = %17, %3
  store i32 1, ptr %9, align 4
  br label %95

21:                                               ; preds = %17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.asn_CHOICE_specifics_s, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.asn_CHOICE_specifics_s, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = call i32 @_fetch_present_idx(ptr noundef %22, i32 noundef %25, i32 noundef %28)
  store i32 %29, ptr %8, align 4, !tbaa !9
  %30 = load i32, ptr %8, align 4, !tbaa !9
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %89

32:                                               ; preds = %21
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %34, i32 0, i32 18
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %37 = icmp sle i32 %33, %36
  br i1 %37, label %38, label %89

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %39, i32 0, i32 17
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = sub nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %41, i64 %44
  store ptr %45, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = and i32 %48, 1
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %72

51:                                               ; preds = %38
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !20
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %52, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  store ptr %58, ptr %11, align 8, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %71

61:                                               ; preds = %51
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %63, align 8, !tbaa !21
  %65 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !22
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %67, i32 0, i32 5
  %69 = load ptr, ptr %68, align 8, !tbaa !21
  %70 = load ptr, ptr %11, align 8, !tbaa !5
  call void %66(ptr noundef %69, ptr noundef %70, i32 noundef 0)
  br label %71

71:                                               ; preds = %61, %51
  br label %88

72:                                               ; preds = %38
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load ptr, ptr %10, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !20
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i8, ptr %73, i64 %77
  store ptr %78, ptr %11, align 8, !tbaa !5
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %79, i32 0, i32 5
  %81 = load ptr, ptr %80, align 8, !tbaa !21
  %82 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !22
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.asn_TYPE_member_s, ptr %84, i32 0, i32 5
  %86 = load ptr, ptr %85, align 8, !tbaa !21
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  call void %83(ptr noundef %86, ptr noundef %87, i32 noundef 1)
  br label %88

88:                                               ; preds = %72, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %89

89:                                               ; preds = %88, %32, %21
  %90 = load i32, ptr %6, align 4, !tbaa !9
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %94, label %92

92:                                               ; preds = %89
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  call void @free(ptr noundef %93) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %94

94:                                               ; preds = %92, %89
  store i32 0, ptr %9, align 4
  br label %95

95:                                               ; preds = %94, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %96 = load i32, ptr %9, 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: nounwind
declare void @free(ptr noundef) #2

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 "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 }

!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 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_member_s = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr }

; 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 void @CHOICE_free(ptr noundef readonly %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %1, null
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %6, label %44

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

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

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

30:                                               ; preds = %18
  %31 = load ptr, ptr %29, align 8, !tbaa !19
  %.not29 = icmp eq ptr %31, null
  br i1 %.not29, label %42, label %32

32:                                               ; preds = %30
  %33 = getelementptr i8, ptr %22, i64 -40
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !21
  tail call void %36(ptr noundef %34, ptr noundef nonnull %31, i32 noundef 0) #2
  br label %42

37:                                               ; preds = %18
  %38 = getelementptr i8, ptr %22, i64 -40
  %39 = load ptr, ptr %38, align 8, !tbaa !20
  %40 = getelementptr inbounds i8, ptr %39, i64 16
  %41 = load ptr, ptr %40, align 8, !tbaa !21
  tail call void %41(ptr noundef %39, ptr noundef nonnull %29, i32 noundef 1) #2
  br label %42

42:                                               ; preds = %37, %32, %30, %15, %6
  %.not30 = icmp eq i32 %2, 0
  br i1 %.not30, label %43, label %44

43:                                               ; preds = %42
  tail call void @free(ptr noundef nonnull %1) #2
  br label %44

44:                                               ; preds = %42, %43, %3
  ret void
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #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, !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 16}


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