; LLVM IR from openanolis/openssl :: crypto/ec (ec_asn1)

; 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.ec_key_st = type { ptr, ptr, i32, ptr, ptr, ptr, i32, i32, %struct.CRYPTO_REF_COUNT, i32, %struct.crypto_ex_data_st, ptr, ptr, i64 }
%struct.CRYPTO_REF_COUNT = type { i32 }
%struct.crypto_ex_data_st = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__func__.i2o_ECPublicKey = external hidden unnamed_addr constant [16 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

declare void @ERR_new() #1

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

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

declare void @CRYPTO_free(ptr noundef, ptr noundef, i32 noundef) #1

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

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @i2o_ECPublicKey(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
  %8 = 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
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.2, i32 noundef 1160, ptr noundef @__func__.i2o_ECPublicKey)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 786690, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

12:                                               ; preds = %2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ec_key_st, ptr %13, i32 0, i32 3
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ec_key_st, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !17
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ec_key_st, ptr %19, i32 0, i32 7
  %21 = load i32, ptr %20, align 4, !tbaa !18
  %22 = call i64 @EC_POINT_point2oct(ptr noundef %15, ptr noundef %18, i32 noundef %21, ptr noundef null, i64 noundef 0, ptr noundef null)
  store i64 %22, ptr %6, align 8, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %28, label %25

25:                                               ; preds = %12
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %25, %12
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = trunc i64 %29 to i32
  store i32 %30, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

31:                                               ; preds = %25
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = call ptr @CRYPTO_malloc(i64 noundef %36, ptr noundef @.str.2, i32 noundef 1172)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %37, ptr %38, align 8, !tbaa !5
  %39 = icmp eq ptr %37, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %35
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

41:                                               ; preds = %35
  store i32 1, ptr %7, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %41, %31
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ec_key_st, ptr %43, i32 0, i32 3
  %45 = load ptr, ptr %44, align 8, !tbaa !13
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ec_key_st, ptr %46, i32 0, i32 4
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ec_key_st, ptr %49, i32 0, i32 7
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = call i64 @EC_POINT_point2oct(ptr noundef %45, ptr noundef %48, i32 noundef %51, ptr noundef %53, i64 noundef %54, ptr noundef null)
  %56 = icmp ne i64 %55, 0
  br i1 %56, label %65, label %57

57:                                               ; preds = %42
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.2, i32 noundef 1178, ptr noundef @__func__.i2o_ECPublicKey)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 524304, ptr noundef null)
  %58 = load i32, ptr %7, align 4, !tbaa !11
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %57
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  call void @CRYPTO_free(ptr noundef %62, ptr noundef @.str.2, i32 noundef 1180)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %63, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %60, %57
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

65:                                               ; preds = %42
  %66 = load i32, ptr %7, align 4, !tbaa !11
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %73, label %68

68:                                               ; preds = %65
  %69 = load i64, ptr %6, align 8, !tbaa !9
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 %69
  store ptr %72, ptr %70, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %68, %65
  %74 = load i64, ptr %6, align 8, !tbaa !9
  %75 = trunc i64 %74 to i32
  store i32 %75, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %76

76:                                               ; preds = %73, %64, %40, %28, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %77 = load i32, ptr %3, align 4
  ret i32 %77
}

declare i64 @EC_POINT_point2oct(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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}
!13 = !{!14, !6, i64 24}
!14 = !{!"ec_key_st", !6, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !15, i64 56, !12, i64 60, !16, i64 64, !6, i64 80, !6, i64 88, !10, i64 96}
!15 = !{!"", !7, i64 0}
!16 = !{!"crypto_ex_data_st", !6, i64 0, !6, i64 8}
!17 = !{!14, !6, i64 32}
!18 = !{!14, !12, i64 52}


; 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.2 = external hidden unnamed_addr constant [72 x i8], align 1
@__func__.i2o_ECPublicKey = external hidden unnamed_addr constant [16 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

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

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @i2o_ECPublicKey(ptr noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %2
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.2, i32 noundef 1160, ptr noundef nonnull @__func__.i2o_ECPublicKey) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 786690, ptr noundef null) #2
  br label %37

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 52
  %11 = load i32, ptr %10, align 4, !tbaa !15
  %12 = tail call i64 @EC_POINT_point2oct(ptr noundef %7, ptr noundef %9, i32 noundef %11, ptr noundef null, i64 noundef 0, ptr noundef null) #2
  %13 = icmp eq ptr %1, null
  %14 = icmp eq i64 %12, 0
  %or.cond = select i1 %13, i1 true, i1 %14
  br i1 %or.cond, label %15, label %17

15:                                               ; preds = %5
  %16 = trunc i64 %12 to i32
  br label %37

17:                                               ; preds = %5
  %18 = load ptr, ptr %1, align 8, !tbaa !16
  %.not28.not = icmp eq ptr %18, null
  br i1 %.not28.not, label %19, label %22

19:                                               ; preds = %17
  %20 = tail call ptr @CRYPTO_malloc(i64 noundef %12, ptr noundef nonnull @.str.2, i32 noundef 1172) #2
  store ptr %20, ptr %1, align 8, !tbaa !16
  %21 = icmp eq ptr %20, null
  br i1 %21, label %37, label %22

22:                                               ; preds = %19, %17
  %23 = phi ptr [ %20, %19 ], [ %18, %17 ]
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !14
  %26 = load i32, ptr %10, align 4, !tbaa !15
  %27 = tail call i64 @EC_POINT_point2oct(ptr noundef %24, ptr noundef %25, i32 noundef %26, ptr noundef nonnull %23, i64 noundef %12, ptr noundef null) #2
  %.not = icmp eq i64 %27, 0
  br i1 %.not, label %28, label %31

28:                                               ; preds = %22
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.2, i32 noundef 1178, ptr noundef nonnull @__func__.i2o_ECPublicKey) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 524304, ptr noundef null) #2
  br i1 %.not28.not, label %29, label %37

29:                                               ; preds = %28
  %30 = load ptr, ptr %1, align 8, !tbaa !16
  tail call void @CRYPTO_free(ptr noundef %30, ptr noundef nonnull @.str.2, i32 noundef 1180) #2
  store ptr null, ptr %1, align 8, !tbaa !16
  br label %37

31:                                               ; preds = %22
  br i1 %.not28.not, label %35, label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %1, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %33, i64 %12
  store ptr %34, ptr %1, align 8, !tbaa !16
  br label %35

35:                                               ; preds = %32, %31
  %36 = trunc i64 %12 to i32
  br label %37

37:                                               ; preds = %28, %29, %19, %35, %15, %4
  %.023 = phi i32 [ 0, %4 ], [ %16, %15 ], [ %36, %35 ], [ 0, %19 ], [ 0, %29 ], [ 0, %28 ]
  ret i32 %.023
}

declare i64 @EC_POINT_point2oct(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #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 = { 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 = { 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, !7, i64 24}
!6 = !{!"ec_key_st", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !11, i64 56, !10, i64 60, !12, i64 64, !7, i64 80, !7, i64 88, !13, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"", !8, i64 0}
!12 = !{!"crypto_ex_data_st", !7, i64 0, !7, i64 8}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !7, i64 32}
!15 = !{!6, !10, i64 52}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass