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

; 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.BIT_STRING_s = type { ptr, i32, i32, %struct.asn_struct_ctx_s }
%struct.asn_struct_ctx_s = type { i16, i16, i32, ptr, i64 }
%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 }

@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @BIT_STRING_constraint(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %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 i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %12, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %53

15:                                               ; preds = %4
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.BIT_STRING_s, ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %53

20:                                               ; preds = %15
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.BIT_STRING_s, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %30

25:                                               ; preds = %20
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.BIT_STRING_s, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 4, !tbaa !16
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %40, label %30

30:                                               ; preds = %25, %20
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.BIT_STRING_s, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = icmp slt i32 %33, 0
  br i1 %34, label %40, label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.BIT_STRING_s, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = icmp sgt i32 %38, 7
  br i1 %39, label %40, label %52

40:                                               ; preds = %35, %30, %25
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %51

43:                                               ; preds = %40
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  call void (ptr, ptr, ptr, ptr, ...) %44(ptr noundef %45, ptr noundef %46, ptr noundef %47, ptr noundef @.str.2, ptr noundef %50, ptr noundef @.str.3, i32 noundef 89)
  br label %51

51:                                               ; preds = %43, %40
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %66

52:                                               ; preds = %35
  br label %65

53:                                               ; preds = %15, %4
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %64

56:                                               ; preds = %53
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.asn_TYPE_descriptor_s, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !17
  call void (ptr, ptr, ptr, ptr, ...) %57(ptr noundef %58, ptr noundef %59, ptr noundef %60, ptr noundef @.str.4, ptr noundef %63, ptr noundef @.str.3, i32 noundef 95)
  br label %64

64:                                               ; preds = %56, %53
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %66

65:                                               ; preds = %52
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %66

66:                                               ; preds = %65, %64, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %67 = load i32, ptr %5, align 4
  ret i32 %67
}

; 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 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 = { 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 0}
!10 = !{!"BIT_STRING_s", !6, i64 0, !11, i64 8, !11, i64 12, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"asn_struct_ctx_s", !13, i64 0, !13, i64 2, !11, i64 4, !6, i64 8, !14, i64 16}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !11, i64 12}
!17 = !{!18, !6, i64 0}
!18 = !{!"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}


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

@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @BIT_STRING_constraint(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %19, label %5

5:                                                ; preds = %4
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %.not22 = icmp eq ptr %6, null
  br i1 %.not22, label %19, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !14
  %10 = icmp eq i32 %9, 0
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !15
  br i1 %10, label %13, label %14

13:                                               ; preds = %7
  %.not24 = icmp eq i32 %12, 0
  br i1 %.not24, label %.thread, label %16

14:                                               ; preds = %7
  %15 = icmp ugt i32 %12, 7
  br i1 %15, label %16, label %.thread

16:                                               ; preds = %14, %13
  %.not25 = icmp eq ptr %2, null
  br i1 %.not25, label %.thread, label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %0, align 8, !tbaa !16
  tail call void (ptr, ptr, ptr, ptr, ...) %2(ptr noundef %3, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull @.str.2, ptr noundef %18, ptr noundef nonnull @.str.3, i32 noundef 89) #1
  br label %.thread

19:                                               ; preds = %5, %4
  %.not23 = icmp eq ptr %2, null
  br i1 %.not23, label %.thread, label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %0, align 8, !tbaa !16
  tail call void (ptr, ptr, ptr, ptr, ...) %2(ptr noundef %3, ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull @.str.4, ptr noundef %21, ptr noundef nonnull @.str.3, i32 noundef 95) #1
  br label %.thread

.thread:                                          ; preds = %13, %14, %19, %20, %16, %17
  %.0 = phi i32 [ -1, %17 ], [ -1, %16 ], [ -1, %20 ], [ -1, %19 ], [ 0, %14 ], [ 0, %13 ]
  ret i32 %.0
}

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 0}
!6 = !{!"BIT_STRING_s", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"asn_struct_ctx_s", !12, i64 0, !12, i64 2, !10, i64 4, !7, i64 8, !13, i64 16}
!12 = !{!"short", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !10, i64 12}
!16 = !{!17, !7, i64 0}
!17 = !{!"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}


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