; 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 }

@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.mpz_set_d = external hidden unnamed_addr constant [39 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
declare hidden ptr @mpz_realloc(ptr noundef, i64 noundef) #2

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

16:                                               ; preds = %2
  %17 = load double, ptr %4, align 8, !tbaa !9
  %18 = load double, ptr %4, align 8, !tbaa !9
  %19 = fmul double %18, 5.000000e-01
  %20 = fcmp oeq double %17, %19
  br i1 %20, label %21, label %24

21:                                               ; preds = %16, %2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.__mpz_struct, ptr %22, i32 0, i32 1
  store i32 0, ptr %23, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %123

24:                                               ; preds = %16
  %25 = load double, ptr %4, align 8, !tbaa !9
  %26 = fcmp olt double %25, 0.000000e+00
  %27 = zext i1 %26 to i32
  store i32 %27, ptr %5, align 4, !tbaa !14
  %28 = load i32, ptr %5, align 4, !tbaa !14
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %24
  %31 = load double, ptr %4, align 8, !tbaa !9
  %32 = fneg double %31
  store double %32, ptr %4, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %30, %24
  %34 = load double, ptr %4, align 8, !tbaa !9
  %35 = fcmp olt double %34, 1.000000e+00
  br i1 %35, label %36, label %39

36:                                               ; preds = %33
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.__mpz_struct, ptr %37, i32 0, i32 1
  store i32 0, ptr %38, align 4, !tbaa !11
  store i32 1, ptr %12, align 4
  br label %123

39:                                               ; preds = %33
  store double 0x43F0000000000000, ptr %9, align 8, !tbaa !9
  %40 = load double, ptr %9, align 8, !tbaa !9
  %41 = fdiv double 1.000000e+00, %40
  store double %41, ptr %10, align 8, !tbaa !9
  store i64 1, ptr %7, align 8, !tbaa !15
  br label %42

42:                                               ; preds = %50, %39
  %43 = load double, ptr %4, align 8, !tbaa !9
  %44 = load double, ptr %9, align 8, !tbaa !9
  %45 = fcmp oge double %43, %44
  br i1 %45, label %46, label %53

46:                                               ; preds = %42
  %47 = load double, ptr %10, align 8, !tbaa !9
  %48 = load double, ptr %4, align 8, !tbaa !9
  %49 = fmul double %48, %47
  store double %49, ptr %4, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %46
  %51 = load i64, ptr %7, align 8, !tbaa !15
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %7, align 8, !tbaa !15
  br label %42, !llvm.loop !17

53:                                               ; preds = %42
  %54 = load i64, ptr %7, align 8, !tbaa !15
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.__mpz_struct, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !19
  %58 = sext i32 %57 to i64
  %59 = icmp sgt i64 %54, %58
  br i1 %59, label %60, label %64

60:                                               ; preds = %53
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = load i64, ptr %7, align 8, !tbaa !15
  %63 = call ptr @mpz_realloc(ptr noundef %61, i64 noundef %62)
  br label %68

64:                                               ; preds = %53
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.__mpz_struct, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !20
  br label %68

68:                                               ; preds = %64, %60
  %69 = phi ptr [ %63, %60 ], [ %67, %64 ]
  store ptr %69, ptr %6, align 8, !tbaa !5
  %70 = load double, ptr %4, align 8, !tbaa !9
  %71 = fptoui double %70 to i64
  store i64 %71, ptr %11, align 8, !tbaa !15
  %72 = load i64, ptr %11, align 8, !tbaa !15
  %73 = uitofp i64 %72 to double
  %74 = load double, ptr %4, align 8, !tbaa !9
  %75 = fsub double %74, %73
  store double %75, ptr %4, align 8, !tbaa !9
  %76 = load double, ptr %4, align 8, !tbaa !9
  %77 = fcmp olt double %76, 1.000000e+00
  br i1 %77, label %78, label %79

78:                                               ; preds = %68
  br label %80

79:                                               ; preds = %68
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 1674, ptr noundef @__PRETTY_FUNCTION__.mpz_set_d) #4
  unreachable

80:                                               ; preds = %78
  %81 = load i64, ptr %7, align 8, !tbaa !15
  %82 = sub nsw i64 %81, 1
  store i64 %82, ptr %8, align 8, !tbaa !15
  %83 = load i64, ptr %11, align 8, !tbaa !15
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i64, ptr %8, align 8, !tbaa !15
  %86 = getelementptr inbounds i64, ptr %84, i64 %85
  store i64 %83, ptr %86, align 8, !tbaa !15
  br label %87

87:                                               ; preds = %105, %80
  %88 = load i64, ptr %8, align 8, !tbaa !15
  %89 = add nsw i64 %88, -1
  store i64 %89, ptr %8, align 8, !tbaa !15
  %90 = icmp sge i64 %89, 0
  br i1 %90, label %91, label %110

91:                                               ; preds = %87
  %92 = load double, ptr %9, align 8, !tbaa !9
  %93 = load double, ptr %4, align 8, !tbaa !9
  %94 = fmul double %92, %93
  store double %94, ptr %4, align 8, !tbaa !9
  %95 = load double, ptr %4, align 8, !tbaa !9
  %96 = fptoui double %95 to i64
  store i64 %96, ptr %11, align 8, !tbaa !15
  %97 = load i64, ptr %11, align 8, !tbaa !15
  %98 = uitofp i64 %97 to double
  %99 = load double, ptr %4, align 8, !tbaa !9
  %100 = fsub double %99, %98
  store double %100, ptr %4, align 8, !tbaa !9
  %101 = load double, ptr %4, align 8, !tbaa !9
  %102 = fcmp olt double %101, 1.000000e+00
  br i1 %102, label %103, label %104

103:                                              ; preds = %91
  br label %105

104:                                              ; preds = %91
  call void @__assert_fail(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 1682, ptr noundef @__PRETTY_FUNCTION__.mpz_set_d) #4
  unreachable

105:                                              ; preds = %103
  %106 = load i64, ptr %11, align 8, !tbaa !15
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = load i64, ptr %8, align 8, !tbaa !15
  %109 = getelementptr inbounds i64, ptr %107, i64 %108
  store i64 %106, ptr %109, align 8, !tbaa !15
  br label %87, !llvm.loop !21

110:                                              ; preds = %87
  %111 = load i32, ptr %5, align 4, !tbaa !14
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %113, label %116

113:                                              ; preds = %110
  %114 = load i64, ptr %7, align 8, !tbaa !15
  %115 = sub nsw i64 0, %114
  br label %118

116:                                              ; preds = %110
  %117 = load i64, ptr %7, align 8, !tbaa !15
  br label %118

118:                                              ; preds = %116, %113
  %119 = phi i64 [ %115, %113 ], [ %117, %116 ]
  %120 = trunc i64 %119 to i32
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.__mpz_struct, ptr %121, i32 0, i32 1
  store i32 %120, ptr %122, align 4, !tbaa !11
  store i32 0, ptr %12, align 4
  br label %123

123:                                              ; preds = %118, %36, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %124 = load i32, ptr %12, align 4
  switch i32 %124, label %126 [
    i32 0, label %125
    i32 1, label %125
  ]

125:                                              ; preds = %123, %123
  ret void

126:                                              ; preds = %123
  unreachable
}

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 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 4}
!12 = !{!"", !13, i64 0, !13, i64 4, !6, i64 8}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !13, i64 0}
!20 = !{!12, !6, i64 8}
!21 = distinct !{!21, !18}


; 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.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.mpz_set_d = external hidden unnamed_addr constant [39 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @mpz_realloc(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @mpz_set_d(ptr noundef %0, double noundef %1) local_unnamed_addr #1 {
  %3 = fcmp uno double %1, 0.000000e+00
  %4 = fmul double %1, 5.000000e-01
  %5 = fcmp oeq double %4, %1
  %or.cond = or i1 %3, %5
  br i1 %or.cond, label %48, label %6

6:                                                ; preds = %2
  %7 = fcmp olt double %1, 0.000000e+00
  %8 = fneg double %1
  %.0 = select i1 %7, double %8, double %1
  %9 = fcmp olt double %.0, 1.000000e+00
  br i1 %9, label %48, label %.preheader

.preheader:                                       ; preds = %6
  %10 = fcmp ult double %.0, 0x43F0000000000000
  br i1 %10, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.150 = phi double [ %11, %.lr.ph ], [ %.0, %.preheader ]
  %.04249 = phi i64 [ %12, %.lr.ph ], [ 1, %.preheader ]
  %11 = fmul double %.150, 0x3BF0000000000000
  %12 = add nuw nsw i64 %.04249, 1
  %13 = fcmp ult double %11, 0x43F0000000000000
  br i1 %13, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.042.lcssa = phi i64 [ 1, %.preheader ], [ %12, %.lr.ph ]
  %.1.lcssa = phi double [ %.0, %.preheader ], [ %11, %.lr.ph ]
  %14 = load i32, ptr %0, align 8, !tbaa !7
  %15 = sext i32 %14 to i64
  %16 = icmp sgt i64 %.042.lcssa, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %._crit_edge
  %18 = tail call ptr @mpz_realloc(ptr noundef nonnull %0, i64 noundef %.042.lcssa)
  br label %22

19:                                               ; preds = %._crit_edge
  %20 = getelementptr inbounds i8, ptr %0, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %19, %17
  %23 = phi ptr [ %18, %17 ], [ %21, %19 ]
  %24 = fptoui double %.1.lcssa to i64
  %25 = uitofp i64 %24 to double
  %26 = fsub double %.1.lcssa, %25
  %27 = fcmp olt double %26, 1.000000e+00
  br i1 %27, label %29, label %28

28:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 1674, ptr noundef nonnull @__PRETTY_FUNCTION__.mpz_set_d) #2
  unreachable

29:                                               ; preds = %22
  %30 = add nsw i64 %.042.lcssa, -1
  %31 = getelementptr inbounds i64, ptr %23, i64 %30
  store i64 %24, ptr %31, align 8, !tbaa !14
  %32 = icmp sgt i64 %.042.lcssa, 1
  br i1 %32, label %.lr.ph54.preheader, label %._crit_edge55

.lr.ph54.preheader:                               ; preds = %29
  %33 = add nsw i64 %.042.lcssa, -2
  br label %.lr.ph54

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %41
  %34 = phi i64 [ %43, %41 ], [ %33, %.lr.ph54.preheader ]
  %.252 = phi double [ %38, %41 ], [ %26, %.lr.ph54.preheader ]
  %35 = fmul double %.252, 0x43F0000000000000
  %36 = fptoui double %35 to i64
  %37 = uitofp i64 %36 to double
  %38 = fsub double %35, %37
  %39 = fcmp olt double %38, 1.000000e+00
  br i1 %39, label %41, label %40

40:                                               ; preds = %.lr.ph54
  tail call void @__assert_fail(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 1682, ptr noundef nonnull @__PRETTY_FUNCTION__.mpz_set_d) #2
  unreachable

41:                                               ; preds = %.lr.ph54
  %42 = getelementptr inbounds i64, ptr %23, i64 %34
  store i64 %36, ptr %42, align 8, !tbaa !14
  %43 = add nsw i64 %34, -1
  %44 = icmp sgt i64 %34, 0
  br i1 %44, label %.lr.ph54, label %._crit_edge55, !llvm.loop !16

._crit_edge55:                                    ; preds = %41, %29
  %45 = sub nsw i64 0, %.042.lcssa
  %46 = select i1 %7, i64 %45, i64 %.042.lcssa
  %47 = trunc i64 %46 to i32
  br label %48

48:                                               ; preds = %6, %2, %._crit_edge55
  %.sink = phi i32 [ %47, %._crit_edge55 ], [ 0, %2 ], [ 0, %6 ]
  %49 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %.sink, ptr %49, align 4, !tbaa !17
  ret void
}

attributes #0 = { 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 #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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 0}
!8 = !{!"", !9, i64 0, !9, i64 4, !12, i64 8}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!8, !12, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !10, i64 0}
!16 = distinct !{!16, !6}
!17 = !{!8, !9, i64 4}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass