; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (ec)

; 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.EcCtx_st = type { ptr, ptr, ptr, ptr, i8, i8 }

@.str = external hidden unnamed_addr constant [19 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

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

declare void @stacktrace_create(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #1

declare void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @ec_free(ptr noundef) #2

declare void @ec_precomp_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @ec_copy_params_with_alloc(ptr noundef) #2

declare ptr @wa_copy_with_alloc(ptr noundef) #1

declare ptr @ec_point_copy_with_alloc(ptr noundef) #1

declare ptr @ec_copy_precomp_with_alloc(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ec_copy_with_alloc(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %1
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %13, label %11

11:                                               ; preds = %8
  store i32 2, ptr %4, align 4, !tbaa !9
  %12 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 602, i32 noundef %12, ptr noundef null)
  br label %107

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call ptr @ec_copy_params_with_alloc(ptr noundef %17)
  store ptr %18, ptr %6, align 8, !tbaa !5
  %19 = icmp eq ptr null, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  store i32 2, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 604, i32 noundef %21)
  br label %107

22:                                               ; preds = %16
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.EcCtx_st, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = icmp ne ptr %27, null
  br i1 %28, label %29, label %43

29:                                               ; preds = %24
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.EcCtx_st, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = call ptr @wa_copy_with_alloc(ptr noundef %33)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.EcCtx_st, ptr %35, i32 0, i32 1
  store ptr %34, ptr %36, align 8, !tbaa !11
  %37 = icmp eq ptr null, %34
  br i1 %37, label %38, label %40

38:                                               ; preds = %30
  store i32 2, ptr %4, align 4, !tbaa !9
  %39 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 607, i32 noundef %39)
  br label %107

40:                                               ; preds = %30
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42, %24
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.EcCtx_st, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %62

48:                                               ; preds = %43
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.EcCtx_st, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = call ptr @ec_point_copy_with_alloc(ptr noundef %52)
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.EcCtx_st, ptr %54, i32 0, i32 2
  store ptr %53, ptr %55, align 8, !tbaa !14
  %56 = icmp eq ptr null, %53
  br i1 %56, label %57, label %59

57:                                               ; preds = %49
  store i32 2, ptr %4, align 4, !tbaa !9
  %58 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 610, i32 noundef %58)
  br label %107

59:                                               ; preds = %49
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61, %43
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.EcCtx_st, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %90

67:                                               ; preds = %62
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.EcCtx_st, ptr %68, i32 0, i32 3
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = icmp ne ptr %70, null
  br i1 %71, label %72, label %76

72:                                               ; preds = %67
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.EcCtx_st, ptr %73, i32 0, i32 3
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  call void @ec_precomp_free(ptr noundef %75)
  br label %76

76:                                               ; preds = %72, %67
  br label %77

77:                                               ; preds = %76
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.EcCtx_st, ptr %78, i32 0, i32 3
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = call ptr @ec_copy_precomp_with_alloc(ptr noundef %80)
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.EcCtx_st, ptr %82, i32 0, i32 3
  store ptr %81, ptr %83, align 8, !tbaa !15
  %84 = icmp eq ptr null, %81
  br i1 %84, label %85, label %87

85:                                               ; preds = %77
  store i32 2, ptr %4, align 4, !tbaa !9
  %86 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 616, i32 noundef %86)
  br label %107

87:                                               ; preds = %77
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89, %62
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.EcCtx_st, ptr %91, i32 0, i32 4
  %93 = load i8, ptr %92, align 8, !tbaa !16, !range !17, !noundef !18
  %94 = trunc i8 %93 to i1
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.EcCtx_st, ptr %95, i32 0, i32 4
  %97 = zext i1 %94 to i8
  store i8 %97, ptr %96, align 8, !tbaa !16
  %98 = load ptr, ptr %3, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.EcCtx_st, ptr %98, i32 0, i32 5
  %100 = load i8, ptr %99, align 1, !tbaa !19, !range !17, !noundef !18
  %101 = trunc i8 %100 to i1
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.EcCtx_st, ptr %102, i32 0, i32 5
  %104 = zext i1 %101 to i8
  store i8 %104, ptr %103, align 1, !tbaa !19
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ba_free_private(ptr noundef %105)
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %106, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %110

107:                                              ; preds = %85, %57, %38, %20, %11
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ec_free(ptr noundef %108)
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ba_free_private(ptr noundef %109)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %110

110:                                              ; preds = %107, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %111 = load ptr, ptr %2, align 8
  ret ptr %111
}

declare void @ba_free_private(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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"EcCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 33}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}
!16 = !{!12, !13, i64 32}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !13, i64 33}


; 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 [19 x i8], align 1

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

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

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

declare void @ec_precomp_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @ec_copy_params_with_alloc(ptr noundef) local_unnamed_addr #1

declare ptr @wa_copy_with_alloc(ptr noundef) local_unnamed_addr #0

declare ptr @ec_point_copy_with_alloc(ptr noundef) local_unnamed_addr #0

declare ptr @ec_copy_precomp_with_alloc(ptr noundef) local_unnamed_addr #0

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

2:                                                ; preds = %1
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 602, i32 noundef 2, ptr noundef null) #2
  br label %42

3:                                                ; preds = %1
  %4 = tail call ptr @ec_copy_params_with_alloc(ptr noundef nonnull %0)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 604, i32 noundef 2) #2
  br label %42

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not32 = icmp eq ptr %9, null
  br i1 %.not32, label %15, label %10

10:                                               ; preds = %7
  %11 = tail call ptr @wa_copy_with_alloc(ptr noundef nonnull %9) #2
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %11, ptr %12, align 8, !tbaa !5
  %13 = icmp eq ptr %11, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 607, i32 noundef 2) #2
  br label %42

15:                                               ; preds = %10, %7
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %.not33 = icmp eq ptr %17, null
  br i1 %.not33, label %23, label %18

18:                                               ; preds = %15
  %19 = tail call ptr @ec_point_copy_with_alloc(ptr noundef nonnull %17) #2
  %20 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %19, ptr %20, align 8, !tbaa !11
  %21 = icmp eq ptr %19, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 610, i32 noundef 2) #2
  br label %42

23:                                               ; preds = %18, %15
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %.not34 = icmp eq ptr %25, null
  br i1 %.not34, label %35, label %26

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %4, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %.not35 = icmp eq ptr %28, null
  br i1 %.not35, label %30, label %29

29:                                               ; preds = %26
  tail call void @ec_precomp_free(ptr noundef nonnull %28) #2
  %.pre = load ptr, ptr %24, align 8, !tbaa !12
  br label %30

30:                                               ; preds = %26, %29
  %31 = phi ptr [ %25, %26 ], [ %.pre, %29 ]
  %32 = tail call ptr @ec_copy_precomp_with_alloc(ptr noundef %31) #2
  store ptr %32, ptr %27, align 8, !tbaa !12
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 616, i32 noundef 2) #2
  br label %42

35:                                               ; preds = %30, %23
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  %37 = load i8, ptr %36, align 8, !tbaa !13, !range !14, !noundef !15
  %38 = getelementptr inbounds i8, ptr %4, i64 32
  store i8 %37, ptr %38, align 8, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %0, i64 33
  %40 = load i8, ptr %39, align 1, !tbaa !16, !range !14, !noundef !15
  %41 = getelementptr inbounds i8, ptr %4, i64 33
  store i8 %40, ptr %41, align 1, !tbaa !16
  br label %43

42:                                               ; preds = %34, %22, %14, %6, %2
  %.0 = phi ptr [ null, %6 ], [ %4, %14 ], [ %4, %22 ], [ %4, %34 ], [ null, %2 ]
  tail call void @ec_free(ptr noundef %.0)
  br label %43

43:                                               ; preds = %42, %35
  %.026 = phi ptr [ null, %42 ], [ %4, %35 ]
  tail call void @ba_free_private(ptr noundef null) #2
  ret ptr %.026
}

declare void @ba_free_private(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 8}
!6 = !{!"EcCtx_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 33}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !10, i64 32}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!6, !10, i64 33}


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