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

@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_object_identifier_from_der_ex = external hidden unnamed_addr constant [35 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_length_from_der(ptr noundef, ptr noundef, ptr noundef) #2

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

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

16:                                               ; preds = %5
  %17 = load ptr, ptr %9, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %29

19:                                               ; preds = %16
  %20 = load ptr, ptr %10, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %29

22:                                               ; preds = %19
  %23 = load ptr, ptr %10, align 8, !tbaa !9
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %29

26:                                               ; preds = %22
  %27 = load ptr, ptr %11, align 8, !tbaa !9
  %28 = icmp ne ptr %27, null
  br i1 %28, label %35, label %29

29:                                               ; preds = %26, %22, %19, %16, %5
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr @stderr, align 8, !tbaa !9
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1104, ptr noundef @__FUNCTION__.asn1_object_identifier_from_der_ex) #3
  br label %33

33:                                               ; preds = %30
  br label %34

34:                                               ; preds = %33
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

35:                                               ; preds = %26
  %36 = load ptr, ptr %11, align 8, !tbaa !9
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %46, label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr %10, align 8, !tbaa !9
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = load i8, ptr %41, align 1, !tbaa !13
  %43 = zext i8 %42 to i32
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = icmp ne i32 %43, %44
  br i1 %45, label %46, label %48

46:                                               ; preds = %39, %35
  %47 = load ptr, ptr %9, align 8, !tbaa !9
  store i64 0, ptr %47, align 8, !tbaa !11
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

48:                                               ; preds = %39
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %50, i32 1
  store ptr %51, ptr %49, align 8, !tbaa !9
  %52 = load ptr, ptr %11, align 8, !tbaa !9
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = add i64 %53, -1
  store i64 %54, ptr %52, align 8, !tbaa !11
  %55 = load ptr, ptr %10, align 8, !tbaa !9
  %56 = load ptr, ptr %11, align 8, !tbaa !9
  %57 = call i32 @asn1_length_from_der(ptr noundef %12, ptr noundef %55, ptr noundef %56)
  %58 = icmp ne i32 %57, 1
  br i1 %58, label %59, label %65

59:                                               ; preds = %48
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr @stderr, align 8, !tbaa !9
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1118, ptr noundef @__FUNCTION__.asn1_object_identifier_from_der_ex) #3
  br label %63

63:                                               ; preds = %60
  br label %64

64:                                               ; preds = %63
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

65:                                               ; preds = %48
  %66 = load i64, ptr %12, align 8, !tbaa !11
  %67 = icmp ult i64 %66, 1
  br i1 %67, label %68, label %74

68:                                               ; preds = %65
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr @stderr, align 8, !tbaa !9
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1122, ptr noundef @__FUNCTION__.asn1_object_identifier_from_der_ex) #3
  br label %72

72:                                               ; preds = %69
  br label %73

73:                                               ; preds = %72
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

74:                                               ; preds = %65
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = load ptr, ptr %9, align 8, !tbaa !9
  %77 = load ptr, ptr %10, align 8, !tbaa !9
  %78 = load ptr, ptr %77, align 8, !tbaa !9
  %79 = load i64, ptr %12, align 8, !tbaa !11
  %80 = call i32 @asn1_object_identifier_from_octets(ptr noundef %75, ptr noundef %76, ptr noundef %78, i64 noundef %79)
  %81 = icmp ne i32 %80, 1
  br i1 %81, label %82, label %88

82:                                               ; preds = %74
  br label %83

83:                                               ; preds = %82
  %84 = load ptr, ptr @stderr, align 8, !tbaa !9
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1128, ptr noundef @__FUNCTION__.asn1_object_identifier_from_der_ex) #3
  br label %86

86:                                               ; preds = %83
  br label %87

87:                                               ; preds = %86
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

88:                                               ; preds = %74
  %89 = load i64, ptr %12, align 8, !tbaa !11
  %90 = load ptr, ptr %10, align 8, !tbaa !9
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = getelementptr inbounds i8, ptr %91, i64 %89
  store ptr %92, ptr %90, align 8, !tbaa !9
  %93 = load i64, ptr %12, align 8, !tbaa !11
  %94 = load ptr, ptr %11, align 8, !tbaa !9
  %95 = load i64, ptr %94, align 8, !tbaa !11
  %96 = sub i64 %95, %93
  store i64 %96, ptr %94, align 8, !tbaa !11
  store i32 1, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %97

97:                                               ; preds = %88, %87, %73, %64, %46, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %98 = load i32, ptr %6, align 4
  ret i32 %98
}

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 }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}


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

@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_object_identifier_from_der_ex = external hidden unnamed_addr constant [35 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress 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_length_from_der(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @asn1_object_identifier_from_der_ex(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %7 = icmp ne ptr %1, null
  %8 = icmp ne ptr %2, null
  %or.cond = and i1 %7, %8
  %9 = icmp ne ptr %3, null
  %or.cond3 = and i1 %or.cond, %9
  br i1 %or.cond3, label %10, label %14

10:                                               ; preds = %5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  %13 = icmp ne ptr %4, null
  %or.cond5 = and i1 %13, %12
  br i1 %or.cond5, label %17, label %14

14:                                               ; preds = %5, %10
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1104, ptr noundef nonnull @__FUNCTION__.asn1_object_identifier_from_der_ex) #4
  br label %49

17:                                               ; preds = %10
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = icmp eq i64 %18, 0
  br i1 %19, label %23, label %20

20:                                               ; preds = %17
  %21 = load i8, ptr %11, align 1, !tbaa !11
  %22 = zext i8 %21 to i32
  %.not = icmp eq i32 %22, %0
  br i1 %.not, label %24, label %23

23:                                               ; preds = %20, %17
  store i64 0, ptr %2, align 8, !tbaa !9
  br label %49

24:                                               ; preds = %20
  %25 = getelementptr inbounds i8, ptr %11, i64 1
  store ptr %25, ptr %3, align 8, !tbaa !5
  %26 = add i64 %18, -1
  store i64 %26, ptr %4, align 8, !tbaa !9
  %27 = call i32 @asn1_length_from_der(ptr noundef nonnull %6, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %.not29 = icmp eq i32 %27, 1
  br i1 %.not29, label %31, label %28

28:                                               ; preds = %24
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1118, ptr noundef nonnull @__FUNCTION__.asn1_object_identifier_from_der_ex) #4
  br label %49

31:                                               ; preds = %24
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1122, ptr noundef nonnull @__FUNCTION__.asn1_object_identifier_from_der_ex) #4
  br label %49

37:                                               ; preds = %31
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @asn1_object_identifier_from_octets(ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef %38, i64 noundef %32)
  %.not30 = icmp eq i32 %39, 1
  br i1 %.not30, label %43, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1128, ptr noundef nonnull @__FUNCTION__.asn1_object_identifier_from_der_ex) #4
  br label %49

43:                                               ; preds = %37
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 %44
  store ptr %46, ptr %3, align 8, !tbaa !5
  %47 = load i64, ptr %4, align 8, !tbaa !9
  %48 = sub i64 %47, %44
  store i64 %48, ptr %4, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %43, %40, %34, %28, %23, %14
  %.0 = phi i32 [ 0, %23 ], [ -1, %28 ], [ -1, %34 ], [ -1, %40 ], [ 1, %43 ], [ -1, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret i32 %.0
}

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 = { mustprogress 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 }
attributes #4 = { 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 = !{!7, !7, i64 0}


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