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

34:                                               ; preds = %10
  %35 = load i64, ptr %19, align 8, !tbaa !9
  %36 = icmp eq i64 %35, 0
  br i1 %36, label %37, label %41

37:                                               ; preds = %34
  %38 = load i64, ptr %21, align 8, !tbaa !9
  %39 = icmp eq i64 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  store i32 0, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %94

41:                                               ; preds = %37, %34, %10
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 %43
  store ptr %45, ptr %12, align 8, !tbaa !5
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  %47 = load i64, ptr %17, align 8, !tbaa !9
  %48 = load ptr, ptr %18, align 8, !tbaa !5
  %49 = load i64, ptr %19, align 8, !tbaa !9
  %50 = load ptr, ptr %20, align 8, !tbaa !5
  %51 = load i64, ptr %21, align 8, !tbaa !9
  %52 = call i32 @x509_authority_key_identifier_to_der(ptr noundef %46, i64 noundef %47, ptr noundef %48, i64 noundef %49, ptr noundef %50, i64 noundef %51, ptr noundef null, ptr noundef %27)
  %53 = icmp ne i32 %52, 1
  br i1 %53, label %87, label %54

54:                                               ; preds = %41
  %55 = load i64, ptr %27, align 8, !tbaa !9
  %56 = call i32 @asn1_length_le(i64 noundef %55, i64 noundef 512)
  %57 = icmp ne i32 %56, 1
  br i1 %57, label %87, label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = load i64, ptr %17, align 8, !tbaa !9
  %61 = load ptr, ptr %18, align 8, !tbaa !5
  %62 = load i64, ptr %19, align 8, !tbaa !9
  %63 = load ptr, ptr %20, align 8, !tbaa !5
  %64 = load i64, ptr %21, align 8, !tbaa !9
  %65 = call i32 @x509_authority_key_identifier_to_der(ptr noundef %59, i64 noundef %60, ptr noundef %61, i64 noundef %62, ptr noundef %63, i64 noundef %64, ptr noundef %25, ptr noundef %26)
  %66 = icmp ne i32 %65, 1
  br i1 %66, label %87, label %67

67:                                               ; preds = %58
  %68 = load i32, ptr %22, align 4, !tbaa !11
  %69 = load i32, ptr %15, align 4, !tbaa !11
  %70 = getelementptr inbounds [512 x i8], ptr %24, i64 0, i64 0
  %71 = load i64, ptr %26, align 8, !tbaa !9
  %72 = call i32 @x509_ext_to_der(i32 noundef %68, i32 noundef %69, ptr noundef %70, i64 noundef %71, ptr noundef null, ptr noundef %23)
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %87, label %74

74:                                               ; preds = %67
  %75 = load i64, ptr %23, align 8, !tbaa !9
  %76 = load i64, ptr %14, align 8, !tbaa !9
  %77 = call i32 @asn1_length_le(i64 noundef %75, i64 noundef %76)
  %78 = icmp ne i32 %77, 1
  br i1 %78, label %87, label %79

79:                                               ; preds = %74
  %80 = load i32, ptr %22, align 4, !tbaa !11
  %81 = load i32, ptr %15, align 4, !tbaa !11
  %82 = getelementptr inbounds [512 x i8], ptr %24, i64 0, i64 0
  %83 = load i64, ptr %26, align 8, !tbaa !9
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  %85 = call i32 @x509_ext_to_der(i32 noundef %80, i32 noundef %81, ptr noundef %82, i64 noundef %83, ptr noundef %12, ptr noundef %84)
  %86 = icmp ne i32 %85, 1
  br i1 %86, label %87, label %93

87:                                               ; preds = %79, %74, %67, %58, %54, %41
  br label %88

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

91:                                               ; preds = %88
  br label %92

92:                                               ; preds = %91
  store i32 -1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %94

93:                                               ; preds = %79
  store i32 1, ptr %11, align 4
  store i32 1, ptr %28, align 4
  br label %94

94:                                               ; preds = %93, %92, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  %95 = load i32, ptr %11, align 4
  ret i32 %95
}

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

20:                                               ; preds = %10
  %21 = getelementptr inbounds i8, ptr %0, i64 %17
  store ptr %21, ptr %11, align 8, !tbaa !9
  %22 = call i32 @x509_authority_key_identifier_to_der(ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef null, ptr noundef nonnull %16)
  %.not = icmp eq i32 %22, 1
  br i1 %.not, label %23, label %37

23:                                               ; preds = %20
  %24 = load i64, ptr %16, align 8, !tbaa !5
  %25 = call i32 @asn1_length_le(i64 noundef %24, i64 noundef 512) #4
  %.not26 = icmp eq i32 %25, 1
  br i1 %.not26, label %26, label %37

26:                                               ; preds = %23
  %27 = call i32 @x509_authority_key_identifier_to_der(ptr noundef %4, i64 noundef %5, ptr noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9, ptr noundef nonnull %14, ptr noundef nonnull %15)
  %.not27 = icmp eq i32 %27, 1
  br i1 %.not27, label %28, label %37

28:                                               ; preds = %26
  %29 = load i64, ptr %15, align 8, !tbaa !5
  %30 = call i32 @x509_ext_to_der(i32 noundef 44, i32 noundef %3, ptr noundef nonnull %13, i64 noundef %29, ptr noundef null, ptr noundef nonnull %12)
  %.not28 = icmp eq i32 %30, 1
  br i1 %.not28, label %31, label %37

31:                                               ; preds = %28
  %32 = load i64, ptr %12, align 8, !tbaa !5
  %33 = call i32 @asn1_length_le(i64 noundef %32, i64 noundef %2) #4
  %.not29 = icmp eq i32 %33, 1
  br i1 %.not29, label %34, label %37

34:                                               ; preds = %31
  %35 = load i64, ptr %15, align 8, !tbaa !5
  %36 = call i32 @x509_ext_to_der(i32 noundef 44, i32 noundef %3, ptr noundef nonnull %13, i64 noundef %35, ptr noundef nonnull %11, ptr noundef nonnull %1)
  %.not30 = icmp eq i32 %36, 1
  br i1 %.not30, label %40, label %37

37:                                               ; preds = %20, %23, %26, %28, %31, %34
  %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 344, ptr noundef nonnull @__FUNCTION__.x509_exts_add_authority_key_identifier) #5
  br label %40

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @x509_authority_key_identifier_to_der(ptr noundef, i64 noundef, 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