; LLVM IR from cryptid-org/cryptid-native :: dependencies/gmp/src (mini-gmp)

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

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.mpn_get_str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

15:                                               ; preds = %4
  br label %17

16:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 1279, ptr noundef @__PRETTY_FUNCTION__.mpn_get_str) #4
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load i64, ptr %9, align 8, !tbaa !11
  %20 = sub nsw i64 %19, 1
  %21 = getelementptr inbounds i64, ptr %18, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !11
  %23 = icmp ugt i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %17
  br label %26

25:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 1280, ptr noundef @__PRETTY_FUNCTION__.mpn_get_str) #4
  unreachable

26:                                               ; preds = %24
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = call i32 @mpn_base_power_of_two_p(i32 noundef %27)
  store i32 %28, ptr %10, align 4, !tbaa !9
  %29 = load i32, ptr %10, align 4, !tbaa !9
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %26
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load i64, ptr %9, align 8, !tbaa !11
  %36 = call i64 @mpn_get_str_bits(ptr noundef %32, i32 noundef %33, ptr noundef %34, i64 noundef %35)
  store i64 %36, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %45

37:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #3
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  call void @mpn_get_base_info(ptr noundef %12, i64 noundef %39)
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i64, ptr %9, align 8, !tbaa !11
  %44 = call i64 @mpn_get_str_other(ptr noundef %40, i32 noundef %41, ptr noundef %12, ptr noundef %42, i64 noundef %43)
  store i64 %44, ptr %5, align 8
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #3
  br label %45

45:                                               ; preds = %37, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %46 = load i64, ptr %5, align 8
  ret i64 %46
}

; Function Attrs: nounwind uwtable
declare hidden i32 @mpn_base_power_of_two_p(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @mpn_get_base_info(ptr noundef, i64 noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { noreturn 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, !12, i64 0}
!12 = !{!"long", !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"

%struct.mpn_base_info = type { i32, i64 }

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@__PRETTY_FUNCTION__.mpn_get_str = external hidden unnamed_addr constant [60 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [13 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @mpn_get_str(ptr noundef %0, i32 noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.mpn_base_info, align 8
  %6 = icmp sgt i64 %3, 0
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 1279, ptr noundef nonnull @__PRETTY_FUNCTION__.mpn_get_str) #3
  unreachable

8:                                                ; preds = %4
  %9 = getelementptr i64, ptr %2, i64 %3
  %10 = getelementptr i8, ptr %9, i64 -8
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %.not = icmp eq i64 %11, 0
  br i1 %.not, label %12, label %13

12:                                               ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 1280, ptr noundef nonnull @__PRETTY_FUNCTION__.mpn_get_str) #3
  unreachable

13:                                               ; preds = %8
  %14 = tail call i32 @mpn_base_power_of_two_p(i32 noundef %1)
  %.not16 = icmp eq i32 %14, 0
  br i1 %.not16, label %17, label %15

15:                                               ; preds = %13
  %16 = tail call i64 @mpn_get_str_bits(ptr noundef %0, i32 noundef %14, ptr noundef nonnull %2, i64 noundef %3)
  br label %20

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  %18 = sext i32 %1 to i64
  call void @mpn_get_base_info(ptr noundef nonnull %5, i64 noundef %18)
  %19 = call i64 @mpn_get_str_other(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %2, i64 noundef %3)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  br label %20

20:                                               ; preds = %17, %15
  %.0 = phi i64 [ %16, %15 ], [ %19, %17 ]
  ret i64 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @mpn_base_power_of_two_p(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i64 @mpn_get_str_bits(ptr noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @mpn_get_base_info(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i64 @mpn_get_str_other(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { noreturn nounwind }
attributes #4 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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