; 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
@x509_crl_reason_names = external hidden global [11 x ptr], align 16
@__FUNCTION__.x509_crl_reason_from_name = external hidden unnamed_addr constant [26 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @x509_crl_reason_from_name(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %23, %2
  %9 = load i64, ptr %6, align 8, !tbaa !9
  %10 = icmp ult i64 %9, 11
  br i1 %10, label %11, label %26

11:                                               ; preds = %8
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = getelementptr inbounds [11 x ptr], ptr @x509_crl_reason_names, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = call i32 @strcmp(ptr noundef %12, ptr noundef %15) #5
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %11
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = trunc i64 %19 to i32
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 %20, ptr %21, align 4, !tbaa !11
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %32

22:                                               ; preds = %11
  br label %23

23:                                               ; preds = %22
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = add i64 %24, 1
  store i64 %25, ptr %6, align 8, !tbaa !9
  br label %8, !llvm.loop !13

26:                                               ; preds = %8
  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 61, ptr noundef @__FUNCTION__.x509_crl_reason_from_name) #4
  br label %30

30:                                               ; preds = %27
  br label %31

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

32:                                               ; preds = %31, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %33 = load i32, ptr %3, align 4
  ret i32 %33
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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

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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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
@x509_crl_reason_names = external hidden local_unnamed_addr global [11 x ptr], align 16
@__FUNCTION__.x509_crl_reason_from_name = external hidden unnamed_addr constant [26 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: nofree nounwind uwtable
define dso_local range(i32 -1, 2) i32 @x509_crl_reason_from_name(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = load ptr, ptr @x509_crl_reason_names, align 16, !tbaa !5
  %4 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %3) #3
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %7

6:                                                ; preds = %43, %39, %35, %31, %27, %23, %19, %15, %11, %7, %2
  %.08.lcssa = phi i32 [ 0, %2 ], [ 1, %7 ], [ 2, %11 ], [ 3, %15 ], [ 4, %19 ], [ 5, %23 ], [ 6, %27 ], [ 7, %31 ], [ 8, %35 ], [ 9, %39 ], [ 10, %43 ]
  store i32 %.08.lcssa, ptr %0, align 4, !tbaa !9
  br label %50

7:                                                ; preds = %2
  %8 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 8), align 8, !tbaa !5
  %9 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %8) #3
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %6, label %11

11:                                               ; preds = %7
  %12 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 16), align 16, !tbaa !5
  %13 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %12) #3
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %6, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 24), align 8, !tbaa !5
  %17 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %16) #3
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %6, label %19

19:                                               ; preds = %15
  %20 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 32), align 16, !tbaa !5
  %21 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %20) #3
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %6, label %23

23:                                               ; preds = %19
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 40), align 8, !tbaa !5
  %25 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %24) #3
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %6, label %27

27:                                               ; preds = %23
  %28 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 48), align 16, !tbaa !5
  %29 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %28) #3
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %6, label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 56), align 8, !tbaa !5
  %33 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %32) #3
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %6, label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 64), align 16, !tbaa !5
  %37 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %36) #3
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %6, label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 72), align 8, !tbaa !5
  %41 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %40) #3
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %6, label %43

43:                                               ; preds = %39
  %44 = load ptr, ptr getelementptr inbounds (i8, ptr @x509_crl_reason_names, i64 80), align 16, !tbaa !5
  %45 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) %44) #3
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %6, label %47

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

50:                                               ; preds = %47, %6
  %.06 = phi i32 [ 1, %6 ], [ -1, %47 ]
  ret i32 %.06
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

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 = { nofree 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #4 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass