; LLVM IR from openssl/openssl :: crypto/ec (ecx_key)

; 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.ecx_key_st = type { ptr, ptr, i8, [57 x i8], ptr, i64, i32, %struct.CRYPTO_REF_COUNT }
%struct.CRYPTO_REF_COUNT = type { i32 }

@.str = external hidden unnamed_addr constant [69 x i8], align 1
@__func__.ossl_ecx_compute_key = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_ecx_compute_key(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %24, label %16

16:                                               ; preds = %6
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ecx_key_st, ptr %17, i32 0, i32 4
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = icmp eq ptr %19, null
  br i1 %20, label %24, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %21, %16, %6
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 116, ptr noundef @__func__.ossl_ecx_compute_key)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 128, ptr noundef null)
  store i32 0, ptr %7, align 4
  br label %80

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

28:                                               ; preds = %25
  %29 = load i64, ptr %10, align 8, !tbaa !9
  %30 = icmp eq i64 %29, 56
  br label %31

31:                                               ; preds = %28, %25
  %32 = phi i1 [ true, %25 ], [ %30, %28 ]
  %33 = zext i1 %32 to i32
  %34 = icmp ne i32 %33, 0
  %35 = zext i1 %34 to i32
  %36 = call i32 @ossl_assert_int(i32 noundef %35, ptr noundef @.str.2, ptr noundef @.str, i32 noundef 121)
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %39, label %38

38:                                               ; preds = %31
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 122, ptr noundef @__func__.ossl_ecx_compute_key)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 105, ptr noundef null)
  store i32 0, ptr %7, align 4
  br label %80

39:                                               ; preds = %31
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %45

42:                                               ; preds = %39
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %43, ptr %44, align 8, !tbaa !9
  store i32 1, ptr %7, align 4
  br label %80

45:                                               ; preds = %39
  %46 = load i64, ptr %13, align 8, !tbaa !9
  %47 = load i64, ptr %10, align 8, !tbaa !9
  %48 = icmp ult i64 %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %45
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 131, ptr noundef @__func__.ossl_ecx_compute_key)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 106, ptr noundef null)
  store i32 0, ptr %7, align 4
  br label %80

50:                                               ; preds = %45
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = icmp eq i64 %51, 32
  br i1 %52, label %53, label %65

53:                                               ; preds = %50
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ecx_key_st, ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ecx_key_st, ptr %58, i32 0, i32 3
  %60 = getelementptr inbounds [57 x i8], ptr %59, i64 0, i64 0
  %61 = call i32 @ossl_x25519(ptr noundef %54, ptr noundef %57, ptr noundef %60)
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %53
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 146, ptr noundef @__func__.ossl_ecx_compute_key)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 164, ptr noundef null)
  store i32 0, ptr %7, align 4
  br label %80

64:                                               ; preds = %53
  br label %77

65:                                               ; preds = %50
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ecx_key_st, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !11
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ecx_key_st, ptr %70, i32 0, i32 3
  %72 = getelementptr inbounds [57 x i8], ptr %71, i64 0, i64 0
  %73 = call i32 @ossl_x448(ptr noundef %66, ptr noundef %69, ptr noundef %72)
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %65
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 160, ptr noundef @__func__.ossl_ecx_compute_key)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 164, ptr noundef null)
  store i32 0, ptr %7, align 4
  br label %80

76:                                               ; preds = %65
  br label %77

77:                                               ; preds = %76, %64
  %78 = load i64, ptr %10, align 8, !tbaa !9
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %78, ptr %79, align 8, !tbaa !9
  store i32 1, ptr %7, align 4
  br label %80

80:                                               ; preds = %77, %75, %63, %49, %42, %38, %24
  %81 = load i32, ptr %7, align 4
  ret i32 %81
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ossl_assert_int(i32 noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @ossl_x25519(ptr noundef, ptr noundef, ptr noundef) #1

declare i32 @ossl_x448(ptr noundef, ptr noundef, ptr noundef) #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 = { inlinehint 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" }

!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, !6, i64 80}
!12 = !{!"ecx_key_st", !6, i64 0, !6, i64 8, !13, i64 16, !7, i64 17, !6, i64 80, !10, i64 88, !13, i64 96, !14, i64 100}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !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 = external hidden unnamed_addr constant [69 x i8], align 1
@__func__.ossl_ecx_compute_key = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_ecx_compute_key(ptr noundef %0, ptr noundef readonly %1, i64 noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4, i64 noundef %5) local_unnamed_addr #0 {
  %7 = icmp eq ptr %1, null
  br i1 %7, label %13, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 80
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  %12 = icmp eq ptr %0, null
  %or.cond = or i1 %12, %11
  br i1 %or.cond, label %13, label %14

13:                                               ; preds = %8, %6
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 116, ptr noundef nonnull @__func__.ossl_ecx_compute_key) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 128, ptr noundef null) #3
  br label %39

14:                                               ; preds = %8
  %15 = icmp eq i64 %2, 32
  %16 = icmp eq i64 %2, 56
  %17 = or i1 %15, %16
  %18 = zext i1 %17 to i32
  %19 = tail call i32 @ossl_assert_int(i32 noundef %18, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str, i32 noundef 121)
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %20, label %21

20:                                               ; preds = %14
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 122, ptr noundef nonnull @__func__.ossl_ecx_compute_key) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 105, ptr noundef null) #3
  br label %39

21:                                               ; preds = %14
  %22 = icmp eq ptr %3, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %21
  store i64 %2, ptr %4, align 8, !tbaa !13
  br label %39

24:                                               ; preds = %21
  %25 = icmp ult i64 %5, %2
  br i1 %25, label %26, label %27

26:                                               ; preds = %24
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 131, ptr noundef nonnull @__func__.ossl_ecx_compute_key) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 106, ptr noundef null) #3
  br label %39

27:                                               ; preds = %24
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 17
  br i1 %15, label %30, label %34

30:                                               ; preds = %27
  %31 = tail call i32 @ossl_x25519(ptr noundef nonnull %3, ptr noundef %28, ptr noundef nonnull %29) #3
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %38

33:                                               ; preds = %30
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 146, ptr noundef nonnull @__func__.ossl_ecx_compute_key) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 164, ptr noundef null) #3
  br label %39

34:                                               ; preds = %27
  %35 = tail call i32 @ossl_x448(ptr noundef nonnull %3, ptr noundef %28, ptr noundef nonnull %29) #3
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 160, ptr noundef nonnull @__func__.ossl_ecx_compute_key) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 57, i32 noundef 164, ptr noundef null) #3
  br label %39

38:                                               ; preds = %34, %30
  store i64 %2, ptr %4, align 8, !tbaa !13
  br label %39

39:                                               ; preds = %38, %37, %33, %26, %23, %20, %13
  %.0 = phi i32 [ 0, %13 ], [ 1, %23 ], [ 0, %26 ], [ 0, %33 ], [ 1, %38 ], [ 0, %37 ], [ 0, %20 ]
  ret i32 %.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: inlinehint nounwind uwtable
declare hidden i32 @ossl_assert_int(i32 noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @ossl_x25519(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @ossl_x448(ptr noundef, ptr noundef, 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 = { inlinehint 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, !7, i64 80}
!6 = !{!"ecx_key_st", !7, i64 0, !7, i64 8, !10, i64 16, !8, i64 17, !7, i64 80, !11, i64 88, !10, i64 96, !12, i64 100}
!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 = !{!"", !8, i64 0}
!13 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass