; 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_authority_info_access_to_der = external hidden unnamed_addr constant [34 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

declare i32 @asn1_header_to_der(i32 noundef, i64 noundef, ptr noundef, ptr noundef) #2

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

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

18:                                               ; preds = %6
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = icmp ne i64 %19, 0
  br i1 %20, label %21, label %33

21:                                               ; preds = %18
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load i64, ptr %9, align 8, !tbaa !9
  %24 = call i32 @x509_access_description_to_der(i32 noundef 62, ptr noundef %22, i64 noundef %23, ptr noundef null, ptr noundef %14)
  %25 = icmp ne i32 %24, 1
  br i1 %25, label %26, label %32

26:                                               ; preds = %21
  br label %27

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

30:                                               ; preds = %27
  br label %31

31:                                               ; preds = %30
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

32:                                               ; preds = %21
  br label %33

33:                                               ; preds = %32, %18, %6
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %51

36:                                               ; preds = %33
  %37 = load i64, ptr %11, align 8, !tbaa !9
  %38 = icmp ne i64 %37, 0
  br i1 %38, label %39, label %51

39:                                               ; preds = %36
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = call i32 @x509_access_description_to_der(i32 noundef 63, ptr noundef %40, i64 noundef %41, ptr noundef null, ptr noundef %14)
  %43 = icmp ne i32 %42, 1
  br i1 %43, label %44, label %50

44:                                               ; preds = %39
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 3114, ptr noundef @__FUNCTION__.x509_authority_info_access_to_der) #4
  br label %48

48:                                               ; preds = %45
  br label %49

49:                                               ; preds = %48
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

50:                                               ; preds = %39
  br label %51

51:                                               ; preds = %50, %36, %33
  %52 = load i64, ptr %14, align 8, !tbaa !9
  %53 = icmp ne i64 %52, 0
  br i1 %53, label %60, label %54

54:                                               ; preds = %51
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 3119, ptr noundef @__FUNCTION__.x509_authority_info_access_to_der) #4
  br label %58

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

60:                                               ; preds = %51
  %61 = load i64, ptr %14, align 8, !tbaa !9
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %61, ptr noundef %62, ptr noundef %63)
  %65 = icmp ne i32 %64, 1
  br i1 %65, label %66, label %72

66:                                               ; preds = %60
  br label %67

67:                                               ; preds = %66
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 3123, ptr noundef @__FUNCTION__.x509_authority_info_access_to_der) #4
  br label %70

70:                                               ; preds = %67
  br label %71

71:                                               ; preds = %70
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

72:                                               ; preds = %60
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %75, label %92

75:                                               ; preds = %72
  %76 = load i64, ptr %9, align 8, !tbaa !9
  %77 = icmp ne i64 %76, 0
  br i1 %77, label %78, label %92

78:                                               ; preds = %75
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load i64, ptr %9, align 8, !tbaa !9
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = call i32 @x509_access_description_to_der(i32 noundef 62, ptr noundef %79, i64 noundef %80, ptr noundef %81, ptr noundef %82)
  %84 = icmp ne i32 %83, 1
  br i1 %84, label %85, label %91

85:                                               ; preds = %78
  br label %86

86:                                               ; preds = %85
  %87 = load ptr, ptr @stderr, align 8, !tbaa !5
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef @.str, ptr noundef @.str.1, i32 noundef 3128, ptr noundef @__FUNCTION__.x509_authority_info_access_to_der) #4
  br label %89

89:                                               ; preds = %86
  br label %90

90:                                               ; preds = %89
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

91:                                               ; preds = %78
  br label %92

92:                                               ; preds = %91, %75, %72
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %95, label %112

95:                                               ; preds = %92
  %96 = load i64, ptr %11, align 8, !tbaa !9
  %97 = icmp ne i64 %96, 0
  br i1 %97, label %98, label %112

98:                                               ; preds = %95
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = load i64, ptr %11, align 8, !tbaa !9
  %101 = load ptr, ptr %12, align 8, !tbaa !5
  %102 = load ptr, ptr %13, align 8, !tbaa !5
  %103 = call i32 @x509_access_description_to_der(i32 noundef 63, ptr noundef %99, i64 noundef %100, ptr noundef %101, ptr noundef %102)
  %104 = icmp ne i32 %103, 1
  br i1 %104, label %105, label %111

105:                                              ; preds = %98
  br label %106

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

109:                                              ; preds = %106
  br label %110

110:                                              ; preds = %109
  store i32 -1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

111:                                              ; preds = %98
  br label %112

112:                                              ; preds = %111, %95, %92
  store i32 1, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %113

113:                                              ; preds = %112, %110, %90, %71, %59, %49, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %114 = load i32, ptr %7, align 4
  ret i32 %114
}

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


; 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_authority_info_access_to_der = external hidden unnamed_addr constant [34 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

declare i32 @asn1_header_to_der(i32 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

10:                                               ; preds = %6
  %11 = call i32 @x509_access_description_to_der(i32 noundef 62, ptr noundef nonnull %0, i64 noundef %1, ptr noundef null, ptr noundef nonnull %7)
  %.not = icmp eq i32 %11, 1
  br i1 %.not, label %12, label %.sink.split

12:                                               ; preds = %10, %6
  %13 = icmp ne ptr %2, null
  %14 = icmp ne i64 %3, 0
  %or.cond3 = and i1 %13, %14
  br i1 %or.cond3, label %15, label %17

15:                                               ; preds = %12
  %16 = call i32 @x509_access_description_to_der(i32 noundef 63, ptr noundef nonnull %2, i64 noundef %3, ptr noundef null, ptr noundef nonnull %7)
  %.not37 = icmp eq i32 %16, 1
  br i1 %.not37, label %17, label %.sink.split

17:                                               ; preds = %15, %12
  %18 = load i64, ptr %7, align 8, !tbaa !5
  %.not38 = icmp eq i64 %18, 0
  br i1 %.not38, label %.sink.split, label %19

19:                                               ; preds = %17
  %20 = call i32 @asn1_header_to_der(i32 noundef 48, i64 noundef %18, ptr noundef %4, ptr noundef %5) #4
  %.not39 = icmp eq i32 %20, 1
  br i1 %.not39, label %21, label %.sink.split

21:                                               ; preds = %19
  br i1 %or.cond, label %22, label %24

22:                                               ; preds = %21
  %23 = call i32 @x509_access_description_to_der(i32 noundef 62, ptr noundef nonnull %0, i64 noundef %1, ptr noundef %4, ptr noundef %5)
  %.not40 = icmp eq i32 %23, 1
  br i1 %.not40, label %24, label %.sink.split

24:                                               ; preds = %22, %21
  br i1 %or.cond3, label %25, label %29

25:                                               ; preds = %24
  %26 = call i32 @x509_access_description_to_der(i32 noundef 63, ptr noundef nonnull %2, i64 noundef %3, ptr noundef %4, ptr noundef %5)
  %.not41 = icmp eq i32 %26, 1
  br i1 %.not41, label %29, label %.sink.split

.sink.split:                                      ; preds = %25, %22, %19, %17, %15, %10
  %.sink42 = phi i32 [ 3108, %10 ], [ 3114, %15 ], [ 3119, %17 ], [ 3123, %19 ], [ 3128, %22 ], [ 3134, %25 ]
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef %.sink42, ptr noundef nonnull @__FUNCTION__.x509_authority_info_access_to_der) #5
  br label %29

29:                                               ; preds = %.sink.split, %24, %25
  %.0 = phi i32 [ 1, %25 ], [ 1, %24 ], [ -1, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  ret i32 %.0
}

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 = { "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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass