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

; 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_point_st = type { ptr, i32, ptr, ptr, ptr, i32 }

declare ptr @BN_copy(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

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

declare ptr @BN_CTX_new() #0

declare void @BN_CTX_start(ptr noundef) #0

declare ptr @BN_CTX_get(ptr noundef) #0

declare void @BN_CTX_end(ptr noundef) #0

declare void @BN_CTX_free(ptr noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ossl_ec_GF2m_simple_make_affine(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ec_point_st, ptr %13, i32 0, i32 5
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %22, label %17

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call i32 @EC_POINT_is_at_infinity(ptr noundef %18, ptr noundef %19)
  %21 = icmp ne i32 %20, 0
  br i1 %21, label %22, label %23

22:                                               ; preds = %17, %3
  store i32 1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %80

23:                                               ; preds = %17
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = call ptr @BN_CTX_new()
  store ptr %27, ptr %11, align 8, !tbaa !5
  store ptr %27, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %31

30:                                               ; preds = %26
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %80

31:                                               ; preds = %26
  br label %32

32:                                               ; preds = %31, %23
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  call void @BN_CTX_start(ptr noundef %33)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = call ptr @BN_CTX_get(ptr noundef %34)
  store ptr %35, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call ptr @BN_CTX_get(ptr noundef %36)
  store ptr %37, ptr %9, align 8, !tbaa !5
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %32
  br label %76

41:                                               ; preds = %32
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call i32 @EC_POINT_get_affine_coordinates(ptr noundef %42, ptr noundef %43, ptr noundef %44, ptr noundef %45, ptr noundef %46)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %50, label %49

49:                                               ; preds = %41
  br label %76

50:                                               ; preds = %41
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ec_point_st, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = call ptr @BN_copy(ptr noundef %53, ptr noundef %54)
  %56 = icmp ne ptr %55, null
  br i1 %56, label %58, label %57

57:                                               ; preds = %50
  br label %76

58:                                               ; preds = %50
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.ec_point_st, ptr %59, i32 0, i32 3
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = call ptr @BN_copy(ptr noundef %61, ptr noundef %62)
  %64 = icmp ne ptr %63, null
  br i1 %64, label %66, label %65

65:                                               ; preds = %58
  br label %76

66:                                               ; preds = %58
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ec_point_st, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = call i32 @BN_set_word(ptr noundef %69, i64 noundef 1)
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %73, label %72

72:                                               ; preds = %66
  br label %76

73:                                               ; preds = %66
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ec_point_st, ptr %74, i32 0, i32 5
  store i32 1, ptr %75, align 8, !tbaa !11
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %73, %72, %65, %57, %49, %40
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  call void @BN_CTX_end(ptr noundef %77)
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  call void @BN_CTX_free(ptr noundef %78)
  %79 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %79, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %80

80:                                               ; preds = %76, %30, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %81 = load i32, ptr %4, align 4
  ret i32 %81
}

declare i32 @BN_set_word(ptr noundef, i64 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"ec_point_st", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 24}
!15 = !{!12, !6, i64 32}


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

declare ptr @BN_copy(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @BN_CTX_new() local_unnamed_addr #0

declare void @BN_CTX_start(ptr noundef) local_unnamed_addr #0

declare ptr @BN_CTX_get(ptr noundef) local_unnamed_addr #0

declare void @BN_CTX_end(ptr noundef) local_unnamed_addr #0

declare void @BN_CTX_free(ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_ec_GF2m_simple_make_affine(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 40
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %33

6:                                                ; preds = %3
  %7 = tail call i32 @EC_POINT_is_at_infinity(ptr noundef %0, ptr noundef nonnull %1) #2
  %.not29 = icmp eq i32 %7, 0
  br i1 %.not29, label %8, label %33

8:                                                ; preds = %6
  %9 = icmp eq ptr %2, null
  br i1 %9, label %10, label %13

10:                                               ; preds = %8
  %11 = tail call ptr @BN_CTX_new() #2
  %12 = icmp eq ptr %11, null
  br i1 %12, label %33, label %13

13:                                               ; preds = %10, %8
  %.025 = phi ptr [ %11, %10 ], [ %2, %8 ]
  %.0 = phi ptr [ %11, %10 ], [ null, %8 ]
  tail call void @BN_CTX_start(ptr noundef nonnull %.025) #2
  %14 = tail call ptr @BN_CTX_get(ptr noundef nonnull %.025) #2
  %15 = tail call ptr @BN_CTX_get(ptr noundef nonnull %.025) #2
  %16 = icmp eq ptr %15, null
  br i1 %16, label %32, label %17

17:                                               ; preds = %13
  %18 = tail call i32 @EC_POINT_get_affine_coordinates(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %14, ptr noundef nonnull %15, ptr noundef nonnull %.025) #2
  %.not30 = icmp eq i32 %18, 0
  br i1 %.not30, label %32, label %19

19:                                               ; preds = %17
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = tail call ptr @BN_copy(ptr noundef %21, ptr noundef %14) #2
  %.not31 = icmp eq ptr %22, null
  br i1 %.not31, label %32, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %1, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = tail call ptr @BN_copy(ptr noundef %25, ptr noundef nonnull %15) #2
  %.not32 = icmp eq ptr %26, null
  br i1 %.not32, label %32, label %27

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %1, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = tail call i32 @BN_set_word(ptr noundef %29, i64 noundef 1) #2
  %.not33 = icmp eq i32 %30, 0
  br i1 %.not33, label %32, label %31

31:                                               ; preds = %27
  store i32 1, ptr %4, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %27, %23, %19, %17, %13, %31
  %.023 = phi i32 [ 0, %13 ], [ 1, %31 ], [ 0, %27 ], [ 0, %23 ], [ 0, %19 ], [ 0, %17 ]
  tail call void @BN_CTX_end(ptr noundef nonnull %.025) #2
  tail call void @BN_CTX_free(ptr noundef %.0) #2
  br label %33

33:                                               ; preds = %10, %3, %6, %32
  %.024 = phi i32 [ %.023, %32 ], [ 1, %6 ], [ 1, %3 ], [ 0, %10 ]
  ret i32 %.024
}

declare i32 @BN_set_word(ptr noundef, i64 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, !10, i64 40}
!6 = !{!"ec_point_st", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 32}


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