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

; 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 [62 x i8], align 1
@__FUNCTION__.x509_crl_exts_add_issuing_distribution_point = external hidden unnamed_addr constant [45 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

declare i32 @asn1_length_le(i64 noundef, i64 noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_crl_exts_add_issuing_distribution_point(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10) #3 {
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i64, align 8
  %27 = alloca [512 x i8], align 16
  %28 = alloca i64, align 8
  %29 = alloca ptr, align 8
  %30 = alloca i64, align 8
  %31 = alloca i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store ptr %1, ptr %14, align 8, !tbaa !5
  store i64 %2, ptr %15, align 8, !tbaa !9
  store i32 %3, ptr %16, align 4, !tbaa !11
  store ptr %4, ptr %17, align 8, !tbaa !5
  store i64 %5, ptr %18, align 8, !tbaa !9
  store i32 %6, ptr %19, align 4, !tbaa !11
  store i32 %7, ptr %20, align 4, !tbaa !11
  store i32 %8, ptr %21, align 4, !tbaa !11
  store i32 %9, ptr %22, align 4, !tbaa !11
  store i32 %10, ptr %23, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 66, ptr %24, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %32 = load ptr, ptr %14, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !9
  store i64 %33, ptr %26, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 512, ptr %27) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  store i64 0, ptr %28, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  %34 = getelementptr inbounds [512 x i8], ptr %27, i64 0, i64 0
  store ptr %34, ptr %29, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #4
  store i64 0, ptr %30, align 8, !tbaa !9
  %35 = load ptr, ptr %17, align 8, !tbaa !5
  %36 = load i64, ptr %18, align 8, !tbaa !9
  %37 = load i32, ptr %19, align 4, !tbaa !11
  %38 = load i32, ptr %20, align 4, !tbaa !11
  %39 = load i32, ptr %21, align 4, !tbaa !11
  %40 = load i32, ptr %22, align 4, !tbaa !11
  %41 = load i32, ptr %23, align 4, !tbaa !11
  %42 = call i32 @x509_issuing_distribution_point_to_der(ptr noundef %35, i64 noundef %36, i32 noundef %37, i32 noundef %38, i32 noundef %39, i32 noundef %40, i32 noundef %41, ptr noundef null, ptr noundef %30)
  store i32 %42, ptr %25, align 4, !tbaa !11
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %44, label %55

44:                                               ; preds = %11
  %45 = load i32, ptr %25, align 4, !tbaa !11
  %46 = icmp slt i32 %45, 0
  br i1 %46, label %47, label %53

47:                                               ; preds = %44
  br label %48

48:                                               ; preds = %47
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1150, ptr noundef @__FUNCTION__.x509_crl_exts_add_issuing_distribution_point) #4
  br label %51

51:                                               ; preds = %48
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52, %44
  %54 = load i32, ptr %25, align 4, !tbaa !11
  store i32 %54, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %111

55:                                               ; preds = %11
  %56 = load i64, ptr %30, align 8, !tbaa !9
  %57 = icmp ugt i64 %56, 512
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr @stderr, align 8, !tbaa !5
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1154, ptr noundef @__FUNCTION__.x509_crl_exts_add_issuing_distribution_point) #4
  br label %62

62:                                               ; preds = %59
  br label %63

63:                                               ; preds = %62
  store i32 -1, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %111

64:                                               ; preds = %55
  %65 = load ptr, ptr %17, align 8, !tbaa !5
  %66 = load i64, ptr %18, align 8, !tbaa !9
  %67 = load i32, ptr %19, align 4, !tbaa !11
  %68 = load i32, ptr %20, align 4, !tbaa !11
  %69 = load i32, ptr %21, align 4, !tbaa !11
  %70 = load i32, ptr %22, align 4, !tbaa !11
  %71 = load i32, ptr %23, align 4, !tbaa !11
  %72 = call i32 @x509_issuing_distribution_point_to_der(ptr noundef %65, i64 noundef %66, i32 noundef %67, i32 noundef %68, i32 noundef %69, i32 noundef %70, i32 noundef %71, ptr noundef %29, ptr noundef %28)
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %74, label %80

74:                                               ; preds = %64
  br label %75

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

78:                                               ; preds = %75
  br label %79

79:                                               ; preds = %78
  store i32 -1, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %111

80:                                               ; preds = %64
  %81 = load ptr, ptr %14, align 8, !tbaa !5
  %82 = load i64, ptr %81, align 8, !tbaa !9
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 %82
  store ptr %84, ptr %13, align 8, !tbaa !5
  %85 = load i32, ptr %24, align 4, !tbaa !11
  %86 = load i32, ptr %16, align 4, !tbaa !11
  %87 = getelementptr inbounds [512 x i8], ptr %27, i64 0, i64 0
  %88 = load i64, ptr %28, align 8, !tbaa !9
  %89 = call i32 @x509_crl_ext_to_der(i32 noundef %85, i32 noundef %86, ptr noundef %87, i64 noundef %88, ptr noundef null, ptr noundef %26)
  %90 = icmp ne i32 %89, 1
  br i1 %90, label %104, label %91

91:                                               ; preds = %80
  %92 = load i64, ptr %26, align 8, !tbaa !9
  %93 = load i64, ptr %15, align 8, !tbaa !9
  %94 = call i32 @asn1_length_le(i64 noundef %92, i64 noundef %93)
  %95 = icmp ne i32 %94, 1
  br i1 %95, label %104, label %96

96:                                               ; preds = %91
  %97 = load i32, ptr %24, align 4, !tbaa !11
  %98 = load i32, ptr %16, align 4, !tbaa !11
  %99 = getelementptr inbounds [512 x i8], ptr %27, i64 0, i64 0
  %100 = load i64, ptr %28, align 8, !tbaa !9
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  %102 = call i32 @x509_crl_ext_to_der(i32 noundef %97, i32 noundef %98, ptr noundef %99, i64 noundef %100, ptr noundef %13, ptr noundef %101)
  %103 = icmp ne i32 %102, 1
  br i1 %103, label %104, label %110

104:                                              ; preds = %96, %91, %80
  br label %105

105:                                              ; preds = %104
  %106 = load ptr, ptr @stderr, align 8, !tbaa !5
  %107 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 1171, ptr noundef @__FUNCTION__.x509_crl_exts_add_issuing_distribution_point) #4
  br label %108

108:                                              ; preds = %105
  br label %109

109:                                              ; preds = %108
  store i32 -1, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %111

110:                                              ; preds = %96
  store i32 1, ptr %12, align 4
  store i32 1, ptr %31, align 4
  br label %111

111:                                              ; preds = %110, %109, %79, %63, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  %112 = load i32, ptr %12, align 4
  ret i32 %112
}

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 = { "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 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 = !{!"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}


; 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 [62 x i8], align 1
@__FUNCTION__.x509_crl_exts_add_issuing_distribution_point = external hidden unnamed_addr constant [45 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

declare i32 @asn1_length_le(i64 noundef, i64 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_crl_exts_add_issuing_distribution_point(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10) local_unnamed_addr #3 {
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca [512 x i8], align 16
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #4
  %18 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %18, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #4
  store i64 0, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #4
  store ptr %14, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %17) #4
  store i64 0, ptr %17, align 8, !tbaa !5
  %19 = call i32 @x509_issuing_distribution_point_to_der(ptr noundef %4, i64 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10, ptr noundef null, ptr noundef nonnull %17)
  %.not = icmp eq i32 %19, 1
  br i1 %.not, label %22, label %20

20:                                               ; preds = %11
  %21 = icmp slt i32 %19, 0
  br i1 %21, label %.sink.split, label %40

22:                                               ; preds = %11
  %23 = load i64, ptr %17, align 8, !tbaa !5
  %24 = icmp ugt i64 %23, 512
  br i1 %24, label %.sink.split, label %25

25:                                               ; preds = %22
  %26 = call i32 @x509_issuing_distribution_point_to_der(ptr noundef %4, i64 noundef %5, i32 noundef %6, i32 noundef %7, i32 noundef %8, i32 noundef %9, i32 noundef %10, ptr noundef nonnull %16, ptr noundef nonnull %15)
  %.not25 = icmp eq i32 %26, 1
  br i1 %.not25, label %27, label %.sink.split

27:                                               ; preds = %25
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 %28
  store ptr %29, ptr %12, align 8, !tbaa !9
  %30 = load i64, ptr %15, align 8, !tbaa !5
  %31 = call i32 @x509_crl_ext_to_der(i32 noundef 66, i32 noundef %3, ptr noundef nonnull %14, i64 noundef %30, ptr noundef null, ptr noundef nonnull %13)
  %.not26 = icmp eq i32 %31, 1
  br i1 %.not26, label %32, label %.sink.split

32:                                               ; preds = %27
  %33 = load i64, ptr %13, align 8, !tbaa !5
  %34 = call i32 @asn1_length_le(i64 noundef %33, i64 noundef %2) #4
  %.not27 = icmp eq i32 %34, 1
  br i1 %.not27, label %35, label %.sink.split

35:                                               ; preds = %32
  %36 = load i64, ptr %15, align 8, !tbaa !5
  %37 = call i32 @x509_crl_ext_to_der(i32 noundef 66, i32 noundef %3, ptr noundef nonnull %14, i64 noundef %36, ptr noundef nonnull %12, ptr noundef nonnull %1)
  %.not28 = icmp eq i32 %37, 1
  br i1 %.not28, label %40, label %.sink.split

.sink.split:                                      ; preds = %35, %32, %27, %25, %22, %20
  %.sink29 = phi i32 [ 1150, %20 ], [ 1154, %22 ], [ 1164, %25 ], [ 1171, %27 ], [ 1171, %32 ], [ 1171, %35 ]
  %.0.ph = phi i32 [ %19, %20 ], [ -1, %22 ], [ -1, %25 ], [ -1, %27 ], [ -1, %32 ], [ -1, %35 ]
  %38 = load ptr, ptr @stderr, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef %.sink29, ptr noundef nonnull @__FUNCTION__.x509_crl_exts_add_issuing_distribution_point) #5
  br label %40

40:                                               ; preds = %.sink.split, %35, %20
  %.0 = phi i32 [ %19, %20 ], [ 1, %35 ], [ %.0.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #4
  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 = { "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 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 = !{!"long", !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}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass