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

; 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: nounwind uwtable
declare dso_local i64 @mpn_mul(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @mpz_init2(ptr noundef, i64 noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mpz_mul(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca [1 x %struct.__mpz_struct], align 16
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.__mpz_struct, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  store i64 %17, ptr %8, align 8, !tbaa !12
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.__mpz_struct, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  store i64 %21, ptr %9, align 8, !tbaa !12
  %22 = load i64, ptr %8, align 8, !tbaa !12
  %23 = icmp eq i64 %22, 0
  br i1 %23, label %27, label %24

24:                                               ; preds = %3
  %25 = load i64, ptr %9, align 8, !tbaa !12
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %24, %3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.__mpz_struct, ptr %28, i32 0, i32 1
  store i32 0, ptr %29, align 4, !tbaa !9
  store i32 1, ptr %13, align 4
  br label %116

30:                                               ; preds = %24
  %31 = load i64, ptr %8, align 8, !tbaa !12
  %32 = load i64, ptr %9, align 8, !tbaa !12
  %33 = xor i64 %31, %32
  %34 = icmp slt i64 %33, 0
  %35 = zext i1 %34 to i32
  store i32 %35, ptr %7, align 4, !tbaa !14
  %36 = load i64, ptr %8, align 8, !tbaa !12
  %37 = icmp sge i64 %36, 0
  br i1 %37, label %38, label %40

38:                                               ; preds = %30
  %39 = load i64, ptr %8, align 8, !tbaa !12
  br label %43

40:                                               ; preds = %30
  %41 = load i64, ptr %8, align 8, !tbaa !12
  %42 = sub nsw i64 0, %41
  br label %43

43:                                               ; preds = %40, %38
  %44 = phi i64 [ %39, %38 ], [ %42, %40 ]
  store i64 %44, ptr %8, align 8, !tbaa !12
  %45 = load i64, ptr %9, align 8, !tbaa !12
  %46 = icmp sge i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = load i64, ptr %9, align 8, !tbaa !12
  br label %52

49:                                               ; preds = %43
  %50 = load i64, ptr %9, align 8, !tbaa !12
  %51 = sub nsw i64 0, %50
  br label %52

52:                                               ; preds = %49, %47
  %53 = phi i64 [ %48, %47 ], [ %51, %49 ]
  store i64 %53, ptr %9, align 8, !tbaa !12
  %54 = getelementptr inbounds [1 x %struct.__mpz_struct], ptr %11, i64 0, i64 0
  %55 = load i64, ptr %8, align 8, !tbaa !12
  %56 = load i64, ptr %9, align 8, !tbaa !12
  %57 = add nsw i64 %55, %56
  %58 = mul i64 %57, 64
  call void @mpz_init2(ptr noundef %54, i64 noundef %58)
  %59 = getelementptr inbounds [1 x %struct.__mpz_struct], ptr %11, i64 0, i64 0
  %60 = getelementptr inbounds %struct.__mpz_struct, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  store ptr %61, ptr %12, align 8, !tbaa !5
  %62 = load i64, ptr %8, align 8, !tbaa !12
  %63 = load i64, ptr %9, align 8, !tbaa !12
  %64 = icmp sge i64 %62, %63
  br i1 %64, label %65, label %76

65:                                               ; preds = %52
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.__mpz_struct, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load i64, ptr %8, align 8, !tbaa !12
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.__mpz_struct, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  %74 = load i64, ptr %9, align 8, !tbaa !12
  %75 = call i64 @mpn_mul(ptr noundef %66, ptr noundef %69, i64 noundef %70, ptr noundef %73, i64 noundef %74)
  br label %87

76:                                               ; preds = %52
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.__mpz_struct, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = load i64, ptr %9, align 8, !tbaa !12
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.__mpz_struct, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !15
  %85 = load i64, ptr %8, align 8, !tbaa !12
  %86 = call i64 @mpn_mul(ptr noundef %77, ptr noundef %80, i64 noundef %81, ptr noundef %84, i64 noundef %85)
  br label %87

87:                                               ; preds = %76, %65
  %88 = load i64, ptr %8, align 8, !tbaa !12
  %89 = load i64, ptr %9, align 8, !tbaa !12
  %90 = add nsw i64 %88, %89
  store i64 %90, ptr %10, align 8, !tbaa !12
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  %92 = load i64, ptr %10, align 8, !tbaa !12
  %93 = sub nsw i64 %92, 1
  %94 = getelementptr inbounds i64, ptr %91, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !12
  %96 = icmp eq i64 %95, 0
  %97 = zext i1 %96 to i32
  %98 = sext i32 %97 to i64
  %99 = load i64, ptr %10, align 8, !tbaa !12
  %100 = sub nsw i64 %99, %98
  store i64 %100, ptr %10, align 8, !tbaa !12
  %101 = load i32, ptr %7, align 4, !tbaa !14
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %106

103:                                              ; preds = %87
  %104 = load i64, ptr %10, align 8, !tbaa !12
  %105 = sub nsw i64 0, %104
  br label %108

106:                                              ; preds = %87
  %107 = load i64, ptr %10, align 8, !tbaa !12
  br label %108

108:                                              ; preds = %106, %103
  %109 = phi i64 [ %105, %103 ], [ %107, %106 ]
  %110 = trunc i64 %109 to i32
  %111 = getelementptr inbounds [1 x %struct.__mpz_struct], ptr %11, i64 0, i64 0
  %112 = getelementptr inbounds %struct.__mpz_struct, ptr %111, i32 0, i32 1
  store i32 %110, ptr %112, align 4, !tbaa !9
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds [1 x %struct.__mpz_struct], ptr %11, i64 0, i64 0
  call void @mpz_swap(ptr noundef %113, ptr noundef %114)
  %115 = getelementptr inbounds [1 x %struct.__mpz_struct], ptr %11, i64 0, i64 0
  call void @mpz_clear(ptr noundef %115)
  store i32 0, ptr %13, align 4
  br label %116

116:                                              ; preds = %108, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  %117 = load i32, ptr %13, align 4
  switch i32 %117, label %119 [
    i32 0, label %118
    i32 1, label %118
  ]

118:                                              ; preds = %116, %116
  ret void

119:                                              ; preds = %116
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 8}


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

; 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: nounwind uwtable
declare dso_local i64 @mpn_mul(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @mpz_mul(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #1 {
  %4 = alloca [1 x %struct.__mpz_struct], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp eq i32 %6, 0
  %10 = icmp eq i32 %8, 0
  %or.cond = select i1 %9, i1 true, i1 %10
  br i1 %or.cond, label %11, label %13

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %46

13:                                               ; preds = %3
  %14 = sext i32 %8 to i64
  %15 = sext i32 %6 to i64
  %16 = xor i64 %14, %15
  %17 = icmp slt i64 %16, 0
  %18 = tail call i64 @llvm.abs.i64(i64 %15, i1 true)
  %19 = tail call i64 @llvm.abs.i64(i64 %14, i1 true)
  %20 = add nuw nsw i64 %19, %18
  %21 = shl nuw nsw i64 %20, 6
  call void @mpz_init2(ptr noundef nonnull %4, i64 noundef %21)
  %22 = getelementptr inbounds i8, ptr %4, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %.not = icmp ult i64 %18, %19
  br i1 %.not, label %30, label %24

24:                                               ; preds = %13
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %2, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = call i64 @mpn_mul(ptr noundef %23, ptr noundef %26, i64 noundef %18, ptr noundef %28, i64 noundef %19)
  br label %36

30:                                               ; preds = %13
  %31 = getelementptr inbounds i8, ptr %2, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %1, i64 8
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = call i64 @mpn_mul(ptr noundef %23, ptr noundef %32, i64 noundef %19, ptr noundef %34, i64 noundef %18)
  br label %36

36:                                               ; preds = %30, %24
  %37 = getelementptr i64, ptr %23, i64 %20
  %38 = getelementptr i8, ptr %37, i64 -8
  %39 = load i64, ptr %38, align 8, !tbaa !12
  %40 = icmp eq i64 %39, 0
  %.neg = sext i1 %40 to i64
  %41 = add nsw i64 %20, %.neg
  %42 = sub nsw i64 0, %41
  %43 = select i1 %17, i64 %42, i64 %41
  %44 = trunc i64 %43 to i32
  %45 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 %44, ptr %45, align 4, !tbaa !5
  call void @mpz_swap(ptr noundef %0, ptr noundef nonnull %4)
  call void @mpz_clear(ptr noundef nonnull %4)
  br label %46

46:                                               ; preds = %36, %11
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 speculatable willreturn memory(none) }
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, !7, i64 4}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}


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