; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (math-ec2m-internal)

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

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

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

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

declare ptr @wa_copy_with_alloc(ptr noundef) #1

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

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

10:                                               ; preds = %7
  store i32 2, ptr %4, align 4, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 688, i32 noundef %11, ptr noundef null)
  br label %60

12:                                               ; preds = %7
  br label %13

13:                                               ; preds = %12
  br label %14

14:                                               ; preds = %13
  br label %15

15:                                               ; preds = %14
  %16 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 32) #5
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = icmp eq ptr null, %16
  br i1 %17, label %18, label %20

18:                                               ; preds = %15
  store i32 1, ptr %4, align 4, !tbaa !9
  %19 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 690, i32 noundef %19, ptr noundef null)
  br label %60

20:                                               ; preds = %15
  br label %21

21:                                               ; preds = %20
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.EC2m_st, ptr %23, i32 0, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EC2m_st, ptr %26, i32 0, i32 1
  store i64 %25, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.EC2m_st, ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.EC2m_st, ptr %31, i32 0, i32 3
  store i64 %30, ptr %32, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %22
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.EC2m_st, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = call ptr @wa_copy_with_alloc(ptr noundef %36)
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.EC2m_st, ptr %38, i32 0, i32 2
  store ptr %37, ptr %39, align 8, !tbaa !15
  %40 = icmp eq ptr null, %37
  br i1 %40, label %41, label %43

41:                                               ; preds = %33
  store i32 2, ptr %4, align 4, !tbaa !9
  %42 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 695, i32 noundef %42)
  br label %60

43:                                               ; preds = %33
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.EC2m_st, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !16
  %50 = call ptr @gf2m_copy_with_alloc(ptr noundef %49)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.EC2m_st, ptr %51, i32 0, i32 0
  store ptr %50, ptr %52, align 8, !tbaa !16
  %53 = icmp eq ptr null, %50
  br i1 %53, label %54, label %56

54:                                               ; preds = %46
  store i32 2, ptr %4, align 4, !tbaa !9
  %55 = load i32, ptr %4, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 696, i32 noundef %55)
  br label %60

56:                                               ; preds = %46
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %59, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %62

60:                                               ; preds = %54, %41, %18, %10
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  call void @ec2m_free(ptr noundef %61)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %62

62:                                               ; preds = %60, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %63 = load ptr, ptr %2, align 8
  ret ptr %63
}

declare ptr @gf2m_copy_with_alloc(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @ec2m_free(ptr noundef) #3

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 allocsize(0,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 #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0,1) }

!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, !13, i64 8}
!12 = !{!"EC2m_st", !6, i64 0, !13, i64 8, !6, i64 16, !13, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 24}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, 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 [28 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

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

declare ptr @wa_copy_with_alloc(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @ec2m_copy_with_alloc(ptr noundef readonly %0) local_unnamed_addr #2 {
  %.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 688, i32 noundef 2, ptr noundef null) #3
  br label %25

3:                                                ; preds = %1
  %4 = tail call noalias dereferenceable_or_null(32) ptr @calloc(i64 noundef 1, i64 noundef 32) #4
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %3
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 690, i32 noundef 1, ptr noundef null) #3
  br label %25

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %9, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i64, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %4, i64 24
  store i64 %12, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = tail call ptr @wa_copy_with_alloc(ptr noundef %15) #3
  %17 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %16, ptr %17, align 8, !tbaa !12
  %18 = icmp eq ptr %16, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %7
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 695, i32 noundef 2) #3
  br label %25

20:                                               ; preds = %7
  %21 = load ptr, ptr %0, align 8, !tbaa !13
  %22 = tail call ptr @gf2m_copy_with_alloc(ptr noundef %21) #3
  store ptr %22, ptr %4, align 8, !tbaa !13
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %20
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 696, i32 noundef 2) #3
  br label %25

25:                                               ; preds = %24, %19, %6, %2
  %.0 = phi ptr [ null, %6 ], [ %4, %19 ], [ %4, %24 ], [ null, %2 ]
  tail call void @ec2m_free(ptr noundef %.0)
  br label %26

26:                                               ; preds = %20, %25
  %.015 = phi ptr [ null, %25 ], [ %4, %20 ]
  ret ptr %.015
}

declare ptr @gf2m_copy_with_alloc(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @ec2m_free(ptr noundef) local_unnamed_addr #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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 }
attributes #4 = { nounwind allocsize(0,1) }

!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 8}
!6 = !{!"EC2m_st", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 0}


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