; 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_generalized_time_from_der_ex = external hidden unnamed_addr constant [34 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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) #3

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

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

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

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

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

26:                                               ; preds = %23, %19, %16, %4
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr @stderr, align 8, !tbaa !9
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1747, ptr noundef @__FUNCTION__.asn1_generalized_time_from_der_ex) #4
  br label %30

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %112

32:                                               ; preds = %23
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  %34 = load i64, ptr %33, align 8, !tbaa !11
  %35 = icmp eq i64 %34, 0
  br i1 %35, label %43, label %36

36:                                               ; preds = %32
  %37 = load ptr, ptr %8, align 8, !tbaa !9
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = zext i8 %39 to i32
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = icmp ne i32 %40, %41
  br i1 %42, label %43, label %45

43:                                               ; preds = %36, %32
  %44 = load ptr, ptr %7, align 8, !tbaa !9
  store i64 -1, ptr %44, align 8, !tbaa !11
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %112

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

56:                                               ; preds = %45
  br label %57

57:                                               ; preds = %56
  %58 = load ptr, ptr @stderr, align 8, !tbaa !9
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1761, ptr noundef @__FUNCTION__.asn1_generalized_time_from_der_ex) #4
  br label %60

60:                                               ; preds = %57
  br label %61

61:                                               ; preds = %60
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %112

62:                                               ; preds = %45
  %63 = load i64, ptr %10, align 8, !tbaa !11
  %64 = icmp eq i64 %63, 15
  br i1 %64, label %65, label %84

65:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 15, ptr %12) #4
  %66 = getelementptr inbounds [15 x i8], ptr %12, i64 0, i64 0
  %67 = load ptr, ptr %8, align 8, !tbaa !9
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = load i64, ptr %10, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %66, ptr align 1 %68, i64 %69, i1 false)
  %70 = load ptr, ptr %7, align 8, !tbaa !9
  %71 = getelementptr inbounds [15 x i8], ptr %12, i64 0, i64 0
  %72 = call i32 @asn1_time_from_str(i32 noundef 0, ptr noundef %70, ptr noundef %71)
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %74, label %80

74:                                               ; preds = %65
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr @stderr, align 8, !tbaa !9
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1769, ptr noundef @__FUNCTION__.asn1_generalized_time_from_der_ex) #4
  br label %78

78:                                               ; preds = %75
  br label %79

79:                                               ; preds = %78
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %81

80:                                               ; preds = %65
  store i32 0, ptr %11, align 4
  br label %81

81:                                               ; preds = %80, %79
  call void @llvm.lifetime.end.p0(i64 15, ptr %12) #4
  %82 = load i32, ptr %11, align 4
  switch i32 %82, label %112 [
    i32 0, label %83
  ]

83:                                               ; preds = %81
  br label %103

84:                                               ; preds = %62
  %85 = load i64, ptr %10, align 8, !tbaa !11
  %86 = icmp eq i64 %85, 19
  br i1 %86, label %87, label %97

87:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 19, ptr %13) #4
  %88 = getelementptr inbounds [19 x i8], ptr %13, i64 0, i64 0
  %89 = load ptr, ptr %8, align 8, !tbaa !9
  %90 = load ptr, ptr %89, align 8, !tbaa !9
  %91 = load i64, ptr %10, align 8, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %88, ptr align 1 %90, i64 %91, i1 false)
  br label %92

92:                                               ; preds = %87
  %93 = load ptr, ptr @stderr, align 8, !tbaa !9
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %93, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1775, ptr noundef @__FUNCTION__.asn1_generalized_time_from_der_ex) #4
  br label %95

95:                                               ; preds = %92
  br label %96

96:                                               ; preds = %95
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 19, ptr %13) #4
  br label %112

97:                                               ; preds = %84
  br label %98

98:                                               ; preds = %97
  %99 = load ptr, ptr @stderr, align 8, !tbaa !9
  %100 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %99, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1778, ptr noundef @__FUNCTION__.asn1_generalized_time_from_der_ex) #4
  br label %101

101:                                              ; preds = %98
  br label %102

102:                                              ; preds = %101
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %112

103:                                              ; preds = %83
  %104 = load i64, ptr %10, align 8, !tbaa !11
  %105 = load ptr, ptr %8, align 8, !tbaa !9
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  %107 = getelementptr inbounds i8, ptr %106, i64 %104
  store ptr %107, ptr %105, align 8, !tbaa !9
  %108 = load i64, ptr %10, align 8, !tbaa !11
  %109 = load ptr, ptr %9, align 8, !tbaa !9
  %110 = load i64, ptr %109, align 8, !tbaa !11
  %111 = sub i64 %110, %108
  store i64 %111, ptr %109, align 8, !tbaa !11
  store i32 1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %112

112:                                              ; preds = %103, %102, %96, %81, %61, %43, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %113 = load i32, ptr %5, align 4
  ret i32 %113
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !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_generalized_time_from_der_ex = external hidden unnamed_addr constant [34 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; 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 #3

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

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

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

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

16:                                               ; preds = %9
  %17 = load i64, ptr %3, align 8, !tbaa !9
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %22, label %19

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

22:                                               ; preds = %19, %16
  store i64 -1, ptr %1, align 8, !tbaa !9
  br label %49

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %10, i64 1
  store ptr %24, ptr %2, align 8, !tbaa !5
  %25 = add i64 %17, -1
  store i64 %25, ptr %3, align 8, !tbaa !9
  %26 = call i32 @asn1_length_from_der(ptr noundef nonnull %5, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %.not27 = icmp eq i32 %26, 1
  br i1 %.not27, label %30, label %27

27:                                               ; preds = %23
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1761, ptr noundef nonnull @__FUNCTION__.asn1_generalized_time_from_der_ex) #5
  br label %49

30:                                               ; preds = %23
  %31 = load i64, ptr %5, align 8, !tbaa !9
  switch i64 %31, label %41 [
    i64 15, label %32
    i64 19, label %38
  ]

32:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 15, ptr nonnull %6) #4
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(15) %6, ptr noundef nonnull align 1 dereferenceable(15) %33, i64 15, i1 false)
  %34 = call i32 @asn1_time_from_str(i32 noundef 0, ptr noundef nonnull %1, ptr noundef nonnull %6)
  %.not28 = icmp eq i32 %34, 1
  br i1 %.not28, label %.critedge, label %35

35:                                               ; preds = %32
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1769, ptr noundef nonnull @__FUNCTION__.asn1_generalized_time_from_der_ex) #5
  call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %6) #4
  br label %49

38:                                               ; preds = %30
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1775, ptr noundef nonnull @__FUNCTION__.asn1_generalized_time_from_der_ex) #5
  br label %49

41:                                               ; preds = %30
  %42 = load ptr, ptr @stderr, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 1778, ptr noundef nonnull @__FUNCTION__.asn1_generalized_time_from_der_ex) #5
  br label %49

.critedge:                                        ; preds = %32
  call void @llvm.lifetime.end.p0(i64 15, ptr nonnull %6) #4
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 %44
  store ptr %46, ptr %2, align 8, !tbaa !5
  %47 = load i64, ptr %3, align 8, !tbaa !9
  %48 = sub i64 %47, %44
  store i64 %48, ptr %3, align 8, !tbaa !9
  br label %49

49:                                               ; preds = %35, %.critedge, %41, %38, %27, %22, %13
  %.1 = phi i32 [ 0, %22 ], [ -1, %27 ], [ 1, %.critedge ], [ -1, %35 ], [ -1, %38 ], [ -1, %41 ], [ -1, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret i32 %.1
}

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind }
attributes #5 = { 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,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass