; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1152)

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

@r = external dso_local global double, align 8
@X1 = external dso_local global double, align 8
@Y1 = external dso_local global double, align 8
@X2 = external dso_local global double, align 8
@Y2 = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  store i32 0, ptr %1, align 4
  br label %5

5:                                                ; preds = %58, %56, %0
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @r, ptr noundef @X1, ptr noundef @Y1, ptr noundef @X2, ptr noundef @Y2)
  %7 = icmp eq i32 %6, 5
  br i1 %7, label %8, label %59

8:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %9 = load double, ptr @X1, align 8, !tbaa !5
  %10 = load double, ptr @X2, align 8, !tbaa !5
  %11 = fsub double %9, %10
  %12 = load double, ptr @X1, align 8, !tbaa !5
  %13 = load double, ptr @X2, align 8, !tbaa !5
  %14 = fsub double %12, %13
  %15 = load double, ptr @Y1, align 8, !tbaa !5
  %16 = load double, ptr @Y2, align 8, !tbaa !5
  %17 = fsub double %15, %16
  %18 = load double, ptr @Y1, align 8, !tbaa !5
  %19 = load double, ptr @Y2, align 8, !tbaa !5
  %20 = fsub double %18, %19
  %21 = fmul double %17, %20
  %22 = call double @llvm.fmuladd.f64(double %11, double %14, double %21)
  %23 = fdiv double %22, 4.000000e+00
  store double %23, ptr %2, align 8, !tbaa !5
  %24 = load double, ptr %2, align 8, !tbaa !5
  %25 = load double, ptr @r, align 8, !tbaa !5
  %26 = load double, ptr @r, align 8, !tbaa !5
  %27 = fmul double %25, %26
  %28 = fcmp ogt double %24, %27
  br i1 %28, label %29, label %35

29:                                               ; preds = %8
  %30 = load double, ptr @r, align 8, !tbaa !5
  %31 = fmul double 0x401921FB54442C46, %30
  %32 = load double, ptr @r, align 8, !tbaa !5
  %33 = fmul double %31, %32
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %33)
  store i32 2, ptr %3, align 4
  br label %56, !llvm.loop !9

35:                                               ; preds = %8
  %36 = load double, ptr %2, align 8, !tbaa !5
  %37 = call double @sqrt(double noundef %36) #5
  store double %37, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %38 = load double, ptr %2, align 8, !tbaa !5
  %39 = load double, ptr @r, align 8, !tbaa !5
  %40 = fdiv double %38, %39
  %41 = call double @acos(double noundef %40) #5
  %42 = fmul double %41, 2.000000e+00
  store double %42, ptr %4, align 8, !tbaa !5
  %43 = load double, ptr %4, align 8, !tbaa !5
  %44 = fsub double 0x401921FB54442C46, %43
  %45 = load double, ptr @r, align 8, !tbaa !5
  %46 = fmul double %44, %45
  %47 = load double, ptr @r, align 8, !tbaa !5
  %48 = load double, ptr @r, align 8, !tbaa !5
  %49 = load double, ptr @r, align 8, !tbaa !5
  %50 = fmul double %48, %49
  %51 = load double, ptr %4, align 8, !tbaa !5
  %52 = call double @sin(double noundef %51) #5
  %53 = fmul double %50, %52
  %54 = call double @llvm.fmuladd.f64(double %46, double %47, double %53)
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %54)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  store i32 0, ptr %3, align 4
  br label %56

56:                                               ; preds = %35, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %57 = load i32, ptr %3, align 4
  switch i32 %57, label %61 [
    i32 0, label %58
    i32 2, label %5
  ]

58:                                               ; preds = %56
  br label %5, !llvm.loop !9

59:                                               ; preds = %5
  %60 = load i32, ptr %1, align 4
  ret i32 %60

61:                                               ; preds = %56
  unreachable
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nounwind
declare double @acos(double noundef) #4

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

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

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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

@r = external dso_local global double, align 8
@X1 = external dso_local global double, align 8
@Y1 = external dso_local global double, align 8
@X2 = external dso_local global double, align 8
@Y2 = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @r, ptr noundef nonnull @X1, ptr noundef nonnull @Y1, ptr noundef nonnull @X2, ptr noundef nonnull @Y2)
  %2 = icmp eq i32 %1, 5
  br i1 %2, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %31
  %3 = load double, ptr @X1, align 8, !tbaa !5
  %4 = load double, ptr @X2, align 8, !tbaa !5
  %5 = fsub double %3, %4
  %6 = load double, ptr @Y1, align 8, !tbaa !5
  %7 = load double, ptr @Y2, align 8, !tbaa !5
  %8 = fsub double %6, %7
  %9 = fmul double %8, %8
  %10 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %9)
  %11 = fmul double %10, 2.500000e-01
  %12 = load double, ptr @r, align 8, !tbaa !5
  %13 = fmul double %12, %12
  %14 = fcmp ogt double %11, %13
  br i1 %14, label %15, label %18

15:                                               ; preds = %.lr.ph
  %16 = fmul double %12, 0x401921FB54442C46
  %17 = fmul double %12, %16
  br label %31, !llvm.loop !9

18:                                               ; preds = %.lr.ph
  %19 = tail call double @sqrt(double noundef %11) #4
  %20 = load double, ptr @r, align 8, !tbaa !5
  %21 = fdiv double %19, %20
  %22 = tail call double @acos(double noundef %21) #4
  %23 = fmul double %22, 2.000000e+00
  %24 = fsub double 0x401921FB54442C46, %23
  %25 = load double, ptr @r, align 8, !tbaa !5
  %26 = fmul double %25, %24
  %27 = fmul double %25, %25
  %28 = tail call double @sin(double noundef %23) #4
  %29 = fmul double %27, %28
  %30 = tail call double @llvm.fmuladd.f64(double %26, double %25, double %29)
  br label %31

31:                                               ; preds = %18, %15
  %.sink = phi double [ %30, %18 ], [ %17, %15 ]
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %.sink)
  %33 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @r, ptr noundef nonnull @X1, ptr noundef nonnull @Y1, ptr noundef nonnull @X2, ptr noundef nonnull @Y2)
  %34 = icmp eq i32 %33, 5
  br i1 %34, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %31, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

attributes #0 = { mustprogress nofree norecurse 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 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass