; LLVM IR from dynexcoin/Dynex :: src/DynexCNCore/DynexCNBasicImpl.ll (ZN7DynexCN18getPenalizedAmountEmmm)

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

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm = external hidden unnamed_addr constant [63 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 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: mustprogress uwtable
define dso_local noundef i64 @_ZN7DynexCN18getPenalizedAmountEmmm(i64 noundef %0, i64 noundef %1, i64 noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !5
  %13 = load i64, ptr %7, align 8, !tbaa !5
  %14 = load i64, ptr %6, align 8, !tbaa !5
  %15 = mul i64 2, %14
  %16 = icmp ule i64 %13, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  br label %20

18:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.3, i32 noundef 58, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

19:                                               ; No predecessors!
  br label %20

20:                                               ; preds = %19, %17
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = call noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() #6
  %23 = zext i32 %22 to i64
  %24 = icmp ule i64 %21, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %20
  br label %28

26:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.3, i32 noundef 59, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = call noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() #6
  %31 = zext i32 %30 to i64
  %32 = icmp ule i64 %29, %31
  br i1 %32, label %33, label %34

33:                                               ; preds = %28
  br label %36

34:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.3, i32 noundef 60, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

35:                                               ; No predecessors!
  br label %36

36:                                               ; preds = %35, %33
  %37 = load i64, ptr %5, align 8, !tbaa !5
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  store i64 0, ptr %4, align 8
  br label %81

40:                                               ; preds = %36
  %41 = load i64, ptr %7, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !5
  %43 = icmp ule i64 %41, %42
  br i1 %43, label %44, label %46

44:                                               ; preds = %40
  %45 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %45, ptr %4, align 8
  br label %81

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %47 = load i64, ptr %6, align 8, !tbaa !5
  %48 = mul i64 2, %47
  %49 = load i64, ptr %7, align 8, !tbaa !5
  %50 = sub i64 %48, %49
  store i64 %50, ptr %9, align 8, !tbaa !5
  %51 = load i64, ptr %7, align 8, !tbaa !5
  %52 = load i64, ptr %9, align 8, !tbaa !5
  %53 = mul i64 %52, %51
  store i64 %53, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %54 = load i64, ptr %5, align 8, !tbaa !5
  %55 = load i64, ptr %9, align 8, !tbaa !5
  %56 = call noundef i64 @_ZL6mul128mmPm(i64 noundef %54, i64 noundef %55, ptr noundef %8)
  store i64 %56, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %57 = load i64, ptr %8, align 8, !tbaa !5
  %58 = load i64, ptr %10, align 8, !tbaa !5
  %59 = load i64, ptr %6, align 8, !tbaa !5
  %60 = trunc i64 %59 to i32
  %61 = call noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef %57, i64 noundef %58, i32 noundef %60, ptr noundef %11, ptr noundef %12)
  %62 = load i64, ptr %11, align 8, !tbaa !5
  %63 = load i64, ptr %12, align 8, !tbaa !5
  %64 = load i64, ptr %6, align 8, !tbaa !5
  %65 = trunc i64 %64 to i32
  %66 = call noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef %62, i64 noundef %63, i32 noundef %65, ptr noundef %11, ptr noundef %12)
  %67 = load i64, ptr %11, align 8, !tbaa !5
  %68 = icmp eq i64 0, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %46
  br label %72

70:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.3, i32 noundef 82, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

71:                                               ; No predecessors!
  br label %72

72:                                               ; preds = %71, %69
  %73 = load i64, ptr %12, align 8, !tbaa !5
  %74 = load i64, ptr %5, align 8, !tbaa !5
  %75 = icmp ult i64 %73, %74
  br i1 %75, label %76, label %77

76:                                               ; preds = %72
  br label %79

77:                                               ; preds = %72
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.3, i32 noundef 83, ptr noundef @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

78:                                               ; No predecessors!
  br label %79

79:                                               ; preds = %78, %76
  %80 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %80, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %81

81:                                               ; preds = %79, %44, %39
  %82 = load i64, ptr %4, align 8
  ret i64 %82
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i64 @_ZL6mul128mmPm(i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 "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 = { mustprogress 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 = { inlinehint mustprogress 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 #5 = { noreturn nounwind }
attributes #6 = { 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++ TBAA"}


; 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 [35 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm = external hidden unnamed_addr constant [63 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [27 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: mustprogress uwtable
define dso_local noundef i64 @_ZN7DynexCN18getPenalizedAmountEmmm(i64 noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = shl i64 %1, 1
  %.not = icmp ult i64 %7, %2
  br i1 %.not, label %8, label %9

8:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, i32 noundef 58, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

9:                                                ; preds = %3
  %10 = tail call noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() #6
  %11 = zext i32 %10 to i64
  %.not24 = icmp ult i64 %11, %1
  br i1 %.not24, label %12, label %13

12:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.3, i32 noundef 59, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

13:                                               ; preds = %9
  %14 = tail call noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() #6
  %15 = zext i32 %14 to i64
  %.not25 = icmp ult i64 %15, %2
  br i1 %.not25, label %16, label %17

16:                                               ; preds = %13
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.3, i32 noundef 60, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

17:                                               ; preds = %13
  %18 = icmp eq i64 %0, 0
  br i1 %18, label %38, label %19

19:                                               ; preds = %17
  %.not26 = icmp ugt i64 %2, %1
  br i1 %.not26, label %20, label %38

20:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %21 = sub i64 %7, %2
  %22 = mul i64 %21, %2
  %23 = call noundef i64 @_ZL6mul128mmPm(i64 noundef %0, i64 noundef %22, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = trunc nuw i64 %1 to i32
  %26 = call noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef %24, i64 noundef %23, i32 noundef %25, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = load i64, ptr %6, align 8, !tbaa !5
  %29 = call noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef %27, i64 noundef %28, i32 noundef %25, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %30 = load i64, ptr %5, align 8, !tbaa !5
  %31 = icmp eq i64 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %20
  call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.3, i32 noundef 82, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

33:                                               ; preds = %20
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = icmp ult i64 %34, %0
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.3, i32 noundef 83, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7DynexCN18getPenalizedAmountEmmm) #5
  unreachable

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %38

38:                                               ; preds = %19, %17, %37
  %.0 = phi i64 [ %34, %37 ], [ 0, %17 ], [ %0, %19 ]
  ret i64 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNSt14numeric_limitsIjE3maxEv() local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i64 @_ZL6mul128mmPm(i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef i32 @_ZL9div128_32mmjPmS_(i64 noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 "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 = { mustprogress 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 = { inlinehint mustprogress 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 #5 = { noreturn nounwind }
attributes #6 = { 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++ TBAA"}


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