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

; 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__PRIMITIVE_TYPE_s = type { ptr, i32 }

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

24:                                               ; preds = %4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ASN__PRIMITIVE_TYPE_s, ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = icmp ne ptr %27, null
  br i1 %28, label %31, label %29

29:                                               ; preds = %24, %4
  %30 = call ptr @__errno_location() #5
  store i32 22, ptr %30, align 4, !tbaa !9
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %89

31:                                               ; preds = %24
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %84, %31
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ASN__PRIMITIVE_TYPE_s, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !13
  %37 = icmp slt i32 %33, %36
  br i1 %37, label %38, label %87

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ASN__PRIMITIVE_TYPE_s, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !14
  store i8 %45, ptr %15, align 1, !tbaa !14
  %46 = load i8, ptr %15, align 1, !tbaa !14
  %47 = zext i8 %46 to i32
  %48 = and i32 %47, 128
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %38
  store i32 4, ptr %14, align 4
  br label %81

51:                                               ; preds = %38
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = icmp ult ptr %52, %53
  br i1 %54, label %55, label %78

55:                                               ; preds = %51
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ASN__PRIMITIVE_TYPE_s, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !11
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds i8, ptr %58, i64 %60
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = sub nsw i32 %62, %63
  %65 = add nsw i32 %64, 1
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = call i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef %61, i32 noundef %65, i32 noundef 0, ptr noundef %66, i32 noundef %67)
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %55
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %81

71:                                               ; preds = %55
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds i8, ptr %72, i64 %74
  store ptr %75, ptr %7, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %11, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %71, %51
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %14, align 4
  br label %81

81:                                               ; preds = %78, %70, %50
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #4
  %82 = load i32, ptr %14, align 4
  switch i32 %82, label %89 [
    i32 0, label %83
    i32 4, label %84
  ]

83:                                               ; preds = %81
  br label %84

84:                                               ; preds = %83, %81
  %85 = load i32, ptr %13, align 4, !tbaa !9
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %13, align 4, !tbaa !9
  br label %32, !llvm.loop !15

87:                                               ; preds = %32
  %88 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %88, ptr %5, align 4
  store i32 1, ptr %14, align 4
  br label %89

89:                                               ; preds = %87, %81, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %90 = load i32, ptr %5, align 4
  ret i32 %90
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #2

declare i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #3

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 willreturn memory(none) "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 = { "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 = { nounwind }
attributes #5 = { nounwind willreturn memory(none) }

!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 0}
!12 = !{!"ASN__PRIMITIVE_TYPE_s", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nounwind uwtable
define dso_local i32 @RELATIVE_OID_get_arcs(ptr noundef readonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = mul i32 %3, %2
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds i8, ptr %1, i64 %6
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %14, label %8

8:                                                ; preds = %4
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %.not36 = icmp eq ptr %9, null
  br i1 %.not36, label %14, label %.preheader

.preheader:                                       ; preds = %8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %13 = zext i32 %2 to i64
  br label %16

14:                                               ; preds = %8, %4
  %15 = tail call ptr @__errno_location() #3
  store i32 22, ptr %15, align 4, !tbaa !12
  br label %.loopexit

16:                                               ; preds = %.lr.ph, %35
  %.pre54 = phi i32 [ %11, %.lr.ph ], [ %.pre55, %35 ]
  %17 = phi i32 [ %11, %.lr.ph ], [ %36, %35 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.pre-phi, %35 ]
  %.02748 = phi i32 [ 0, %.lr.ph ], [ %.128.ph, %35 ]
  %.02947 = phi i32 [ 0, %.lr.ph ], [ %.231.ph, %35 ]
  %.03246 = phi ptr [ %1, %.lr.ph ], [ %.234.ph, %35 ]
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 %indvars.iv
  %20 = load i8, ptr %19, align 1, !tbaa !13
  %.not37 = icmp sgt i8 %20, -1
  br i1 %.not37, label %21, label %._crit_edge

._crit_edge:                                      ; preds = %16
  %.pre57 = add nuw nsw i64 %indvars.iv, 1
  br label %35

21:                                               ; preds = %16
  %22 = icmp ult ptr %.03246, %7
  br i1 %22, label %23, label %32

23:                                               ; preds = %21
  %24 = sext i32 %.02748 to i64
  %25 = getelementptr inbounds i8, ptr %18, i64 %24
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  %reass.sub = sub i32 %26, %.02748
  %27 = add i32 %reass.sub, 1
  %28 = tail call i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef %25, i32 noundef %27, i32 noundef 0, ptr noundef %.03246, i32 noundef %2) #4
  %.not38 = icmp eq i32 %28, 0
  br i1 %.not38, label %29, label %.loopexit

29:                                               ; preds = %23
  %30 = getelementptr inbounds i8, ptr %.03246, i64 %13
  %31 = add nsw i32 %.02947, 1
  %.pre.pre = load i32, ptr %10, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %29, %21
  %.pre = phi i32 [ %.pre.pre, %29 ], [ %.pre54, %21 ]
  %.133 = phi ptr [ %30, %29 ], [ %.03246, %21 ]
  %.130 = phi i32 [ %31, %29 ], [ %.02947, %21 ]
  %33 = add nuw nsw i64 %indvars.iv, 1
  %34 = trunc nuw nsw i64 %33 to i32
  br label %35

35:                                               ; preds = %._crit_edge, %32
  %indvars.iv.next.pre-phi = phi i64 [ %.pre57, %._crit_edge ], [ %33, %32 ]
  %.pre55 = phi i32 [ %.pre54, %._crit_edge ], [ %.pre, %32 ]
  %36 = phi i32 [ %17, %._crit_edge ], [ %.pre, %32 ]
  %.234.ph = phi ptr [ %.03246, %._crit_edge ], [ %.133, %32 ]
  %.231.ph = phi i32 [ %.02947, %._crit_edge ], [ %.130, %32 ]
  %.128.ph = phi i32 [ %.02748, %._crit_edge ], [ %34, %32 ]
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next.pre-phi, %37
  br i1 %38, label %16, label %.loopexit, !llvm.loop !14

.loopexit:                                        ; preds = %35, %23, %.preheader, %14
  %.2 = phi i32 [ -1, %14 ], [ 0, %.preheader ], [ %.231.ph, %35 ], [ -1, %23 ]
  ret i32 %.2
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #1

declare i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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 nofree nosync nounwind willreturn memory(none) "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 = { "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 willreturn memory(none) }
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__PRIMITIVE_TYPE_s", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass