; LLVM IR from openanolis/openssl :: crypto (params)

; 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"

%struct.ossl_param_st = type { ptr, i32, ptr, i64, i64 }

@.str = external hidden unnamed_addr constant [68 x i8], align 1
@__func__.OSSL_PARAM_set_BN = external hidden unnamed_addr constant [18 x i8], align 1

declare void @ERR_new() #0

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) #0

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @OSSL_PARAM_set_BN(ptr noundef %0, ptr noundef %1) #2 {
  %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) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1074, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 786690, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.ossl_param_st, ptr %12, i32 0, i32 4
  store i64 0, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1079, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 786690, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

17:                                               ; preds = %11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ossl_param_st, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp eq i32 %20, 2
  br i1 %21, label %22, label %27

22:                                               ; preds = %17
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 @BN_is_negative(ptr noundef %23)
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1083, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 129, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

27:                                               ; preds = %22, %17
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i32 @BN_num_bits(ptr noundef %28)
  %30 = add nsw i32 %29, 7
  %31 = sdiv i32 %30, 8
  %32 = sext i32 %31 to i64
  store i64 %32, ptr %6, align 8, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ossl_param_st, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %40

37:                                               ; preds = %27
  %38 = load i64, ptr %6, align 8, !tbaa !14
  %39 = add i64 %38, 1
  store i64 %39, ptr %6, align 8, !tbaa !14
  br label %40

40:                                               ; preds = %37, %27
  %41 = load i64, ptr %6, align 8, !tbaa !14
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load i64, ptr %6, align 8, !tbaa !14
  %45 = add i64 %44, 1
  store i64 %45, ptr %6, align 8, !tbaa !14
  br label %46

46:                                               ; preds = %43, %40
  %47 = load i64, ptr %6, align 8, !tbaa !14
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ossl_param_st, ptr %48, i32 0, i32 4
  store i64 %47, ptr %49, align 8, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ossl_param_st, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %46
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

55:                                               ; preds = %46
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ossl_param_st, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !16
  %59 = load i64, ptr %6, align 8, !tbaa !14
  %60 = icmp uge i64 %58, %59
  br i1 %60, label %61, label %98

61:                                               ; preds = %55
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ossl_param_st, ptr %62, i32 0, i32 3
  %64 = load i64, ptr %63, align 8, !tbaa !16
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ossl_param_st, ptr %65, i32 0, i32 4
  store i64 %64, ptr %66, align 8, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ossl_param_st, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %68, align 8, !tbaa !13
  switch i32 %69, label %96 [
    i32 2, label %70
    i32 1, label %83
  ]

70:                                               ; preds = %61
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ossl_param_st, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ossl_param_st, ptr %75, i32 0, i32 3
  %77 = load i64, ptr %76, align 8, !tbaa !16
  %78 = trunc i64 %77 to i32
  %79 = call i32 @BN_bn2nativepad(ptr noundef %71, ptr noundef %74, i32 noundef %78)
  %80 = icmp sge i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %70
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

82:                                               ; preds = %70
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1105, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 127, ptr noundef null)
  br label %97

83:                                               ; preds = %61
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ossl_param_st, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.ossl_param_st, ptr %88, i32 0, i32 3
  %90 = load i64, ptr %89, align 8, !tbaa !16
  %91 = trunc i64 %90 to i32
  %92 = call i32 @BN_signed_bn2native(ptr noundef %84, ptr noundef %87, i32 noundef %91)
  %93 = icmp sge i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %83
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

95:                                               ; preds = %83
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1110, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 127, ptr noundef null)
  br label %97

96:                                               ; preds = %61
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1113, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 129, ptr noundef null)
  br label %97

97:                                               ; preds = %96, %95, %82
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

98:                                               ; preds = %55
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1118, ptr noundef @__func__.OSSL_PARAM_set_BN)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 116, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

99:                                               ; preds = %98, %97, %94, %81, %54, %26, %16, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %100 = load i32, ptr %3, align 4
  ret i32 %100
}

declare i32 @BN_is_negative(ptr noundef) #0

declare i32 @BN_num_bits(ptr noundef) #0

declare i32 @BN_bn2nativepad(ptr noundef, ptr noundef, i32 noundef) #0

declare i32 @BN_signed_bn2native(ptr noundef, ptr noundef, i32 noundef) #0

attributes #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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !12, i64 32}
!10 = !{!"ossl_param_st", !6, i64 0, !11, i64 8, !6, i64 16, !12, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!12, !12, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !12, i64 24}


; 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"

@.str = external hidden unnamed_addr constant [68 x i8], align 1
@__func__.OSSL_PARAM_set_BN = external hidden unnamed_addr constant [18 x i8], align 1

declare void @ERR_new() local_unnamed_addr #0

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @OSSL_PARAM_set_BN(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %.sink.split, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 0, ptr %5, align 8, !tbaa !5
  %6 = icmp eq ptr %1, null
  br i1 %6, label %.sink.split, label %7

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %11, label %13

11:                                               ; preds = %7
  %12 = tail call i32 @BN_is_negative(ptr noundef nonnull %1) #3
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %.sink.split

13:                                               ; preds = %11, %7
  %14 = tail call i32 @BN_num_bits(ptr noundef nonnull %1) #3
  %15 = add nsw i32 %14, 7
  %16 = sdiv i32 %15, 8
  %17 = sext i32 %16 to i64
  %18 = load i32, ptr %8, align 8, !tbaa !12
  %19 = icmp eq i32 %18, 1
  %20 = zext i1 %19 to i64
  %spec.select = add nsw i64 %17, %20
  %.1 = tail call i64 @llvm.umax.i64(i64 %spec.select, i64 1)
  store i64 %.1, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = icmp eq ptr %22, null
  br i1 %23, label %36, label %24

24:                                               ; preds = %13
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %.not28 = icmp ult i64 %26, %.1
  br i1 %.not28, label %.sink.split, label %27

27:                                               ; preds = %24
  store i64 %26, ptr %5, align 8, !tbaa !5
  switch i32 %18, label %.sink.split [
    i32 2, label %28
    i32 1, label %32
  ]

28:                                               ; preds = %27
  %29 = trunc i64 %26 to i32
  %30 = tail call i32 @BN_bn2nativepad(ptr noundef nonnull %1, ptr noundef nonnull %22, i32 noundef %29) #3
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %36, label %.sink.split

32:                                               ; preds = %27
  %33 = trunc i64 %26 to i32
  %34 = tail call i32 @BN_signed_bn2native(ptr noundef nonnull %1, ptr noundef nonnull %22, i32 noundef %33) #3
  %35 = icmp sgt i32 %34, -1
  br i1 %35, label %36, label %.sink.split

.sink.split:                                      ; preds = %24, %27, %32, %28, %11, %4, %2
  %.sink29 = phi i32 [ 1074, %2 ], [ 1079, %4 ], [ 1083, %11 ], [ 1105, %28 ], [ 1110, %32 ], [ 1113, %27 ], [ 1118, %24 ]
  %.sink = phi i32 [ 786690, %2 ], [ 786690, %4 ], [ 129, %11 ], [ 127, %28 ], [ 127, %32 ], [ 129, %27 ], [ 116, %24 ]
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef %.sink29, ptr noundef nonnull @__func__.OSSL_PARAM_set_BN) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef %.sink, ptr noundef null) #3
  br label %36

36:                                               ; preds = %.sink.split, %32, %28, %13
  %.024 = phi i32 [ 1, %13 ], [ 1, %28 ], [ 1, %32 ], [ 0, %.sink.split ]
  ret i32 %.024
}

declare i32 @BN_is_negative(ptr noundef) local_unnamed_addr #0

declare i32 @BN_num_bits(ptr noundef) local_unnamed_addr #0

declare i32 @BN_bn2nativepad(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @BN_signed_bn2native(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

attributes #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 #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 speculatable willreturn memory(none) }
attributes #3 = { 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, !11, i64 32}
!6 = !{!"ossl_param_st", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !7, i64 16}
!14 = !{!6, !11, i64 24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass