; LLVM IR from tangjz/acm-icpc :: 51nod/1131.ll (Z5solvexxx)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvexxx(i64 noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %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 i32, align 4
  %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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = load i64, ptr %6, align 8, !tbaa !5
  %13 = sub nsw i64 %12, 1
  %14 = load i64, ptr %7, align 8, !tbaa !5
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = sub nsw i64 %14, %15
  %17 = sdiv i64 %13, %16
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = load i64, ptr %6, align 8, !tbaa !5
  %21 = sdiv i64 %19, %20
  store i64 %21, ptr %9, align 8, !tbaa !5
  %22 = load i64, ptr %8, align 8, !tbaa !5
  %23 = load i64, ptr %9, align 8, !tbaa !5
  %24 = icmp sle i64 %22, %23
  br i1 %24, label %25, label %45

25:                                               ; preds = %3
  %26 = load i64, ptr %8, align 8, !tbaa !5
  %27 = load i64, ptr %8, align 8, !tbaa !5
  %28 = sub nsw i64 %27, 1
  %29 = mul nsw i64 %26, %28
  %30 = sdiv i64 %29, 2
  %31 = load i64, ptr %7, align 8, !tbaa !5
  %32 = load i64, ptr %6, align 8, !tbaa !5
  %33 = sub nsw i64 %31, %32
  %34 = mul nsw i64 %30, %33
  %35 = load i64, ptr %8, align 8, !tbaa !5
  %36 = add nsw i64 %34, %35
  %37 = sub nsw i64 %36, 1
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = add nsw i64 %37, %38
  %40 = load i64, ptr %8, align 8, !tbaa !5
  %41 = load i64, ptr %6, align 8, !tbaa !5
  %42 = mul nsw i64 %40, %41
  %43 = sub nsw i64 %39, %42
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %69

45:                                               ; preds = %3
  %46 = load i64, ptr %9, align 8, !tbaa !5
  %47 = load i64, ptr %9, align 8, !tbaa !5
  %48 = sub nsw i64 %47, 1
  %49 = mul nsw i64 %46, %48
  %50 = sdiv i64 %49, 2
  %51 = load i64, ptr %7, align 8, !tbaa !5
  %52 = load i64, ptr %6, align 8, !tbaa !5
  %53 = sub nsw i64 %51, %52
  %54 = mul nsw i64 %50, %53
  %55 = load i64, ptr %9, align 8, !tbaa !5
  %56 = add nsw i64 %54, %55
  %57 = sub nsw i64 %56, 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %58 = load i64, ptr %9, align 8, !tbaa !5
  %59 = load i64, ptr %7, align 8, !tbaa !5
  %60 = mul nsw i64 %58, %59
  store i64 %60, ptr %11, align 8, !tbaa !5
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %62 = load i64, ptr %61, align 8, !tbaa !5
  %63 = add nsw i64 %57, %62
  %64 = load i64, ptr %9, align 8, !tbaa !5
  %65 = load i64, ptr %6, align 8, !tbaa !5
  %66 = mul nsw i64 %64, %65
  %67 = sub nsw i64 %63, %66
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  store i32 1, ptr %10, align 4
  br label %69

69:                                               ; preds = %45, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %70 = load i64, ptr %4, align 8
  ret i64 %70
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i64 -9223372036854775807, -9223372036854775808) i64 @_Z5solvexxx(i64 noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  %6 = add nsw i64 %1, -1
  %7 = sub nsw i64 %2, %1
  %8 = sdiv i64 %6, %7
  %9 = sdiv i64 %0, %1
  %.not.not = icmp slt i64 %8, %9
  br i1 %.not.not, label %10, label %18

10:                                               ; preds = %3
  %.neg = xor i64 %8, -1
  %11 = add nsw i64 %8, 1
  %12 = mul nsw i64 %11, %8
  %13 = sdiv i64 %12, 2
  %14 = mul nsw i64 %13, %7
  %.neg26 = mul i64 %.neg, %1
  %15 = add i64 %8, %0
  %16 = add i64 %15, %.neg26
  %17 = add i64 %16, %14
  br label %31

18:                                               ; preds = %3
  %19 = add nsw i64 %9, -1
  %20 = mul nsw i64 %19, %9
  %21 = sdiv i64 %20, 2
  %22 = mul nsw i64 %21, %7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %23 = mul nsw i64 %9, %2
  store i64 %23, ptr %5, align 8, !tbaa !5
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %25 = load i64, ptr %24, align 8, !tbaa !5
  %26 = mul nsw i64 %9, %1
  %27 = xor i64 %26, -1
  %28 = add i64 %9, %27
  %29 = add i64 %28, %22
  %30 = add i64 %29, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %31

31:                                               ; preds = %18, %10
  %.0.in = phi i64 [ %17, %10 ], [ %30, %18 ]
  %.0 = add nsw i64 %.0.in, 1
  ret i64 %.0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

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


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