; 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_group_st = type { ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr, i64, ptr, [6 x i32], ptr, ptr, i32, ptr, ptr, ptr, ptr, i32, %union.anon, ptr, ptr }
%union.anon = type { ptr }

@.str = external hidden unnamed_addr constant [70 x i8], align 1
@__func__.ossl_ec_GF2m_simple_group_set_curve = external hidden unnamed_addr constant [36 x i8], align 1

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

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

declare void @bn_set_all_zero(ptr noundef) #0

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

19:                                               ; preds = %5
  br label %92

20:                                               ; preds = %5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ec_group_st, ptr %21, i32 0, i32 10
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ec_group_st, ptr %24, i32 0, i32 11
  %26 = getelementptr inbounds [6 x i32], ptr %25, i64 0, i64 0
  %27 = call i32 @BN_GF2m_poly2arr(ptr noundef %23, ptr noundef %26, i32 noundef 6)
  %28 = sub nsw i32 %27, 1
  store i32 %28, ptr %12, align 4, !tbaa !9
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 5
  br i1 %30, label %31, label %35

31:                                               ; preds = %20
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 3
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 112, ptr noundef @__func__.ossl_ec_GF2m_simple_group_set_curve)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 131, ptr noundef null)
  br label %92

35:                                               ; preds = %31, %20
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ec_group_st, ptr %36, i32 0, i32 12
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ec_group_st, ptr %40, i32 0, i32 11
  %42 = getelementptr inbounds [6 x i32], ptr %41, i64 0, i64 0
  %43 = call i32 @BN_GF2m_mod_arr(ptr noundef %38, ptr noundef %39, ptr noundef %42)
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %46, label %45

45:                                               ; preds = %35
  br label %92

46:                                               ; preds = %35
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ec_group_st, ptr %47, i32 0, i32 12
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ec_group_st, ptr %50, i32 0, i32 11
  %52 = getelementptr inbounds [6 x i32], ptr %51, i64 0, i64 0
  %53 = load i32, ptr %52, align 8, !tbaa !9
  %54 = add nsw i32 %53, 64
  %55 = sub nsw i32 %54, 1
  %56 = sdiv i32 %55, 64
  %57 = call ptr @bn_wexpand(ptr noundef %49, i32 noundef %56)
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %60

59:                                               ; preds = %46
  br label %92

60:                                               ; preds = %46
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ec_group_st, ptr %61, i32 0, i32 12
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  call void @bn_set_all_zero(ptr noundef %63)
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ec_group_st, ptr %64, i32 0, i32 13
  %66 = load ptr, ptr %65, align 8, !tbaa !15
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ec_group_st, ptr %68, i32 0, i32 11
  %70 = getelementptr inbounds [6 x i32], ptr %69, i64 0, i64 0
  %71 = call i32 @BN_GF2m_mod_arr(ptr noundef %66, ptr noundef %67, ptr noundef %70)
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %74, label %73

73:                                               ; preds = %60
  br label %92

74:                                               ; preds = %60
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.ec_group_st, ptr %75, i32 0, i32 13
  %77 = load ptr, ptr %76, align 8, !tbaa !15
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ec_group_st, ptr %78, i32 0, i32 11
  %80 = getelementptr inbounds [6 x i32], ptr %79, i64 0, i64 0
  %81 = load i32, ptr %80, align 8, !tbaa !9
  %82 = add nsw i32 %81, 64
  %83 = sub nsw i32 %82, 1
  %84 = sdiv i32 %83, 64
  %85 = call ptr @bn_wexpand(ptr noundef %77, i32 noundef %84)
  %86 = icmp eq ptr %85, null
  br i1 %86, label %87, label %88

87:                                               ; preds = %74
  br label %92

88:                                               ; preds = %74
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ec_group_st, ptr %89, i32 0, i32 13
  %91 = load ptr, ptr %90, align 8, !tbaa !15
  call void @bn_set_all_zero(ptr noundef %91)
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %92

92:                                               ; preds = %88, %87, %73, %59, %45, %34, %19
  %93 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %93
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 willreturn memory(argmem: readwrite) }
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, !6, i64 64}
!12 = !{!"ec_group_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !13, i64 56, !6, i64 64, !7, i64 72, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !10, i64 152, !7, i64 160, !6, i64 168, !6, i64 176}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !6, i64 96}
!15 = !{!12, !6, i64 104}


; 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 [70 x i8], align 1
@__func__.ossl_ec_GF2m_simple_group_set_curve = external hidden unnamed_addr constant [36 x i8], align 1

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

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

declare void @bn_set_all_zero(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ossl_ec_GF2m_simple_group_set_curve(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr nocapture noundef readnone %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call ptr @BN_copy(ptr noundef %7, ptr noundef %1) #2
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %39, label %9

9:                                                ; preds = %5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = tail call i32 @BN_GF2m_poly2arr(ptr noundef %10, ptr noundef nonnull %11, i32 noundef 6) #2
  switch i32 %12, label %13 [
    i32 6, label %14
    i32 4, label %14
  ]

13:                                               ; preds = %9
  tail call void @ERR_new() #2
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 112, ptr noundef nonnull @__func__.ossl_ec_GF2m_simple_group_set_curve) #2
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 16, i32 noundef 131, ptr noundef null) #2
  br label %39

14:                                               ; preds = %9, %9
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = tail call i32 @BN_GF2m_mod_arr(ptr noundef %16, ptr noundef %2, ptr noundef nonnull %11) #2
  %.not19 = icmp eq i32 %17, 0
  br i1 %.not19, label %39, label %18

18:                                               ; preds = %14
  %19 = load ptr, ptr %15, align 8, !tbaa !12
  %20 = load i32, ptr %11, align 8, !tbaa !13
  %21 = add nsw i32 %20, 63
  %22 = sdiv i32 %21, 64
  %23 = tail call ptr @bn_wexpand(ptr noundef %19, i32 noundef %22) #2
  %24 = icmp eq ptr %23, null
  br i1 %24, label %39, label %25

25:                                               ; preds = %18
  %26 = load ptr, ptr %15, align 8, !tbaa !12
  tail call void @bn_set_all_zero(ptr noundef %26) #2
  %27 = getelementptr inbounds i8, ptr %0, i64 104
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = tail call i32 @BN_GF2m_mod_arr(ptr noundef %28, ptr noundef %3, ptr noundef nonnull %11) #2
  %.not20 = icmp eq i32 %29, 0
  br i1 %.not20, label %39, label %30

30:                                               ; preds = %25
  %31 = load ptr, ptr %27, align 8, !tbaa !14
  %32 = load i32, ptr %11, align 8, !tbaa !13
  %33 = add nsw i32 %32, 63
  %34 = sdiv i32 %33, 64
  %35 = tail call ptr @bn_wexpand(ptr noundef %31, i32 noundef %34) #2
  %36 = icmp eq ptr %35, null
  br i1 %36, label %39, label %37

37:                                               ; preds = %30
  %38 = load ptr, ptr %27, align 8, !tbaa !14
  tail call void @bn_set_all_zero(ptr noundef %38) #2
  br label %39

39:                                               ; preds = %30, %25, %18, %14, %5, %37, %13
  %.0 = phi i32 [ 0, %13 ], [ 0, %18 ], [ 0, %30 ], [ 1, %37 ], [ 0, %25 ], [ 0, %14 ], [ 0, %5 ]
  ret i32 %.0
}

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

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 i32 @BN_GF2m_mod_arr(ptr noundef, ptr 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 64}
!6 = !{!"ec_group_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !7, i64 48, !11, i64 56, !7, i64 64, !8, i64 72, !7, i64 96, !7, i64 104, !10, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !10, i64 152, !8, i64 160, !7, i64 168, !7, i64 176}
!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, !7, i64 96}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 104}


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