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

; 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_exts_add_crl_distribution_points_ex = external hidden unnamed_addr constant [41 x i8], align 1

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

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

; 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 @x509_ext_to_der(i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_exts_add_crl_distribution_points_ex(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7, i64 noundef %8) #2 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca [256 x i8], align 16
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store i64 %2, ptr %13, align 8, !tbaa !9
  store i32 %3, ptr %14, align 4, !tbaa !11
  store i32 %4, ptr %15, align 4, !tbaa !11
  store ptr %5, ptr %16, align 8, !tbaa !5
  store i64 %6, ptr %17, align 8, !tbaa !9
  store ptr %7, ptr %18, align 8, !tbaa !5
  store i64 %8, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !9
  store i64 %27, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 256, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %28 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  store ptr %28, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  store i64 0, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  store i64 0, ptr %24, align 8, !tbaa !9
  %29 = load i64, ptr %17, align 8, !tbaa !9
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %31, label %35

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

34:                                               ; preds = %31
  store i32 0, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %86

35:                                               ; preds = %31, %9
  %36 = load ptr, ptr %16, align 8, !tbaa !5
  %37 = load i64, ptr %17, align 8, !tbaa !9
  %38 = call i32 @x509_uri_as_distribution_points_to_der(ptr noundef %36, i64 noundef %37, i32 noundef -1, ptr noundef null, i64 noundef 0, ptr noundef null, ptr noundef %24)
  %39 = icmp ne i32 %38, 1
  br i1 %39, label %49, label %40

40:                                               ; preds = %35
  %41 = load i64, ptr %24, align 8, !tbaa !9
  %42 = call i32 @asn1_length_le(i64 noundef %41, i64 noundef 256)
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %49, label %44

44:                                               ; preds = %40
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = load i64, ptr %17, align 8, !tbaa !9
  %47 = call i32 @x509_uri_as_distribution_points_to_der(ptr noundef %45, i64 noundef %46, i32 noundef -1, ptr noundef null, i64 noundef 0, ptr noundef %22, ptr noundef %23)
  %48 = icmp ne i32 %47, 1
  br i1 %48, label %49, label %55

49:                                               ; preds = %44, %40, %35
  br label %50

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

53:                                               ; preds = %50
  br label %54

54:                                               ; preds = %53
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %86

55:                                               ; preds = %44
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 %57
  store ptr %59, ptr %11, align 8, !tbaa !5
  %60 = load i32, ptr %14, align 4, !tbaa !11
  %61 = load i32, ptr %15, align 4, !tbaa !11
  %62 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  %63 = load i64, ptr %23, align 8, !tbaa !9
  %64 = call i32 @x509_ext_to_der(i32 noundef %60, i32 noundef %61, ptr noundef %62, i64 noundef %63, ptr noundef null, ptr noundef %20)
  %65 = icmp ne i32 %64, 1
  br i1 %65, label %79, label %66

66:                                               ; preds = %55
  %67 = load i64, ptr %20, align 8, !tbaa !9
  %68 = load i64, ptr %13, align 8, !tbaa !9
  %69 = call i32 @asn1_length_le(i64 noundef %67, i64 noundef %68)
  %70 = icmp ne i32 %69, 1
  br i1 %70, label %79, label %71

71:                                               ; preds = %66
  %72 = load i32, ptr %14, align 4, !tbaa !11
  %73 = load i32, ptr %15, align 4, !tbaa !11
  %74 = getelementptr inbounds [256 x i8], ptr %21, i64 0, i64 0
  %75 = load i64, ptr %23, align 8, !tbaa !9
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = call i32 @x509_ext_to_der(i32 noundef %72, i32 noundef %73, ptr noundef %74, i64 noundef %75, ptr noundef %11, ptr noundef %76)
  %78 = icmp ne i32 %77, 1
  br i1 %78, label %79, label %85

79:                                               ; preds = %71, %66, %55
  br label %80

80:                                               ; preds = %79
  %81 = load ptr, ptr @stderr, align 8, !tbaa !5
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %81, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 616, ptr noundef @__FUNCTION__.x509_exts_add_crl_distribution_points_ex) #4
  br label %83

83:                                               ; preds = %80
  br label %84

84:                                               ; preds = %83
  store i32 -1, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %86

85:                                               ; preds = %71
  store i32 1, ptr %10, align 4
  store i32 1, ptr %25, align 4
  br label %86

86:                                               ; preds = %85, %84, %54, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  %87 = load i32, ptr %10, align 4
  ret i32 %87
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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_exts_add_crl_distribution_points_ex = external hidden unnamed_addr constant [41 x i8], align 1

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

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

; 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 @x509_ext_to_der(i32 noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @x509_exts_add_crl_distribution_points_ex(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, i64 noundef %6, ptr nocapture noundef readnone %7, i64 noundef %8) local_unnamed_addr #2 {
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca [256 x i8], align 16
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  %16 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %16, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #4
  store ptr %12, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #4
  store i64 0, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #4
  store i64 0, ptr %15, align 8, !tbaa !5
  %17 = or i64 %8, %6
  %or.cond = icmp eq i64 %17, 0
  br i1 %or.cond, label %38, label %18

18:                                               ; preds = %9
  %19 = call i32 @x509_uri_as_distribution_points_to_der(ptr noundef %5, i64 noundef %6, i32 noundef -1, ptr noundef null, i64 noundef 0, ptr noundef null, ptr noundef nonnull %15)
  %.not = icmp eq i32 %19, 1
  br i1 %.not, label %20, label %.sink.split

20:                                               ; preds = %18
  %21 = load i64, ptr %15, align 8, !tbaa !5
  %22 = call i32 @asn1_length_le(i64 noundef %21, i64 noundef 256) #4
  %.not15 = icmp eq i32 %22, 1
  br i1 %.not15, label %23, label %.sink.split

23:                                               ; preds = %20
  %24 = call i32 @x509_uri_as_distribution_points_to_der(ptr noundef %5, i64 noundef %6, i32 noundef -1, ptr noundef null, i64 noundef 0, ptr noundef nonnull %13, ptr noundef nonnull %14)
  %.not16 = icmp eq i32 %24, 1
  br i1 %.not16, label %25, label %.sink.split

25:                                               ; preds = %23
  %26 = load i64, ptr %1, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 %26
  store ptr %27, ptr %10, align 8, !tbaa !9
  %28 = load i64, ptr %14, align 8, !tbaa !5
  %29 = call i32 @x509_ext_to_der(i32 noundef %3, i32 noundef %4, ptr noundef nonnull %12, i64 noundef %28, ptr noundef null, ptr noundef nonnull %11)
  %.not17 = icmp eq i32 %29, 1
  br i1 %.not17, label %30, label %.sink.split

30:                                               ; preds = %25
  %31 = load i64, ptr %11, align 8, !tbaa !5
  %32 = call i32 @asn1_length_le(i64 noundef %31, i64 noundef %2) #4
  %.not18 = icmp eq i32 %32, 1
  br i1 %.not18, label %33, label %.sink.split

33:                                               ; preds = %30
  %34 = load i64, ptr %14, align 8, !tbaa !5
  %35 = call i32 @x509_ext_to_der(i32 noundef %3, i32 noundef %4, ptr noundef nonnull %12, i64 noundef %34, ptr noundef nonnull %10, ptr noundef nonnull %1)
  %.not19 = icmp eq i32 %35, 1
  br i1 %.not19, label %38, label %.sink.split

.sink.split:                                      ; preds = %33, %30, %25, %23, %20, %18
  %.sink20 = phi i32 [ 609, %18 ], [ 609, %20 ], [ 609, %23 ], [ 616, %25 ], [ 616, %30 ], [ 616, %33 ]
  %36 = load ptr, ptr @stderr, align 8, !tbaa !9
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef %.sink20, ptr noundef nonnull @__FUNCTION__.x509_exts_add_crl_distribution_points_ex) #5
  br label %38

38:                                               ; preds = %.sink.split, %33, %9
  %.0 = phi i32 [ 0, %9 ], [ 1, %33 ], [ -1, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  ret i32 %.0
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass