; LLVM IR from guanzhi/GmSSL :: src (asn1)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [58 x i8], align 1
@__FUNCTION__.asn1_oid_info_from_der_ex = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @asn1_object_identifier_from_der_ex(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @asn1_oid_info_from_der_ex(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store ptr %2, ptr %11, align 8, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !5
  store i64 %4, ptr %13, align 8, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %27, label %21

21:                                               ; preds = %7
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1205, ptr noundef @__FUNCTION__.asn1_oid_info_from_der_ex) #4
  br label %25

25:                                               ; preds = %22
  br label %26

26:                                               ; preds = %25
  store i32 -1, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %84

27:                                               ; preds = %7
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  %32 = call i32 @asn1_object_identifier_from_der_ex(i32 noundef 6, ptr noundef %28, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %16, align 4, !tbaa !11
  %33 = icmp ne i32 %32, 1
  br i1 %33, label %34, label %47

34:                                               ; preds = %27
  %35 = load i32, ptr %16, align 4, !tbaa !11
  %36 = icmp slt i32 %35, 0
  br i1 %36, label %37, label %43

37:                                               ; preds = %34
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1209, ptr noundef @__FUNCTION__.asn1_oid_info_from_der_ex) #4
  br label %41

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %41
  br label %45

43:                                               ; preds = %34
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %44, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %43, %42
  %46 = load i32, ptr %16, align 4, !tbaa !11
  store i32 %46, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %84

47:                                               ; preds = %27
  store i64 0, ptr %17, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %79, %47
  %49 = load i64, ptr %17, align 8, !tbaa !9
  %50 = load i64, ptr %13, align 8, !tbaa !9
  %51 = icmp ult i64 %49, %50
  br i1 %51, label %52, label %82

52:                                               ; preds = %48
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = load i64, ptr %17, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %55, i64 %56
  %58 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %57, i32 0, i32 3
  %59 = load i64, ptr %58, align 8, !tbaa !13
  %60 = icmp eq i64 %54, %59
  br i1 %60, label %61, label %78

61:                                               ; preds = %52
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = load i64, ptr %17, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %63, i64 %64
  %66 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = mul i64 %69, 4
  %71 = call i32 @memcmp(ptr noundef %62, ptr noundef %67, i64 noundef %70) #5
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %78

73:                                               ; preds = %61
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = load i64, ptr %17, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %74, i64 %75
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %76, ptr %77, align 8, !tbaa !5
  store i32 1, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %84

78:                                               ; preds = %61, %52
  br label %79

79:                                               ; preds = %78
  %80 = load i64, ptr %17, align 8, !tbaa !9
  %81 = add i64 %80, 1
  store i64 %81, ptr %17, align 8, !tbaa !9
  br label %48, !llvm.loop !16

82:                                               ; preds = %48
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %83, align 8, !tbaa !5
  store i32 1, ptr %8, align 4
  store i32 1, ptr %18, align 4
  br label %84

84:                                               ; preds = %82, %73, %45, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %85 = load i32, ptr %8, align 4
  ret i32 %85
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nounwind willreturn memory(read) "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(read) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !12, i64 32, !6, i64 40}
!15 = !{!14, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"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"

%struct.ASN1_OID_INFO = type { i32, ptr, ptr, i64, i32, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [58 x i8], align 1
@__FUNCTION__.asn1_oid_info_from_der_ex = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

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

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

8:                                                ; preds = %7
  %9 = load ptr, ptr @stderr, align 8, !tbaa !5
  %10 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1205, ptr noundef nonnull @__FUNCTION__.asn1_oid_info_from_der_ex) #3
  br label %33

11:                                               ; preds = %7
  %12 = tail call i32 @asn1_object_identifier_from_der_ex(i32 noundef 6, ptr noundef %1, ptr noundef %2, ptr noundef %5, ptr noundef %6)
  %.not26 = icmp eq i32 %12, 1
  br i1 %.not26, label %.preheader, label %15

.preheader:                                       ; preds = %11
  %.not28 = icmp eq i64 %4, 0
  br i1 %.not28, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %13 = load i64, ptr %2, align 8, !tbaa !9
  %14 = shl i64 %13, 2
  br label %21

15:                                               ; preds = %11
  %16 = icmp slt i32 %12, 0
  br i1 %16, label %17, label %20

17:                                               ; preds = %15
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1209, ptr noundef nonnull @__FUNCTION__.asn1_oid_info_from_der_ex) #3
  br label %33

20:                                               ; preds = %15
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %33

21:                                               ; preds = %.lr.ph, %31
  %.027 = phi i64 [ 0, %.lr.ph ], [ %32, %31 ]
  %22 = getelementptr inbounds %struct.ASN1_OID_INFO, ptr %3, i64 %.027
  %23 = getelementptr inbounds i8, ptr %22, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i64 %13, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %21
  %27 = getelementptr inbounds i8, ptr %22, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %bcmp = tail call i32 @bcmp(ptr %1, ptr %28, i64 %14)
  %29 = icmp eq i32 %bcmp, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store ptr %22, ptr %0, align 8, !tbaa !5
  br label %33

31:                                               ; preds = %21, %26
  %32 = add nuw i64 %.027, 1
  %exitcond.not = icmp eq i64 %32, %4
  br i1 %exitcond.not, label %._crit_edge, label %21, !llvm.loop !15

._crit_edge:                                      ; preds = %31, %.preheader
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %17, %20, %._crit_edge, %30, %8
  %.022 = phi i32 [ 1, %30 ], [ 1, %._crit_edge ], [ -1, %8 ], [ %12, %20 ], [ %12, %17 ]
  ret i32 %.022
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #2

attributes #0 = { nofree 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 #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 = { nofree nounwind willreturn memory(argmem: read) }
attributes #3 = { cold 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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"", !13, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !13, i64 32, !6, i64 40}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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