; LLVM IR from VastoLorde95/Competitive-Programming :: SPOJ/Random/EQBOX/equipmentbox.ll (Z5checkxxxx)

; 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 zeroext i1 @_Z5checkxxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !5
  %15 = load i64, ptr %8, align 8, !tbaa !5
  %16 = load i64, ptr %6, align 8, !tbaa !5
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %18, label %23

18:                                               ; preds = %4
  %19 = load i64, ptr %9, align 8, !tbaa !5
  %20 = load i64, ptr %7, align 8, !tbaa !5
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i1 true, ptr %5, align 1
  br label %82

23:                                               ; preds = %18, %4
  %24 = load i64, ptr %8, align 8, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !5
  %26 = icmp sge i64 %24, %25
  br i1 %26, label %27, label %32

27:                                               ; preds = %23
  %28 = load i64, ptr %9, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = icmp sge i64 %28, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %27
  store i1 false, ptr %5, align 1
  br label %82

32:                                               ; preds = %27, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %33 = load i64, ptr %9, align 8, !tbaa !5
  %34 = load i64, ptr %8, align 8, !tbaa !5
  %35 = call noundef double @_ZSt5atan2IxxEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef %33, i64 noundef %34)
  store double %35, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %36 = load i64, ptr %7, align 8, !tbaa !5
  %37 = sitofp i64 %36 to double
  %38 = load i64, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %8, align 8, !tbaa !5
  %40 = mul nsw i64 %38, %39
  %41 = load i64, ptr %9, align 8, !tbaa !5
  %42 = load i64, ptr %9, align 8, !tbaa !5
  %43 = mul nsw i64 %41, %42
  %44 = add nsw i64 %40, %43
  %45 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %44)
  %46 = fdiv double %37, %45
  %47 = call double @asin(double noundef %46) #5
  %48 = load double, ptr %10, align 8, !tbaa !9
  %49 = fsub double %47, %48
  store double %49, ptr %11, align 8, !tbaa !9
  %50 = load double, ptr %11, align 8, !tbaa !9
  %51 = fcmp olt double %50, 0.000000e+00
  br i1 %51, label %52, label %53

52:                                               ; preds = %32
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %81

53:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %54 = load i64, ptr %9, align 8, !tbaa !5
  %55 = sitofp i64 %54 to double
  %56 = load double, ptr %11, align 8, !tbaa !9
  %57 = call double @sin(double noundef %56) #5
  %58 = fmul double %55, %57
  store double %58, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %59 = load i64, ptr %8, align 8, !tbaa !5
  %60 = load i64, ptr %8, align 8, !tbaa !5
  %61 = mul nsw i64 %59, %60
  %62 = load i64, ptr %9, align 8, !tbaa !5
  %63 = load i64, ptr %9, align 8, !tbaa !5
  %64 = mul nsw i64 %62, %63
  %65 = add nsw i64 %61, %64
  %66 = load i64, ptr %7, align 8, !tbaa !5
  %67 = load i64, ptr %7, align 8, !tbaa !5
  %68 = mul nsw i64 %66, %67
  %69 = sub nsw i64 %65, %68
  %70 = call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %69)
  store double %70, ptr %14, align 8, !tbaa !9
  %71 = load double, ptr %13, align 8, !tbaa !9
  %72 = load double, ptr %14, align 8, !tbaa !9
  %73 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %71, double %72)
  %74 = load i64, ptr %6, align 8, !tbaa !5
  %75 = sitofp i64 %74 to double
  %76 = fsub double %73, %75
  %77 = fcmp oge double %76, 0.000000e+00
  br i1 %77, label %78, label %79

78:                                               ; preds = %53
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %80

79:                                               ; preds = %53
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %80

80:                                               ; preds = %79, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %81

81:                                               ; preds = %80, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %82

82:                                               ; preds = %81, %31, %22
  %83 = load i1, ptr %5, align 1
  ret i1 %83
}

; 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 double @_ZSt5atan2IxxEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind
declare double @asin(double noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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

; 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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkxxxx(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = icmp slt i64 %2, %0
  %6 = icmp slt i64 %3, %1
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %29, label %7

7:                                                ; preds = %4
  %or.cond30 = or i1 %5, %6
  br i1 %or.cond30, label %8, label %29

8:                                                ; preds = %7
  %9 = tail call noundef double @_ZSt5atan2IxxEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef %3, i64 noundef %2)
  %10 = sitofp i64 %1 to double
  %11 = mul nsw i64 %2, %2
  %12 = mul nsw i64 %3, %3
  %13 = add nuw nsw i64 %12, %11
  %14 = tail call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %13)
  %15 = fdiv double %10, %14
  %16 = tail call double @asin(double noundef %15) #4
  %17 = fsub double %16, %9
  %18 = fcmp olt double %17, 0.000000e+00
  br i1 %18, label %29, label %19

19:                                               ; preds = %8
  %20 = sitofp i64 %3 to double
  %21 = tail call double @sin(double noundef %17) #4
  %22 = fmul double %21, %20
  %23 = mul nsw i64 %1, %1
  %24 = sub nsw i64 %13, %23
  %25 = tail call noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef %24)
  %26 = tail call double @llvm.fmuladd.f64(double %22, double 2.000000e+00, double %25)
  %27 = sitofp i64 %0 to double
  %28 = fcmp ult double %26, %27
  br label %29

29:                                               ; preds = %19, %8, %7, %4
  %.2 = phi i1 [ true, %4 ], [ false, %7 ], [ %28, %19 ], [ false, %8 ]
  ret i1 %.2
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt5atan2IxxEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @asin(double noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt4sqrtIxEN9__gnu_cxx11__enable_ifIXsr12__is_integerIT_EE7__valueEdE6__typeES2_(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #2

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

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 = { 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 #2 = { mustprogress nofree nounwind willreturn memory(write) "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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