; LLVM IR from specinfo-ua/UAPKI :: library/uapkif/src/asn1/OBJECT_IDENTIFIER.ll_OBJECT_IDENTIFIER (dump_arc)

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

; 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 dso_local i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @OBJECT_IDENTIFIER__dump_arc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca i64, align 8
  %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
  %12 = alloca [64 x i8], align 16
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  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 64, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = call i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef %17, i32 noundef %18, i32 noundef %19, ptr noundef %13, i32 noundef 8)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %5
  store i64 -1, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %70

23:                                               ; preds = %5
  %24 = load i64, ptr %13, align 8, !tbaa !11
  %25 = icmp ne i64 %24, 0
  br i1 %25, label %26, label %61

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %27 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %28 = getelementptr inbounds i8, ptr %27, i64 64
  store ptr %28, ptr %14, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %41, %26
  %30 = load i64, ptr %13, align 8, !tbaa !11
  %31 = icmp ne i64 %30, 0
  br i1 %31, label %32, label %44

32:                                               ; preds = %29
  %33 = load i64, ptr %13, align 8, !tbaa !11
  %34 = urem i64 %33, 10
  %35 = trunc i64 %34 to i8
  %36 = sext i8 %35 to i32
  %37 = add nsw i32 %36, 48
  %38 = trunc i32 %37 to i8
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i32 -1
  store ptr %40, ptr %14, align 8, !tbaa !5
  store i8 %38, ptr %40, align 1, !tbaa !13
  br label %41

41:                                               ; preds = %32
  %42 = load i64, ptr %13, align 8, !tbaa !11
  %43 = udiv i64 %42, 10
  store i64 %43, ptr %13, align 8, !tbaa !11
  br label %29, !llvm.loop !14

44:                                               ; preds = %29
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %47 = ptrtoint ptr %45 to i64
  %48 = ptrtoint ptr %46 to i64
  %49 = sub i64 %47, %48
  %50 = sub i64 64, %49
  store i64 %50, ptr %16, align 8, !tbaa !11
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = load i64, ptr %16, align 8, !tbaa !11
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = call i32 %51(ptr noundef %52, i64 noundef %53, ptr noundef %54)
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %44
  store i64 -1, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %60

58:                                               ; preds = %44
  %59 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %59, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %60

60:                                               ; preds = %58, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  br label %70

61:                                               ; preds = %23
  %62 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  store i8 48, ptr %62, align 16, !tbaa !13
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = getelementptr inbounds [64 x i8], ptr %12, i64 0, i64 0
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = call i32 %63(ptr noundef %64, i64 noundef 1, ptr noundef %65)
  %67 = icmp slt i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  store i64 -1, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %70

69:                                               ; preds = %61
  store i64 1, ptr %6, align 8
  store i32 1, ptr %15, align 4
  br label %70

70:                                               ; preds = %69, %68, %60, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 64, ptr %12) #2
  %71 = load i64, ptr %6, align 8
  ret i64 %71
}

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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef, i32 noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @OBJECT_IDENTIFIER__dump_arc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca [64 x i8], align 16
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #2
  %8 = call i32 @OBJECT_IDENTIFIER_get_single_arc(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull %7, i32 noundef 8)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %9, label %29

9:                                                ; preds = %5
  %10 = load i64, ptr %7, align 8, !tbaa !5
  %.not14 = icmp eq i64 %10, 0
  br i1 %.not14, label %26, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %6, i64 64
  br label %13

13:                                               ; preds = %11, %13
  %.01217 = phi ptr [ %12, %11 ], [ %18, %13 ]
  %14 = phi i64 [ %10, %11 ], [ %19, %13 ]
  %15 = urem i64 %14, 10
  %16 = trunc nuw nsw i64 %15 to i8
  %17 = or disjoint i8 %16, 48
  %18 = getelementptr inbounds i8, ptr %.01217, i64 -1
  store i8 %17, ptr %18, align 1, !tbaa !9
  %19 = udiv i64 %14, 10
  %.not15 = icmp ult i64 %14, 10
  br i1 %.not15, label %20, label %13, !llvm.loop !10

20:                                               ; preds = %13
  store i64 %19, ptr %7, align 8, !tbaa !5
  %21 = ptrtoint ptr %18 to i64
  %22 = ptrtoint ptr %6 to i64
  %.neg = sub i64 %22, %21
  %23 = add i64 %.neg, 64
  %24 = call i32 %3(ptr noundef nonnull %18, i64 noundef %23, ptr noundef %4) #2
  %25 = icmp slt i32 %24, 0
  %. = select i1 %25, i64 -1, i64 %23
  br label %29

26:                                               ; preds = %9
  store i8 48, ptr %6, align 16, !tbaa !9
  %27 = call i32 %3(ptr noundef nonnull %6, i64 noundef 1, ptr noundef %4) #2
  %28 = icmp slt i32 %27, 0
  %.16 = select i1 %28, i64 -1, i64 1
  br label %29

29:                                               ; preds = %26, %5, %20
  %.1 = phi i64 [ %., %20 ], [ -1, %5 ], [ %.16, %26 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #2
  ret i64 %.1
}

attributes #0 = { mustprogress 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass