; LLVM IR from tangjz/acm-icpc :: codeforces/complete/700A.ll (Z3band)

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

@m = external dso_local global i32, align 4
@v1 = external dso_local global i32, align 4
@v2 = external dso_local global i32, align 4
@cs = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z3band(double noundef %0) #0 {
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  store double %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load i32, ptr @m, align 4, !tbaa !9
  %5 = sitofp i32 %4 to double
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = load i32, ptr @v1, align 4, !tbaa !9
  %8 = sitofp i32 %7 to double
  %9 = fneg double %6
  %10 = call double @llvm.fmuladd.f64(double %9, double %8, double %5)
  store double %10, ptr %3, align 8, !tbaa !5
  %11 = load i32, ptr @cs, align 4, !tbaa !9
  %12 = sitofp i32 %11 to double
  %13 = load double, ptr %3, align 8, !tbaa !5
  %14 = load i32, ptr @v2, align 4, !tbaa !9
  %15 = load i32, ptr @v1, align 4, !tbaa !9
  %16 = sub nsw i32 %14, %15
  %17 = sitofp i32 %16 to double
  %18 = fdiv double %13, %17
  %19 = load i32, ptr @cs, align 4, !tbaa !9
  %20 = sub nsw i32 %19, 1
  %21 = sitofp i32 %20 to double
  %22 = load double, ptr %3, align 8, !tbaa !5
  %23 = load i32, ptr @v2, align 4, !tbaa !9
  %24 = load i32, ptr @v1, align 4, !tbaa !9
  %25 = add nsw i32 %23, %24
  %26 = sitofp i32 %25 to double
  %27 = fdiv double %22, %26
  %28 = fmul double %21, %27
  %29 = call double @llvm.fmuladd.f64(double %12, double %18, double %28)
  %30 = load double, ptr %2, align 8, !tbaa !5
  %31 = fcmp ogt double %29, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret i1 %31
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 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 = { 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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

@m = external dso_local local_unnamed_addr global i32, align 4
@v1 = external dso_local local_unnamed_addr global i32, align 4
@v2 = external dso_local local_unnamed_addr global i32, align 4
@cs = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z3band(double noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr @m, align 4, !tbaa !5
  %3 = sitofp i32 %2 to double
  %4 = load i32, ptr @v1, align 4, !tbaa !5
  %5 = sitofp i32 %4 to double
  %6 = fneg double %0
  %7 = tail call double @llvm.fmuladd.f64(double %6, double %5, double %3)
  %8 = load i32, ptr @cs, align 4, !tbaa !5
  %9 = sitofp i32 %8 to double
  %10 = load i32, ptr @v2, align 4, !tbaa !5
  %11 = sub nsw i32 %10, %4
  %12 = sitofp i32 %11 to double
  %13 = fdiv double %7, %12
  %14 = add nsw i32 %8, -1
  %15 = sitofp i32 %14 to double
  %16 = add nsw i32 %10, %4
  %17 = sitofp i32 %16 to double
  %18 = fdiv double %7, %17
  %19 = fmul double %18, %15
  %20 = tail call double @llvm.fmuladd.f64(double %9, double %13, double %19)
  %21 = fcmp ogt double %20, %0
  ret i1 %21
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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 speculatable willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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