; LLVM IR from tangjz/acm-icpc :: poj (1905)

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

@l = external dso_local global double, align 8
@n = external dso_local global double, align 8
@c = external dso_local global double, align 8
@s = external dso_local global double, align 8
@r = external dso_local global double, align 8
@L = external dso_local global double, align 8
@R = external dso_local global double, align 8
@M = external dso_local global double, align 8
@.str = external hidden unnamed_addr constant [10 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
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %58, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @l, ptr noundef @n, ptr noundef @c)
  %4 = icmp eq i32 %3, 3
  br i1 %4, label %5, label %61

5:                                                ; preds = %2
  %6 = load double, ptr @l, align 8, !tbaa !5
  %7 = fcmp olt double %6, 0.000000e+00
  br i1 %7, label %8, label %15

8:                                                ; preds = %5
  %9 = load double, ptr @n, align 8, !tbaa !5
  %10 = fcmp olt double %9, 0.000000e+00
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = load double, ptr @c, align 8, !tbaa !5
  %13 = fcmp olt double %12, 0.000000e+00
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %61

15:                                               ; preds = %11, %8, %5
  %16 = load double, ptr @n, align 8, !tbaa !5
  %17 = load double, ptr @c, align 8, !tbaa !5
  %18 = call double @llvm.fmuladd.f64(double %16, double %17, double 1.000000e+00)
  %19 = load double, ptr @l, align 8, !tbaa !5
  %20 = fmul double %18, %19
  store double %20, ptr @s, align 8, !tbaa !5
  store double 0.000000e+00, ptr @L, align 8, !tbaa !5
  %21 = load double, ptr @l, align 8, !tbaa !5
  %22 = fdiv double %21, 2.000000e+00
  store double %22, ptr @R, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %57, %15
  %24 = load double, ptr @R, align 8, !tbaa !5
  %25 = load double, ptr @L, align 8, !tbaa !5
  %26 = fsub double %24, %25
  %27 = fcmp oge double %26, 1.000000e-04
  br i1 %27, label %28, label %58

28:                                               ; preds = %23
  %29 = load double, ptr @L, align 8, !tbaa !5
  %30 = load double, ptr @R, align 8, !tbaa !5
  %31 = fadd double %29, %30
  %32 = fdiv double %31, 2.000000e+00
  store double %32, ptr @M, align 8, !tbaa !5
  %33 = load double, ptr @M, align 8, !tbaa !5
  %34 = fmul double 4.000000e+00, %33
  %35 = load double, ptr @M, align 8, !tbaa !5
  %36 = load double, ptr @l, align 8, !tbaa !5
  %37 = load double, ptr @l, align 8, !tbaa !5
  %38 = fmul double %36, %37
  %39 = call double @llvm.fmuladd.f64(double %34, double %35, double %38)
  %40 = load double, ptr @M, align 8, !tbaa !5
  %41 = fmul double 8.000000e+00, %40
  %42 = fdiv double %39, %41
  store double %42, ptr @r, align 8, !tbaa !5
  %43 = load double, ptr @r, align 8, !tbaa !5
  %44 = fmul double 2.000000e+00, %43
  %45 = load double, ptr @l, align 8, !tbaa !5
  %46 = load double, ptr @r, align 8, !tbaa !5
  %47 = fmul double 2.000000e+00, %46
  %48 = fdiv double %45, %47
  %49 = call double @asin(double noundef %48) #4
  %50 = fmul double %44, %49
  %51 = load double, ptr @s, align 8, !tbaa !5
  %52 = fcmp olt double %50, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %28
  %54 = load double, ptr @M, align 8, !tbaa !5
  store double %54, ptr @L, align 8, !tbaa !5
  br label %57

55:                                               ; preds = %28
  %56 = load double, ptr @M, align 8, !tbaa !5
  store double %56, ptr @R, align 8, !tbaa !5
  br label %57

57:                                               ; preds = %55, %53
  br label %23, !llvm.loop !9

58:                                               ; preds = %23
  %59 = load double, ptr @L, align 8, !tbaa !5
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %59)
  br label %2, !llvm.loop !11

61:                                               ; preds = %14, %2
  ret i32 0
}

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

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

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

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

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 speculatable willreturn memory(none) }
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 = { 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"}
!11 = distinct !{!11, !10}


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

@l = external dso_local global double, align 8
@n = external dso_local global double, align 8
@c = external dso_local global double, align 8
@s = external dso_local local_unnamed_addr global double, align 8
@r = external dso_local local_unnamed_addr global double, align 8
@L = external dso_local local_unnamed_addr global double, align 8
@R = external dso_local local_unnamed_addr global double, align 8
@M = external dso_local local_unnamed_addr global double, align 8
@.str = external hidden unnamed_addr constant [10 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 @l, ptr noundef nonnull @n, ptr noundef nonnull @c)
  %2 = icmp eq i32 %1, 3
  br i1 %2, label %.lr.ph5, label %._crit_edge6

.lr.ph5:                                          ; preds = %0, %._crit_edge
  %3 = load double, ptr @l, align 8, !tbaa !5
  %4 = fcmp olt double %3, 0.000000e+00
  %5 = load double, ptr @n, align 8
  %6 = fcmp olt double %5, 0.000000e+00
  %or.cond = select i1 %4, i1 %6, i1 false
  %7 = load double, ptr @c, align 8
  %8 = fcmp olt double %7, 0.000000e+00
  %or.cond3 = select i1 %or.cond, i1 %8, i1 false
  br i1 %or.cond3, label %._crit_edge6, label %9

9:                                                ; preds = %.lr.ph5
  %10 = tail call double @llvm.fmuladd.f64(double %5, double %7, double 1.000000e+00)
  %11 = fmul double %3, %10
  store double %11, ptr @s, align 8, !tbaa !5
  store double 0.000000e+00, ptr @L, align 8, !tbaa !5
  %12 = fmul double %3, 5.000000e-01
  store double %12, ptr @R, align 8, !tbaa !5
  %13 = fcmp ult double %12, 1.000000e-04
  br i1 %13, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %33
  %14 = phi double [ %34, %33 ], [ 0.000000e+00, %9 ]
  %15 = phi double [ %35, %33 ], [ %12, %9 ]
  %16 = fadd double %15, %14
  %17 = fmul double %16, 5.000000e-01
  store double %17, ptr @M, align 8, !tbaa !5
  %18 = fmul double %17, 4.000000e+00
  %19 = load double, ptr @l, align 8, !tbaa !5
  %20 = fmul double %19, %19
  %21 = tail call double @llvm.fmuladd.f64(double %18, double %17, double %20)
  %22 = fmul double %17, 8.000000e+00
  %23 = fdiv double %21, %22
  store double %23, ptr @r, align 8, !tbaa !5
  %24 = fmul double %23, 2.000000e+00
  %25 = fdiv double %19, %24
  %26 = tail call double @asin(double noundef %25) #4
  %27 = fmul double %26, %24
  %28 = load double, ptr @s, align 8, !tbaa !5
  %29 = fcmp olt double %27, %28
  %30 = load double, ptr @M, align 8, !tbaa !5
  br i1 %29, label %31, label %32

31:                                               ; preds = %.lr.ph
  store double %30, ptr @L, align 8, !tbaa !5
  %.pre = load double, ptr @R, align 8, !tbaa !5
  br label %33

32:                                               ; preds = %.lr.ph
  store double %30, ptr @R, align 8, !tbaa !5
  %.pre9 = load double, ptr @L, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %32, %31
  %34 = phi double [ %.pre9, %32 ], [ %30, %31 ]
  %35 = phi double [ %30, %32 ], [ %.pre, %31 ]
  %36 = fsub double %35, %34
  %37 = fcmp ult double %36, 1.000000e-04
  br i1 %37, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %33, %9
  %.lcssa = phi double [ 0.000000e+00, %9 ], [ %34, %33 ]
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %.lcssa)
  %39 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @l, ptr noundef nonnull @n, ptr noundef nonnull @c)
  %40 = icmp eq i32 %39, 3
  br i1 %40, label %.lr.ph5, label %._crit_edge6, !llvm.loop !11

._crit_edge6:                                     ; preds = %._crit_edge, %.lr.ph5, %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: mustprogress nofree nounwind willreturn memory(write)
declare double @asin(double noundef) local_unnamed_addr #3

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

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"}
!11 = distinct !{!11, !10}


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