; 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_name_constraints = external hidden unnamed_addr constant [31 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_name_constraints(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7) #2 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca [512 x i8], align 16
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store i64 %2, ptr %12, align 8, !tbaa !9
  store i32 %3, ptr %13, align 4, !tbaa !11
  store ptr %4, ptr %14, align 8, !tbaa !5
  store i64 %5, ptr %15, align 8, !tbaa !9
  store ptr %6, ptr %16, align 8, !tbaa !5
  store i64 %7, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 53, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load i64, ptr %25, align 8, !tbaa !9
  store i64 %26, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 512, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %27 = getelementptr inbounds [512 x i8], ptr %20, i64 0, i64 0
  store ptr %27, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  store i64 0, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  store i64 0, ptr %23, align 8, !tbaa !9
  %28 = load i64, ptr %15, align 8, !tbaa !9
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %34

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

33:                                               ; preds = %30
  store i32 0, ptr %9, align 4
  store i32 1, ptr %24, align 4
  br label %83

34:                                               ; preds = %30, %8
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 %36
  store ptr %38, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = load i64, ptr %15, align 8, !tbaa !9
  %41 = load ptr, ptr %16, align 8, !tbaa !5
  %42 = load i64, ptr %17, align 8, !tbaa !9
  %43 = call i32 @x509_name_constraints_to_der(ptr noundef %39, i64 noundef %40, ptr noundef %41, i64 noundef %42, ptr noundef null, ptr noundef %23)
  %44 = icmp ne i32 %43, 1
  br i1 %44, label %76, label %45

45:                                               ; preds = %34
  %46 = load i64, ptr %23, align 8, !tbaa !9
  %47 = call i32 @asn1_length_le(i64 noundef %46, i64 noundef 512)
  %48 = icmp ne i32 %47, 1
  br i1 %48, label %76, label %49

49:                                               ; preds = %45
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = load i64, ptr %15, align 8, !tbaa !9
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = load i64, ptr %17, align 8, !tbaa !9
  %54 = call i32 @x509_name_constraints_to_der(ptr noundef %50, i64 noundef %51, ptr noundef %52, i64 noundef %53, ptr noundef %21, ptr noundef %22)
  %55 = icmp ne i32 %54, 1
  br i1 %55, label %76, label %56

56:                                               ; preds = %49
  %57 = load i32, ptr %18, align 4, !tbaa !11
  %58 = load i32, ptr %13, align 4, !tbaa !11
  %59 = getelementptr inbounds [512 x i8], ptr %20, i64 0, i64 0
  %60 = load i64, ptr %22, align 8, !tbaa !9
  %61 = call i32 @x509_ext_to_der(i32 noundef %57, i32 noundef %58, ptr noundef %59, i64 noundef %60, ptr noundef null, ptr noundef %19)
  %62 = icmp ne i32 %61, 1
  br i1 %62, label %76, label %63

63:                                               ; preds = %56
  %64 = load i64, ptr %19, align 8, !tbaa !9
  %65 = load i64, ptr %12, align 8, !tbaa !9
  %66 = call i32 @asn1_length_le(i64 noundef %64, i64 noundef %65)
  %67 = icmp ne i32 %66, 1
  br i1 %67, label %76, label %68

68:                                               ; preds = %63
  %69 = load i32, ptr %18, align 4, !tbaa !11
  %70 = load i32, ptr %13, align 4, !tbaa !11
  %71 = getelementptr inbounds [512 x i8], ptr %20, i64 0, i64 0
  %72 = load i64, ptr %22, align 8, !tbaa !9
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = call i32 @x509_ext_to_der(i32 noundef %69, i32 noundef %70, ptr noundef %71, i64 noundef %72, ptr noundef %10, ptr noundef %73)
  %75 = icmp ne i32 %74, 1
  br i1 %75, label %76, label %82

76:                                               ; preds = %68, %63, %56, %49, %45, %34
  br label %77

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

80:                                               ; preds = %77
  br label %81

81:                                               ; preds = %80
  store i32 -1, ptr %9, align 4
  store i32 1, ptr %24, align 4
  br label %83

82:                                               ; preds = %68
  store i32 1, ptr %9, align 4
  store i32 1, ptr %24, align 4
  br label %83

83:                                               ; preds = %82, %81, %33
  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 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %84 = load i32, ptr %9, align 4
  ret i32 %84
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_name_constraints_to_der(ptr noundef, i64 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_name_constraints = external hidden unnamed_addr constant [31 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_name_constraints(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7) local_unnamed_addr #2 {
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca [512 x i8], align 16
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  %15 = load i64, ptr %1, align 8, !tbaa !5
  store i64 %15, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #4
  store ptr %11, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #4
  store i64 0, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #4
  store i64 0, ptr %14, align 8, !tbaa !5
  %16 = or i64 %7, %5
  %or.cond = icmp eq i64 %16, 0
  br i1 %or.cond, label %37, label %17

17:                                               ; preds = %8
  %18 = getelementptr inbounds i8, ptr %0, i64 %15
  store ptr %18, ptr %9, align 8, !tbaa !9
  %19 = call i32 @x509_name_constraints_to_der(ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef null, ptr noundef nonnull %14)
  %.not = icmp eq i32 %19, 1
  br i1 %.not, label %20, label %34

20:                                               ; preds = %17
  %21 = load i64, ptr %14, align 8, !tbaa !5
  %22 = call i32 @asn1_length_le(i64 noundef %21, i64 noundef 512) #4
  %.not19 = icmp eq i32 %22, 1
  br i1 %.not19, label %23, label %34

23:                                               ; preds = %20
  %24 = call i32 @x509_name_constraints_to_der(ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef nonnull %12, ptr noundef nonnull %13)
  %.not20 = icmp eq i32 %24, 1
  br i1 %.not20, label %25, label %34

25:                                               ; preds = %23
  %26 = load i64, ptr %13, align 8, !tbaa !5
  %27 = call i32 @x509_ext_to_der(i32 noundef 53, i32 noundef %3, ptr noundef nonnull %11, i64 noundef %26, ptr noundef null, ptr noundef nonnull %10)
  %.not21 = icmp eq i32 %27, 1
  br i1 %.not21, label %28, label %34

28:                                               ; preds = %25
  %29 = load i64, ptr %10, align 8, !tbaa !5
  %30 = call i32 @asn1_length_le(i64 noundef %29, i64 noundef %2) #4
  %.not22 = icmp eq i32 %30, 1
  br i1 %.not22, label %31, label %34

31:                                               ; preds = %28
  %32 = load i64, ptr %13, align 8, !tbaa !5
  %33 = call i32 @x509_ext_to_der(i32 noundef 53, i32 noundef %3, ptr noundef nonnull %11, i64 noundef %32, ptr noundef nonnull %9, ptr noundef nonnull %1)
  %.not23 = icmp eq i32 %33, 1
  br i1 %.not23, label %37, label %34

34:                                               ; preds = %17, %20, %23, %25, %28, %31
  %35 = load ptr, ptr @stderr, align 8, !tbaa !9
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 513, ptr noundef nonnull @__FUNCTION__.x509_exts_add_name_constraints) #5
  br label %37

37:                                               ; preds = %31, %8, %34
  %.0 = phi i32 [ -1, %34 ], [ 0, %8 ], [ 1, %31 ]
  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 8, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_name_constraints_to_der(ptr noundef, i64 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass