; LLVM IR from atcoder/ac-library :: test/example/floor_sum_practice.ll (ZN7atcoder9floor_sumExxxx)

; 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.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx = external hidden unnamed_addr constant [73 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN7atcoder8internal18floor_sum_unsignedEyyyy(i64 noundef, i64 noundef, i64 noundef, i64 noundef) #0

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

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

; 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 i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN7atcoder9floor_sumExxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #3 {
  %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
  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
  store i64 %3, ptr %8, align 8, !tbaa !5
  %12 = load i64, ptr %5, align 8, !tbaa !5
  %13 = icmp sle i64 0, %12
  br i1 %13, label %14, label %17

14:                                               ; preds = %4
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %16 = icmp slt i64 %15, 4294967296
  br label %17

17:                                               ; preds = %14, %4
  %18 = phi i1 [ false, %4 ], [ %16, %14 ]
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  br label %22

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 83, ptr noundef @__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = icmp sle i64 1, %23
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = icmp slt i64 %26, 4294967296
  br label %28

28:                                               ; preds = %25, %22
  %29 = phi i1 [ false, %22 ], [ %27, %25 ]
  br i1 %29, label %30, label %31

30:                                               ; preds = %28
  br label %33

31:                                               ; preds = %28
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 84, ptr noundef @__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx) #4
  unreachable

32:                                               ; No predecessors!
  br label %33

33:                                               ; preds = %32, %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !5
  %34 = load i64, ptr %7, align 8, !tbaa !5
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %55

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %37 = load i64, ptr %7, align 8, !tbaa !5
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = call noundef i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef %37, i64 noundef %38)
  store i64 %39, ptr %10, align 8, !tbaa !5
  %40 = load i64, ptr %5, align 8, !tbaa !5
  %41 = mul i64 1, %40
  %42 = load i64, ptr %5, align 8, !tbaa !5
  %43 = sub nsw i64 %42, 1
  %44 = mul i64 %41, %43
  %45 = udiv i64 %44, 2
  %46 = load i64, ptr %10, align 8, !tbaa !5
  %47 = load i64, ptr %7, align 8, !tbaa !5
  %48 = sub i64 %46, %47
  %49 = load i64, ptr %6, align 8, !tbaa !5
  %50 = udiv i64 %48, %49
  %51 = mul i64 %45, %50
  %52 = load i64, ptr %9, align 8, !tbaa !5
  %53 = sub i64 %52, %51
  store i64 %53, ptr %9, align 8, !tbaa !5
  %54 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %54, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %55

55:                                               ; preds = %36, %33
  %56 = load i64, ptr %8, align 8, !tbaa !5
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %58, label %73

58:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %59 = load i64, ptr %8, align 8, !tbaa !5
  %60 = load i64, ptr %6, align 8, !tbaa !5
  %61 = call noundef i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef %59, i64 noundef %60)
  store i64 %61, ptr %11, align 8, !tbaa !5
  %62 = load i64, ptr %5, align 8, !tbaa !5
  %63 = mul i64 1, %62
  %64 = load i64, ptr %11, align 8, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = sub i64 %64, %65
  %67 = load i64, ptr %6, align 8, !tbaa !5
  %68 = udiv i64 %66, %67
  %69 = mul i64 %63, %68
  %70 = load i64, ptr %9, align 8, !tbaa !5
  %71 = sub i64 %70, %69
  store i64 %71, ptr %9, align 8, !tbaa !5
  %72 = load i64, ptr %11, align 8, !tbaa !5
  store i64 %72, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %73

73:                                               ; preds = %58, %55
  %74 = load i64, ptr %9, align 8, !tbaa !5
  %75 = load i64, ptr %5, align 8, !tbaa !5
  %76 = load i64, ptr %6, align 8, !tbaa !5
  %77 = load i64, ptr %7, align 8, !tbaa !5
  %78 = load i64, ptr %8, align 8, !tbaa !5
  %79 = call noundef i64 @_ZN7atcoder8internal18floor_sum_unsignedEyyyy(i64 noundef %75, i64 noundef %76, i64 noundef %77, i64 noundef %78)
  %80 = add i64 %74, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret i64 %80
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { noreturn nounwind }
attributes #5 = { 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 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.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx = external hidden unnamed_addr constant [73 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN7atcoder8internal18floor_sum_unsignedEyyyy(i64 noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN7atcoder9floor_sumExxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = icmp ult i64 %0, 4294967296
  br i1 %5, label %7, label %6

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 83, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx) #2
  unreachable

7:                                                ; preds = %4
  %8 = add i64 %1, -1
  %9 = icmp ult i64 %8, 4294967295
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 84, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7atcoder9floor_sumExxxx) #2
  unreachable

11:                                               ; preds = %7
  %12 = icmp slt i64 %2, 0
  br i1 %12, label %13, label %22

13:                                               ; preds = %11
  %14 = tail call noundef i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef %2, i64 noundef %1)
  %15 = add nsw i64 %0, -1
  %16 = mul i64 %15, %0
  %17 = lshr i64 %16, 1
  %18 = sub i64 %14, %2
  %19 = udiv i64 %18, %1
  %20 = mul i64 %17, %19
  %21 = sub i64 0, %20
  br label %22

22:                                               ; preds = %13, %11
  %.029 = phi i64 [ %21, %13 ], [ 0, %11 ]
  %.0 = phi i64 [ %14, %13 ], [ %2, %11 ]
  %23 = icmp slt i64 %3, 0
  br i1 %23, label %24, label %30

24:                                               ; preds = %22
  %25 = tail call noundef i64 @_ZN7atcoder8internal8safe_modExx(i64 noundef %3, i64 noundef %1)
  %26 = sub i64 %25, %3
  %27 = udiv i64 %26, %1
  %28 = mul i64 %27, %0
  %29 = sub i64 %.029, %28
  br label %30

30:                                               ; preds = %24, %22
  %.1 = phi i64 [ %29, %24 ], [ %.029, %22 ]
  %.028 = phi i64 [ %25, %24 ], [ %3, %22 ]
  %31 = tail call noundef i64 @_ZN7atcoder8internal18floor_sum_unsignedEyyyy(i64 noundef %0, i64 noundef %1, i64 noundef %.0, i64 noundef %.028)
  %32 = add i64 %31, %.1
  ret i64 %32
}

attributes #0 = { 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 #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 = { 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)"}


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