; LLVM IR from openssl/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.ecpk_parameters_st = type { i32, %union.anon }
%union.anon = type { ptr }

@.str.2 = external hidden unnamed_addr constant [69 x i8], align 1
@__func__.EC_GROUP_get_ecpkparameters = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @ECPARAMETERS_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ECPKPARAMETERS_new() #0

; Function Attrs: nounwind uwtable
declare dso_local void @ECPKPARAMETERS_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @EC_GROUP_get_ecparameters(ptr 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

declare void @ERR_new() #2

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

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

; 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 ptr @EC_GROUP_get_ecpkparameters(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  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 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %19

14:                                               ; preds = %2
  %15 = call ptr @ECPKPARAMETERS_new()
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.2, i32 noundef 475, ptr noundef @__func__.EC_GROUP_get_ecpkparameters)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 524301, ptr noundef null)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %90

18:                                               ; preds = %14
  br label %44

19:                                               ; preds = %2
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %28

24:                                               ; preds = %19
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  call void @ASN1_OBJECT_free(ptr noundef %27)
  br label %43

28:                                               ; preds = %19
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %42

33:                                               ; preds = %28
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %42

38:                                               ; preds = %33
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  call void @ECPARAMETERS_free(ptr noundef %41)
  br label %42

42:                                               ; preds = %38, %33, %28
  br label %43

43:                                               ; preds = %42, %24
  br label %44

44:                                               ; preds = %43, %18
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = call i32 @EC_GROUP_get_asn1_flag(ptr noundef %45)
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %73

48:                                               ; preds = %44
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call i32 @EC_GROUP_get_curve_name(ptr noundef %49)
  store i32 %50, ptr %7, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %71

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = call ptr @OBJ_nid2obj(i32 noundef %54)
  store ptr %55, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %62, label %58

58:                                               ; preds = %53
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = call i64 @OBJ_length(ptr noundef %59)
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %58, %53
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  call void @ASN1_OBJECT_free(ptr noundef %63)
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str.2, i32 noundef 496, ptr noundef @__func__.EC_GROUP_get_ecpkparameters)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 167, ptr noundef null)
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %70

64:                                               ; preds = %58
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %65, i32 0, i32 0
  store i32 0, ptr %66, align 8, !tbaa !11
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !13
  br label %70

70:                                               ; preds = %64, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %72

71:                                               ; preds = %48
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %71, %70
  br label %83

73:                                               ; preds = %44
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %74, i32 0, i32 0
  store i32 1, ptr %75, align 8, !tbaa !11
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = call ptr @EC_GROUP_get_ecparameters(ptr noundef %76, ptr noundef null)
  %78 = load ptr, ptr %8, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ecpk_parameters_st, ptr %78, i32 0, i32 1
  store ptr %77, ptr %79, align 8, !tbaa !13
  %80 = icmp eq ptr %77, null
  br i1 %80, label %81, label %82

81:                                               ; preds = %73
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %81, %73
  br label %83

83:                                               ; preds = %82, %72
  %84 = load i32, ptr %6, align 4, !tbaa !9
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %88, label %86

86:                                               ; preds = %83
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ECPKPARAMETERS_free(ptr noundef %87)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %90

88:                                               ; preds = %83
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %89, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %90

90:                                               ; preds = %88, %86, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %91 = load ptr, ptr %3, align 8
  ret ptr %91
}

declare void @ASN1_OBJECT_free(ptr noundef) #2

declare i32 @EC_GROUP_get_asn1_flag(ptr noundef) #2

declare i32 @EC_GROUP_get_curve_name(ptr noundef) #2

declare ptr @OBJ_nid2obj(i32 noundef) #2

declare i64 @OBJ_length(ptr noundef) #2

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

!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}
!11 = !{!12, !10, i64 0}
!12 = !{!"ecpk_parameters_st", !10, i64 0, !7, i64 8}
!13 = !{!7, !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"

@.str.2 = external hidden unnamed_addr constant [69 x i8], align 1
@__func__.EC_GROUP_get_ecpkparameters = external hidden unnamed_addr constant [28 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @ECPARAMETERS_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ECPKPARAMETERS_new() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @ECPKPARAMETERS_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @EC_GROUP_get_ecparameters(ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @ERR_new() local_unnamed_addr #1

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

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

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

4:                                                ; preds = %2
  %5 = tail call ptr @ECPKPARAMETERS_new()
  %6 = icmp eq ptr %5, null
  br i1 %6, label %7, label %17

7:                                                ; preds = %4
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.2, i32 noundef 475, ptr noundef nonnull @__func__.EC_GROUP_get_ecpkparameters) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 524301, ptr noundef null) #2
  br label %34

8:                                                ; preds = %2
  %9 = load i32, ptr %1, align 8, !tbaa !5
  switch i32 %9, label %17 [
    i32 0, label %10
    i32 1, label %13
  ]

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !10
  tail call void @ASN1_OBJECT_free(ptr noundef %12) #2
  br label %17

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !10
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %17, label %16

16:                                               ; preds = %13
  tail call void @ECPARAMETERS_free(ptr noundef nonnull %15)
  br label %17

17:                                               ; preds = %8, %10, %16, %13, %4
  %.023 = phi ptr [ %5, %4 ], [ %1, %10 ], [ %1, %16 ], [ %1, %13 ], [ %1, %8 ]
  %18 = tail call i32 @EC_GROUP_get_asn1_flag(ptr noundef %0) #2
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %30

20:                                               ; preds = %17
  %21 = tail call i32 @EC_GROUP_get_curve_name(ptr noundef %0) #2
  %.not31 = icmp eq i32 %21, 0
  br i1 %.not31, label %.critedge, label %22

22:                                               ; preds = %20
  %23 = tail call ptr @OBJ_nid2obj(i32 noundef %21) #2
  %24 = icmp eq ptr %23, null
  br i1 %24, label %28, label %25

25:                                               ; preds = %22
  %26 = tail call i64 @OBJ_length(ptr noundef nonnull %23) #2
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %.critedge34

28:                                               ; preds = %25, %22
  tail call void @ASN1_OBJECT_free(ptr noundef %23) #2
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str.2, i32 noundef 496, ptr noundef nonnull @__func__.EC_GROUP_get_ecpkparameters) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 167, ptr noundef null) #2
  br label %.critedge

.critedge34:                                      ; preds = %25
  store i32 0, ptr %.023, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.023, i64 8
  store ptr %23, ptr %29, align 8, !tbaa !10
  br label %34

30:                                               ; preds = %17
  store i32 1, ptr %.023, align 8, !tbaa !5
  %31 = tail call ptr @EC_GROUP_get_ecparameters(ptr noundef %0, ptr noundef null)
  %32 = getelementptr inbounds i8, ptr %.023, i64 8
  store ptr %31, ptr %32, align 8, !tbaa !10
  %33 = icmp eq ptr %31, null
  br i1 %33, label %.critedge, label %34

.critedge:                                        ; preds = %28, %20, %30
  tail call void @ECPKPARAMETERS_free(ptr noundef nonnull %.023)
  br label %34

34:                                               ; preds = %30, %.critedge34, %.critedge, %7
  %.0 = phi ptr [ null, %7 ], [ null, %.critedge ], [ %.023, %.critedge34 ], [ %.023, %30 ]
  ret ptr %.0
}

declare void @ASN1_OBJECT_free(ptr noundef) local_unnamed_addr #1

declare i32 @EC_GROUP_get_asn1_flag(ptr noundef) local_unnamed_addr #1

declare i32 @EC_GROUP_get_curve_name(ptr noundef) local_unnamed_addr #1

declare ptr @OBJ_nid2obj(i32 noundef) local_unnamed_addr #1

declare i64 @OBJ_length(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 }

!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 0}
!6 = !{!"ecpk_parameters_st", !7, i64 0, !8, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}


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